This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/*] Expand arena_get macro.


On Tue, Feb 11, 2014 at 10:10:02AM +0530, Siddhesh Poyarekar wrote:
> On Wed, Dec 11, 2013 at 12:39:16PM +0100, OndÅej BÃlka wrote:
> > Hi,
> > 
> > For thread local caches we would need to distinguish arena data from
> > thread data. As this access was hidden in arena_get macro we expand it.
> 
> I'm not sure I understand why.  Could you elaborate?  There may be a
> case for consolidating those macros, but I don't see the point in
> actually breaking it down.
> 
Simple in lockless implementation you want to get arena but not lock it.
As macros are now they decrease readibility, you cannot use arena_lookup
directly as it may be null so you would duplicate a arena_lock casing
anyway, relevant macros are:

#define arena_get(ptr, size) do { \
      arena_lookup (ptr);\
      arena_lock (ptr, size);\
  } while (0)

#define arena_lookup(ptr) do { \
      void *vptr = NULL;\
      ptr = (mstate) tsd_getspecific (arena_key, vptr);\
  } while (0)

#define arena_lock(ptr, size) do {\
      if (ptr)\
        (void) mutex_lock (&ptr->mutex);\
      else\
        ptr = arena_get2 (ptr, (size), NULL);\
  } while (0)



> > 
> > This also could allow more simplification, is a check if arena is null
> > now needeed?
> > 
> 
> The check is needed; that is how a thread asks for its own arena (or
> share with someone else) when it doesn't have one in its pthread_key.
> 
> Siddhesh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]