public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] systemtap: kernel marker tapset
@ 2008-09-12 22:22 Masami Hiramatsu
  2008-09-12 23:02 ` Stone, Joshua I
  2008-09-17  8:07 ` [ltt-dev] " Jan Blunck
  0 siblings, 2 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2008-09-12 22:22 UTC (permalink / raw)
  To: systemtap-ml; +Cc: ltt-dev, Hideo AOKI, Takahiro Yasui

[-- Attachment #1: Type: text/plain, Size: 278 bytes --]

Hi,

Here is a patch which adds a tapset for kernel markers.
this tapset supports lttng's kernel marker(+my cpuid patch) too.

Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


[-- Attachment #2: tapset-add-marker.patch --]
[-- Type: text/plain, Size: 8925 bytes --]

---
 tapset/marker.stp |  378 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 378 insertions(+)

Index: systemtap/tapset/marker.stp
===================================================================
--- systemtap.orig/tapset/marker.stp	2008-09-12 13:21:49.000000000 -0400
+++ systemtap/tapset/marker.stp	2008-09-12 13:36:03.000000000 -0400
@@ -20,3 +20,381 @@
 		 (CONTEXT->marker_format)?CONTEXT->marker_format:"",
 		 MAXSTRINGLEN); /* pure */
 %}
+
+/*-------------------------------------------*
+ * marker.irq.* - IRQ related markers
+ *-------------------------------------------*/
+
+/*
+ * probe marker.irq.hardirq.entry
+ *
+ *  Fires just before handing a hard interrupt.
+ *
+ * Context:
+ *  A hard interrupt occurs.
+ *
+ * Arguments:
+ * irq_id - the id of hard irq.
+ * kernel_mode - boolean indicating whether the interrupt occurred
+ *               in kernel mode.
+ */
+probe marker.irq.hardirq.entry
+	= kernel.mark("kernel_irq_entry").format("irq_id %u kernel_mode %u ip %lu")!,
+	  kernel.mark("kernel_irq_entry").format("irq_id %u kernel_mode %u")
+{
+	irq_id = $arg1
+	kernel_mode = $arg2
+}
+
+/*
+ * probe marker.irq.hardirq.exit
+ *
+ *  Fires after handling a hard interrupt.
+ *
+ * Context:
+ *  A hard interrupt was handled.
+ *
+ * Arguments:
+ * irq_id - the id of hard irq (if possible).
+ * retval - return value of handle_IRQ_event().
+ */
+probe __marker.irq.hardirq.exit1
+	= kernel.mark("kernel_irq_exit").format("irq_id %u retval %ld")!,
+	  kernel.mark("kernel_irq_exit").format("irq_id %u handled #1u%u")
+{
+	irq_id = $arg1
+	retval = $arg2
+}
+
+# we need per-cpu stack variables
+global __marker_irq_stack, __marker_irq_idx;
+function __marker_irq_push(id:long)
+{
+	idx = __marker_irq_idx[cpu()]++;
+	__marker_irq_stack[cpu()][idx]=id;
+}
+function __marker_irq_pop:long()
+{
+	idx = --__marker_irq_idx[cpu()];
+	return __marker_irq_stack[cpu()][idx];
+}
+
+probe __marker.irq.hardirq.enter_helper
+	 = kernel.mark("kernel_irq_entry").format("irq_id %u kernel_mode %u ip %lu")
+{
+	__marker_irq_push($arg1)
+}
+
+probe __marker.irq.hardirq.exit2
+	= kernel.mark("kernel_irq_exit").format("handled #1u%u"),
+          __marker.irq.hardirq.enter_helper
+{
+	irq_id = __marker_irq_pop();
+	retval = $arg1
+}
+
+probe marker.irq.hardirq.exit
+	= __marker.irq.hardirq.exit1 !,
+	  __marker.irq.hardirq.exit2
+{}
+
+/*
+ * probe marker.irq.softirq.enter
+ *
+ *  Fires before calling softirq handler.
+ *
+ * Context:
+ *  Softirq handler will be invoked.
+ *
+ * Arguments:
+ *  softirq_id - the id of softirq.
+ *  func - the pointer of softirq handler (if possible).
+ *
+ * Note:
+ *  On specific architecture(ex. ia64) the "func" is not the address of
+ * the actuall function. You might need to derefer *func for getting
+ * actuall address.
+ */
+probe __marker.irq.softirq.entry1
+	= kernel.mark("kernel_softirq_entry").format("softirq_id %lu")
+{
+	softirq_id = $arg1
+	func = 0
+}
+probe __marker.irq.softirq.entry2
+	= kernel.mark("kernel_softirq_entry").format("softirq_id %lu func %p")
+{
+	softirq_id = $arg1
+	func = $arg2
+}
+
+probe marker.irq.softirq.entry
+	=  __marker.irq.softirq.entry1 !, __marker.irq.softirq.entry2
+{}
+
+/*
+ * probe marker.irq.softirq.exit
+ *
+ *  Fires after calling softirq handler.
+ *
+ * Context:
+ *  Softirq handler was handled.
+ *
+ * Arguments:
+ *  softirq_id - the id of softirq.
+ */
+probe marker.irq.softirq.exit
+	= kernel.mark("kernel_softirq_exit")
+{
+	softirq_id = $arg1
+}
+
+/*
+ * probe marker.irq.tasklet_low.enter
+ *
+ *  Fires before calling tasklet_low handler.
+ *
+ * Context:
+ *  Tasklet(low) handler will be invoked.
+ *
+ * Arguments:
+ *  func - the pointer of tasklet_low handler.
+ *  data - the data passed to the handler.
+ *
+ * Note:
+ *  On specific architecture(ex. ia64) the "func" is not the address of
+ * the actuall function. You might need to derefer *func for getting
+ * actuall address.
+ */
+probe marker.irq.tasklet_low.entry
+	= kernel.mark("kernel_tasklet_low_entry")
+{
+	func = $arg1
+	data = $arg2
+}
+
+/*
+ * probe marker.irq.tasklet_low.exit
+ *
+ *  Fires after calling tasklet_low handler.
+ *
+ * Context:
+ *  Tasklet(low) handler was handled.
+ *
+ * Arguments:
+ *  func - the pointer of tasklet_low handler.
+ *  data - the data passed to the handler.
+ *
+ * Note:
+ *  On specific architecture(ex. ia64) the "func" is not the address of
+ * the actuall function. You might need to derefer *func for getting
+ * actuall address.
+ */
+probe marker.irq.tasklet_low.exit
+	= kernel.mark("kernel_tasklet_low_exit")
+{
+	func = $arg1
+	data = $arg2
+}
+
+/*
+ * probe marker.irq.tasklet_high.enter
+ *
+ *  Fires before calling tasklet_high handler.
+ *
+ * Context:
+ *  Tasklet(high) handler will be invoked.
+ *
+ * Arguments:
+ *  func - the pointer of tasklet_high handler.
+ *  data - the data passed to the handler.
+ *
+ * Note:
+ *  On specific architecture(ex. ia64) the "func" is not the address of
+ * the actuall function. You might need to derefer *func for getting
+ * actuall address.
+ */
+probe marker.irq.tasklet_high.entry
+	= kernel.mark("kernel_tasklet_high_entry")
+{
+	func = $arg1
+	data = $arg2
+}
+
+/*
+ * probe marker.irq.tasklet_high.exit
+ *
+ *  Fires after calling tasklet_high handler.
+ *
+ * Context:
+ *  Tasklet(high) handler was handled.
+ *
+ * Arguments:
+ *  func - the pointer of tasklet_high handler.
+ *  data - the data passed to the handler.
+ *
+ * Note:
+ *  On specific architecture(ex. ia64) the "func" is not the address of
+ * the actuall function. You might need to derefer *func for getting
+ * actuall address.
+ */
+probe marker.irq.tasklet_high.exit
+	= kernel.mark("kernel_tasklet_high_exit")
+{
+	func = $arg1
+	data = $arg2
+}
+
+
+/*-------------------------------------------*
+ * marker.process.* - Process related markers
+ *-------------------------------------------*/
+
+/*
+ * probe marker.process.free
+ *
+ *  Fires when task_struct will be released.
+ *
+ * Context:
+ *  A process is released.
+ *
+ * Arguments:
+ *  pid - released process pid.
+ */
+probe marker.process.free
+	= kernel.mark("kernel_process_free")
+{
+	pid = $arg1
+}
+
+/*
+ * probe marker.process.wait
+ *
+ *  Fires when do_wait() is called.
+ *
+ * Context:
+ *  Current process waits another process.
+ *
+ * Arguments:
+ *  pid - waiting target pid.
+ */
+probe marker.process.wait
+	= kernel.mark("kernel_process_wait")
+{
+	pid = $arg1
+}
+
+/*
+ * probe marker.process.exit
+ *
+ *  Fires when do_exit() is called.
+ *
+ * Context:
+ *  A process exits.
+ *
+ * Arguments:
+ *  pid - exit process pid.
+ */
+probe marker.process.exit
+	= kernel.mark("kernel_process_exit")
+{
+	pid = $arg1
+}
+
+/*
+ * probe marker.process.fork
+ *
+ *  Fires when a process forked/cloned.
+ *
+ * Context:
+ *  A process forked/cloned.
+ *
+ * Arguments:
+ *  pid - parent pid.
+ *  parent_pid - same as above "pid".
+ *  child_pid - forked child pid.
+ *  child_tgid - forked child thread group id.
+ */
+probe marker.process.fork
+	= kernel.mark("kernel_process_fork")
+{
+	pid = $arg1
+	parent_pid = $arg1
+	child_pid = $arg2
+	child_tgid = $arg3
+}
+
+
+/*-----------------------------------------------*
+ * marker.scheduler.* - scheduler related markers
+ *-----------------------------------------------*/
+
+probe __marker.scheduler.wakeup
+	= kernel.mark("kernel_sched_wakeup")!,
+	  kernel.mark("kernel_sched_try_wakeup")
+{
+}
+probe __marker.scheduler.wakeup_new
+	= kernel.mark("kernel_sched_wakeup_new")!,
+	  kernel.mark("kernel_sched_wakeup_new_task")
+{
+}
+
+/*
+ * probe marker.scheduler.wakeup
+ *
+ *  Fires a process wakeup.
+ *
+ * Context:
+ *  A process wakeup.
+ *
+ * Arguments:
+ *  pid - wakeup process pid.
+ *  state - process task state.
+ *  cpu_id - the id of cpu where the process wakeup.
+ */
+probe marker.scheduler.wakeup
+	= __marker.scheduler.wakeup,
+	  __marker.scheduler.wakeup_new
+{
+	pid = $arg1
+	state = $arg2
+	cpu_id = $arg3
+}
+
+/*
+ * probe marker.scheduler.switch
+ *
+ *  Fires scheduler switches tasks.
+ *
+ * Context:
+ *  A process is switching to another process.
+ *
+ * Arguments:
+ *  prev_pid - the pid of the process from which next task is switched.
+ *  next_pid - the pid of the process to which previous task switches.
+ *  prev_state - task state of previous process
+ *  prev_prio - task priority of previous process (if possible)
+ *  next_prio - task priority of next process (if possible)
+ */
+probe __marker.scheduler.switch
+	= kernel.mark("kernel_sched_switch")
+{
+	prev_prio = $arg4
+	next_prio = $arg5
+}
+probe __marker.scheduler.schedule
+	= kernel.mark("kernel_sched_schedule").format("prev_pid %d next_pid %d prev_state %ld")
+{
+	prev_prio = 0;
+	next_prio = 0;
+}
+
+probe marker.scheduler.switch
+	= __marker.scheduler.switch !,
+	  __marker.scheduler.schedule
+{
+	prev_pid = $arg1
+	next_pid = $arg2
+	prev_state = $arg3
+}

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

