Thread (11 messages) flat view 11 messages, 3 authors, 2021-05-18

Re: [PATCH net v8 1/3] net: sched: fix packet stuck problem for lockless qdisc

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-05-15 00:18:06
Also in: bpf, linux-can, lkml

On Fri, 14 May 2021 16:57:29 -0700 Cong Wang wrote:
On Fri, May 14, 2021 at 4:39 PM Jakub Kicinski [off-list ref] wrote:
quoted
On Fri, 14 May 2021 16:36:16 -0700 Cong Wang wrote:  
 [...]  
quoted
quoted
We have test_and_clear_bit() which is atomic, test_bit()+clear_bit()
is not.  
It doesn't have to be atomic, right? I asked to split the test because
test_and_clear is a locked op on x86, test by itself is not.  
It depends on whether you expect the code under the true condition
to run once or multiple times, something like:

if (test_bit()) {
  clear_bit();
  // this code may run multiple times
}

With the atomic test_and_clear_bit(), it only runs once:

if (test_and_clear_bit()) {
  // this code runs once
}

This is why __netif_schedule() uses test_and_set_bit() instead of
test_bit()+set_bit().
Thanks, makes sense, so hopefully the MISSED-was-set case is not common
and we can depend on __netif_schedule() to DTRT, avoiding the atomic op
in the common case.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help