public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sasha.levin@oracle.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: torvalds@linux-foundation.org, mingo@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 7/9] liblockdep: Support using LD_PRELOAD
Date: Tue, 28 May 2013 15:38:38 -0400	[thread overview]
Message-ID: <51A507BE.5060001@oracle.com> (raw)
In-Reply-To: <20130522092711.GI18810@twins.programming.kicks-ass.net>

On 05/22/2013 05:27 AM, Peter Zijlstra wrote:
> On Wed, May 15, 2013 at 11:15:39PM -0400, Sasha Levin wrote:
>> +
>> +/* pthread mutex API */
>> +
>> +#ifdef __GLIBC__
>> +extern int __pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
>> +extern int __pthread_mutex_lock(pthread_mutex_t *mutex);
>> +extern int __pthread_mutex_trylock(pthread_mutex_t *mutex);
>> +extern int __pthread_mutex_unlock(pthread_mutex_t *mutex);
>> +extern int __pthread_mutex_destroy(pthread_mutex_t *mutex);
>> +#else
>> +#define __pthread_mutex_init	NULL
>> +#define __pthread_mutex_lock	NULL
>> +#define __pthread_mutex_trylock	NULL
>> +#define __pthread_mutex_unlock	NULL
>> +#define __pthread_mutex_destroy	NULL
>> +#endif
>> +static int (*ll_pthread_mutex_init)(pthread_mutex_t *mutex,
>> +			const pthread_mutexattr_t *attr)	= __pthread_mutex_init;
>> +static int (*ll_pthread_mutex_lock)(pthread_mutex_t *mutex)	= __pthread_mutex_lock;
>> +static int (*ll_pthread_mutex_trylock)(pthread_mutex_t *mutex)	= __pthread_mutex_trylock;
>> +static int (*ll_pthread_mutex_unlock)(pthread_mutex_t *mutex)	= __pthread_mutex_unlock;
>> +static int (*ll_pthread_mutex_destroy)(pthread_mutex_t *mutex)	= __pthread_mutex_destroy;
>> +
>> +/* pthread rwlock API */
>> +
>> +#ifdef __GLIBC__
>> +extern int __pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr);
>> +extern int __pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
>> +extern int __pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
>> +extern int __pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
>> +extern int __pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
>> +extern int __pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
>> +extern int __pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
>> +#else
>> +#define __pthread_rwlock_init		NULL
>> +#define __pthread_rwlock_destroy	NULL
>> +#define __pthread_rwlock_wrlock		NULL
>> +#define __pthread_rwlock_trywrlock	NULL
>> +#define __pthread_rwlock_rdlock		NULL
>> +#define __pthread_rwlock_tryrdlock	NULL
>> +#define __pthread_rwlock_unlock		NULL
>> +#endif
>> +
>> +static int (*ll_pthread_rwlock_init)(pthread_rwlock_t *rwlock,
>> +			const pthread_rwlockattr_t *attr)		= __pthread_rwlock_init;
>> +static int (*ll_pthread_rwlock_destroy)(pthread_rwlock_t *rwlock)	= __pthread_rwlock_destroy;
>> +static int (*ll_pthread_rwlock_rdlock)(pthread_rwlock_t *rwlock)	= __pthread_rwlock_rdlock;
>> +static int (*ll_pthread_rwlock_tryrdlock)(pthread_rwlock_t *rwlock)	= __pthread_rwlock_tryrdlock;
>> +static int (*ll_pthread_rwlock_trywrlock)(pthread_rwlock_t *rwlock)	= __pthread_rwlock_trywrlock;
>> +static int (*ll_pthread_rwlock_wrlock)(pthread_rwlock_t *rwlock)	= __pthread_rwlock_wrlock;
>> +static int (*ll_pthread_rwlock_unlock)(pthread_rwlock_t *rwlock)	= __pthread_rwlock_unlock;
>> +
> 
>> +__attribute__((constructor)) static void init_preload(void)
>> +{
>> +	if (__init_state != done)
>> +		return;
>> +
>> +#ifndef __GLIBC__
>> +	__init_state = prepare;
>> +
>> +	ll_pthread_mutex_init = dlsym(RTLD_NEXT, "pthread_mutex_init");
>> +	ll_pthread_mutex_lock = dlsym(RTLD_NEXT, "pthread_mutex_lock");
>> +	ll_pthread_mutex_trylock = dlsym(RTLD_NEXT, "pthread_mutex_trylock");
>> +	ll_pthread_mutex_unlock = dlsym(RTLD_NEXT, "pthread_mutex_unlock");
>> +	ll_pthread_mutex_destroy = dlsym(RTLD_NEXT, "pthread_mutex_destroy");
>> +
>> +	ll_pthread_rwlock_init = dlsym(RTLD_NEXT, "pthread_rwlock_init");
>> +	ll_pthread_rwlock_destroy = dlsym(RTLD_NEXT, "pthread_rwlock_destroy");
>> +	ll_pthread_rwlock_rdlock = dlsym(RTLD_NEXT, "pthread_rwlock_rdlock");
>> +	ll_pthread_rwlock_tryrdlock = dlsym(RTLD_NEXT, "pthread_rwlock_tryrdlock");
>> +	ll_pthread_rwlock_wrlock = dlsym(RTLD_NEXT, "pthread_rwlock_wrlock");
>> +	ll_pthread_rwlock_trywrlock = dlsym(RTLD_NEXT, "pthread_rwlock_trywrlock");
>> +	ll_pthread_rwlock_unlock = dlsym(RTLD_NEXT, "pthread_rwlock_unlock");
>> +#endif
>> +
>> +	printf("%p\n", ll_pthread_mutex_trylock);fflush(stdout);
>> +
>> +	lockdep_init();
>> +
>> +	__init_state = done;
>> +}
> 
> I guess that begs the question do we really want to support !glibc?

