From: Mathieu Desnoyers Date: Thu, 14 Jul 2011 18:09:09 +0000 (-0400) Subject: Check if channel has closed stream in channel poll for CPU hotplug X-Git-Tag: v2.0-pre1~24 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f71ecafa46ad2ba9998ba6e4c425645d988d7f8c;p=lttng-modules.git Check if channel has closed stream in channel poll for CPU hotplug Signed-off-by: Mathieu Desnoyers --- diff --git a/ltt-debugfs-abi.c b/ltt-debugfs-abi.c index 0aa2cec0..72077183 100644 --- a/ltt-debugfs-abi.c +++ b/ltt-debugfs-abi.c @@ -609,8 +609,9 @@ unsigned int lttng_channel_poll(struct file *file, poll_table *wait) return POLLERR; if (channel->ops->is_finalized(channel->chan)) return POLLHUP; - else + if (channel->ops->buffer_has_read_closed_stream(channel->chan)) return POLLIN | POLLRDNORM; + return 0; } return mask; diff --git a/ltt-events.h b/ltt-events.h index 1307c36b..304bcb69 100644 --- a/ltt-events.h +++ b/ltt-events.h @@ -191,6 +191,7 @@ struct ltt_channel_ops { unsigned int read_timer_interval); void (*channel_destroy)(struct channel *chan); struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); + int (*buffer_has_read_closed_stream)(struct channel *chan); void (*buffer_read_close)(struct lib_ring_buffer *buf); int (*event_reserve)(struct lib_ring_buffer_ctx *ctx, uint32_t event_id); diff --git a/ltt-ring-buffer-client.h b/ltt-ring-buffer-client.h index 39587dd0..25152bf3 100644 --- a/ltt-ring-buffer-client.h +++ b/ltt-ring-buffer-client.h @@ -399,6 +399,20 @@ struct lib_ring_buffer *ltt_buffer_read_open(struct channel *chan) return NULL; } +static +int ltt_buffer_has_read_closed_stream(struct channel *chan) +{ + struct lib_ring_buffer *buf; + int cpu; + + for_each_channel_cpu(cpu, chan) { + buf = channel_get_ring_buffer(&client_config, chan, cpu); + if (!atomic_long_read(&buf->active_readers)) + return 1; + } + return 0; +} + static void ltt_buffer_read_close(struct lib_ring_buffer *buf) { @@ -485,6 +499,8 @@ static struct ltt_transport ltt_relay_transport = { .channel_create = _channel_create, .channel_destroy = ltt_channel_destroy, .buffer_read_open = ltt_buffer_read_open, + .buffer_has_read_closed_stream = + ltt_buffer_has_read_closed_stream, .buffer_read_close = ltt_buffer_read_close, .event_reserve = ltt_event_reserve, .event_commit = ltt_event_commit, diff --git a/ltt-ring-buffer-metadata-client.h b/ltt-ring-buffer-metadata-client.h index 43a711ca..06936aaa 100644 --- a/ltt-ring-buffer-metadata-client.h +++ b/ltt-ring-buffer-metadata-client.h @@ -177,6 +177,20 @@ struct lib_ring_buffer *ltt_buffer_read_open(struct channel *chan) return NULL; } +static +int ltt_buffer_has_read_closed_stream(struct channel *chan) +{ + struct lib_ring_buffer *buf; + int cpu; + + for_each_channel_cpu(cpu, chan) { + buf = channel_get_ring_buffer(&client_config, chan, cpu); + if (!atomic_long_read(&buf->active_readers)) + return 1; + } + return 0; +} + static void ltt_buffer_read_close(struct lib_ring_buffer *buf) { @@ -250,6 +264,8 @@ static struct ltt_transport ltt_relay_transport = { .channel_create = _channel_create, .channel_destroy = ltt_channel_destroy, .buffer_read_open = ltt_buffer_read_open, + .buffer_has_read_closed_stream = + ltt_buffer_has_read_closed_stream, .buffer_read_close = ltt_buffer_read_close, .event_reserve = ltt_event_reserve, .event_commit = ltt_event_commit,