public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* perf: allow command to attach local data to thread/evsel structs
@ 2012-02-07 18:11 David Ahern
  2012-02-07 20:10 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 5+ messages in thread
From: David Ahern @ 2012-02-07 18:11 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra,
	Frederic Weisbecker, Stephane Eranian
  Cc: LKML

This is an API I have been using for some 'local' commands that process
perf events. It allows the commands to attach data to events and threads
and avoid local caching and lookups.


diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 326b8e4..866de40 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -66,6 +66,12 @@ struct perf_evsel {
        void        *data;
    } handler;
    bool            supported;
+
+   /*
+    * can be used by commands that process samples
+    * for storing local, event-based data
+    */
+   void *private;
 };

 struct cpu_map;
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 70c2c13..9f62859 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -16,6 +16,12 @@ struct thread {
    bool            comm_set;
    char            *comm;
    int         comm_len;
+
+    /*
+    * can be used by commands that process samples
+    * for storing local, thread-based data
+    */
+   void *private;
 };

 struct machine;

One wrinkle is that for the thread-based one the thread__delete(),
thread__fork() and thread__set_comm() functions would free the
allocations if set -- or a handler is needed to free private structs to
handle layered mallocs.

Any objections to pushing this kind of open-ended API into perf?

David

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-02-07 21:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-07 18:11 perf: allow command to attach local data to thread/evsel structs David Ahern
2012-02-07 20:10 ` Arnaldo Carvalho de Melo
2012-02-07 21:18   ` David Ahern
2012-02-07 21:33     ` Arnaldo Carvalho de Melo
2012-02-07 21:55       ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox