summaryrefslogtreecommitdiff
path: root/perf-event/src
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2025-04-16 12:37:18 +0200
committerDennis Kobert <dennis@kobert.dev>2025-04-16 12:45:53 +0200
commit62e5b43451c31b9edca4fa5c5df8dd9e441c0949 (patch)
tree28bb9a5b539a212b99c2108eec841a18c74b6854 /perf-event/src
parent09b9625b807b880106b66a28568118e3138348d8 (diff)
Inherit energy counters
Diffstat (limited to 'perf-event/src')
-rw-r--r--perf-event/src/lib.rs19
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.