This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/*] Expand arena_get macro.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 21 Feb 2014 13:02:57 +0100
- Subject: Re: [PATCH 2/*] Expand arena_get macro.
- Authentication-results: sourceware.org; auth=none
- References: <20131211102701 dot GA25483 at domone dot podge> <20131211113916 dot GA26438 at domone dot podge> <20140211044001 dot GB14750 at spoyarek dot pnq dot redhat dot com>
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