I assumed we didn't want to give up on that based on your patch. I think that
if we plan to get it into tools/lib/ we shouldn't give up on that straight away.


Thanks,
Sasha


  reply	other threads:[~2013-05-28 19:39 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-16  3:15 [PATCH v4 0/9] liblockdep: userspace lockdep Sasha Levin
2013-05-16  3:15 ` [PATCH v4 1/9] lockdep: Be nice about building from userspace Sasha Levin
2013-05-16  7:32   ` Pekka Enberg
2013-05-16  3:15 ` [PATCH v4 2/9] liblockdep: Wrap kernel/lockdep.c to allow usage " Sasha Levin
2013-05-22  9:14   ` Peter Zijlstra
2013-05-22  9:17   ` Peter Zijlstra
2013-05-28 19:30     ` Sasha Levin
2013-05-29 11:11       ` Peter Zijlstra
2013-05-16  3:15 ` [PATCH v4 3/9] liblockdep: Add public headers for pthread_mutex_t implementation Sasha Levin
2013-05-22  9:22   ` Peter Zijlstra
2013-05-28 19:33     ` Sasha Levin
2013-05-29 11:14       ` Peter Zijlstra
2013-05-16  3:15 ` [PATCH v4 4/9] liblockdep: Add pthread_mutex_t test suite Sasha Levin
2013-05-16  3:15 ` [PATCH v4 5/9] liblockdep: Add public headers for pthread_rwlock_t implementation Sasha Levin
2013-05-22  9:23   ` Peter Zijlstra
2013-05-16  3:15 ` [PATCH v4 6/9] liblockdep: Add pthread_rwlock_t test suite Sasha Levin
2013-05-16  3:15 ` [PATCH v4 7/9] liblockdep: Support using LD_PRELOAD Sasha Levin
2013-05-22  9:24   ` Peter Zijlstra
2013-05-28 19:35     ` Sasha Levin
2013-05-29 11:15       ` Peter Zijlstra
2013-05-22  9:27   ` Peter Zijlstra
2013-05-28 19:38     ` Sasha Levin [this message]
2013-05-29 11:16       ` Peter Zijlstra
2013-05-16  3:15 ` [PATCH v4 8/9] liblockdep: Add the 'lockdep' user-space utility Sasha Levin
2013-05-22  9:27   ` Peter Zijlstra
2013-05-16  3:15 ` [PATCH v4 9/9] liblockdep: Add a MAINTAINERS entry Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51A507BE.5060001@oracle.com \
    --to=sasha.levin@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox