Re: CVS commit: src/sys/arch/xen/xen

2011-05-15 Thread Mindaugas Rasiukevicius
Hello,

Jean-Yves Migeon j...@netbsd.org wrote:
 Module Name:  src
 Committed By: jym
 Date: Sun May 15 07:24:15 UTC 2011
 
 Modified Files:
   src/sys/arch/xen/xen: xbdback_xenbus.c
 
 Log Message:
 Use atomic_ops(3) for ref counting.
 

 +   atomic_dec_uint((xbdip)-xbdi_refcnt);  \
 +   if (0 == (xbdip)-xbdi_refcnt)   \
 xbdback_finish_disconnect(xbdip); \

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.

-- 
Mindaugas


Re: CVS commit: src/sys/arch/xen/xen

2011-05-15 Thread Jean-Yves Migeon
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.mig...@free.fr


Re: CVS commit: src/sys/fs/tmpfs

2011-05-15 Thread Matt Thomas

On May 14, 2011, at 1:43 PM, Martin Husemann wrote:

 On Sat, May 14, 2011 at 10:34:05AM +0200, Marc Balmer wrote:
 What is the current state of C99 vs. older Cs?  Do all arches /
 compilers we have support C99?
 
 We have lost the playstation2 port, because we don't have a working C99
 compiler for it (so a -current kernel can not be compiled).

No, we lost the playstation2 port because it required a special compiler
and needs lots of one-off changes in the mips code.