Adapt poll layer behaviour to match the epoll layer
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 Adapt poll layer behaviour to match the epoll layer
--- src/common/compat/compat-poll.c | 28 ++++++++++++++++++---------- src/common/compat/poll.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)
src/common/compat/compat-poll.c +18 -10
@@ -1,5 +1,6 @@/* * Copyright (C) 2011 - David Goulet <[email protected]> +* Copyright (C) 2019 - Yannick Lamarre <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only,
@@ -204,10 +205,10 @@ int compat_poll_mod(struct lttng_poll_event *events, int fd, uint32_t req_events) {int i; -bool fd_found = false;struct compat_poll_event_array *current; -if (events ==NULL || events->current.events ==NULL || fd <0 ) { +if (events ==NULL || events->current.nb_fd ==0 || events->current.events + ==NULL || fd <0 ) {ERR ("Bad compat poll mod arguments" ); goto error; }
@@ -216,16 +217,15 @@ int compat_poll_mod(struct lttng_poll_event *events, int fd,for (i =0 ; i < current->nb_fd; i++) {if (current->events[i].fd == fd) { - fd_found = true; current->events[i].events = req_events; events->need_update =1 ;break ; } } -if (!fd_found) { - goto error; - } +/* +* The epoll flavor doesn't flag modifying a non-included FD as an error. +*/ return 0 ;
@@ -238,11 +238,12 @@ error:*/ int compat_poll_del (struct lttng_poll_event *events,int fd) { -int new_size, i, count =0 , ret; +int i, count =0 , ret; +uint32_t new_size;struct compat_poll_event_array *current; -if (events ==NULL || events->current.events ==NULL || fd <0 ) { -ERR ("Wrong arguments for poll del" ); +if (events ==NULL || events->current.nb_fd ==0 || events->current.events + ==NULL || fd <0 ) { goto error; }
@@ -257,13 +258,19 @@ int compat_poll_del(struct lttng_poll_event *events, int fd) count++; } } + +/* The fd was not in our set, return no error as with epoll. */ +if (current->nb_fd == count) { + goto skip; + } +/* No fd duplicate should be ever added into array. */ assert (current->nb_fd -1 == count); current->nb_fd = count;/* Resize array if needed. */ new_size =1U <<utils_get_count_order_u32 (current->nb_fd); -if (new_size != current->alloc_size && new_size >= current->init_size) { +if (new_size != current->alloc_size && new_size >= current->init_size && current->nb_fd !=0 ) { ret =resize_poll_event (current, new_size);if (ret <0 ) { goto error;
@@ -272,6 +279,7 @@ int compat_poll_del(struct lttng_poll_event *events, int fd) events->need_update =1 ; +skip:return 0 ; error:
src/common/compat/poll.h +1 -0
@@ -1,5 +1,6 @@/* * Copyright (C) 2011 - David Goulet <[email protected]> +* Copyright (C) 2019 - Yannick Lamarre <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only,
Signature · 1 line
2.11.0
PATCH v2 1/1 Fix hang in thread_rotation when using compat-poll
In reply to a message not in the archiveAdd missing verification to prevent a blocking read on an empty fd.
--- src/bin/lttng-sessiond/rotation-thread.c | 4 ++++ 1 file changed, 4 insertions(+)
src/bin/lttng-sessiond/rotation-thread.c +4 -0
@@ -974,6 +974,10 @@ void *thread_rotation(void *data)int fd =LTTNG_POLL_GETFD (&thread.events, i);uint32_t revents =LTTNG_POLL_GETEV (&thread.events, i); +if (!revents) { +/* No activity for this FD (poll implementation). */ +continue ; + }DBG ("[rotation-thread] Handling fd (%i) activity (%u)" , fd, revents);
Signature · 1 line
2.11.0
PATCH v2 1/1 Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
In reply to a message not in the archiveThis removes the need to verify for eventless file descriptors and mitigates risks of bug due to behaviour mismatch.
--- src/common/compat/compat-poll.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
src/common/compat/compat-poll.c +30 -3
@@ -292,6 +292,7 @@ error:int compat_poll_wait (struct lttng_poll_event *events,int timeout) {int ret; +int eidx =0 ;if (events ==NULL || events->current.events ==NULL ) {ERR ("poll wait arguments error" );
@@ -324,10 +325,36 @@ int compat_poll_wait(struct lttng_poll_event *events, int timeout) }/* -* poll() should always iterate on all FDs since we handle the pollset in -* user space and after poll returns, we have to try every fd for a match. +* Swap all nonzero revents pollfd structs to the beginning of the array to +* emulate compat-epoll behaviour. This algorithm takes advantage of poll's +* returned value and the burst nature of waking events on the file +* descriptors. The while loop garantees that idlepfd will always point to +* a pollfd with revents == 0. */ -return events->wait.nb_fd; +if (ret == events->wait.nb_fd) { + goto skip; + } +while (eidx < ret && events->wait.events[eidx].revents !=0 ) { + eidx +=1 ; + } + +for (int idx = eidx +1 ; eidx < ret; idx++) { +struct pollfd swapfd; +struct pollfd *idlepfd = &events->wait.events[eidx]; +struct pollfd *ipfd = &events->wait.events[idx]; + +assert (idx < events->wait.nb_fd); + +if (ipfd->revents !=0 ) { + swapfd = *ipfd; + *ipfd = *idlepfd; + *idlepfd = swapfd; + eidx +=1 ; + } + } + +skip: +return ret; error:return -1 ;
Signature · 1 line
2.11.0
PATCH v2 1/1 Fix typo
In reply to a message not in the archive--- src/common/compat/poll.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/common/compat/poll.h +1 -1
@@ -359,7 +359,7 @@ extern int compat_poll_del(struct lttng_poll_event *events, int fd);compat_poll_del (events, fd)/* -* Modify an fd's events in the epoll set. +* Modify an fd's events in the poll set. */extern int compat_poll_mod (struct lttng_poll_event *events,int fd,uint32_t req_events);
Signature · 1 line
2.11.0
PATCH v2 1/1 Add Unit test to poll compatibility layer
In reply to a message not in the archive--- .gitignore | 1 + tests/unit/Makefile.am | 9 +- tests/unit/test_utils_compat_poll.c | 236 ++++++++++++++++++++++++++++++++++++ 3 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 tests/unit/test_utils_compat_poll.c
.gitignore +1 -0
@@ -73,6 +73,7 @@ TAGS /tests/unit/test_session /tests/unit/test_uri /tests/unit/test_ust_data +/tests/unit/test_utils_compat_poll /tests/unit/test_utils_parse_size_suffix /tests/unit/test_utils_parse_time_suffix /tests/unit/test_utils_expand_path
tests/unit/Makefile.am +8 -1
@@ -12,6 +12,7 @@ TESTS = test_kernel_data \ test_utils_parse_size_suffix \ test_utils_parse_time_suffix \ test_utils_expand_path \ + test_utils_compat_poll \ test_string_utils \ test_notification \ ini_config/test_ini_config
@@ -28,7 +29,8 @@ LIBLTTNG_CTL=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la # Define test programs noinst_PROGRAMS = test_uri test_session test_kernel_data \ test_utils_parse_size_suffix test_utils_parse_time_suffix \ - test_utils_expand_path test_string_utils test_notification + test_utils_expand_path test_utils_compat_poll \ + test_string_utils test_notification if HAVE_LIBLTTNG_UST_CTL noinst_PROGRAMS += test_ust_data
@@ -145,6 +147,11 @@ test_utils_parse_size_suffix_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON) $(DL test_utils_parse_time_suffix_SOURCES = test_utils_parse_time_suffix.c test_utils_parse_time_suffix_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON) +# compat_poll unit test +test_utils_compat_poll_SOURCES = test_utils_compat_poll.c +test_utils_compat_poll_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(DL_LIBS) \ + $(top_builddir)/src/common/compat/libcompat.la $(LIBCOMMON) + # expand_path unit test test_utils_expand_path_SOURCES = test_utils_expand_path.c test_utils_expand_path_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON) $(DL_LIBS)
tests/unit/test_utils_compat_poll.c new file +236 -0
236 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v2 1/1 Change LTTNG_POLL_GETNB behaviour for poll flavor
In reply to a message not in the archiveModify LTTNG_POLL_GETNB to provide compatibility with the epoll flavor. Since it is only used after a lttng_poll_wait call with no modification (add, del, mod) between, this change does not modify the behaviour in its current usage while ensuring similar API behavior between compatibility layer implementations.
--- src/common/compat/poll.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
src/common/compat/poll.h +3 -1
@@ -315,10 +315,12 @@ static inline int __lttng_poll_get_prev_fd(struct lttng_poll_event *events,/* * For the following calls, consider 'e' to be a lttng_poll_event pointer and i * being the index of the events array. +* LTTNG_POLL_GETNB is always used after lttng_poll_wait, thus we can use the +* current list for test compatibility purposes. */ #define LTTNG_POLL_GETFD (e, i) LTTNG_REF(e)->wait.events[i].fd#define LTTNG_POLL_GETEV (e, i) LTTNG_REF(e)->wait.events[i].revents -#define LTTNG_POLL_GETNB (e) LTTNG_REF(e)->wait.nb_fd +#define LTTNG_POLL_GETNB (e) LTTNG_REF(e)->current.nb_fd#define LTTNG_POLL_GETSZ (e) LTTNG_REF(e)->wait.events_size#define LTTNG_POLL_GET_PREV_FD (e, i, nb_fd) \ __lttng_poll_get_prev_fd(LTTNG_REF(e), i, nb_fd)
Signature · 1 line
2.11.0
PATCH v2 1/1 Clean code base from redundant verification
In reply to a message not in the archiveRemove redundant verification for file descriptors with 0 revents in code base.
--- src/bin/lttng-consumerd/health-consumerd.c | 5 ----- src/bin/lttng-relayd/health-relayd.c | 5 ----- src/bin/lttng-relayd/live.c | 10 ---------- src/bin/lttng-relayd/main.c | 16 ---------------- src/bin/lttng-sessiond/agent-thread.c | 5 ----- src/bin/lttng-sessiond/client.c | 5 ----- src/bin/lttng-sessiond/dispatch.c | 5 ----- src/bin/lttng-sessiond/health.c | 5 ----- src/bin/lttng-sessiond/ht-cleanup.c | 5 ----- src/bin/lttng-sessiond/manage-apps.c | 5 ----- src/bin/lttng-sessiond/manage-consumer.c | 10 ---------- src/bin/lttng-sessiond/manage-kernel.c | 5 ----- src/bin/lttng-sessiond/notification-thread.c | 3 --- src/bin/lttng-sessiond/notify-apps.c | 5 ----- src/bin/lttng-sessiond/register.c | 5 ----- src/bin/lttng-sessiond/rotation-thread.c | 4 ---- src/common/consumer/consumer.c | 10 ---------- 17 files changed, 108 deletions(-)
src/bin/lttng-consumerd/health-consumerd.c +0 -5
@@ -259,11 +259,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ ret =check_health_quit_pipe (pollfd, revents);if (ret) {
src/bin/lttng-relayd/health-relayd.c +0 -5
@@ -329,11 +329,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ ret =check_health_quit_pipe (pollfd, revents);if (ret) {
src/bin/lttng-relayd/live.c +0 -10
@@ -543,11 +543,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ ret =check_thread_quit_pipe (pollfd, revents);if (ret) {
@@ -2000,11 +1995,6 @@ restart:health_code_update (); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ ret =check_thread_quit_pipe (pollfd, revents);if (ret) {
src/bin/lttng-relayd/main.c +0 -16
@@ -858,14 +858,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* -* No activity for this FD (poll -* implementation). -*/ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ ret =check_thread_quit_pipe (pollfd, revents);if (ret) {
@@ -3811,14 +3803,6 @@ restart:health_code_update (); -if (!revents) { -/* -* No activity for this FD (poll -* implementation). -*/ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ ret =check_thread_quit_pipe (pollfd, revents);if (ret) {
src/bin/lttng-sessiond/agent-thread.c +0 -5
@@ -404,11 +404,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ if (pollfd == quit_pipe_read_fd) { goto exit;
src/bin/lttng-sessiond/client.c +0 -5
@@ -2174,11 +2174,6 @@ static void *thread_manage_clients(void *data)health_code_update (); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -if (pollfd == thread_quit_pipe_fd) { err =0 ; goto exit;
src/bin/lttng-sessiond/dispatch.c +0 -5
@@ -144,11 +144,6 @@ static void sanitize_wait_queue(struct ust_reg_wait_queue *wait_queue)uint32_t revents =LTTNG_POLL_GETEV (&events, i);int pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -cds_list_for_each_entry_safe (wait_node, tmp_wait_node, &wait_queue->head, head) { if (pollfd == wait_node->app->sock &&
src/bin/lttng-sessiond/health.c +0 -5
@@ -158,11 +158,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Event on the registration socket */ if (pollfd == sock) {if (revents &LPOLLIN ) {
src/bin/lttng-sessiond/ht-cleanup.c +0 -5
@@ -155,11 +155,6 @@ static void *thread_ht_cleanup(void *data) revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -if (pollfd != ht_cleanup_pipe[0 ]) {continue ; }
src/bin/lttng-sessiond/manage-apps.c +0 -5
@@ -123,11 +123,6 @@ static void *thread_application_management(void *data)health_code_update (); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -if (pollfd == quit_pipe_read_fd) { err =0 ; goto exit;
src/bin/lttng-sessiond/manage-consumer.c +0 -10
@@ -134,11 +134,6 @@ void *thread_consumer_management(void *data)health_code_update (); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ if (pollfd == quit_pipe_read_fd) { err =0 ;
@@ -298,11 +293,6 @@ void *thread_consumer_management(void *data)health_code_update (); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* * Thread quit pipe has been triggered, flag that we should stop * but continue the current loop to handle potential data from
src/bin/lttng-sessiond/manage-kernel.c +0 -5
@@ -267,11 +267,6 @@ static void *thread_kernel_management(void *data)health_code_update (); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -if (pollfd == quit_pipe_read_fd) { err =0 ; goto exit;
src/bin/lttng-sessiond/notification-thread.c +0 -3
@@ -562,9 +562,6 @@ void *thread_notification(void *data)int fd =LTTNG_POLL_GETFD (&state.events, i);uint32_t revents =LTTNG_POLL_GETEV (&state.events, i); -if (!revents) { -continue ; - }DBG ("[notification-thread] Handling fd (%i) activity (%u)" , fd, revents);if (fd == state.notification_channel_socket) {
src/bin/lttng-sessiond/notify-apps.c +0 -5
@@ -109,11 +109,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ if (pollfd == quit_pipe_read_fd) { err =0 ;
src/bin/lttng-sessiond/register.c +0 -5
@@ -239,11 +239,6 @@ static void *thread_application_registration(void *data) revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -/* Thread quit pipe has been closed. Killing thread. */ if (pollfd == quit_pipe_read_fd) { err =0 ;
src/bin/lttng-sessiond/rotation-thread.c +0 -4
@@ -974,10 +974,6 @@ void *thread_rotation(void *data)int fd =LTTNG_POLL_GETFD (&thread.events, i);uint32_t revents =LTTNG_POLL_GETEV (&thread.events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - }DBG ("[rotation-thread] Handling fd (%i) activity (%u)" , fd, revents);
src/common/consumer/consumer.c +0 -10
@@ -2396,11 +2396,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -if (pollfd ==lttng_pipe_get_readfd (ctx->consumer_metadata_pipe)) {if (revents &LPOLLIN ) {ssize_t pipe_len;
@@ -2990,11 +2985,6 @@ restart: revents =LTTNG_POLL_GETEV (&events, i); pollfd =LTTNG_POLL_GETFD (&events, i); -if (!revents) { -/* No activity for this FD (poll implementation). */ -continue ; - } -if (pollfd == ctx->consumer_channel_pipe[0 ]) {if (revents &LPOLLIN ) {enum consumer_channel_action action;
Signature · 1 line
2.11.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools v2] Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
Thanks for this patch, it does allow a worthwhile clean-up! Read on for comments about style.
Quoted 14 lines · Yannick Lamarre
This removes the need to verify for eventless file descriptors and mitigates risks of bug due to behaviour mismatch.
Signed-off-by Yannick Lamarre <[email protected]>--- src/common/compat/compat-poll.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)src/common/compat/compat-poll.c +0
-0
src/common/compat/compat-poll.c error: · line 295
Quoted 4 lines
src/common/compat/compat-poll.c +1
-0@@ -292,6 +292,7 @@ error:int compat_poll_wait (struct lttng_poll_event *events,int timeout) {int ret; +int eidx =0 ;
Reading the code, this seems to mean the "index of the first idle file descriptor".
As a general rule, don't use uncommon abbreviations. Abbreviations are okay when they are common-place, unambiguous and save a lot of characters (e.g. cfg for configuration, or lttng for linux_trace_toolkit_next_generation).
When in doubt, prefer verbose names.
In this case, "idle_pfd_index" and a comment (see below) would clarify the intent.
src/common/compat/compat-poll.c int compat_poll_wait(struct lttng_poll_event *events, int timeout) · line 331
Quoted 13 lines
src/common/compat/compat-poll.c +4
-2if (events ==NULL || events->current.events ==NULL ) {ERR ("poll wait arguments error" );@@ -324,10 +325,36 @@ int compat_poll_wait(struct lttng_poll_event *events, int timeout) }/* -* poll() should always iterate on all FDs since we handle the pollset in -* user space and after poll returns, we have to try every fd for a match. +* Swap all nonzero revents pollfd structs to the beginning of the array to +* emulate compat-epoll behaviour. This algorithm takes advantage of poll's +* returned value and the burst nature of waking events on the file +* descriptors. The while loop garantees that idlepfd will always point to
garantees -> guarantees
This comment block exceeds 80 chars. Make sure your editor's tab width is set to 8 characters.
The code, commit message, and comments make use of multiple terms to refer to the same file descriptor state ('idle', 'empty', 'eventless', and 'zero').
Please stick to one of those terms.
Idle seems preferable, but feel free to whichever term the poll() specification uses.
src/common/compat/compat-poll.c int compat_poll_wait(struct lttng_poll_event *events, int timeout) · line 338
Quoted 8 lines
src/common/compat/compat-poll.c +6
-1+* a pollfd with revents == 0. */ -return events->wait.nb_fd; +if (ret == events->wait.nb_fd) { + goto skip; + } +while (eidx < ret && events->wait.events[eidx].revents !=0 ) { + eidx +=1 ;
Prefer "eidx++".
Using variables for a single purpose is fine and tends to make the code clearer.
For example, reworking this section of code to:
active_fd_count = ret;
/* Find the first idle pollfd. */
while (idle_pfd_index < active_fd_count &&
events->wait.events[idle_pfd_index].revents != 0) {
idle_pfd_index++;
}makes the intent clearer.
src/common/compat/compat-poll.c int compat_poll_wait(struct lttng_poll_event *events, int timeout) · line 341
Quoted 3 lines
src/common/compat/compat-poll.c +3
-0+ } + +for (int idx = eidx +1 ; eidx < ret; idx++) {
Same change here (regarding 'ret').
To maintain uniformity with the rest of the code base, please declare variables at the top of the inner-most scope containing the loop.
When declaring a trivial loop counter/index, use the name 'i'. Here, the difference between 'idx' and 'eidx' is not immediately apparent. Renaming 'eidx' makes the loop clearer.
Also, in this particular case, 'i' is fine since you are only using it to assign the current pollfd, which is fairly descriptive.
src/common/compat/compat-poll.c int compat_poll_wait(struct lttng_poll_event *events, int timeout) · line 344
Quoted 3 lines
src/common/compat/compat-poll.c +3
-0+struct pollfd swapfd; +struct pollfd *idlepfd = &events->wait.events[eidx]; +struct pollfd *ipfd = &events->wait.events[idx];
Use an underscore to split variable names, e.g. swap_pfd, idle_pfd, current_pfd. Again, verbose names are preferable.
src/common/compat/compat-poll.c int compat_poll_wait(struct lttng_poll_event *events, int timeout) · line 346
Quoted 2 lines
src/common/compat/compat-poll.c +2
-0+ +assert (idx < events->wait.nb_fd);
Not needed. Using assert() is fine to highlight assumptions across interfaces/functions and/or catch catastrophic internal errors. Here, this would be a very local condition that seems to be already enforced.
Reworking the 'for' condition to use 'i < events->wait.nb_fd' and breaking out early of the loop is also an option here.
src/common/compat/compat-poll.c int compat_poll_wait(struct lttng_poll_event *events, int timeout) · line 352
Quoted 6 lines
src/common/compat/compat-poll.c +6
-0+ +if (ipfd->revents !=0 ) { + swapfd = *ipfd; + *ipfd = *idlepfd; + *idlepfd = swapfd; + eidx +=1 ;
eidx++;
src/common/compat/compat-poll.c int compat_poll_wait(struct lttng_poll_event *events, int timeout) · line 356
Quoted 4 lines
src/common/compat/compat-poll.c +4
-0+ } + } + +skip:
Rename label to 'end'.
Thanks!
Jérémie
Quoted 7 lines
src/common/compat/compat-poll.c +1
-1+return ret; error:return -1 ; --2.11.0
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): CA+jJMxui0_5EF6XLH-9G90-yJEE63zdiBifTeF4i9iQp95D7tg@mail.gmail.com
Re: [PATCH lttng-tools v2] Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
----- On Mar 21, 2019, at 4:25 PM, Jeremie Galarneau [email protected] wrote:
[...]
Quoted 9 lines
Quoted 1 line
+
assert(idx < events->wait.nb_fd);Not needed. Using
assert()is fine to highlight assumptions across interfaces/functions and/or catch catastrophic internal errors. Here, this would be a very local condition that seems to be already enforced.Reworking the 'for' condition to use 'i <
events->wait.nb_fd' and breaking out early of the loop is also an option here.
The reason for using assert() here is to ensure that there is no discrepancy between the number of active poll fd in the set and the value returned by poll indicating that same number of active fds.
We'd need a kernel bug (or memory corruption) to have a mismatch, but I thought having an assert in there would not hurt, since it might help diagnose issues that cross user-kernel boundaries.
Thoughts ?
Mathieu
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools v2] Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
Quoted 18 lines · Mathieu Desnoyers
----- On Mar 21, 2019, at 4:25 PM, Jeremie Galarneau [email protected] wrote:
[...]
Quoted 9 lines
Quoted 1 line
+
assert(idx < events->wait.nb_fd);Not needed. Using
assert()is fine to highlight assumptions across interfaces/functions and/or catch catastrophic internal errors. Here, this would be a very local condition that seems to be already enforced.Reworking the 'for' condition to use 'i <
events->wait.nb_fd' and breaking out early of the loop is also an option here.The reason for using
assert()here is to ensure that there is no discrepancy between the number of active poll fd in the set and the value returned by poll indicating that same number of active fds.
Quoted 5 lines
We'd need a kernel bug (or memory corruption) to have a mismatch, but I thought having an assert in there would not hurt, since it might help diagnose issues that cross user-kernel boundaries.
Thoughts ?
Hi,
I understand the intent, but I don't feel these type of kernel tests/checks belong in the code.
However, if there is a specific concern that our use of poll() could highlight this type of bug (in the kernel or in the interactions with lttng-modules), we can add tests for that.
Thanks,
Jérémie
Quoted 7 lines
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): CA+jJMxsbA0ksOJN9yqbtCVXkTLKOqfEMek6P9_bxSdKH75zEPQ@mail.gmail.com
Re: [PATCH lttng-tools v2] Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
Quoted 27 lines · ----- On Mar 25, 2019, at 11:10 AM, Jeremie Galarneau…
Quoted 19 lines · Mathieu Desnoyers
----- On Mar 21, 2019, at 4:25 PM, Jeremie Galarneau [email protected] wrote:
[...]
Quoted 9 lines
Quoted 1 line
+
assert(idx < events->wait.nb_fd);Not needed. Using
assert()is fine to highlight assumptions across interfaces/functions and/or catch catastrophic internal errors. Here, this would be a very local condition that seems to be already enforced.Reworking the 'for' condition to use 'i <
events->wait.nb_fd' and breaking out early of the loop is also an option here.The reason for using
assert()here is to ensure that there is no discrepancy between the number of active poll fd in the set and the value returned by poll indicating that same number of active fds.Quoted 5 lines
We'd need a kernel bug (or memory corruption) to have a mismatch, but I thought having an assert in there would not hurt, since it might help diagnose issues that cross user-kernel boundaries.
Thoughts ?
Quoted 8 lines
Hi,
I understand the intent, but I don't feel these type of kernel tests/checks belong in the code.
However, if there is a specific concern that our use of
poll()could highlight this type of bug (in the kernel or in the interactions with lttng-modules), we can add tests for that.
There is no specific concern. We can remove the assert.
Thanks,
Mathieu
Quoted 17 lines
Thanks,
JérémieQuoted 7 lines
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
Signature · 7 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools v2] Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
Alright, I'll remove the assert for v4.
----- Original Message -----
From: "Mathieu Desnoyers" <[email protected]>
To: "Jeremie Galarneau" <[email protected]>
Cc: "Yannick Lamarre" <[email protected]>, "lttng-dev" <[email protected]>, "jgalar" <[email protected]>
Sent: Monday, March 25, 2019 11:56:11 AM
Subject: Re: [lttng-dev] [PATCH lttng-tools v2] Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
Quoted 27 lines · ----- On Mar 25, 2019, at 11:10 AM, Jeremie Galarneau…
Quoted 19 lines · Mathieu Desnoyers
----- On Mar 21, 2019, at 4:25 PM, Jeremie Galarneau [email protected] wrote:
[...]
Quoted 9 lines
Quoted 1 line
+
assert(idx < events->wait.nb_fd);Not needed. Using
assert()is fine to highlight assumptions across interfaces/functions and/or catch catastrophic internal errors. Here, this would be a very local condition that seems to be already enforced.Reworking the 'for' condition to use 'i <
events->wait.nb_fd' and breaking out early of the loop is also an option here.The reason for using
assert()here is to ensure that there is no discrepancy between the number of active poll fd in the set and the value returned by poll indicating that same number of active fds.Quoted 5 lines
We'd need a kernel bug (or memory corruption) to have a mismatch, but I thought having an assert in there would not hurt, since it might help diagnose issues that cross user-kernel boundaries.
Thoughts ?
Quoted 8 lines
Hi,
I understand the intent, but I don't feel these type of kernel tests/checks belong in the code.
However, if there is a specific concern that our use of
poll()could highlight this type of bug (in the kernel or in the interactions with lttng-modules), we can add tests for that.
There is no specific concern. We can remove the assert.
Thanks,
Mathieu
Quoted 17 lines
Thanks,
JérémieQuoted 7 lines
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
Signature · 7 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev