Skip to contentSkip to conversation

kernelshark: Fix bug with Plot CPU filtering

PATCH In review David Sharp 2 participants 9 messages Nov 15, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 kernelshark: Fix bug with Plot CPU filtering

From: Venkatesh Pallipadi <[email protected]>

Plot CPU filtering in kernelshark has the following bug:
1) Deselect CPU A from Plot CPU list
2) Plot gets updated with no CPU A
3) Deselect CPU B
4) Plot continues to have CPU B

This is due to a bug in graph_plot_cpus_update_callback(), which seems to be checking old_all_cpus != new_all_cpus before doing any update. This condition is true on 1, but false on 2. Removing that check fixes the problem.

Tested:
Above sequence now does expected filtering.

Google-bug-id: 4258610

---
 trace-plot-cpu.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
trace-plot-cpu.c +2 -3
index 630d6c2..bb767d3 100644
@@ -498,9 +498,8 @@ void graph_plot_cpus_update_callback(gboolean accept,
 	/* Get the current status */
 	graph_plot_cpus_plotted(ginfo, &old_all_cpus, &old_cpu_mask);
 
-	if (old_all_cpus == all_cpus ||
-	    (selected_cpu_mask &&
-	     cpus_equal(old_cpu_mask, selected_cpu_mask, ginfo->cpus))) {
+	if (selected_cpu_mask &&
+	     cpus_equal(old_cpu_mask, selected_cpu_mask, ginfo->cpus)) {
 		/* Nothing to do */
 		g_free(old_cpu_mask);
 		return;
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 2/4 kernel-shark: Allow unsetting of all CPUs in filter

From: Vaibhav Nagarnaik <[email protected]>

The button "All CPUs" in CPU filter dialog allows setting of all CPUs but doesn't clear CPUs when it is unchecked. Make sure that when the "All CPUs" button is unchecked, all the CPUs get unchecked.

Tested: In kernelshark, go to Filter->list CPUs and uncheck "All CPUs" button. All the CPUs should be unchecked at that point.

---
 trace-filter.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
trace-filter.c +4 -6
index c657a18..89cf032 100644
@@ -1723,12 +1723,10 @@ void cpu_toggle(gpointer data, GtkWidget *widget)
 
 	if (strcmp(label, CPU_ALL_CPUS_STR) == 0) {
 		cpu_helper->allcpus = active;
-		if (active) {
-			/* enable all toggles */
-			for (cpu = 0; cpu < cpu_helper->cpus; cpu++)
-				gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu]),
-							     TRUE);
-		}
+		/* enable/disable all toggles */
+		for (cpu = 0; cpu < cpu_helper->cpus; cpu++)
+			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu]),
+						     active ? TRUE : FALSE);
 		return;
 	}
 
Signature · 1 line
1.7.7.3
#2 lore raw

Re: [PATCH 2/4] kernel-shark: Allow unsetting of all CPUs in filter

Quoted 8 lines · David Sharp

From: Vaibhav Nagarnaik <[email protected]>

The button "All CPUs" in CPU filter dialog allows setting of all CPUs but doesn't clear CPUs when it is unchecked. Make sure that when the "All CPUs" button is unchecked, all the CPUs get unchecked.

Tested: In kernelshark, go to Filter->list CPUs and uncheck "All CPUs" button. All the CPUs should be unchecked at that point.

This was actually done purposely, as I thought it may be used as a way to change to a mode to select individual CPUs.

But I'm fine with having it do this feature, except...

Now when I apply this patch, if I go to deselect a CPU, it unselects the "All CPUs" and causes all CPUs to be unselected.

Need to make it so it only unselects all CPUs if it was directly unselected. Not when its done by deselecting a single CPU.

So, I'm going to NAK this patch, but if you can fix it so that deselecting the "All CPUs" directly has this feature, but I can still deselect a single CPU without it causing all other CPUs to be deselected, then I'm fine with the change.

-- Steve

Quoted 28 lines
---
 trace-filter.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
trace-filter.c +4 -6
index c657a18..89cf032 100644
@@ -1723,12 +1723,10 @@ void cpu_toggle(gpointer data, GtkWidget *widget)
 
 	if (strcmp(label, CPU_ALL_CPUS_STR) == 0) {
 		cpu_helper->allcpus = active;
-		if (active) {
-			/* enable all toggles */
-			for (cpu = 0; cpu < cpu_helper->cpus; cpu++)
-				gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu]),
-							     TRUE);
-		}
+		/* enable/disable all toggles */
+		for (cpu = 0; cpu < cpu_helper->cpus; cpu++)
+			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu]),
+						     active ? TRUE : FALSE);
 		return;
 	}
 
