From: Mark Wielaard Date: Fri, 12 Aug 2011 17:34:20 +0000 (+0200) Subject: Remove _stp_ctl_work_timer from module transport layer. X-Git-Tag: release-1.7~153^2~110 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=46ac9ed5bad86641e552bee4e42a2d973ffc12d0;p=systemtap.git Remove _stp_ctl_work_timer from module transport layer. The _stp_ctl_work_timer would trigger every 20ms to check whether there were cmd messages queued, but not announced yet and to check the _stp_exit_flag was set. This commit makes all control messages announce themselves and check the _stp_exit_flag in the _stp_ctl_read_cmd loop (delivery is still possibly delayed since the messages are just pushed on a wait queue). --- diff --git a/runtime/io.c b/runtime/io.c index 82be03cc7..4de682570 100644 --- a/runtime/io.c +++ b/runtime/io.c @@ -64,9 +64,7 @@ static void _stp_vlog (enum code type, const char *func, int line, const char *f else printk (KERN_INFO "%s", buf); #else if (type != DBUG) { - /* This is non-urgent .cmd data, so call - _stp_ctl_write, instead of _stp_ctl_send. */ - _stp_ctl_write(STP_OOB_DATA, buf, start + num + 1); + _stp_ctl_send(STP_OOB_DATA, buf, start + num + 1); } else { _stp_print(buf); _stp_print_flush(); diff --git a/runtime/print_flush.c b/runtime/print_flush.c index 6741e9926..a66a305e7 100644 --- a/runtime/print_flush.c +++ b/runtime/print_flush.c @@ -99,11 +99,11 @@ void EXPORT_FN(stp_print_flush)(_stp_pbuf *pb) #else /* !STP_BULKMODE */ #if STP_TRANSPORT_VERSION == 1 - /** STP_TRANSPORT_VERSION == 1 is special, _stp_ctl_write will + /** STP_TRANSPORT_VERSION == 1 is special, _stp_ctl_send/write will pass through procfs _stp_ctl_write_fs which recognizes STP_REALTIME_DATA as data that needs to be send right away over the .cmd channel instead of being queued. */ - if (unlikely(_stp_ctl_write(STP_REALTIME_DATA, pb->buf, len) <= 0)) + if (unlikely(_stp_ctl_send(STP_REALTIME_DATA, pb->buf, len) <= 0)) atomic_inc (&_stp_transport_failures); #else /* STP_TRANSPORT_VERSION != 1 */ diff --git a/runtime/transport/control.c b/runtime/transport/control.c index fd1b6ef9e..d76ad820e 100644 --- a/runtime/transport/control.c +++ b/runtime/transport/control.c @@ -441,6 +441,12 @@ static ssize_t _stp_ctl_read_cmd(struct file *file, char __user *buf, spin_lock_irqsave(&_stp_ctl_ready_lock, flags); while (list_empty(&_stp_ctl_ready_q)) { spin_unlock_irqrestore(&_stp_ctl_ready_lock, flags); + + /* Someone is listening, if exit flag is set AND we have finished + with probe_start() we might want them to know. */ + if (unlikely(_stp_exit_flag && _stp_probes_started)) + _stp_request_exit(); + if (file->f_flags & O_NONBLOCK) return -EAGAIN; if (wait_event_interruptible(_stp_ctl_wq, !list_empty(&_stp_ctl_ready_q))) diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index e6a7a90a6..5d30a93d6 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -33,12 +33,6 @@ static int _stp_probes_started = 0; static int _stp_exit_called = 0; static DEFINE_MUTEX(_stp_transport_mutex); -#ifndef STP_CTL_TIMER_INTERVAL -/* ctl timer interval in jiffies (default 20 ms) */ -#define STP_CTL_TIMER_INTERVAL ((HZ+49)/50) -#endif - - // For now, disable transport version 3 (unless STP_USE_RING_BUFFER is // defined). #if STP_TRANSPORT_VERSION == 3 && !defined(STP_USE_RING_BUFFER) @@ -72,8 +66,6 @@ MODULE_PARM_DESC(_stp_bufsize, "buffer size"); static void probe_exit(void); static int probe_start(void); -struct timer_list _stp_ctl_work_timer; - /* * _stp_handle_start - handle STP_START */ @@ -163,7 +155,6 @@ static void _stp_detach(void) if (!_stp_exit_flag) _stp_transport_data_fs_overwrite(1); - del_timer_sync(&_stp_ctl_work_timer); wake_up_interruptible(&_stp_ctl_wq); } @@ -178,37 +169,6 @@ static void _stp_attach(void) dbug_trans(1, "attach\n"); _stp_pid = current->pid; _stp_transport_data_fs_overwrite(0); - init_timer(&_stp_ctl_work_timer); - _stp_ctl_work_timer.expires = jiffies + STP_CTL_TIMER_INTERVAL; - _stp_ctl_work_timer.function = _stp_ctl_work_callback; - _stp_ctl_work_timer.data= 0; - add_timer(&_stp_ctl_work_timer); -} - -/* - * _stp_ctl_work_callback - periodically check for IO or exit - * This IO comes from ERRORs or WARNINGs which are send with - * _stp_ctl_write as type STP_OOB_DATA, so don't immediately - * trigger a wake_up of _stp_ctl_wq. - * This is run by a kernel thread and may NOT sleep. - */ -static void _stp_ctl_work_callback(unsigned long val) -{ - int do_io = 0; - unsigned long flags; - - spin_lock_irqsave(&_stp_ctl_ready_lock, flags); - if (!list_empty(&_stp_ctl_ready_q)) - do_io = 1; - spin_unlock_irqrestore(&_stp_ctl_ready_lock, flags); - if (do_io) - wake_up_interruptible(&_stp_ctl_wq); - - /* if exit flag is set AND we have finished with probe_start() */ - if (unlikely(_stp_exit_flag && _stp_probes_started)) - _stp_request_exit(); - if (atomic_read(& _stp_ctl_attached)) - mod_timer (&_stp_ctl_work_timer, jiffies + STP_CTL_TIMER_INTERVAL); } /** diff --git a/runtime/transport/transport.h b/runtime/transport/transport.h index b3c6fe194..c803d459a 100644 --- a/runtime/transport/transport.h +++ b/runtime/transport/transport.h @@ -11,7 +11,7 @@ /* amount of data a print can send. */ #define STP_BUFFER_SIZE 8192 -static int _stp_ctl_write(int type, void *data, unsigned len); +static void _stp_request_exit(void); /* STP_CTL_BUFFER_SIZE is the maximum size of a message */ /* exchanged on the control channel. */ diff --git a/tapset/system.stp b/tapset/system.stp index c17637ae4..c3927975c 100644 --- a/tapset/system.stp +++ b/tapset/system.stp @@ -9,8 +9,5 @@ * running the stap or staprun command. */ function system (cmd:string) %{ - /* NOTE this uses _stp_ctl_write and not _stp_ctl_send, - so this will only be flushed to the .cmd stream on - the next periodic _stp_ctl_work timer tick. */ - _stp_ctl_write(STP_SYSTEM, THIS->cmd, strlen(THIS->cmd)+1); + _stp_ctl_send(STP_SYSTEM, THIS->cmd, strlen(THIS->cmd)+1); %}