From patchwork Mon Apr 11 14:38:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 65525 Delivered-To: patch@linaro.org Received: by 10.112.43.237 with SMTP id z13csp1513018lbl; Mon, 11 Apr 2016 07:39:28 -0700 (PDT) X-Received: by 10.98.16.93 with SMTP id y90mr33578475pfi.155.1460385566792; Mon, 11 Apr 2016 07:39:26 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q73si3850929pfi.65.2016.04.11.07.39.26; Mon, 11 Apr 2016 07:39:26 -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 S1753456AbcDKOjU (ORCPT + 29 others); Mon, 11 Apr 2016 10:39:20 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:37762 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750928AbcDKOjR (ORCPT ); Mon, 11 Apr 2016 10:39:17 -0400 Received: by mail-wm0-f41.google.com with SMTP id n3so107683421wmn.0 for ; Mon, 11 Apr 2016 07:39:16 -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:in-reply-to:references; bh=XcdlgGPZX5qGNg20BAMHS4CjE28XyJAarLWIaJsiv6E=; b=ErX4cXshnY5+T4MI0OHvhjBOW22jRWXOHZ1EvOA6a4g1/d8BDxnBqd1kVEKYlbh6tY 4IJSess6EHZJtvxOzhKY46SWOSMs3Uw7HmNVfsOEXc0kFU7qukJlbAiAlLSYOwxxHIzX ozOFTIHeYRzasQMss5eIZSF5pnbevtXq775EI= 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:in-reply-to :references; bh=XcdlgGPZX5qGNg20BAMHS4CjE28XyJAarLWIaJsiv6E=; b=R6g5rICJz70K79m+fa7HbUei1WR/KSE4qSl3IJ6D/y0WFI5+XwsbT+OlFTRnD7qWP3 lF6N82n1YMP1+f1qt8uq+PzeiXPQzTWNs3x1Y1xOO7d0Rqoqi1G8lkAC1rM0dFWNpAM8 0xpFXKJYO2BxuWeOLwSF+V3gKmPM5+5GTOaFqYQUKWNi1l1QUiHtau8YzpTeWTKj4JcW qSfjfIfR7L3mF6s3Uyt4oYqw993sFR+mnJOl8vZavm4xn2CObqobhkti3D416VTIqKwE jdW7j7IRkVECj7VekEIL1pADcEmFr+3c/LlX4qpULni3am9fI1P4irlRSw8JjHwu1HXs 0Xew== X-Gm-Message-State: AD7BkJLjE6o6SAEpnfK/0vhO3l7ijyiCnefJUUJ3UQmjTUkFHzWtPjDEZdOQ+J8Of40JJIRP X-Received: by 10.28.153.65 with SMTP id b62mr19719880wme.36.1460385556097; Mon, 11 Apr 2016 07:39:16 -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 om6sm28175798wjc.40.2016.04.11.07.39.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Apr 2016 07:39:15 -0700 (PDT) From: Daniel Lezcano To: peterz@infradead.org Cc: Ingo Molnar , linux-kernel@vger.kernel.org (open list:SCHEDULER) Subject: [PATCH V2 2/2] sched/clock: Make local_clock/cpu_clock inline Date: Mon, 11 Apr 2016 16:38:34 +0200 Message-Id: <1460385514-14700-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460385514-14700-1-git-send-email-daniel.lezcano@linaro.org> References: <1460385514-14700-1-git-send-email-daniel.lezcano@linaro.org> 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. sched_clock_cpu() is called via the inlined local_clock()/cpu_clock() functions from sched.h. So any module code including sched.h will reference sched_clock_cpu(). Thus it must be exported with the EXPORT_SYMBOL_GPL macro. Signed-off-by: Daniel Lezcano --- V2 - Add EXPORT_SYMBOL_GPL(sched_clock_cpu) to fix the unresolved symbol errors: >> ERROR: "sched_clock_cpu" [kernel/torture.ko] undefined! >> ERROR: "sched_clock_cpu" [drivers/gpu/drm/i915/i915.ko] undefined! --- include/linux/sched.h | 32 ++++++++++++++++++++++++++++++-- kernel/sched/clock.c | 42 +----------------------------------------- 2 files changed, 31 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..e85a725 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -318,6 +318,7 @@ u64 sched_clock_cpu(int cpu) return clock; } +EXPORT_SYMBOL_GPL(sched_clock_cpu); void sched_clock_tick(void) { @@ -363,33 +364,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 +378,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.