Expose kernel tracer to user-space (version 6)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · * Francis Giraldeau ([email protected]) wrote:
By writing to the file
/proc/lttng_uevent, a user-space application creates a kernel event. The event's payload is by default UTF-8 text, but any data can be written, up to 1024 bytes. Null-character is optional and is not enforced.
The 1024 byte limit is removed now, right ?
Quoted 72 lines
The
event uses sequence for space efficiency and to store any data as payload.The feature is enabled when the module lttng-uevent is loaded. The module can be removed if no tracing sessions with
lttng_ueventenabled is active.Signed-off-by Francis Giraldeau <[email protected]>--- instrumentation/events/lttng-module/uevent.h | 33 +++++++++ probes/Makefile | 1 + probes/lttng-uevent.c | 97 ++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 instrumentation/events/lttng-module/uevent.h create mode 100644 probes/lttng-uevent.cinstrumentation/events/lttng-module/uevent.h new file +33
-0@@ -0,0 +1,33 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM uevent + +#if !defined(UEVENT_H_ ) || defined(TRACE_HEADER_MULTI_READ ) +#define UEVENT_H_ + +#include <linux/tracepoint.h> + +TRACE_EVENT (lttng_uevent, + + TP_PROTO(const char *str, size_t len), + +TP_ARGS (str, len), + +/* +* Uses sequence to hold variable size data, by default considered +* as text. Null-terminal character is optional and is not enforced. +*/ +TP_STRUCT__entry ( +__dynamic_array_text (char, text, len) + ), + +TP_fast_assign ( +tp_memcpy_dyn_from_user (text, str) + ), + +TP_printk ("" ) +) + +#endif /* UEVENT_H_ */ + +/* This part must be outside protection */ +#include "../../../probes/define_trace.h" probes/Makefile +1
-0@@ -14,6 +14,7 @@ obj-m += lttng-probe-sched.o obj-m += lttng-probe-irq.o obj-m += lttng-probe-signal.o obj-m += lttng-probe-timer.o +obj-m += lttng-uevent.o obj-m += lttng-probe-statedump.oprobes/lttng-uevent.c new file +0
-0
probes/lttng-uevent.c line 6
Quoted 6 lines
probes/lttng-uevent.c new file +6
-0@@ -0,0 +1,97 @@ +/* +* probes/lttng-uevent.c +* +* Expose kernel tracer to user-space through /proc/lttng +* +* Copyright (C) 2009-2012 Mathieu Desnoyers <[email protected]>
you might want to add your own copyright in here too.
the rest looks good. I look forward to see the updated version.
Thanks,
Mathieu
Quoted 99 lines
probes/lttng-uevent.c new file +91
-0+* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; only +* version 2.1 of the License. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <linux/module.h> +#include <linux/proc_fs.h> + +/* +* Create lttng_uevent tracepoint probes. +*/ + +#define TP_MODULE_NOAUTOLOAD +#define LTTNG_PACKAGE_BUILD +#define CREATE_TRACE_POINTS +#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module +#include "../instrumentation/events/lttng-module/uevent.h" + +#define LTTNG_UEVENT_FILE "lttng_uevent" + +/** +* lttng_uevent_write - write user-space data into kernel trace +* @file: file pointer +* @user_buf: user string +* @count: length to copy +* @ppos: unused +* +* Copy count bytes into a trace event "lttng_uevent". +* +* Returns the number of bytes copied from the source. +* Notice that there is no guarantee that the event is +* actually written in a trace. This can occur in 3 +* situations: +* +* * Buffer overrun +* * No trace session are active +* * The data size is greater than a sub-buffer +*/ + +ssize_t lttng_uevent_write (struct file *file,const char __user *ubuf, +size_t count,loff_t *fpos) +{ +trace_lttng_uevent (ubuf, count); +return count; +} + +static const struct file_operations uev_ops = { + .owner =THIS_MODULE , + .write = lttng_uevent_write +}; + +static int __init lttng_uevent_init (void ) +{ +struct proc_dir_entry *uev_file; + + uev_file =create_proc_entry (LTTNG_UEVENT_FILE ,0444 ,NULL ); +if (!uev_file) +return -ENOENT ; + uev_file->proc_fops = &uev_ops; + uev_file->mode =S_IFREG |S_IWUGO ; + uev_file->uid =0 ; + uev_file->gid =0 ; +/* register manually the probe */ +__lttng_events_init__uevent (); +return 0 ; +} + +static void __exit lttng_uevent_exit(void) +{ +/* unregister manually the probe */ +__lttng_events_exit__uevent (); +remove_proc_entry (LTTNG_UEVENT_FILE ,NULL ); +} + +module_init (lttng_uevent_init); +module_exit (lttng_uevent_exit); + +MODULE_LICENSE ("GPL and additional rights" ); +MODULE_AUTHOR ("Francis Giraldeau <[email protected]>" ); +MODULE_DESCRIPTION ("Append custom events to kernel trace from user-space" );Signature · 7 lines
1.7.9.5 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): 20120702222340.GA1702@Krystal
Quoted 6 lines · Mathieu Desnoyers
Quoted 3 lines · * Francis Giraldeau ([email protected]) wrote:
By writing to the file
/proc/lttng_uevent, a user-space application creates a kernel event. The event's payload is by default UTF-8 text, but any data can be written, up to 1024 bytes. Null-character is optional and is not enforced.The 1024 byte limit is removed now, right ?
Exactly.
Quoted 1 line
Quoted 1 line
+ * Expose kernel tracer to user-space through
/proc/lttng
I just saw a typo here, we should read "through /proc/lttng_uevent"
Quoted 3 lines
Quoted 1 line
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <[email protected]>
you might want to add your own copyright in here too.
I transfer you the copyright.
Thanks!
Francis
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · * Francis Giraldeau ([email protected]) wrote:
Quoted 6 lines · Mathieu Desnoyers
Quoted 3 lines · * Francis Giraldeau ([email protected]) wrote:
By writing to the file
/proc/lttng_uevent, a user-space application creates a kernel event. The event's payload is by default UTF-8 text, but any data can be written, up to 1024 bytes. Null-character is optional and is not enforced.The 1024 byte limit is removed now, right ?
Exactly.
OK, please provide an updated version with the updated changelog.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
+ * Expose kernel tracer to user-space through
/proc/lttngI just saw a typo here, we should read "through
/proc/lttng_uevent"
Same here.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <[email protected]>
you might want to add your own copyright in here too.
I transfer you the copyright.
Thanks!
One more thing:
In the testing you did, did you try running, in parallel:
for a in $(seq 1 10000); do
modprobe nameofuevent_module
rmmod nameofevent_module
done
and in 4 another terminals:
echo "blahblahblah" > /proc/lttng_uevent
?
I understand that you tested only the write path in parallel, but I'm not sure, from your changelog, that you stress-tested load/unload vs write.
Thanks,
Mathieu
Quoted 12 lines
Thanks!
Francis
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): 20120703113947.GA24563@Krystal
Quoted 7 lines · Mathieu Desnoyers
Quoted 6 lines · * Francis Giraldeau ([email protected]) wrote:
Quoted 5 lines · Mathieu Desnoyers
Quoted 3 lines · * Francis Giraldeau ([email protected]) wrote:
By writing to the file
/proc/lttng_uevent, a user-space application creates a kernel event. The event's payload is by default UTF-8 text, but any data can be written, up to 1024 bytes. Null-character is optional and is not enforced.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
The 1024 byte limit is removed now, right ?
Exactly.
OK, please provide an updated version with the updated changelog.
Fixed.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
+ * Expose kernel tracer to user-space through
/proc/lttngI just saw a typo here, we should read "through
/proc/lttng_uevent"Same here.
Fixed.
Quoted 21 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <[email protected]>
you might want to add your own copyright in here too.
I transfer you the copyright.
Thanks!
One more thing:
In the testing you did, did you try running, in parallel:
for a in $(seq 1 10000); do
modprobenameofuevent_module
rmmodnameofevent_module
doneand in 4 another terminals:
Quoted 7 lines
echo "blahblahblah" >
/proc/lttng_uevent?
I understand that you tested only the write path in parallel, but I'm not sure, from your changelog, that you stress-tested load/unload vs write.
The test I did was to write in parallel to /proc/lttng_uevent and see the behavior. It takes about 15us on my i5 2.5Ghz to log an event this way in a tight loop, so yeah, it's quite slow.
It's not possible to remove the module while an active tracing session references the event lttng_uevent. I tested insertion/removal of the module while tracing with the previous version that was using RCU and it was working well.
Cheers,
Francis
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 51 lines · * Francis Giraldeau ([email protected]) wrote:
Quoted 7 lines · Mathieu Desnoyers
Quoted 6 lines · * Francis Giraldeau ([email protected]) wrote:
Quoted 5 lines · Mathieu Desnoyers
Quoted 3 lines · * Francis Giraldeau ([email protected]) wrote:
By writing to the file
/proc/lttng_uevent, a user-space application creates a kernel event. The event's payload is by default UTF-8 text, but any data can be written, up to 1024 bytes. Null-character is optional and is not enforced.Quoted 5 lines
Quoted 3 lines
Quoted 1 line
The 1024 byte limit is removed now, right ?
Exactly.
OK, please provide an updated version with the updated changelog.
Fixed.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
+ * Expose kernel tracer to user-space through
/proc/lttngI just saw a typo here, we should read "through
/proc/lttng_uevent"Same here.
Fixed.
Quoted 25 lines
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <[email protected]>
you might want to add your own copyright in here too.
I transfer you the copyright.
Thanks!
One more thing:
In the testing you did, did you try running, in parallel:
for a in $(seq 1 10000); do
modprobenameofuevent_module
rmmodnameofevent_module
doneand in 4 another terminals:
echo "blahblahblah" >
/proc/lttng_uevent?
Quoted 7 lines
Quoted 3 lines
I understand that you tested only the write path in parallel, but I'm not sure, from your changelog, that you stress-tested load/unload vs write.
The test I did was to write in parallel to
/proc/lttng_ueventand see the behavior. It takes about 15us on my i5 2.5Ghz to log an event this way in a tight loop, so yeah, it's quite slow.
Yep, that's benchmarking. I'm more concerned about correctness.
Quoted 4 lines
It's not possible to remove the module while an active tracing session references the event
lttng_uevent. I tested insertion/removal of the module while tracing with the previous version that was using RCU and it was working well.
But you don't need to have an active tracing session to perform the test I point to above. Could you run it on this latest version ?
Thanks,
Mathieu
Quoted 12 lines
Cheers,
Francis
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): 20120703134031.GB32190@Krystal
Quoted 7 lines · Mathieu Desnoyers
Quoted 4 lines
It's not possible to remove the module while an active tracing session references the event
lttng_uevent. I tested insertion/removal of the module while tracing with the previous version that was using RCU and it was working well.But you don't need to have an active tracing session to perform the test I point to above. Could you run it on this latest version ?
Ok. I updated the test to run in a loop rmmod/modprobe, while writing with 20 threads into /proc/lttng_uevent. The result is that the module can be unloaded properly, the test shows no race that prevent the module to be unloaded or other problems.
If somebody wants to test it for themselves, I added the code for this test under workload-kit/tests.
* test-uevent : runs 4 times 20 threads each producing 64k events
* module-reload-forever.sh : rmmod/modprobe of lttng_uevent
* test-uevent.sh : quick wrapper for testing functionnality
Thanks!
Francis
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Just a bit of follow-up: has this been merged ? If not, is there a latest version available somewhere ?
Thanks,
Mathieu
Quoted 32 lines · * Francis Giraldeau ([email protected]) wrote:
Quoted 7 lines · Mathieu Desnoyers
Quoted 4 lines
It's not possible to remove the module while an active tracing session references the event
lttng_uevent. I tested insertion/removal of the module while tracing with the previous version that was using RCU and it was working well.But you don't need to have an active tracing session to perform the test I point to above. Could you run it on this latest version ?
Ok. I updated the test to run in a loop rmmod/modprobe, while writing with 20 threads into
/proc/lttng_uevent. The result is that the module can be unloaded properly, the test shows no race that prevent the module to be unloaded or other problems.If somebody wants to test it for themselves, I added the code for this test under workload-kit/tests.
* test-uevent : runs 4 times 20 threads each producing 64k events
*module-reload-forever.sh: rmmod/modprobe oflttng_uevent
*test-uevent.sh: quick wrapper for testing functionnalityThanks!
Francis
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com