From: David Ahern <dsahern@gmail.com>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Stephane Eranian <eranian@google.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: perf: allow command to attach local data to thread/evsel structs
Date: Tue, 07 Feb 2012 14:55:43 -0700 [thread overview]
Message-ID: <4F319DDF.4020303@gmail.com> (raw)
In-Reply-To: <20120207213322.GF2172@infradead.org>
On 02/07/2012 02:33 PM, Arnaldo Carvalho de Melo wrote:
>>> I think we either use {thread_conf,evsel_conf} for global configuration
>>> options for these two core data structures or we just provide some
>>> optional, per perf_tool allocator.
>>
>> Meaning conf's that parallel symbol_conf -- allocated and 'owned' by the
>> perf library but exported for the user to set values. In this case
>> handlers are needed for allocation and free as instances come and go?
>> e.g., thread__new invokes thread_conf.allocator if defined and
>> thread__priv returns a pointer to private data.
>
> Well, the symbol way of doing things is to just allocate as many bytes
> as the tool being used asks for and then at free time nothing special
> has to be done.
Consider the case of events and you want to track time last seen by cpu.
You need an array:
u64 last_seen[]
with CPU as an index, but do not want to assume some value of max_cpus.
So one option is:
struct priv {
u64 *last_seen; /* time this event was last seen */
u32 max_cpu; /* highest cpu slot allocated */
};
last_seen is malloc'ed first time the event is processed and realloc'ed
as max_cpu increases. Attaching that struct to an event means an
embedded allocation that does not follow the static model of symbol_conf.
David
prev parent reply other threads:[~2012-02-07 21:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F319DDF.4020303@gmail.com \
--to=dsahern@gmail.com \
--cc=acme@ghostprotocols.net \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox