netdev
[Top] [All Lists]

Re: atomic_dec_and_test for child dst needed in dst_destroy?

To: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Subject: Re: atomic_dec_and_test for child dst needed in dst_destroy?
From: Christoph Lameter <christoph@xxxxxxxxxxx>
Date: Tue, 5 Apr 2005 15:14:26 -0700 (PDT)
Cc: netdev@xxxxxxxxxxx, davem@xxxxxxxxxxxxx
In-reply-to: <E1DIvr8-0002yy-00@xxxxxxxxxxxxxxxxxxxxxxxx>
References: <E1DIvr8-0002yy-00@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
On Wed, 6 Apr 2005, Herbert Xu wrote:

> > -               if (atomic_dec_and_test(&dst->__refcnt)) {
> > +               atomic_dec(&dst->__refcnt);
> > +               if (!atomic_read(&dst->__refcnt)) {
>
> This is racy (albeit very unlikely) because dst may be freed by
> dst_run_gc after the atomic_dec.

If that is so then it is also possible that the gc frees after
atomic_dec_and_test:

cpu0 dst_destroy        cpu1 dst_run_gc

atomic_dec_and_test(refcnt)
                        if (atomic_read(refcnt)) ...
                        ..
                        dst_destroy(dst)
                        kmem_cache_free(dst)
..
goto again
...
kmem_cache_free(dst)



<Prev in Thread] Current Thread [Next in Thread>