[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/11] include: add lock-less reference counting primitives
From: |
Neal H. Walfield |
Subject: |
Re: [PATCH 03/11] include: add lock-less reference counting primitives |
Date: |
Tue, 13 May 2014 13:58:32 +0200 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/23.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
At Tue, 13 May 2014 13:47:51 +0200,
Samuel Thibault wrote:
>
> Neal H. Walfield, le Tue 13 May 2014 13:44:37 +0200, a écrit :
> > At Tue, 13 May 2014 12:52:03 +0200,
> > Justus Winter wrote:
> > > Quoting Neal H. Walfield (2014-05-13 09:44:21)
> > > > At Mon, 12 May 2014 12:05:41 +0200,
> > > > Justus Winter wrote:
> > > > > +/* Decrement REF. Return the result of the operation. This function
> > > > > + uses atomic operations. It is not required to serialize calls to
> > > > > + this function. */
> > > > > +static inline unsigned int
> > > > > +refcount_deref (refcount_t *ref)
> > > > > +{
> > > > > + return __atomic_sub_fetch (ref, 1, __ATOMIC_RELAXED);
> > > > > +}
> > > >
> > > > How about adding assert(*ref >= 0)?
> > >
> > > It is there, you just can't see it because I optimized it away (as gcc
> > > would, as refcount_t is unsigned ;).
> >
> > I meant assert(*ref > 0), sorry.
>
> Well, I'd rather check that the result didn't underflow, otherwise you
> may miss it in some rare conditions.
Good point. The assert that I proposed would introduce a TOCTTOU bug.
:) Neal
- Re: [PATCH 03/11] include: add lock-less reference counting primitives, (continued)
Re: [PATCH 03/11] include: add lock-less reference counting primitives, Neal H. Walfield, 2014/05/13
Re: [PATCH 03/11] include: add lock-less reference counting primitives, Neal H. Walfield, 2014/05/13
Re: [PATCH 03/11] include: add lock-less reference counting primitives, Samuel Thibault, 2014/05/13
Re: [PATCH 03/11] include: add lock-less reference counting primitives,
Neal H. Walfield <=
[PATCH 06/11] libtrivfs: lock-less reference counting for trivfs_peropen objects, Justus Winter, 2014/05/12
[PATCH 02/11] libports: use a single hash table, Justus Winter, 2014/05/12
[PATCH 04/11] libports: lock-less reference counting for port_info objects, Justus Winter, 2014/05/12
[PATCH 08/11] libihash: reduce the default maximum load factor to 75%, Justus Winter, 2014/05/12