* Re: [PATCH 1/3] systemtap: kernel marker tapset
  2008-09-12 22:22 [PATCH 1/3] systemtap: kernel marker tapset Masami Hiramatsu
@ 2008-09-12 23:02 ` Stone, Joshua I
  2008-09-17  8:07 ` [ltt-dev] " Jan Blunck
  1 sibling, 0 replies; 4+ messages in thread
From: Stone, Joshua I @ 2008-09-12 23:02 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: systemtap-ml, ltt-dev, Hideo AOKI, Takahiro Yasui

Masami Hiramatsu wrote:
> Here is a patch which adds a tapset for kernel markers.
> this tapset supports lttng's kernel marker(+my cpuid patch) too.

This looks very nice!  It will be great to finally use markers for lower
overhead probing...

In the "Context" documentation, you tend to restate the event, but I'm
looking for a description of which process environment is active when
the event occurs.  For some events, it's not obvious which process I
would see if I checked pid(), execname(), etc.  For example, does
marker.process.fork fire in the parent or the child?  Does
marker.scheduler.switch fire from the previous or next task?

Eventually, we'll also want to push these to a higher namespace without
the marker prefix.  Users generally shouldn't care *how* an event is
captured; stap should just pick the best option available.  Something
like:

probe process.exit =
    marker.process.exit!, // markers
    process("*").end!, // utrace
    kernel.function("do_exit") // kprobe


