From: Julian Seward Date: Tue, 16 Apr 2002 03:44:31 +0000 (+0000) Subject: Handle VG_USERREQ__PTHREAD_GET_THREADID and VG_USERREQ__RUNNING_ON_VALGRIND X-Git-Tag: svn/VALGRIND_1_0_3~362 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f5c165ccc48418de58aadd8acf212f3ae204e75;p=thirdparty%2Fvalgrind.git Handle VG_USERREQ__PTHREAD_GET_THREADID and VG_USERREQ__RUNNING_ON_VALGRIND cheaply, with the trivial-client-request mechanism. The latter is called once per pthread call, even simple ones like pthread_mutex_[un]lock. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@88 --- diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 9dd5562849..33cb15766e 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -549,6 +549,13 @@ Bool maybe_do_trivial_clientreq ( ThreadId tid ) SIMPLE_RETURN( (UInt)VG_(client_memalign) ( tst, arg[1], arg[2] ) ); + + /* These are heavily used. */ + case VG_USERREQ__PTHREAD_GET_THREADID: + SIMPLE_RETURN(tid); + case VG_USERREQ__RUNNING_ON_VALGRIND: + SIMPLE_RETURN(1); + default: /* Too hard; wimp out. */ return False; @@ -1743,13 +1750,6 @@ void do_nontrivial_clientreq ( ThreadId tid ) do_pthread_join( tid, arg[1], (void**)(arg[2]) ); break; - /* Sigh ... this probably will cause huge numbers of major - (expensive) scheduling events, for no real reason. - Perhaps should be classified as a trivial-request. */ - case VG_USERREQ__PTHREAD_GET_THREADID: - vg_threads[tid].m_edx = tid; - break; - case VG_USERREQ__PTHREAD_MUTEX_INIT: do_pthread_mutex_init( tid, (pthread_mutex_t *)(arg[1]), diff --git a/vg_clientperms.c b/vg_clientperms.c index 081b7c65d5..02d0b7bf89 100644 --- a/vg_clientperms.c +++ b/vg_clientperms.c @@ -372,8 +372,12 @@ UInt VG_(handle_client_request) ( ThreadState* tst, UInt* arg_block ) vg_add_client_stack_block ( tst, arg[1], arg[2] ); return 0; + /* Is handled by the scheduler as a trivial request, for + performance reasons. */ + /* case VG_USERREQ__RUNNING_ON_VALGRIND: return 1; + */ case VG_USERREQ__DO_LEAK_CHECK: if (!VG_(clo_instrument)) diff --git a/vg_scheduler.c b/vg_scheduler.c index 9dd5562849..33cb15766e 100644 --- a/vg_scheduler.c +++ b/vg_scheduler.c @@ -549,6 +549,13 @@ Bool maybe_do_trivial_clientreq ( ThreadId tid ) SIMPLE_RETURN( (UInt)VG_(client_memalign) ( tst, arg[1], arg[2] ) ); + + /* These are heavily used. */ + case VG_USERREQ__PTHREAD_GET_THREADID: + SIMPLE_RETURN(tid); + case VG_USERREQ__RUNNING_ON_VALGRIND: + SIMPLE_RETURN(1); + default: /* Too hard; wimp out. */ return False; @@ -1743,13 +1750,6 @@ void do_nontrivial_clientreq ( ThreadId tid ) do_pthread_join( tid, arg[1], (void**)(arg[2]) ); break; - /* Sigh ... this probably will cause huge numbers of major - (expensive) scheduling events, for no real reason. - Perhaps should be classified as a trivial-request. */ - case VG_USERREQ__PTHREAD_GET_THREADID: - vg_threads[tid].m_edx = tid; - break; - case VG_USERREQ__PTHREAD_MUTEX_INIT: do_pthread_mutex_init( tid, (pthread_mutex_t *)(arg[1]),