[sheepdog] [PATCH 3/3] collie: don't use uint64_t for atomic operations

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon Aug 5 07:16:28 CEST 2013


At Mon, 5 Aug 2013 12:59:00 +0800,
YunQiang Su wrote:
> 
> On Fri, Aug 2, 2013 at 5:00 PM, MORITA Kazutaka
> <morita.kazutaka at lab.ntt.co.jp> wrote:
> > At Fri, 2 Aug 2013 16:34:00 +0800,
> > Liu Yuan wrote:
> >>
> >> On Fri, Aug 02, 2013 at 04:14:41PM +0900, MORITA Kazutaka wrote:
> >> > From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> >> >
> >> > Atomic operations against 64 bit integers are not allowed on 32 bit
> >> > architectures.  Using unsigned long instead of uint64_t fixes the
> >> > problem and doesn't hurt x86_64.
> >> >
> >> > Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> >> > ---
> >> >  collie/farm/farm.c |    4 ++--
> >> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git a/collie/farm/farm.c b/collie/farm/farm.c
> >> > index 2a4e307..4b43f3d 100644
> >> > --- a/collie/farm/farm.c
> >> > +++ b/collie/farm/farm.c
> >> > @@ -255,7 +255,7 @@ static void save_object_done(struct work *work)
> >> >  {
> >> >     struct snapshot_work *sw = container_of(work, struct snapshot_work,
> >> >                                             work);
> >> > -   static uint64_t saved;
> >> > +   static unsigned long saved;
> >> >
> >> >     if (uatomic_is_true(&work_error))
> >> >             goto out;
> >> > @@ -329,7 +329,7 @@ static void do_load_object(struct work *work)
> >> >     void *buffer = NULL;
> >> >     size_t size;
> >> >     struct snapshot_work *sw;
> >> > -   static uint64_t loaded;
> >> > +   static unsigned long loaded;
> >> >
> >> >     if (uatomic_is_true(&work_error))
> >> >             return;
> >>
> >> So this means for 32 bit machine, we can only support up to 4G objects, that is
> >> 16P storage in total?
> >
> > I think so, but isn't it enough for 32 bit machines?  I think most
> > users use 64 bit machines to create large storage system.
> >
> >> Do you know why uatomic can't operate on u64?
> >
> > Sorry, I don't know.
> >
> > If we really want to use a 64 bit integer for atomic operations, we
> > should use pthread_mutex_lock instead of urcu macros.  IMHO, it looks
> > overkill here.
> In C11, there is a new _Atomic. Is it suit for us here?

Does it support atomic operations for 64-bit variables on 32-bit
machines?  Anyway, moving to C11 looks much more overkill to me.

Thanks,

Kazutaka



More information about the sheepdog mailing list