From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92220 invoked by alias); 15 Feb 2018 19:50:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 92177 invoked by uid 89); 15 Feb 2018 19:50:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=Bye, HX-Google-Smtp-Source:AH8x226t X-HELO: mail-qk0-f170.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=u5V2nQGVP/0SFnRDt6YJyGZXKw+D2HVERKoMpm6K2oQ=; b=RBIZQxEBul/2szM1O1yyjuZe+MuUXA2MGGgEE5ryGSPMGV/3L4NUWg/iaMbOEmm+Cq HEJRsSs799GXPueoTdAOBRFJWlXzOtgXaHg/CD/vdvMBfrfRjTubzAKw0OTPAdp+irTA 0CksHrQSJ8S+eQCp9vL75YP6fr489GoEBkmL4wk65xY76YW3YYXei4Wx2xGDuthz0hml BNewLUbMuzi0n+gG5Hpvzr+6GUvS4Ir5J+F+Tz6abzjZMNrmUnU5NXWBUw9NTbbKtzPS AtFMHZcboFbKqbyhvbxiA0wtnWaqP9pGSPU/6z7oDMpx9x5TwXwBAyCKeSwYXTkW7dYW m/cQ== X-Gm-Message-State: APf1xPDklc28qSz9uh6WmxsHuzb2WTVF52iPC/bTOCpKkbJ38reLqiZB ukILlJbMRLoXaa33JNNYNb4x2LUs+zA= X-Google-Smtp-Source: AH8x226t/DzvoNJyrxW8Q6O87qjLPR1KVj0TOYxiMq/mqlLISpK+a8LIQog6poyGokFnbUa2k9v7eg== X-Received: by 10.55.22.144 with SMTP id 16mr5653445qkw.11.1518724254082; Thu, 15 Feb 2018 11:50:54 -0800 (PST) Subject: Re: [PATCH] Add runtime check if mutex will be elided in tst-mutex8 testcases. To: Stefan Liebler , GNU C Library References: <60a40476-2f26-2756-df5e-b05ddaeb5483@linux.vnet.ibm.com> From: Carlos O'Donell Message-ID: <9efe9818-ae3a-9265-1dae-bf7139b116e6@redhat.com> Date: Thu, 15 Feb 2018 20:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <60a40476-2f26-2756-df5e-b05ddaeb5483@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-02/txt/msg00459.txt.bz2 On 02/05/2018 10:41 PM, Stefan Liebler wrote: > Hi, > > An elided mutex don't fail destroy. Elision was disabled for the > test nptl/tst-mutex8 in nptl/Makefile. Thus we can run tests which > destroy a locked mutex. > > As elision is only disabled for tst-mutex8, the variants > tst-mutex8-static, tst-mutexpi8 and tst-mutexpi8-static are still > failing if lock elision is enabled. > > This patch adds a runtime check, if the checked type of mutex will > be elided. This check is using TUNABLE_GET_FULL to determine if > elision is enabled via the tunables framework. > The pthread_mutex_destroy tests are only run if we dont't assume an > elided mutex. > > This way, we can run the whole glibc testsuite with or without enabled > lock elision. > > Okay to commit? LGTM. Reviewed-by: Carlos O'Donell > Bye > Stefan > > ChangeLog: > >     * nptl/Makefile (tst-mutex8-ENV): Delete. >     * nptl/tst-mutex8.c (check_type): >     Add runtime check if mutex will be elided. > > 20180205_tstmutex8_elision.patch > > > commit eb4c91a86de283ff314c068d9d89368b229b9a33 > Author: Stefan Liebler > Date: Mon Feb 5 09:16:14 2018 +0000 > > Add runtime check if mutex will be elided in tst-mutex8 testcases. > > An elided mutex don't fail destroy. Elision was disabled for the > test nptl/tst-mutex8 in nptl/Makefile. Thus we can run tests which > destroy a locked mutex. > > As elision is only disabled for tst-mutex8, the variants > tst-mutex8-static, tst-mutexpi8 and tst-mutexpi8-static are still > failing if lock elision is enabled. > > This patch adds a runtime check, if the checked type of mutex will > be elided. This check is using TUNABLE_GET_FULL to determine if > elision is enabled via the tunables framework. > The pthread_mutex_destroy tests are only run if we dont't assume an > elided mutex. > > This way, we can run the whole glibc testsuite with or without enabled > lock elision. > > ChangeLog: > > * nptl/Makefile (tst-mutex8-ENV): Delete. > * nptl/tst-mutex8.c (check_type): > Add runtime check if mutex will be elided. > > diff --git a/nptl/Makefile b/nptl/Makefile > index 6fc2c8bb6a..9340f9f699 100644 > --- a/nptl/Makefile > +++ b/nptl/Makefile > @@ -726,10 +726,6 @@ endif > > $(objpfx)tst-compat-forwarder: $(objpfx)tst-compat-forwarder-mod.so > > -# Disable elision for tst-mutex8 so it can verify error case for > -# destroying a mutex. > -tst-mutex8-ENV = GLIBC_TUNABLES=glibc.elision.enable=0 > - OK. > # The tests here better do not run in parallel > ifneq ($(filter %tests,$(MAKECMDGOALS)),) > .NOTPARALLEL: > diff --git a/nptl/tst-mutex8.c b/nptl/tst-mutex8.c > index 516ef3809e..d31f342751 100644 > --- a/nptl/tst-mutex8.c > +++ b/nptl/tst-mutex8.c > @@ -22,7 +22,8 @@ > #include > #include > #include > - > +#include > +#include OK. > > static pthread_mutex_t *m; > static pthread_barrier_t b; > @@ -95,6 +96,30 @@ check_type (const char *mas, pthread_mutexattr_t *ma) > { > int e; > > + /* Check if a mutex will be elided. Lock elision can only be activated via > + the tunables framework. By default, lock elision is disabled. */ > + bool assume_elided_mutex = false; > +#if HAVE_TUNABLES > + int ma_type = PTHREAD_MUTEX_TIMED_NP; > + if (ma != NULL) > + { > + e = pthread_mutexattr_gettype (ma, &ma_type); > + if (e != 0) > + { > + printf ("pthread_mutexattr_gettype failed with %d (%m)\n", e); > + return 1; > + } > + } > + if (ma_type == PTHREAD_MUTEX_TIMED_NP) > + { > + /* This type of mutex can be elided if elision is enabled via the tunables > + framework. Some tests below are failing if the mutex is elided. > + Thus we only run those if we assume that the mutex won't be elided. */ > + if (TUNABLE_GET_FULL (glibc, elision, enable, int32_t, NULL) == 1) > + assume_elided_mutex = true; > + } > +#endif OK. > + > e = pthread_mutex_init (m, ma); > if (e != 0) > { > @@ -127,19 +152,23 @@ check_type (const char *mas, pthread_mutexattr_t *ma) > return 1; > } > > - /* Elided mutexes don't fail destroy, but this test is run with > - elision disabled so we can test them. */ > - e = pthread_mutex_destroy (m); > - if (e == 0) > + /* Elided mutexes don't fail destroy, thus only test this if we don't assume > + elision. */ > + if (assume_elided_mutex == false) > { > - printf ("mutex_destroy of self-locked mutex succeeded for %s\n", mas); > - return 1; > - } > - if (e != EBUSY) > - { > - printf ("mutex_destroy of self-locked mutex did not return EBUSY %s\n", > - mas); > - return 1; > + e = pthread_mutex_destroy (m); > + if (e == 0) > + { > + printf ("mutex_destroy of self-locked mutex succeeded for %s\n", mas); > + return 1; > + } > + if (e != EBUSY) > + { > + printf ("\ > +mutex_destroy of self-locked mutex did not return EBUSY %s\n", > + mas); > + return 1; > + } OK. > } > > if (pthread_mutex_unlock (m) != 0) > @@ -155,18 +184,22 @@ check_type (const char *mas, pthread_mutexattr_t *ma) > } > > /* Elided mutexes don't fail destroy. */ > - e = pthread_mutex_destroy (m); > - if (e == 0) > + if (assume_elided_mutex == false) > { > - printf ("mutex_destroy of self-trylocked mutex succeeded for %s\n", mas); > - return 1; > - } > - if (e != EBUSY) > - { > - printf ("\ > + e = pthread_mutex_destroy (m); > + if (e == 0) > + { > + printf ("mutex_destroy of self-trylocked mutex succeeded for %s\n", > + mas); > + return 1; > + } > + if (e != EBUSY) > + { > + printf ("\ > mutex_destroy of self-trylocked mutex did not return EBUSY %s\n", > - mas); > - return 1; > + mas); > + return 1; > + } OK. > } > > if (pthread_mutex_unlock (m) != 0) > @@ -203,17 +236,21 @@ mutex_destroy of self-trylocked mutex did not return EBUSY %s\n", > } > > /* Elided mutexes don't fail destroy. */ > - e = pthread_mutex_destroy (m); > - if (e == 0) > - { > - printf ("mutex_destroy of condvar-used mutex succeeded for %s\n", mas); > - return 1; > - } > - if (e != EBUSY) > + if (assume_elided_mutex == false) > { > - printf ("\ > + e = pthread_mutex_destroy (m); > + if (e == 0) > + { > + printf ("mutex_destroy of condvar-used mutex succeeded for %s\n", > + mas); > + return 1; > + } > + if (e != EBUSY) > + { > + printf ("\ > mutex_destroy of condvar-used mutex did not return EBUSY for %s\n", mas); > - return 1; > + return 1; > + } OK. > } > > done = true; > @@ -274,19 +311,22 @@ mutex_destroy of condvar-used mutex did not return EBUSY for %s\n", mas); > } > > /* Elided mutexes don't fail destroy. */ > - e = pthread_mutex_destroy (m); > - if (e == 0) > - { > - printf ("2nd mutex_destroy of condvar-used mutex succeeded for %s\n", > - mas); > - return 1; > - } > - if (e != EBUSY) > + if (assume_elided_mutex == false) > { > - printf ("\ > + e = pthread_mutex_destroy (m); > + if (e == 0) > + { > + printf ("2nd mutex_destroy of condvar-used mutex succeeded for %s\n", > + mas); > + return 1; > + } > + if (e != EBUSY) > + { > + printf ("\ > 2nd mutex_destroy of condvar-used mutex did not return EBUSY for %s\n", > - mas); > - return 1; > + mas); > + return 1; > + } OK. > } > > if (pthread_cancel (th) != 0) -- Cheers, Carlos.