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


William Cohen wrote:
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.

Frank pointed out that there were some probes contexts that CONTEXT->regs was not available, e.g. probe begin,end. The begin and end could be considered to be in kernel mode. The probe timer sets CONTEXT->regs (if it didn't, the original WSthreadCPUshare example wouldn't work). The revised version of the patch assumes that kernel mode if CONTEXT->regs isn't available.


-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..f9ebf9c 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -140,6 +140,13 @@ 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);
+  else
+    THIS->__retvalue = 0;
+%}
+
 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]