Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Mar 2014 19:38:03 +0000
From:      "Meyer, Conrad" <conrad.meyer@isilon.com>
To:        John Baldwin <jhb@freebsd.org>, "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Cc:        Bryan Drewery <bdrewery@freebsd.org>
Subject:   RE: [PATCH] amd64/pcpu.h: Use Clang builtins for clarity when referencing thread's pcpu
Message-ID:  <A3CAF0E84A34A540B4C74454358E003F1292F043@MX103CL02.corp.emc.com>
In-Reply-To: <201403181452.13685.jhb@freebsd.org>
References:  <1394821826-19412-1-git-send-email-conrad.meyer@isilon.com>, <201403181452.13685.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

From: John Baldwin [jhb@freebsd.org]
Sent: Tuesday, March 18, 2014 11:52 AM
To: freebsd-hackers@freebsd.org
Cc: Meyer, Conrad; Bryan Drewery
Subject: Re: [PATCH] amd64/pcpu.h: Use Clang builtins for clarity when referencing thread's pcpu

> >   - How atomic does PCPU_INC() need to be? It looks like it updates cpu-local
> >     counters; as long as it's a single asm instruction, should it be fine
> >     w.r.t. interrupts? The existing implementation does NOT use the 'lock; ' prefix.
> 
> I think a single instruction is fine.

Unfortunately, I'm seeing crashes under stress in internal testing that I can't attribute to anything else. I'm not sure why Clang would generate more than one instruction for any of this, but I haven't probed too deeply.

> > diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
> > index fe898e9..68892fc 100644
> > --- a/sys/amd64/include/pcpu.h
> > +++ b/sys/amd64/include/pcpu.h
> > +#define      curthread __extension__ ({                                      \
> > +     *((volatile __pcpu_type(pc_curthread) __GS_RELATIVE *)          \
> > +             __pcpu_offset(pc_curthread));                           \
> > +})
> 
> Would be nice to not lose the __pure2 attribute for curthread (you
> might need it to still be an inline function to keep that)

Yeah, I think you would need it to be a function for that. As is I don't think Clang has any reason to optimize away redundant loads from a volatile pointer.

Thanks,
Conrad


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A3CAF0E84A34A540B4C74454358E003F1292F043>