#3 lore raw

PATCH 3/4 kernel-shark: Don't check for system name for sched events

In reply to David Sharp

From: Vaibhav Nagarnaik <[email protected]>

The sched tracepoint names are unique and so there is no need to check for the subsystem name while looking up the event ID.

This helps kernel shark display the graphs correctly for trace.dat files generated from trace collection mechanisms that don't record the subsystem.

Google-Bug-Id: 6333917

---
 trace-graph.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
trace-graph.c +3 -3
index 4d81219..6f72350 100644
@@ -1016,7 +1016,7 @@ int trace_graph_check_sched_wakeup(struct graph_info *ginfo,
 		found = FALSE;
 
 		event = pevent_find_event_by_name(ginfo->pevent,
-						  "sched", "sched_wakeup");
+						  NULL, "sched_wakeup");
 		if (event) {
 			found = TRUE;
 			ginfo->event_wakeup_id = event->id;
@@ -1026,7 +1026,7 @@ int trace_graph_check_sched_wakeup(struct graph_info *ginfo,
 
 
 		event = pevent_find_event_by_name(ginfo->pevent,
-						  "sched", "sched_wakeup_new");
+						  NULL, "sched_wakeup_new");
 		if (event) {
 			found = TRUE;
 			ginfo->event_wakeup_new_id = event->id;
@@ -1086,7 +1086,7 @@ int trace_graph_check_sched_switch(struct graph_info *ginfo,
 
 	if (ginfo->event_sched_switch_id < 0) {
 		event = pevent_find_event_by_name(ginfo->pevent,
-						  "sched", "sched_switch");
+						  NULL, "sched_switch");
 		if (!event)
 			return 0;
 
Signature · 1 line
1.7.7.3
#4 lore raw

PATCH 4/4 kernelshark: Full-height cursor and mark lines

In reply to David Sharp

"width" and "height" were swapped, causing the vertical marker and cursor lines to be drawn with the wrong height.

---
 trace-graph.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
trace-graph.c +4 -4
index 6f72350..60e5241 100644
@@ -380,7 +380,7 @@ static void draw_cursor(struct graph_info *ginfo)
 	x = convert_time_to_x(ginfo, ginfo->cursor);
 
 	gdk_draw_line(ginfo->draw->window, ginfo->draw->style->mid_gc[3],
-		      x, 0, x, ginfo->draw->allocation.width);
+		      x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void draw_marka(struct graph_info *ginfo)
@@ -392,7 +392,7 @@ static void draw_marka(struct graph_info *ginfo)
 
 	x = convert_time_to_x(ginfo, ginfo->marka_time);
 	gdk_draw_line(ginfo->draw->window, green,
-		      x, 0, x, ginfo->draw->allocation.width);
+		      x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void draw_markb(struct graph_info *ginfo)
@@ -404,7 +404,7 @@ static void draw_markb(struct graph_info *ginfo)
 
 	x = convert_time_to_x(ginfo, ginfo->markb_time);
 	gdk_draw_line(ginfo->draw->window, red,
-		      x, 0, x, ginfo->draw->allocation.width);
+		      x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void update_with_backend(struct graph_info *ginfo,
@@ -434,7 +434,7 @@ static void
 draw_line(GtkWidget *widget, gdouble x, struct graph_info *ginfo)
 {
 	gdk_draw_line(widget->window, widget->style->black_gc,
-		      x, 0, x, widget->allocation.width);
+		      x, 0, x, widget->allocation.height);
 }
 
 static void clear_line(struct graph_info *ginfo, gint x)
Signature · 1 line
1.7.7.3
#5 lore raw

Re: [PATCH 4/4] kernelshark: Full-height cursor and mark lines

Quoted 2 lines · David Sharp

"width" and "height" were swapped, causing the vertical marker and cursor lines to be drawn with the wrong height.

Is this the fix to the strange "mark bottom stays around" bug? It's been on my TODO list for a long time to fix that. ;-)

-- Steve

Quoted 46 lines
---
 trace-graph.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
trace-graph.c +4 -4
index 6f72350..60e5241 100644
@@ -380,7 +380,7 @@ static void draw_cursor(struct graph_info *ginfo)
 	x = convert_time_to_x(ginfo, ginfo->cursor);
 
 	gdk_draw_line(ginfo->draw->window, ginfo->draw->style->mid_gc[3],
-		      x, 0, x, ginfo->draw->allocation.width);
+		      x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void draw_marka(struct graph_info *ginfo)
@@ -392,7 +392,7 @@ static void draw_marka(struct graph_info *ginfo)
 
 	x = convert_time_to_x(ginfo, ginfo->marka_time);
 	gdk_draw_line(ginfo->draw->window, green,
-		      x, 0, x, ginfo->draw->allocation.width);
+		      x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void draw_markb(struct graph_info *ginfo)
@@ -404,7 +404,7 @@ static void draw_markb(struct graph_info *ginfo)
 
 	x = convert_time_to_x(ginfo, ginfo->markb_time);
 	gdk_draw_line(ginfo->draw->window, red,
-		      x, 0, x, ginfo->draw->allocation.width);
+		      x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void update_with_backend(struct graph_info *ginfo,
@@ -434,7 +434,7 @@ static void
 draw_line(GtkWidget *widget, gdouble x, struct graph_info *ginfo)
 {
 	gdk_draw_line(widget->window, widget->style->black_gc,
-		      x, 0, x, widget->allocation.width);
+		      x, 0, x, widget->allocation.height);
 }
 
 static void clear_line(struct graph_info *ginfo, gint x)
#6 lore raw

Re: [PATCH 4/4] kernelshark: Full-height cursor and mark lines

Quoted 6 lines · Steven Rostedt
Quoted 2 lines · David Sharp

"width" and "height" were swapped, causing the vertical marker and cursor lines to be drawn with the wrong height.

Is this the fix to the strange "mark bottom stays around" bug? It's been on my TODO list for a long time to fix that. ;-)

That's not how I would have described the bug, but maybe it's the same. What I was seeing was the marks not extending all the way to the bottom of all the plot area when scrolled down. I assume it would only manifest that way when the plot is taller than it is wide (eg, tons of thread plots and fully zoomed out). In the reverse situation, it would be telling gdk to draw outside the bounds of the widget, which might do something weird, although I would hope it would just draw what it could and refuse to draw outside.

Quoted 51 lines

-- Steve

Quoted 46 lines
---
 trace-graph.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
trace-graph.c +4 -4
index 6f72350..60e5241 100644
@@ -380,7 +380,7 @@ static void draw_cursor(struct graph_info *ginfo)
      x = convert_time_to_x(ginfo, ginfo->cursor);
 
      gdk_draw_line(ginfo->draw->window, ginfo->draw->style->mid_gc[3],
-                   x, 0, x, ginfo->draw->allocation.width);
+                   x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void draw_marka(struct graph_info *ginfo)
@@ -392,7 +392,7 @@ static void draw_marka(struct graph_info *ginfo)
 
      x = convert_time_to_x(ginfo, ginfo->marka_time);
      gdk_draw_line(ginfo->draw->window, green,
-                   x, 0, x, ginfo->draw->allocation.width);
+                   x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void draw_markb(struct graph_info *ginfo)
@@ -404,7 +404,7 @@ static void draw_markb(struct graph_info *ginfo)
 
      x = convert_time_to_x(ginfo, ginfo->markb_time);
      gdk_draw_line(ginfo->draw->window, red,
-                   x, 0, x, ginfo->draw->allocation.width);
+                   x, 0, x, ginfo->draw->allocation.height);
 }
 
 static void update_with_backend(struct graph_info *ginfo,
@@ -434,7 +434,7 @@ static void
 draw_line(GtkWidget *widget, gdouble x, struct graph_info *ginfo)
 {
      gdk_draw_line(widget->window, widget->style->black_gc,
-                   x, 0, x, widget->allocation.width);
+                   x, 0, x, widget->allocation.height);
 }
 
 static void clear_line(struct graph_info *ginfo, gint x)
#7 lore raw
In reply to David Sharp

sorry for the dups... typoed Steve's domain.

Quoted 19 lines · David Sharp

From: Venkatesh Pallipadi <[email protected]>

Plot CPU filtering in kernelshark has the following bug:
1) Deselect CPU A from Plot CPU list
2) Plot gets updated with no CPU A
3) Deselect CPU B
4) Plot continues to have CPU B

This is due to a bug in graph_plot_cpus_update_callback(), which seems to be checking old_all_cpus != new_all_cpus before doing any update. This condition is true on 1, but false on 2. Removing that check fixes the problem.

Tested:
Above sequence now does expected filtering.

Google-bug-id: 4258610

#8 lore raw
Quoted 2 lines · David Sharp

sorry for the dups... typoed Steve's domain.

I applied and pushed out patches 1,3 and 4. I already commented on why I neglected patch 2.

-- Steve