Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/sys/arch/xen/xen
On 15.05.2011 21:11, Mindaugas Rasiukevicius wrote:
> This is not correct. Atomic op might decrease the reference count to
> 1 while other thread executes xbdi_put() before xbdi_refcnt is fetched,
> thus decreasing it to 0. In such case, both threads would fetch 0.
>
> The following is a correct way:
>
> if (atomic_dec_uint_nv(&xbdip->xbdi_refcnt) == 0)
> xbdback_finish_disconnect(xbdip);
>
> Also, it seems there is no need for xbdi_refcnt to be volatile.
Good point; I was pondering about the _nv() version when I made the
change, but forgot about the possible concurrency regarding refcnt fetch
(not actually possible as port-xen is not MP, but will become soonish)
I'll remove the volatile declaration too, only xbdi_put/_get use the
refcnt for G/C anyway.
Thanks for pointing that out!
--
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost
Home |
Main Index |
Thread Index |
Old Index