Re: [PATCH v2 8/9] atomic,x86: Alternative atomic_*_overflow() scheme
From: Linus Torvalds
Date: Fri Dec 10 2021 - 12:28:13 EST
On Fri, Dec 10, 2021 at 8:53 AM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> That said - it may not matter - I'm not sure a plain "dec" is even a
> valid operation on a ref in the first place. How could you ever
> validly decrement a ref without checking for it being the last entry?
I should have checked the users - it seems to be a pattern at least in
networking where people have extra references and do
refcount_dec(&skb->users);
dev_kfree_skb_any(skb);
because there's no way to tell dev_kfree_skb*() to decrement more than once.
So I guess it's all good, but yes, I still think you can just do "lock
dec .. js" for this operation.
Linus