aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/perf_event.h
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-05-23 07:13:02 -0400
committerIngo Molnar <mingo@kernel.org>2012-05-23 11:40:51 -0400
commitab0cce560ef177bdc7a8f73e9962be9d829a7b2c (patch)
treed9875b21c42862201624eb7d9ea2c36f4ea4035d /include/linux/perf_event.h
parent26252ea675663d1bc6747125fcaa2b7cc4ed8a03 (diff)
Revert "sched, perf: Use a single callback into the scheduler"
This reverts commit cb04ff9ac424 ("sched, perf: Use a single callback into the scheduler"). Before this change was introduced, the process switch worked like this (wrt. to perf event schedule): schedule (prev, next) - schedule out all perf events for prev - switch to next - schedule in all perf events for current (next) After the commit, the process switch looks like: schedule (prev, next) - schedule out all perf events for prev - schedule in all perf events for (next) - switch to next The problem is, that after we schedule perf events in, the pmu is enabled and we can receive events even before we make the switch to next - so "current" still being prev process (event SAMPLE data are filled based on the value of the "current" process). Thats exactly what we see for test__PERF_RECORD test. We receive SAMPLES with PID of the process that our tracee is scheduled from. Discussed with Peter Zijlstra: > Bah!, yeah I guess reverting is the right thing for now. Sad > though. > > So by having the two hooks we have a black-spot between them > where we receive no events at all, this black-spot covers the > hand-over of current and we thus don't receive the 'wrong' > events. > > I rather liked we could do away with both that black-spot and > clean up the code a little, but apparently people rely on it. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: acme@redhat.com Cc: paulus@samba.org Cc: cjashfor@linux.vnet.ibm.com Cc: fweisbec@gmail.com Cc: eranian@google.com Link: http://lkml.kernel.org/r/20120523111302.GC1638@m.brq.redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/perf_event.h')
-rw-r--r--include/linux/perf_event.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 8adf70e9e3cc..f32578634d9d 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1084,8 +1084,10 @@ extern void perf_pmu_unregister(struct pmu *pmu);
1084 1084
1085extern int perf_num_counters(void); 1085extern int perf_num_counters(void);
1086extern const char *perf_pmu_name(void); 1086extern const char *perf_pmu_name(void);
1087extern void __perf_event_task_sched(struct task_struct *prev, 1087extern void __perf_event_task_sched_in(struct task_struct *prev,
1088 struct task_struct *next); 1088 struct task_struct *task);
1089extern void __perf_event_task_sched_out(struct task_struct *prev,
1090 struct task_struct *next);
1089extern int perf_event_init_task(struct task_struct *child); 1091extern int perf_event_init_task(struct task_struct *child);
1090extern void perf_event_exit_task(struct task_struct *child); 1092extern void perf_event_exit_task(struct task_struct *child);
1091extern void perf_event_free_task(struct task_struct *task); 1093extern void perf_event_free_task(struct task_struct *task);
@@ -1205,13 +1207,20 @@ perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr)
1205 1207
1206extern struct static_key_deferred perf_sched_events; 1208extern struct static_key_deferred perf_sched_events;
1207 1209
1208static inline void perf_event_task_sched(struct task_struct *prev, 1210static inline void perf_event_task_sched_in(struct task_struct *prev,
1209 struct task_struct *task) 1211 struct task_struct *task)
1210{ 1212{
1213 if (static_key_false(&perf_sched_events.key))
1214 __perf_event_task_sched_in(prev, task);
1215}
1216
1217static inline void perf_event_task_sched_out(struct task_struct *prev,
1218 struct task_struct *next)
1219{
1211 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0); 1220 perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, NULL, 0);
1212 1221
1213 if (static_key_false(&perf_sched_events.key)) 1222 if (static_key_false(&perf_sched_events.key))
1214 __perf_event_task_sched(prev, task); 1223 __perf_event_task_sched_out(prev, next);
1215} 1224}
1216 1225
1217extern void perf_event_mmap(struct vm_area_struct *vma); 1226extern void perf_event_mmap(struct vm_area_struct *vma);
@@ -1286,8 +1295,11 @@ extern void perf_event_disable(struct perf_event *event);
1286extern void perf_event_task_tick(void); 1295extern void perf_event_task_tick(void);
1287#else 1296#else
1288static inline void 1297static inline void
1289perf_event_task_sched(struct task_struct *prev, 1298perf_event_task_sched_in(struct task_struct *prev,
1290 struct task_struct *task) { } 1299 struct task_struct *task) { }
1300static inline void
1301perf_event_task_sched_out(struct task_struct *prev,
1302 struct task_struct *next) { }
1291static inline int perf_event_init_task(struct task_struct *child) { return 0; } 1303static inline int perf_event_init_task(struct task_struct *child) { return 0; }
1292static inline void perf_event_exit_task(struct task_struct *child) { } 1304static inline void perf_event_exit_task(struct task_struct *child) { }
1293static inline void perf_event_free_task(struct task_struct *task) { } 1305static inline void perf_event_free_task(struct task_struct *task) { }