Josh

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

* Re: [ltt-dev] [PATCH 1/3] systemtap: kernel marker tapset
  2008-09-12 22:22 [PATCH 1/3] systemtap: kernel marker tapset Masami Hiramatsu
  2008-09-12 23:02 ` Stone, Joshua I
@ 2008-09-17  8:07 ` Jan Blunck
  2008-09-17 14:34   ` Masami Hiramatsu
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Blunck @ 2008-09-17  8:07 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: systemtap-ml, ltt-dev, Hideo AOKI, Takahiro Yasui

On Fri, Sep 12, Masami Hiramatsu wrote:

> Hi,
> 
> Here is a patch which adds a tapset for kernel markers.
> this tapset supports lttng's kernel marker(+my cpuid patch) too.

Is there any reason why you only did irq and scheduler related markers? Is
there any reason why we shouldn't convert the existing parts of the tapset
library to markers where that is possible?

Regards,
	Jan

-- 
Jan Blunck <jblunck@suse.de>

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

* Re: [ltt-dev] [PATCH 1/3] systemtap: kernel marker tapset
  2008-09-17  8:07 ` [ltt-dev] " Jan Blunck
@ 2008-09-17 14:34   ` Masami Hiramatsu
  0 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2008-09-17 14:34 UTC (permalink / raw)
  To: Jan Blunck; +Cc: systemtap-ml, ltt-dev, Hideo AOKI, Takahiro Yasui

Jan Blunck wrote:
> On Fri, Sep 12, Masami Hiramatsu wrote:
> 
>> Hi,
>>
>> Here is a patch which adds a tapset for kernel markers.
>> this tapset supports lttng's kernel marker(+my cpuid patch) too.
> 
> Is there any reason why you only did irq and scheduler related markers? Is
> there any reason why we shouldn't convert the existing parts of the tapset
> library to markers where that is possible?

I just started my work on the tapset of markers which covers
my interesting markers. This tapset is just a seed of future
work(and an RFC of namespace rule in systemtap).
So, any changes and additions are welcome :-).

Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

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

end of thread, other threads:[~2008-09-17 14:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-12 22:22 [PATCH 1/3] systemtap: kernel marker tapset Masami Hiramatsu
2008-09-12 23:02 ` Stone, Joshua I
2008-09-17  8:07 ` [ltt-dev] " Jan Blunck
2008-09-17 14:34   ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).