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: Inserting delays with systemtap


On 03/07/2012 03:41 PM, Frank Ch. Eigler wrote:
> Nah, that's only because #! shebang lines are defined to pass a
> solitary argument to the interpreter.  Note the "-g" in the quoted
> string.

Gotcha - thanks. It does indeed work fine if I remove the -g and specify
it on the command line.

I've attached a patch that adds the guru_delay.stp patchset - I also
included a wrapper around udelay() in case anyone has a use for that
(it's too fine a granularity for my application but I can see other
instances where it could be useful).

Tested locally with a simplified version of the original script and
appears to work. Using -g is required as expected:

#!/usr/bin/stap
probe module("cdc_acm").statement("*@drivers/usb/class/cdc-acm.c:341") {
  mdelay($1)
}

Cheers,
Bryn.

>From a3df25a00d83314912bdd743080287618be7896d Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Thu, 8 Mar 2012 17:10:37 +0000
Subject: [PATCH] Add guru_delay.stp to tapset

Adds systemtap mdelay(ms) and udelay(us) functions for inserting
controlled programmable delays at probe sites.
---
 tapset/guru-delay.stp |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 tapset/guru-delay.stp

diff --git a/tapset/guru-delay.stp b/tapset/guru-delay.stp
new file mode 100644
index 0000000..ad3a6be
--- /dev/null
+++ b/tapset/guru-delay.stp
@@ -0,0 +1,28 @@
+// Copyright (C) 2102 Red Hat Inc., Bryn M. Reeves <bmr@redhat.com>
+//
+// This file is part of systemtap, and is free software.  You can
+// redistribute it and/or modify it under the terms of the GNU General
+// Public License (GPL); either version 2, or (at your option) any
+// later version.
+//
+
+// <tapsetdescription>
+// Programable delays at probe sites
+// </tapsetdescription>
+
+%{
+/* guru */
+#undef STP_OVERLOAD
+#include <linux/delay.h>
+%}
+
+function mdelay(ms:long) %{
+ /* guru */
+  mdelay(THIS->ms);
+%}
+
+function udelay(us:long) %{
+ /* guru */
+  udelay(THIS->us);
+%}
+
-- 
1.7.6.5


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