linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf, x86: Don't use clock function pointer to determine clock
@ 2016-04-14 11:59 Alexander Shishkin
  2016-04-19  9:34 ` [tip:sched/core] perf/core, sched: " tip-bot for Alexander Shishkin
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Shishkin @ 2016-04-14 11:59 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, linux-kernel, vince, eranian,
	Arnaldo Carvalho de Melo, Borislav Petkov, Alexander Shishkin,
	Daniel Lezcano

Now that local_clock() is explicitly inlined in sched.h, taking its
pointer would uninline it in the compilation unit where it's done,
making (among other things) comparing pointers to this function
produce different results in different compilation units.

Case in point, x86 perf core's user page updating function compares
event's clock against &local_clock to see if it needs to set zero
time offset related bits in the page.

This patch fixes the latter by looking at the "use_clockid" event
attribute instead, to determine whether local clock is used. Fixing
the uninlined local_clock() in perf core is left as an exercise for
the author of the prior work.

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Fixes: http://lkml.kernel.org/r/1459541050-13654-1-git-send-email-daniel.lezcano@linaro.org
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 arch/x86/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 002b2eadd6..945ce189f5 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2177,7 +2177,7 @@ void arch_perf_update_userpage(struct perf_event *event,
 	 * cap_user_time_zero doesn't make sense when we're using a different
 	 * time base for the records.
 	 */
-	if (event->clock == &local_clock) {
+	if (!event->attr.use_clockid) {
 		userpg->cap_user_time_zero = 1;
 		userpg->time_zero = data->cyc2ns_offset;
 	}
-- 
2.8.0.rc3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [tip:sched/core] perf/core, sched: Don't use clock function pointer to determine clock
  2016-04-14 11:59 [PATCH] perf, x86: Don't use clock function pointer to determine clock Alexander Shishkin
@ 2016-04-19  9:34 ` tip-bot for Alexander Shishkin
  2016-04-20  5:06   ` Daniel Lezcano
  0 siblings, 1 reply; 3+ messages in thread
From: tip-bot for Alexander Shishkin @ 2016-04-19  9:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: daniel.lezcano, tglx, bp, peterz, torvalds, mingo, linux-kernel,
	alexander.shishkin, hpa, a.p.zijlstra, acme

Commit-ID:  f454bfddf6ba557381d8bf5df50eff778602ff23
Gitweb:     http://git.kernel.org/tip/f454bfddf6ba557381d8bf5df50eff778602ff23
Author:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Thu, 14 Apr 2016 14:59:49 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 19 Apr 2016 10:55:29 +0200

perf/core, sched: Don't use clock function pointer to determine clock

Now that local_clock() is explicitly inlined in sched.h, taking its
pointer would uninline it in the compilation unit where it's done,
making (among other things) comparing pointers to this function
produce different results in different compilation units.

Case in point, x86 perf core's user page updating function compares
event's clock against &local_clock to see if it needs to set zero
time offset related bits in the page.

This patch fixes the latter by looking at the "use_clockid" event
attribute instead, to determine whether local clock is used. Fixing
the uninlined local_clock() in perf core is left as an exercise for
the author of the prior work.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: eranian@google.com
Cc: vince@deater.net
Fixes: http://lkml.kernel.org/r/1459541050-13654-1-git-send-email-daniel.lezcano@linaro.org
Link: http://lkml.kernel.org/r/1460635189-2320-1-git-send-email-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 041e442..dd39fde 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2177,7 +2177,7 @@ void arch_perf_update_userpage(struct perf_event *event,
 	 * cap_user_time_zero doesn't make sense when we're using a different
 	 * time base for the records.
 	 */
-	if (event->clock == &local_clock) {
+	if (!event->attr.use_clockid) {
 		userpg->cap_user_time_zero = 1;
 		userpg->time_zero = data->cyc2ns_offset;
 	}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [tip:sched/core] perf/core, sched: Don't use clock function pointer to determine clock
  2016-04-19  9:34 ` [tip:sched/core] perf/core, sched: " tip-bot for Alexander Shishkin
@ 2016-04-20  5:06   ` Daniel Lezcano
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2016-04-20  5:06 UTC (permalink / raw)
  To: torvalds, tglx, bp, peterz, alexander.shishkin, linux-kernel,
	mingo, acme, hpa, a.p.zijlstra
  Cc: linux-tip-commits

On Tue, Apr 19, 2016 at 02:34:50AM -0700, tip-bot for Alexander Shishkin wrote:
> Commit-ID:  f454bfddf6ba557381d8bf5df50eff778602ff23
> Gitweb:     http://git.kernel.org/tip/f454bfddf6ba557381d8bf5df50eff778602ff23
> Author:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
> AuthorDate: Thu, 14 Apr 2016 14:59:49 +0300
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Tue, 19 Apr 2016 10:55:29 +0200
> 
> perf/core, sched: Don't use clock function pointer to determine clock
> 
> Now that local_clock() is explicitly inlined in sched.h, taking its
> pointer would uninline it in the compilation unit where it's done,
> making (among other things) comparing pointers to this function
> produce different results in different compilation units.
> 
> Case in point, x86 perf core's user page updating function compares
> event's clock against &local_clock to see if it needs to set zero
> time offset related bits in the page.
> 
> This patch fixes the latter by looking at the "use_clockid" event
> attribute instead, to determine whether local clock is used. Fixing
> the uninlined local_clock() in perf core is left as an exercise for
> the author of the prior work.

Ouch! Good exercise :)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-20  5:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14 11:59 [PATCH] perf, x86: Don't use clock function pointer to determine clock Alexander Shishkin
2016-04-19  9:34 ` [tip:sched/core] perf/core, sched: " tip-bot for Alexander Shishkin
2016-04-20  5:06   ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).