]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: fd/threads: ensure the fdcache_mask always reflects the cache contents
authorWilly Tarreau <w@1wt.eu>
Tue, 20 Mar 2018 18:06:52 +0000 (19:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Mar 2018 18:14:24 +0000 (19:14 +0100)
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.

include/proto/fd.h

index b9811fe43e0cfd09540a42412631906b662f5281..0f59df6617b2e682c2b3d6eef3dc9baa68a88a62 100644 (file)
@@ -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