]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: poller: use atomic ops to update the fdtab mask
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Jan 2018 17:06:46 +0000 (18:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 5 Feb 2018 15:02:22 +0000 (16:02 +0100)
We don't need to lock the fdtab[].lock anymore since we only have one
modification left (update update_mask). Let's use an atomic AND instead.

src/ev_epoll.c
src/ev_kqueue.c
src/ev_poll.c
src/ev_select.c

index 3edaf288cb6e44aa98a39586d30439aea104c3b0..b98ca8ca80413f704deedd7718c6f31410e01e20 100644 (file)
@@ -79,10 +79,8 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                        continue;
                }
 
-               HA_SPIN_LOCK(FD_LOCK, &fdtab[fd].lock);
-               fdtab[fd].update_mask &= ~tid_bit;
                en = fdtab[fd].state;
-               HA_SPIN_UNLOCK(FD_LOCK, &fdtab[fd].lock);
+               HA_ATOMIC_AND(&fdtab[fd].update_mask, ~tid_bit);
 
                if (fdtab[fd].polled_mask & tid_bit) {
                        if (!(fdtab[fd].thread_mask & tid_bit) || !(en & FD_EV_POLLED_RW)) {
index fcd04fda90a9af451de6028fe5ba8d652daca066..cc96307b0ad94e6903dc56c8d6a67c184be8e905 100644 (file)
@@ -52,10 +52,8 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                        continue;
                }
 
-               HA_SPIN_LOCK(FD_LOCK, &fdtab[fd].lock);
-               fdtab[fd].update_mask &= ~tid_bit;
                en = fdtab[fd].state;
-               HA_SPIN_UNLOCK(FD_LOCK, &fdtab[fd].lock);
+               HA_ATOMIC_AND(&fdtab[fd].update_mask, ~tid_bit);
 
                if (!(fdtab[fd].thread_mask & tid_bit) || !(en & FD_EV_POLLED_RW)) {
                        if (!(fdtab[fd].polled_mask & tid_bit)) {
index 22cb227578ee80b5d3c9dcd17236e0fb834004d5..edcfe65651d35f2d75d76519c7f4c004c3e6a8b5 100644 (file)
@@ -70,10 +70,8 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                        continue;
                }
 
-               HA_SPIN_LOCK(FD_LOCK, &fdtab[fd].lock);
-               fdtab[fd].update_mask &= ~tid_bit;
                en = fdtab[fd].state;
-               HA_SPIN_UNLOCK(FD_LOCK, &fdtab[fd].lock);
+               HA_ATOMIC_AND(&fdtab[fd].update_mask, ~tid_bit);
 
                /* we have a single state for all threads, which is why we
                 * don't check the tid_bit. First thread to see the update
index db0814d6e32af452b0efedd51f6190b2e16afe37..6e834678db4e6bf8b46c5749f3e428cb53fe73ec 100644 (file)
@@ -62,10 +62,8 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                        continue;
                }
 
-               HA_SPIN_LOCK(FD_LOCK, &fdtab[fd].lock);
-               fdtab[fd].update_mask &= ~tid_bit;
                en = fdtab[fd].state;
-               HA_SPIN_UNLOCK(FD_LOCK, &fdtab[fd].lock);
+               HA_ATOMIC_AND(&fdtab[fd].update_mask, ~tid_bit);
 
                /* we have a single state for all threads, which is why we
                 * don't check the tid_bit. First thread to see the update