This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: next steps
Frank Ch. Eigler <fche@redhat.com> [050926]:
> Hi -
>
> On Mon, Sep 26, 2005 at 04:34:11PM -0500, Jose R. Santos wrote:
> > [...]
> > > ln ("cpu", cpu()) # cpu() to go into context tapset
> > This would need to look something like this:
> >
> > function cpu:long () %{
> > [...]
> > THIS->__retvalue = task_cpu(current);
> > %}
> > right? Seems to be working on my 4-way system.
>
> Yes, or perhaps just smp_processor_id() if that were more general and
> still safe.
>
> > [...]
> > > ln ("jiffies", jiffies())) # jiffies() to go into in timestamp tapset
> >
> > Just notice the availability of gettimeofday_(us/ms/s) on the
> > timestamp tapset so I don't think jiffies are needed. Either
> > way, it should be quick and painless to implement.
>
> Exactly. Feel free to submit a patch for one or both of these
> additions to the appropriate .stp files, and brief documentation in
> src/stapfuncs.5. I can commit them for you, or if you forsee becoming
> a frequent contributor, you may request cvs write access.
>
> That reminds me. Time to add a GPL header to the tapset files.
Heres a patch for the cpu() function. I will request for the cvs
access as well.
Index: stapfuncs.5.in
===================================================================
RCS file: /cvs/systemtap/src/stapfuncs.5.in,v
retrieving revision 1.6
diff -u -r1.6 stapfuncs.5.in
--- stapfuncs.5.in 7 Sep 2005 02:16:59 -0000 1.6
+++ stapfuncs.5.in 27 Sep 2005 15:24:47 -0000
@@ -158,6 +158,10 @@
target:long ()
Returns the pid of the target process.
+.TP
+cpu:long ()
+Returns the current cpu of the target process.
+
.SH FILES
.nh
.IR /usr/share/systemtap/tapset
Index: tapset/context.stp
===================================================================
RCS file: /cvs/systemtap/src/tapset/context.stp,v
retrieving revision 1.6
diff -u -r1.6 context.stp
--- tapset/context.stp 6 Sep 2005 17:40:13 -0000 1.6
+++ tapset/context.stp 27 Sep 2005 15:24:47 -0000
@@ -97,3 +97,9 @@
THIS->__retvalue = _stp_target;
%}
+function cpu:long () %{
+ if (unlikely(in_interrupt()))
+ THIS->__retvalue = 0;
+ else
+ THIS->__retvalue = task_cpu(current);
+%}