lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150106101839.GN29390@twins.programming.kicks-ass.net>
Date:	Tue, 6 Jan 2015 11:18:39 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Shaohua Li <shli@...com>
Cc:	Andy Lutomirski <luto@...capital.net>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	X86 ML <x86@...nel.org>, Kernel-team@...com,
	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
	John Stultz <john.stultz@...aro.org>
Subject: Re: [PATCH v2 3/3] X86: Add a thread cpu time implementation to vDSO

On Mon, Jan 05, 2015 at 03:23:38PM -0800, Shaohua Li wrote:
> Good, it works. But the timestamp (.time_running and friends) only gets
> updated for real hardware event between context switches. For software
> event, the timestamp is initialized once, then never updated. If I use
> it to get time, I actually get CLOCK_MONOTONIC. Hardware events work
> well here, but depending on hardware event is too tricky, which I'd like
> to avoid.

Hmm, that's an unfortunate difference in behaviour, does something like
the below cure that for you?

---
 kernel/events/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4c1ee7f2bebc..0feb4e039359 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5965,11 +5965,13 @@ static void perf_swevent_del(struct perf_event *event, int flags)
 static void perf_swevent_start(struct perf_event *event, int flags)
 {
 	event->hw.state = 0;
+	perf_event_update_userpage(event);
 }
 
 static void perf_swevent_stop(struct perf_event *event, int flags)
 {
 	event->hw.state = PERF_HES_STOPPED;
+	perf_event_update_userpage(event);
 }
 
 /* Deref the hlist from the update side */
@@ -6410,12 +6412,14 @@ static void cpu_clock_event_start(struct perf_event *event, int flags)
 {
 	local64_set(&event->hw.prev_count, local_clock());
 	perf_swevent_start_hrtimer(event);
+	perf_event_update_userpage(event);
 }
 
 static void cpu_clock_event_stop(struct perf_event *event, int flags)
 {
 	perf_swevent_cancel_hrtimer(event);
 	cpu_clock_event_update(event);
+	perf_event_update_userpage(event);
 }
 
 static int cpu_clock_event_add(struct perf_event *event, int flags)
@@ -6484,12 +6488,14 @@ static void task_clock_event_start(struct perf_event *event, int flags)
 {
 	local64_set(&event->hw.prev_count, event->ctx->time);
 	perf_swevent_start_hrtimer(event);
+	perf_event_update_userpage(event);
 }
 
 static void task_clock_event_stop(struct perf_event *event, int flags)
 {
 	perf_swevent_cancel_hrtimer(event);
 	task_clock_event_update(event, event->ctx->time);
+	perf_event_update_userpage(event);
 }
 
 static int task_clock_event_add(struct perf_event *event, int flags)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