[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1239960548.23397.4282.camel@laptop>
Date: Fri, 17 Apr 2009 11:29:08 +0200
From: Peter Zijlstra <a.p.zijlstra@...llo.nl>
To: Frédéric Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>, Steven Rostedt <rostedt@...dmis.org>,
Zhaolei <zhaolei@...fujitsu.com>,
Tom Zanussi <tzanussi@...il.com>,
Li Zefan <lizf@...fujitsu.com>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2 v2] tracing/events: provide string with undefined
size support
On Fri, 2009-04-17 at 10:59 +0200, Frédéric Weisbecker wrote:
> struct foo {
> field1;
> field2;
> ...
> };
>
> struct foo *f;
>
> event = ring_buffer_lock_reserve(sizeof(*f), ...);
> f = ring_buffer_event_data(event);
>
> I can't use a kmalloc here. We are tracing a random event which can happen
> at a random frequency, random context, etc...
Can't you add a bit to that ring_buffer_lock_reserve() thing?
The thing I do for perf_counters is I first iterate all the output, then
make the reserve large enough to fit all the output in, then copy the
bits into the output buffer.
The result is that the output cannot be interpreted as a fixed offset
struct, but that's not much of an issue anyway.
Another possibility is using relative pointers for strings that point
beyond the tail of the fixed offset struct.
So something like:
__field(int, foo);
__string(bar);
__field(int, foo2);
__string(bar2);
__field(int, foo3);
would look like:
struct plop {
int foo;
char *bar;
int foo2;
char *bar2;
int foo3;
char data[0];
}
and you'd do something like:
size = sizeof(struct plop);
size += strlen(bar) + 1;
size += strlen(bar2) + 1;
event = ring_buffer_lock_reserve(size);
offset = sizeof(struct plop);
my_plop.bar = (char *)offset;
offset += strlen(bar) + 1;
my_plop.bar2 = (char *)offset;
memcpy(&event, &my_plop, sizeof(struct plop));
memcpy(&event + my_plop.bar, bar, strlen(bar)+1);
memcpy(&event + my_plop.bar2, bar2, strlen(bar2)+1);
ring_buffer_unlock();
Then on reading, you'd get a variable sized entry, with a fixed size
fixed offset struct, that contains relative offset character pointers.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists