+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
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. */
#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
*/
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 */
* @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 */
+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()
_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;
+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.
--- /dev/null
+probe begin
+{
+ printf("Hello");
+ printf("World");
+ exit()
+}
--- /dev/null
+probe begin
+{
+ print("Print");
+ log("Systemtap");
+ warn("warning");
+ exit()
+}
--- /dev/null
+# 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
--- /dev/null
+probe begin {
+ printf("Host: begin\n")
+}