Skip to content

Commit 70d815a

Browse files
committed
perf, sched migration: Make it vertically scrollable
With scheduler traces covering more than two cpus, rectangles of the CPUs 3 and more are not visibles. This makes the vertical navigation scrollable so that all of the CPUs rectangles are available. We also want to be able to zoom vertically, so that we can fit at best the screen with CPU rectangles, but that's for later. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Nikhil Rao <ncrao@google.com> Cc: Tom Zanussi <tzanussi@gmail.com>
1 parent 0cddf56 commit 70d815a

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

‎tools/perf/scripts/python/sched-migration.py‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ def __init__(self, timeslices, parent = None, id = -1, title = "Migration"):
4343
self.timeslices = timeslices
4444
(self.ts_start, self.ts_end) = timeslices.interval()
4545
self.update_width_virtual()
46+
self.nr_cpus = timeslices.max_cpu() + 1
47+
self.height_virtual = RootFrame.Y_OFFSET + (self.nr_cpus * (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE))
4648

4749
# whole window panel
4850
self.panel = wx.Panel(self, size=(self.screen_width, self.screen_height))
4951

5052
# scrollable container
5153
self.scroll = wx.ScrolledWindow(self.panel)
52-
self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, 100 / 10)
54+
self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale)
5355
self.scroll.EnableScrolling(True, True)
5456
self.scroll.SetFocus()
5557

5658
# scrollable drawing area
57-
self.scroll_panel = wx.Panel(self.scroll, size=(self.screen_width, self.screen_height / 2))
59+
self.scroll_panel = wx.Panel(self.scroll, size=(self.screen_width - 15, self.screen_height / 2))
5860
self.scroll_panel.Bind(wx.EVT_PAINT, self.on_paint)
5961
self.scroll_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
6062
self.scroll_panel.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down)
@@ -65,9 +67,8 @@ def __init__(self, timeslices, parent = None, id = -1, title = "Migration"):
6567
self.scroll.Fit()
6668
self.Fit()
6769

68-
self.scroll_panel.SetDimensions(-1, -1, self.width_virtual, -1, wx.SIZE_USE_EXISTING)
70+
self.scroll_panel.SetDimensions(-1, -1, self.width_virtual, self.height_virtual, wx.SIZE_USE_EXISTING)
6971

70-
self.max_cpu = -1
7172
self.txt = None
7273

7374
self.Show(True)
@@ -143,8 +144,6 @@ def update_rectangles(self, dc, start, end):
143144

144145
for cpu in timeslice.rqs:
145146
self.update_rectangle_cpu(dc, timeslice, cpu, self.timeslices[0].start)
146-
if cpu > self.max_cpu:
147-
self.max_cpu = cpu
148147

149148
def on_paint(self, event):
150149
color = wx.Colour(0xff, 0xff, 0xff)
@@ -163,7 +162,7 @@ def cpu_from_ypixel(self, y):
163162
cpu = y / (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE)
164163
height = y % (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE)
165164

166-
if cpu < 0 or cpu > self.max_cpu or height > RootFrame.CPU_HEIGHT:
165+
if cpu < 0 or cpu > self.nr_cpus - 1 or height > RootFrame.CPU_HEIGHT:
167166
return -1
168167

169168
return cpu
@@ -206,7 +205,7 @@ def __zoom(self, x):
206205
self.update_width_virtual()
207206
(xpos, ypos) = self.scroll.GetViewStart()
208207
xpos = self.us_to_px(x) / self.scroll_scale
209-
self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, 100 / 10, xpos, ypos)
208+
self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale, xpos, ypos)
210209
self.Refresh()
211210

212211
def zoom_in(self):
@@ -234,7 +233,11 @@ def on_key_press(self, event):
234233
if key == wx.WXK_RIGHT:
235234
self.scroll.Scroll(x + 1, y)
236235
elif key == wx.WXK_LEFT:
237-
self.scroll.Scroll(x -1, y)
236+
self.scroll.Scroll(x - 1, y)
237+
elif key == wx.WXK_DOWN:
238+
self.scroll.Scroll(x, y + 1)
239+
elif key == wx.WXK_UP:
240+
self.scroll.Scroll(x, y - 1)
238241

239242

240243
threads = { 0 : "idle"}
@@ -504,6 +507,14 @@ def interval(self):
504507

505508
return (self.data[0].start, self.data[-1].end)
506509

510+
def max_cpu(self):
511+
last_ts = self.data[-1]
512+
max_cpu = 0
513+
for cpu in last_ts.rqs:
514+
if cpu > max_cpu:
515+
max_cpu = cpu
516+
return max_cpu
517+
507518

508519
class SchedEventProxy:
509520
def __init__(self):

0 commit comments

Comments
 (0)