Skip to contentSkip to conversation

perf sched timehist: Fix use of CPU list with summary option

PATCH Applied David Ahern 3 participants 3 messages Aug 17, 2020 – Aug 18, 2020 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf sched timehist: Fix use of CPU list with summary option

Do not update thread stats or show idle summary unless CPU is in the list of interest.

Fixes c30d630d1bcf ("perf sched timehist: Add support for filtering on CPU")

---
v2
- check that cpu_list is set before checking cpu_bitmap in timehist_print_summary

 tools/perf/builtin-sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +5 -1
index 0c7d599fa555..e6fc297cee91 100644
@@ -2584,7 +2584,8 @@ static int timehist_sched_change_event(struct perf_tool *tool,
 	}
 
 	if (!sched->idle_hist || thread->tid == 0) {
-		timehist_update_runtime_stats(tr, t, tprev);
+		if (!cpu_list || test_bit(sample->cpu, cpu_bitmap))
+			timehist_update_runtime_stats(tr, t, tprev);
 
 		if (sched->idle_hist) {
 			struct idle_thread_runtime *itr = (void *)tr;
@@ -2857,6 +2858,9 @@ static void timehist_print_summary(struct perf_sched *sched,
 
 	printf("\nIdle stats:\n");
 	for (i = 0; i < idle_max_cpu; ++i) {
+		if (cpu_list && !test_bit(i, cpu_bitmap))
+			continue;
+
 		t = idle_threads[i];
 		if (!t)
 			continue;
Signature · 1 line
2.17.1
maintainer Acked-by on v2 1/1
#1 lore raw

Hi David,

Quoted 6 lines · David Ahern

Do not update thread stats or show idle summary unless CPU is in the list of interest.

Fixes c30d630d1bcf ("perf sched timehist: Add support for filtering on CPU")

Thanks
Namhyung

Quoted 34 lines

---
v2
- check that cpu_list is set before checking cpu_bitmap in timehist_print_summary

 tools/perf/builtin-sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +5 -2
index 0c7d599fa555..e6fc297cee91 100644
@@ -2584,7 +2584,8 @@ static int timehist_sched_change_event(struct perf_tool *tool,
        }
 
        if (!sched->idle_hist || thread->tid == 0) {
-               timehist_update_runtime_stats(tr, t, tprev);
+               if (!cpu_list || test_bit(sample->cpu, cpu_bitmap))
+                       timehist_update_runtime_stats(tr, t, tprev);
 
                if (sched->idle_hist) {
                        struct idle_thread_runtime *itr = (void *)tr;
@@ -2857,6 +2858,9 @@ static void timehist_print_summary(struct perf_sched *sched,
 
        printf("\nIdle stats:\n");
        for (i = 0; i < idle_max_cpu; ++i) {
+               if (cpu_list && !test_bit(i, cpu_bitmap))
+                       continue;
+
                t = idle_threads[i];
                if (!t)
                        continue;
--

2.17.1

maintainer Applied
#2 lore raw

Em Tue, Aug 18, 2020 at 10:29:29AM +0900, Namhyung Kim escreveu:

Quoted 11 lines

Hi David,

Quoted 6 lines · David Ahern

Do not update thread stats or show idle summary unless CPU is in the list of interest.

Fixes c30d630d1bcf ("perf sched timehist: Add support for filtering on CPU")

Thanks, applied.

- Arnaldo

Quoted 37 lines

Thanks
Namhyung

Quoted 34 lines

---
v2
- check that cpu_list is set before checking cpu_bitmap in timehist_print_summary

 tools/perf/builtin-sched.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +5 -2
index 0c7d599fa555..e6fc297cee91 100644
@@ -2584,7 +2584,8 @@ static int timehist_sched_change_event(struct perf_tool *tool,
        }
 
        if (!sched->idle_hist || thread->tid == 0) {
-               timehist_update_runtime_stats(tr, t, tprev);
+               if (!cpu_list || test_bit(sample->cpu, cpu_bitmap))
+                       timehist_update_runtime_stats(tr, t, tprev);
 
                if (sched->idle_hist) {
                        struct idle_thread_runtime *itr = (void *)tr;
@@ -2857,6 +2858,9 @@ static void timehist_print_summary(struct perf_sched *sched,
 
        printf("\nIdle stats:\n");
        for (i = 0; i < idle_max_cpu; ++i) {
+               if (cpu_list && !test_bit(i, cpu_bitmap))
+                       continue;
+
                t = idle_threads[i];
                if (!t)
                        continue;
--

2.17.1

Signature · 1 line
- Arnaldo