Skip to contentSkip to conversation

perf: Keep track of remaining time when enabling/disabling swevent hrtimers

PATCH New Soeren Sandmann 1 participant 1 message Oct 22, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 perf: Keep track of remaining time when enabling/disabling swevent hrtimers

[I don't think this mail got through the first time]

Hi,

These patches against perf/core make the hrtimer based events work for sysprof.

1/2: Don't restart the timer on every scheduler tick 2/2: If exclude_idle is set, don't report idle events

Thanks,
Soren

Quoted 1 line

From f3e9630ccee6c148ee9c5bc1632dfd0384969b2b Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= <[email protected]>
Date: Thu, 22 Oct 2009 09:51:35 -0400
Subject: [PATCH 1/2] perf: Keep track of remaining time when enabling/disabling swevent hrtimers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Whenever a swevent is scheduled out, the hrtimer is canceled. When it is scheduled back in, the timer is restarted. This happens every scheduler tick, which means the timer never expired because it was getting repeatedly restarted over and over with the same period.

To fix that, save the remaining time when disabling; when reenabling, use that saved time as the period instead of the user-specified sampling period.

Also, move the starting and stopping of the hrtimers to helper functions instead of duplicating the code.

---
 include/linux/perf_event.h |    4 +-
 kernel/perf_event.c        |   64 +++++++++++++++++++++++++++++--------------
 2 files changed, 45 insertions(+), 23 deletions(-)
include/linux/perf_event.h +2 -2
index 2e6d95f..9e70126 100644
@@ -471,8 +471,8 @@ struct hw_perf_event {
 			unsigned long	event_base;
 			int		idx;
 		};
-		union { /* software */
-			atomic64_t	count;
+		struct { /* software */
+			s64		remaining;
 			struct hrtimer	hrtimer;
 		};
 	};
kernel/perf_event.c +43 -21

93 lines not on this page · raw message

Signature · 1 line
1.6.5.rc2