From: Anton Ivanov <[email protected]> There is no point to add 512 bytes on the stack every time latch is polled. Alignment, cache line thrashing, etc - you name it.
The result of the read is discarded anyway so the buffer can be shared by all latches. Signed-off-by: Anton Ivanov <[email protected]> --- lib/latch-unix.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/latch-unix.c b/lib/latch-unix.c index 2995076d6..e43fab770 100644 --- a/lib/latch-unix.c +++ b/lib/latch-unix.c @@ -23,6 +23,9 @@ #include "openvswitch/poll-loop.h" #include "socket-util.h" +/* All writes to latch are zero sized. Even 16 bytes are an overkill */ +static char latch_buffer[16]; + /* Initializes 'latch' as initially unset. */ void latch_init(struct latch *latch) @@ -43,9 +46,7 @@ latch_destroy(struct latch *latch) bool latch_poll(struct latch *latch) { - char buffer[_POSIX_PIPE_BUF]; - - return read(latch->fds[0], buffer, sizeof buffer) > 0; + return read(latch->fds[0], &latch_buffer, sizeof latch_buffer) > 0; } /* Sets 'latch'. -- 2.20.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
