From patchwork Fri Apr 1 20:04:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 64900 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp18186lbc; Fri, 1 Apr 2016 13:04:48 -0700 (PDT) X-Received: by 10.66.251.10 with SMTP id zg10mr33729009pac.1.1459541088333; Fri, 01 Apr 2016 13:04:48 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ko9si19370206pab.187.2016.04.01.13.04.47; Fri, 01 Apr 2016 13:04:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753368AbcDAUEr (ORCPT + 29 others); Fri, 1 Apr 2016 16:04:47 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38162 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751927AbcDAUEq (ORCPT ); Fri, 1 Apr 2016 16:04:46 -0400 Received: by mail-wm0-f53.google.com with SMTP id 20so3819956wmh.1 for ; Fri, 01 Apr 2016 13:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3mJtR+pIoTowe402dss7jLBsO23COmesiF4ROrh6K7Y=; b=JvWjaKqwRK3fDD6kW23adYBqITeWu171EAqJn1985dY+Pz9igD7+yV5VmPMg1Yssx2 iPSfOz7EiOJ3cIpjU+iCn3jQxAU6uwbwNzvE7IZ1QLss7p4BFNP804Qr1s3y84RQwHqd OR8h7z56sxRVN9GbwRBZfkWKdwSZdNDQgFpGA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3mJtR+pIoTowe402dss7jLBsO23COmesiF4ROrh6K7Y=; b=m+yb1IDdScKdaSvzePAmssJx775eiBdqE4HO5AzFT2Ay4pXpupMjXUmG3MPVI+Njuk nSynnYucX4dQXxfnC2tFuO3DyfDZKPT4um4Xm6XryyyJwsVoyCCsAawsQWewNwFRD9if G/x8ZjoDCqQrs3DZftGP6JXLFCLp9wypHjGi6eFU1OGJL68u9lBxvxV754PR4oZRtgPP KquXEqYoJuxNF3u/3vGAgMdRgJo1f2TxUvimJwi6HcFI+knIVFQshH8WICC5FujJFavC skzh+lzlwzvHbABxc1huwgx08TKPGT3cg9JQgm+3yur4m3ABiIRt7rW7ZmghvQrqQbD6 Om9A== X-Gm-Message-State: AD7BkJKL8ql7XdByyXK2gk0EI2pyljaf/7TmV/Whaf+sX79lIdcTVbVU6NM8/FNmhoNzqxMx X-Received: by 10.194.176.129 with SMTP id ci1mr6692737wjc.166.1459541084515; Fri, 01 Apr 2016 13:04:44 -0700 (PDT) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id p125sm490587wmd.16.2016.04.01.13.04.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 13:04:43 -0700 (PDT) From: Daniel Lezcano To: peterz@infradead.org Cc: Ingo Molnar , linux-kernel@vger.kernel.org (open list:SCHEDULER) Subject: [PATCH] sched/clock: Make local_clock/cpu_clock inline Date: Fri, 1 Apr 2016 22:04:10 +0200 Message-Id: <1459541050-13654-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The local_clock/cpu_clock functions were changed to prevent a double identical test with sched_clock_cpu() when HAVE_UNSTABLE_SCHED_CLOCK is set. That resulted in one line functions. As these functions are in all the cases one line functions and in the hot path, it is useful to specify them as static inline in order to give a strong hint to the compiler. After verification, it appears the compiler does not inline them without this hint. Change those functions to static inline. Signed-off-by: Daniel Lezcano --- include/linux/sched.h | 32 ++++++++++++++++++++++++++++++-- kernel/sched/clock.c | 41 ----------------------------------------- 2 files changed, 30 insertions(+), 43 deletions(-) -- 1.9.1 diff --git a/include/linux/sched.h b/include/linux/sched.h index 52c4847..13c1c1d 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2303,8 +2303,6 @@ extern unsigned long long notrace sched_clock(void); /* * See the comment in kernel/sched/clock.c */ -extern u64 cpu_clock(int cpu); -extern u64 local_clock(void); extern u64 running_clock(void); extern u64 sched_clock_cpu(int cpu); @@ -2323,6 +2321,16 @@ static inline void sched_clock_idle_sleep_event(void) static inline void sched_clock_idle_wakeup_event(u64 delta_ns) { } + +static inline u64 cpu_clock(int cpu) +{ + return sched_clock(); +} + +static inline u64 local_clock(void) +{ + return sched_clock(); +} #else /* * Architectures can set this to 1 if they have specified @@ -2337,6 +2345,26 @@ extern void clear_sched_clock_stable(void); extern void sched_clock_tick(void); extern void sched_clock_idle_sleep_event(void); extern void sched_clock_idle_wakeup_event(u64 delta_ns); + +/* + * As outlined in clock.c, provides a fast, high resolution, nanosecond + * time source that is monotonic per cpu argument and has bounded drift + * between cpus. + * + * ######################### BIG FAT WARNING ########################## + * # when comparing cpu_clock(i) to cpu_clock(j) for i != j, time can # + * # go backwards !! # + * #################################################################### + */ +static inline u64 cpu_clock(int cpu) +{ + return sched_clock_cpu(cpu); +} + +static inline u64 local_clock(void) +{ + return sched_clock_cpu(raw_smp_processor_id()); +} #endif #ifdef CONFIG_IRQ_TIME_ACCOUNTING diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index 30c4b20..e9d6d6a 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -363,33 +363,6 @@ void sched_clock_idle_wakeup_event(u64 delta_ns) } EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event); -/* - * As outlined at the top, provides a fast, high resolution, nanosecond - * time source that is monotonic per cpu argument and has bounded drift - * between cpus. - * - * ######################### BIG FAT WARNING ########################## - * # when comparing cpu_clock(i) to cpu_clock(j) for i != j, time can # - * # go backwards !! # - * #################################################################### - */ -u64 cpu_clock(int cpu) -{ - return sched_clock_cpu(cpu); -} - -/* - * Similar to cpu_clock() for the current cpu. Time will only be observed - * to be monotonic if care is taken to only compare timestampt taken on the - * same CPU. - * - * See cpu_clock(). - */ -u64 local_clock(void) -{ - return sched_clock_cpu(raw_smp_processor_id()); -} - #else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */ void sched_clock_init(void) @@ -404,22 +377,8 @@ u64 sched_clock_cpu(int cpu) return sched_clock(); } - -u64 cpu_clock(int cpu) -{ - return sched_clock(); -} - -u64 local_clock(void) -{ - return sched_clock(); -} - #endif /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */ -EXPORT_SYMBOL_GPL(cpu_clock); -EXPORT_SYMBOL_GPL(local_clock); - /* * Running clock - returns the time that has elapsed while a guest has been * running.