Messages in this thread | | | Date | Fri, 17 Dec 2021 14:38:04 +1100 | From | Herbert Xu <> | Subject | Re: [PATCH v2 8/9] atomic,x86: Alternative atomic_*_overflow() scheme |
| |
Linus Torvalds <torvalds@linux-foundation.org> 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?
There are actual spots in the network stack where we know we're holding multiple reference counts to a given object and in those cases an unconditional "dec" could make sense. For example, we may have an object that we obtained from a hash lookup, giving us a reference count, which we then try to remove from a linked list, also containing a referencnce count to it. While still holding the referencnce count from the hash lookup, the linked list referencnce count could be dropped with a plain "dec".
Of course we might be better off redesigning things to eliminate reference counts completely but such code does still exist.
Cheers, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
| |