[PATCH v15 23/23] perf machine: Add __guarded_by annotation to machines->guests
From: Ian Rogers
Date: Sat Nov 21 2026 - 02:00:00 EST
Annotate guests in struct machines with __guarded_by(&lock) and mark
machines__init() with __context_unsafe().
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/machine.c | 1 +
tools/perf/util/machine.h | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 0cc593d5372a..70870baa157e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -234,6 +234,7 @@ void machine__delete(struct machine *machine)
}
int machines__init(struct machines *machines, struct perf_session *session)
+ __context_unsafe(/* initialization */)
{
int err = machine__init(&machines->host, "", HOST_KERNEL_ID);
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 80191545ee8a..67d517742fb6 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -3,6 +3,7 @@
#define __PERF_MACHINE_H
#include <sys/types.h>
+#include <linux/compiler-context-analysis.h>
#include <linux/rbtree.h>
#include "maps.h"
#include "dsos.h"
@@ -153,7 +154,7 @@ struct machines {
struct perf_session *session;
struct rw_semaphore lock;
struct machine host;
- struct rb_root_cached guests;
+ struct rb_root_cached guests __guarded_by(&lock);
};
int machines__init(struct machines *machines, struct perf_session *session);
--
2.56.1.750.gf70dc682cf-goog