MEDIUM: poller: use atomic ops to update the fdtab mask

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.
This commit is contained in:
Willy Tarreau 2018-01-25 18:06:46 +01:00
parent 4d84186337
commit 62a627ac19
4 changed files with 4 additions and 12 deletions

View 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)) {

View 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)) {

View 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

View 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