From: Willy Tarreau Date: Tue, 20 Mar 2018 18:06:52 +0000 (+0100) Subject: BUG/MEDIUM: fd/threads: ensure the fdcache_mask always reflects the cache contents X-Git-Tag: v1.9-dev1~358 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26fb5d8449f3b17317d2b7b5c54979f576d5f95b;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: fd/threads: ensure the fdcache_mask always reflects the cache contents Commit 4815c8c ("MAJOR: fd/threads: Make the fdcache mostly lockless.") made the fd cache lockless, but after a few iterations, a subtle part was lost, consisting in setting the bit on the fd_cache_mask immediately when adding an event. Now it was done only when the cache started to process events, but the problem it causes is that fd_cache_mask isn't reliable anymore as an indicator of presence of events to be processed with no delay outside of fd_process_cached_events(). This results in some spurious delays when processing inter-thread wakeups between tasks. Just restoring the flag when the event is added is enough to fix the problem. Kudos to Christopher for spotting this one! No backport is needed as this is only in the development version. --- diff --git a/include/proto/fd.h b/include/proto/fd.h index b9811fe43e..0f59df6617 100644 --- a/include/proto/fd.h +++ b/include/proto/fd.h @@ -117,6 +117,7 @@ static inline void updt_fd_polling(const int fd) */ static inline void fd_alloc_cache_entry(const int fd) { + HA_ATOMIC_OR(&fd_cache_mask, fdtab[fd].thread_mask); if (!(fdtab[fd].thread_mask & (fdtab[fd].thread_mask - 1))) fd_add_to_fd_list(&fd_cache_local[my_ffsl(fdtab[fd].thread_mask) - 1], fd); else