From 614afa949ce9bfa57876f3021a2ddc1abc576e4e Mon Sep 17 00:00:00 2001 From: Stephen Dickey Date: Tue, 22 Dec 2020 16:22:43 -0800 Subject: [PATCH] ANDROID: cpuhp/pause: add trace points for pause and resume Add a tracepoint for pause and resume which measures the duration of time to perform the entire operation, the cpus acted upon with this event, and the current state of the active cpu mask. This should be sufficient for testing pause performance. Bug: 175959069 Change-Id: I9fc269c7d09ac78ec31612d3c552044b72b0e6e3 Signed-off-by: Stephen Dickey --- include/trace/events/cpuhp.h | 22 ++++++++++++++++++++++ kernel/cpu.c | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/trace/events/cpuhp.h b/include/trace/events/cpuhp.h index ad16f77310c6..f302ab6dbfb8 100644 --- a/include/trace/events/cpuhp.h +++ b/include/trace/events/cpuhp.h @@ -89,6 +89,28 @@ TRACE_EVENT(cpuhp_exit, __entry->cpu, __entry->state, __entry->idx, __entry->ret) ); +TRACE_EVENT(cpuhp_pause, + TP_PROTO(struct cpumask *cpus, u64 start_time, unsigned char pause), + + TP_ARGS(cpus, start_time, pause), + + TP_STRUCT__entry( + __field( unsigned int, cpus ) + __field( unsigned int, active_cpus ) + __field( unsigned int, time ) + __field( unsigned char, pause ) + ), + + TP_fast_assign( + __entry->cpus = cpumask_bits(cpus)[0]; + __entry->active_cpus = cpumask_bits(cpu_active_mask)[0]; + __entry->time = div64_u64(sched_clock() - start_time, 1000); + __entry->pause = pause; + ), + + TP_printk("req_cpus=0x%x act_cpus=0x%x time=%u us paused=%d", + __entry->cpus, __entry->active_cpus, __entry->time, __entry->pause) +); #endif /* This part must be outside protection */ diff --git a/kernel/cpu.c b/kernel/cpu.c index d7e6c5bac443..98087a6fd37f 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1135,6 +1135,9 @@ int pause_cpus(struct cpumask *cpus) { int err = 0; int cpu; + u64 start_time = 0; + + start_time = sched_clock(); cpu_maps_update_begin(); @@ -1232,6 +1235,8 @@ err_cpus_write_unlock: err_cpu_maps_update: cpu_maps_update_done(); + trace_cpuhp_pause(cpus, start_time, 1); + return err; } EXPORT_SYMBOL_GPL(pause_cpus); @@ -1240,6 +1245,9 @@ int resume_cpus(struct cpumask *cpus) { unsigned int cpu; int err = 0; + u64 start_time = 0; + + start_time = sched_clock(); cpu_maps_update_begin(); @@ -1298,6 +1306,8 @@ err_cpus_write_unlock: err_cpu_maps_update: cpu_maps_update_done(); + trace_cpuhp_pause(cpus, start_time, 0); + return err; } EXPORT_SYMBOL_GPL(resume_cpus);