--- runtime/print.c | 35 +++++++++++++++++++++++++++++++++++ runtime/print_new.c | 3 +-- runtime/print_old.c | 3 +-- runtime/transport/transport.c | 6 ++++++ 4 files changed, 43 insertions(+), 4 deletions(-) Index: systemtap/runtime/print.c =================================================================== --- systemtap.orig/runtime/print.c +++ systemtap/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 Index: systemtap/runtime/print_new.c =================================================================== --- systemtap.orig/runtime/print_new.c +++ systemtap/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 */ Index: systemtap/runtime/print_old.c =================================================================== --- systemtap.orig/runtime/print_old.c +++ systemtap/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 */ Index: systemtap/runtime/transport/transport.c =================================================================== --- systemtap.orig/runtime/transport/transport.c +++ systemtap/runtime/transport/transport.c @@ -225,6 +225,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;