summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/ChangeLog10
-rw-r--r--runtime/print.c35
-rw-r--r--runtime/print_new.c3
-rw-r--r--runtime/print_old.c3
-rw-r--r--runtime/staprun/ChangeLog5
-rw-r--r--runtime/staprun/mainloop.c2
-rw-r--r--runtime/transport/ChangeLog14
-rw-r--r--runtime/transport/relayfs.c8
-rw-r--r--runtime/transport/transport.c13
-rw-r--r--runtime/transport/utt.c7
-rw-r--r--runtime/transport/utt.h2
-rw-r--r--tapset/ChangeLog8
-rw-r--r--tapset/rpc.stp12
-rw-r--r--testsuite/ChangeLog8
-rw-r--r--testsuite/systemtap.printf/hello.stp6
-rw-r--r--testsuite/systemtap.printf/hello2.stp7
-rw-r--r--testsuite/systemtap.printf/sharedbuf.exp62
-rw-r--r--testsuite/systemtap.printf/sharedbuf.stp3
18 files changed, 190 insertions, 18 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog
index 75272aa0..e6079bea 100644
--- a/runtime/ChangeLog
+++ b/runtime/ChangeLog
@@ -1,3 +1,13 @@
+2007-11-09 Masami Hiramatsu <mhiramat@redhat.com>
+
+ PR3858
+ * print.c: Add -DRELAY_HOST=<hostname> and -DRELAY_GUEST=<hostname>
+ options support.
+ (_stp_print_flush): Disable irqs if -DRELAY_* option is specified.
+ * print_old.c: Export stp_print_flush to other modules if the
+ -DRELAY_HOST option is specified.
+ * print_new.c: Ditto.
+
2007-10-25 Mike Mason <mmlnx@us.ibm.com>
* stat-common.c: Allow histogram bucket elision to be turned off
diff --git a/runtime/print.c b/runtime/print.c
index c100bbfe..326d67d5 100644
--- a/runtime/print.c
+++ b/runtime/print.c
@@ -72,6 +72,21 @@ void _stp_print_cleanup (void)
free_percpu(Stp_lbuf);
}
+#define __DEF_EXPORT_FN(fn, postfix) fn ## _ ## postfix
+#define DEF_EXPORT_FN(fn, postfix) __DEF_EXPORT_FN(fn, postfix)
+
+#if defined(RELAY_GUEST)
+#if defined(RELAY_HOST)
+ #error "Cannot specify both RELAY_HOST and RELAY_GUEST"
+#endif
+#define EXPORT_FN(fn) DEF_EXPORT_FN(fn, RELAY_GUEST)
+#elif defined(RELAY_HOST)
+#define EXPORT_FN(fn) DEF_EXPORT_FN(fn, RELAY_HOST)
+#else /* defined(RELAY_GUEST) || defined(RELAY_HOST) */
+#define EXPORT_FN(fn) fn
+#endif
+
+#if !defined(RELAY_GUEST)
/* The relayfs API changed between 2.6.15 and 2.6.16. */
/* Use the appropriate print flush function. */
@@ -80,6 +95,26 @@ void _stp_print_cleanup (void)
#else
#include "print_new.c"
#endif
+#if defined(RELAY_HOST)
+EXPORT_SYMBOL_GPL(EXPORT_FN(stp_print_flush));
+#endif
+
+#endif /*!RELAY_GUEST*/
+
+#if defined(RELAY_GUEST) || defined(RELAY_HOST)
+/* Prohibit irqs to avoid racing on a relayfs */
+extern void EXPORT_FN(stp_print_flush) (_stp_pbuf *);
+static inline void _stp_print_flush(void)
+{
+ unsigned long flags;
+ local_irq_save(flags);
+ EXPORT_FN(stp_print_flush) (per_cpu_ptr(Stp_pbuf, smp_processor_id()));
+ local_irq_restore(flags);
+}
+#else
+#define _stp_print_flush() \
+ EXPORT_FN(stp_print_flush)(per_cpu_ptr(Stp_pbuf, smp_processor_id()))
+#endif
#ifndef STP_MAXBINARYARGS
#define STP_MAXBINARYARGS 127
diff --git a/runtime/print_new.c b/runtime/print_new.c
index b34aad8a..95a83a8d 100644
--- a/runtime/print_new.c
+++ b/runtime/print_new.c
@@ -17,9 +17,8 @@
*/
spinlock_t _stp_print_lock = SPIN_LOCK_UNLOCKED;
-void _stp_print_flush (void)
+void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb)
{
- _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id());
uint32_t len = pb->len;
/* check to see if there is anything in the buffer */
diff --git a/runtime/print_old.c b/runtime/print_old.c
index 401d1af1..5ee050b5 100644
--- a/runtime/print_old.c
+++ b/runtime/print_old.c
@@ -16,9 +16,8 @@
* @note Preemption must be disabled to use this.
*/
-void _stp_print_flush (void)
+void EXPORT_FN(stp_print_flush) (_stp_pbuf *pb)
{
- _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id());
uint32_t len = pb->len;
/* check to see if there is anything in the buffer */
diff --git a/runtime/staprun/ChangeLog b/runtime/staprun/ChangeLog
index 7c6b89ad..540153d7 100644
--- a/runtime/staprun/ChangeLog
+++ b/runtime/staprun/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-09 Martin Hunt <hunt@redhat.com>
+
+ * mainloop.c (stp_main_loop): Bump recvbuf to 8196 for
+ compatibility with old transport.
+
2007-10-26 Martin Hunt <hunt@redhat.com>
PR5218
* stapio.c (main): Set initialized properly when
diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c
index c0722b56..d8975d18 100644
--- a/runtime/staprun/mainloop.c
+++ b/runtime/staprun/mainloop.c
@@ -249,7 +249,7 @@ int stp_main_loop(void)
void *data;
int type;
FILE *ofp = stdout;
- char recvbuf[8192];
+ char recvbuf[8196];
setvbuf(ofp, (char *)NULL, _IOLBF, 0);
setup_main_signals(0);
diff --git a/runtime/transport/ChangeLog b/runtime/transport/ChangeLog
index 4872fa11..263a6bf8 100644
--- a/runtime/transport/ChangeLog
+++ b/runtime/transport/ChangeLog
@@ -1,3 +1,17 @@
+2007-11-09 Masami Hiramatsu <mhiramat@redhat.com>
+
+ PR3858
+ * transport.c (_stp_transport_init): Reduce relay buffer size to
+ 64KB*2 if -DRELAY_GUEST is specified.
+
+2007-11-09 Martin Hunt <hunt@redhat.com>
+ PR 5281
+ * transport.c (_stp_detach, _stp_attach): Call utt_set_overwrite()
+ instead of setting a flag directly.
+ * utt.c (utt_set_overwrite): New. Set overwrite mode.
+ * relayfs.c (utt_set_overwrite): New. Set overwrite mode.
+ * utt.h: Remove global utt_overwrite_flag.
+
2007-11-01 Martin Hunt <hunt@redhat.com>
* procfs.c, control.c, transport.c: Recognize when stapio
diff --git a/runtime/transport/relayfs.c b/runtime/transport/relayfs.c
index 28bb0e65..2c7ca754 100644
--- a/runtime/transport/relayfs.c
+++ b/runtime/transport/relayfs.c
@@ -1,5 +1,5 @@
/* -*- linux-c -*-
- * relayfs.c - relayfstransport functions
+ * relayfs.c - relayfs transport functions
*
* Copyright (C) IBM Corporation, 2005, 2006
* Copyright (C) Red Hat Inc, 2005, 2006, 2007
@@ -122,6 +122,12 @@ err:
return NULL;
}
+void utt_set_overwrite(int overwrite)
+{
+ if (_stp_utt)
+ _stp_utt->rchan->overwrite = overwrite;
+}
+
int utt_trace_startstop(struct utt_trace *utt, int start,
unsigned int *trace_seq)
{
diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c
index 0a959917..2904cf2f 100644
--- a/runtime/transport/transport.c
+++ b/runtime/transport/transport.c
@@ -21,13 +21,14 @@
#include "symbols.c"
#include "../procfs.c"
+static struct utt_trace *_stp_utt = NULL;
+
#ifdef STP_OLD_TRANSPORT
#include "relayfs.c"
#else
#include "utt.c"
#endif
-static struct utt_trace *_stp_utt = NULL;
static unsigned int utt_seq = 1;
static int _stp_start_finished = 0;
@@ -153,7 +154,7 @@ static void _stp_detach(void)
_stp_pid = 0;
if (!_stp_exit_flag)
- utt_overwrite_flag = 1;
+ utt_set_overwrite(1);
cancel_delayed_work(&_stp_work);
wake_up_interruptible(&_stp_ctl_wq);
@@ -167,7 +168,7 @@ static void _stp_attach(void)
kbug("attach\n");
_stp_attached = 1;
_stp_pid = current->pid;
- utt_overwrite_flag = 0;
+ utt_set_overwrite(0);
queue_delayed_work(_stp_wq, &_stp_work, STP_WORK_TIMER);
}
@@ -248,6 +249,12 @@ int _stp_transport_init(void)
_stp_uid = current->uid;
_stp_gid = current->gid;
+#ifdef RELAY_GUEST
+ /* Guest scripts use relay only for reporting warnings and errors */
+ _stp_subbuf_size = 65536;
+ _stp_nsubbufs = 2;
+#endif
+
if (_stp_bufsize) {
unsigned size = _stp_bufsize * 1024 * 1024;
_stp_subbuf_size = ((size >> 2) + 1) * 65536;
diff --git a/runtime/transport/utt.c b/runtime/transport/utt.c
index 0871266a..ac2e1513 100644
--- a/runtime/transport/utt.c
+++ b/runtime/transport/utt.c
@@ -29,7 +29,12 @@
#include <linux/relay.h>
#include "utt.h"
-int utt_overwrite_flag = 0;
+static int utt_overwrite_flag = 0;
+
+void utt_set_overwrite(int overwrite)
+{
+ utt_overwrite_flag = overwrite;
+}
static void utt_remove_root(struct utt_trace *utt)
{
diff --git a/runtime/transport/utt.h b/runtime/transport/utt.h
index 00da0f7e..b2c9fa9f 100644
--- a/runtime/transport/utt.h
+++ b/runtime/transport/utt.h
@@ -39,6 +39,4 @@ extern int utt_trace_startstop(struct utt_trace *utt, int start,
extern void utt_trace_cleanup(struct utt_trace *utt);
extern int utt_trace_remove(struct utt_trace *utt);
-extern int utt_overwrite_flag;
-
#endif
diff --git a/tapset/ChangeLog b/tapset/ChangeLog
index 07066978..ecab4aea 100644
--- a/tapset/ChangeLog
+++ b/tapset/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-8 Zhaolei <zhaolei@cn.fujitsu.com>
+
+ From Lai Jiangshan <laijs@cn.fujitsu.com>
+ * rpc.stp (clones_from_clnt): Use deref to check, then use
+ atomic_read to read an atomic_t to avoid compilation error of
+ type matching.
+ (tasks_from_clnt): Ditto.
+
2007-11-6 Zhaolei <zhaolei@cn.fujitsu.com>
From Cai Fei <caifei@cn.fujitsu.com>
diff --git a/tapset/rpc.stp b/tapset/rpc.stp
index f9390054..537bf348 100644
--- a/tapset/rpc.stp
+++ b/tapset/rpc.stp
@@ -950,22 +950,22 @@ function port_from_clnt:long(clnt:long)
function clones_from_clnt:long(clnt:long)
%{ /* pure */
struct rpc_clnt *clnt = (struct rpc_clnt *)(long)THIS->clnt;
+ THIS->__retvalue = -1;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,22)
- THIS->__retvalue = kread(&(clnt->cl_count));
+ deref(sizeof(clnt->cl_count), &(clnt->cl_count));
+ THIS->__retvalue = atomic_read(&(clnt->cl_count));
CATCH_DEREF_FAULT();
-#else
- THIS->__retvalue = -1;
#endif
%}
function tasks_from_clnt:long(clnt:long)
%{ /* pure */
struct rpc_clnt *clnt = (struct rpc_clnt *)(long)THIS->clnt;
+ THIS->__retvalue = -1;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,22)
- THIS->__retvalue = kread(&(clnt->cl_users));
+ deref(sizeof(clnt->cl_users), &(clnt->cl_users));
+ THIS->__retvalue = atomic_read(&(clnt->cl_users));
CATCH_DEREF_FAULT();
-#else
- THIS->__retvalue = -1;
#endif
%}
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 3d71c5a4..58f0cc13 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-09 Masami Hiramatsu <mhiramat@redhat.com>
+
+ PR3858
+ * systemtap.printf/sharedbuf.exp: New test for buffer sharing option.
+ * systemtap.printf/sharedbuf.stp: Ditto.
+ * systemtap.printf/hello.stp: Ditto.
+ * systemtap.printf/hello2.stp: Ditto.
+
2007-10-25 Martin Hunt <hunt@redhat.com>
* systemtap.printf/printd.exp: New.
diff --git a/testsuite/systemtap.printf/hello.stp b/testsuite/systemtap.printf/hello.stp
new file mode 100644
index 00000000..c0613225
--- /dev/null
+++ b/testsuite/systemtap.printf/hello.stp
@@ -0,0 +1,6 @@
+probe begin
+{
+ printf("Hello");
+ printf("World");
+ exit()
+}
diff --git a/testsuite/systemtap.printf/hello2.stp b/testsuite/systemtap.printf/hello2.stp
new file mode 100644
index 00000000..aa0798fa
--- /dev/null
+++ b/testsuite/systemtap.printf/hello2.stp
@@ -0,0 +1,7 @@
+probe begin
+{
+ print("Print");
+ log("Systemtap");
+ warn("warning");
+ exit()
+}
diff --git a/testsuite/systemtap.printf/sharedbuf.exp b/testsuite/systemtap.printf/sharedbuf.exp
new file mode 100644
index 00000000..6a182716
--- /dev/null
+++ b/testsuite/systemtap.printf/sharedbuf.exp
@@ -0,0 +1,62 @@
+# Simple test that systemtap can share the buffer with other scripts.
+set test "sharedbuf"
+set TEST_NAME "$subdir/$test"
+
+if {![installtest_p]} { untested $TEST_NAME; return }
+
+set c1 0
+set c2 0
+
+# Load a host script
+spawn stap $srcdir/$subdir/$test.stp -DRELAY_HOST=test1
+
+expect {
+ -timeout 120
+ "Host: begin\r\n" {
+ pass "shared buffer hosting"
+ # Run a guest script which uses printf.
+ if {[catch {exec stap $srcdir/$subdir/hello.stp -DRELAY_GUEST=test1} res]} {
+ fail "shared buffer guest"
+ print $res
+ } else {
+ incr c1
+ exp_continue
+ }
+ }
+ "HelloWorld" {
+ if {$c1 == 1} {incr c1}
+ # Run a guest script which uses print, log and warn.
+ if {[catch {exec stap $srcdir/$subdir/hello2.stp -DRELAY_GUEST=test1} res]} {
+ # check that the guest outputs a warning message.
+ if {$res == "WARNING: warning"} {
+ xfail "shared buffer guest2"
+ incr c2
+ exp_continue
+ } else {
+ fail "shared buffer guest2"
+ }
+ } else {
+ kpass "shared buffer guest2"
+ incr c2
+ exp_continue
+ }
+ }
+ "PrintSystemtap" {
+ if {$c2 == 1} {incr c2}
+ # Run a guest script which tries to use nonexist buffer.
+ if {[catch {exec stap $srcdir/$subdir/hello.stp -DRELAY_GUEST=test2} res]} {
+ xfail "nonexist buffer sharing"
+ } else {
+ fail "nonexist buffer sharing"
+ }
+ }
+ eof {fail "shared buffer hosting. unexpected EOF" }
+}
+send "\003"
+if {$c1 == 2 && $c2 == 2} {
+ pass "buffer sharing"
+} else {
+ fail "buffer sharing ($c1, $c2)"
+}
+close
+wait
diff --git a/testsuite/systemtap.printf/sharedbuf.stp b/testsuite/systemtap.printf/sharedbuf.stp
new file mode 100644
index 00000000..270e6bd1
--- /dev/null
+++ b/testsuite/systemtap.printf/sharedbuf.stp
@@ -0,0 +1,3 @@
+probe begin {
+ printf("Host: begin\n")
+}