[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130522092453.GH18810@twins.programming.kicks-ass.net>
Date: Wed, 22 May 2013 11:24:53 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Sasha Levin <sasha.levin@...cle.com>
Cc: torvalds@...ux-foundation.org, mingo@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 7/9] liblockdep: Support using LD_PRELOAD
On Wed, May 15, 2013 at 11:15:39PM -0400, Sasha Levin wrote:
> +static struct lock_lookup __locks[LIBLOCKDEP_STATIC_ENTRIES];
> +static int __locks_nr;
> +
> +static inline bool is_static_lock(struct lock_lookup *lock)
> +{
> + return lock >= __locks && lock < __locks + ARRAY_SIZE(__locks);
> +}
> +
> +static struct lock_lookup *alloc_lock(void)
> +{
> + if (__init_state != done) {
> + /*
> + * Some programs attempt to initialize and use locks in their
> + * allocation path. This means that a call to malloc() would
> + * result in locks being initialized and locked.
> + *
> + * Why is it an issue for us? dlsym() below will try allocating
> + * to give us the original function. Since this allocation will
> + * result in a locking operations, we have to let pthread deal
> + * with it, but we can't! we don't have the pointer to the
> + * original API since we're inside dlsym() trying to get it
> + */
> +
> + int idx = __locks_nr++;
> + if (idx >= ARRAY_SIZE(__locks)) {
> + fprintf(stderr,
> + "LOCKDEP error: insufficient LIBLOCKDEP_STATIC_ENTRIES\n");
> + exit(EX_UNAVAILABLE);
> + }
> + return __locks + idx;
> + }
> +
> + return malloc(sizeof(struct lock_lookup));
> +}
Do we still need this with the glibc __pthread_* static initialization?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists