This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reduction of guru use in systemtap war stories


Frank Ch. Eigler wrote:
wcohen wrote:

I am looking through the war stories and figuring out how to clean
things up.  [...]

Thanks.


WSthreadCPUshare uses guru mode to determine the instruction pointer
value for the sample and then determine whether this value is in
kernel or user-space. For some 32-bit kernels this approach is not
correct. A better approach would be make the kernel function
user_mode() available in the tapsets. [...]

Indeed, please make it so!

Attached is a simple little patch for the context.stp tapset and documentation to "make it so." Assuming that it looks okay I will commit it.



Some of the other war stories (WSPfiles, WSPsig, and WSPlimit) the
idiom to map a pid to a task struct point comes up and would be a
candidate to add to the tapsets. It looks like some of the other guru
functions in those scripts are already available and can be recast as
task.stp tapset functions. [...]

See bug #6525 for a probably more robust way. The one used in some of that embedded-c code, find_task_by_pid(), is not safe to call from all contexts.

Thanks for the pointer to 6525.


Several of the war stories (such as WSPfiles) include header files
and make use of defines to extract bits/flags out of values. Seems
like there should be a cleaner way to make those bit values
available to scripts.

One possibility is to lobby the kernel to run gcc with -g3 or somesuch to get it to dump macro definitions into the dwarf data; then we could pull it out of there with $MACRO. Sounds unlikely.

At the moment asking for -g3 sounds unlikely. The debuginfo is already large. Adding in all the macros is going to make the debug information even larger.


Other ideas?

-Will


diff --git a/stapfuncs.5.in b/stapfuncs.5.in
index 6d4546a..d8a1a55 100644
--- a/stapfuncs.5.in
+++ b/stapfuncs.5.in
@@ -252,6 +252,9 @@ Return the probe point's module name, if known.
 target:long ()
 Return the pid of the target process.
 .TP
+user_mode:long ()
+Return 1 if the probe point occurred in user-mode.
+.TP
 is_return:long ()
 Return 1 if the probe point is a return probe.  Deprecated.
 
diff --git a/tapset/context.stp b/tapset/context.stp
index 45e3be3..d2195f8 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -140,6 +140,11 @@ function registers_valid:long () %{ /* pure */
 	THIS->__retvalue = (CONTEXT->regs != NULL);
 %}
 
+function user_mode:long () %{ /* pure */ /* currently a user-mode address? */
+  if (CONTEXT->regs)
+    THIS->__retvalue = (uint64_t) user_mode (CONTEXT->regs);
+%}
+
 function is_return:long () %{ /* pure */
 	if (CONTEXT->pi)
 		THIS->__retvalue = 1;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]