diff options
Diffstat (limited to 'perf-event')
| -rw-r--r-- | perf-event/src/lib.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/perf-event/src/lib.rs b/perf-event/src/lib.rs index d1478fe..e09de18 100644 --- a/perf-event/src/lib.rs +++ b/perf-event/src/lib.rs @@ -533,6 +533,25 @@ impl<'a> Builder<'a> { self } + /// Set whether this counter is inherited by new threads. + /// + /// When this flag is set, this counter observes activity in new threads + /// created by any thread already being observed. + /// + /// By default, the flag is unset: counters are not inherited, and observe + /// only the threads specified when they are created. + /// + /// This flag cannot be set if the counter belongs to a `Group`. Doing so + /// will result in an error when the counter is built. This is a kernel + /// limitation. + pub fn inherit_thread(mut self, inherit: bool) -> Builder<'a> { + let flag = if inherit { 1 } else { 0 }; + self.attrs.set_inherit(flag); + self.attrs.set_inherit_stat(flag); + self.attrs.set_inherit_thread(flag); + self + } + /// Count events of the given kind. This accepts an [`Event`] value, /// or any type that can be converted to one, so you can pass [`Hardware`], /// [`Software`] and [`Cache`] values directly. |
