From e0c53d09990b5501e493d048a5dce067d8990281 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 14 Apr 2023 17:50:08 +0100 Subject: [PATCH] ftrace: Set top-level buffer size trace-cmd start -B devlib -b 42 will set the buffer size for the "devlib" ftrace instance but will not set the buffer size of the top-level buffer. Unfortunately, some events still end up in the top-level buffer regardless of any configuration such as the "print" event. This can lead to lost events because the buffer size was too small. Avoid that by using the buffer size for both top-level and devlib's instance. --- devlib/collector/ftrace.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/devlib/collector/ftrace.py b/devlib/collector/ftrace.py index 7a8bcfd..ffdb495 100644 --- a/devlib/collector/ftrace.py +++ b/devlib/collector/ftrace.py @@ -240,6 +240,17 @@ class FtraceCollector(CollectorBase): def reset(self): self.target.execute('{} reset -B devlib'.format(self.target_binary), as_root=True, timeout=TIMEOUT) + + # trace-cmd start will not set the top-level buffer size if passed -B + # parameter, but unfortunately some events still end up there (e.g. + # print event). So we still need to set that size, otherwise the buffer + # might be too small and some event lost. + if self.buffer_size is not None: + self.target.write_value( + self.target.path.join(self.tracing_path, 'buffer_size_kb'), + self.buffer_size + ) + if self.functions: self.target.write_value(self.function_profile_file, 0, verify=False) self._reset_needed = False