From patchwork Tue Sep 17 15:03:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 34553 Received: (qmail 31102 invoked by alias); 17 Sep 2019 15:03:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 31041 invoked by uid 89); 17 Sep 2019 15:03:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=are, and=c2, all, be?= X-HELO: mx0a-001b2d01.pphosted.com Subject: Re: [PATCH] Speedup nptl/tst-rwlock19. To: "Carlos O'Donell" , GNU C Library References: <63377b64-9da9-0588-e3d5-92a4f1a1e6d0@linux.ibm.com> From: Stefan Liebler Date: Tue, 17 Sep 2019 17:03:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: x-cbid: 19091715-0020-0000-0000-0000036E2A99 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19091715-0021-0000-0000-000021C3CFB2 Message-Id: <328befb7-c50f-b2ac-0e63-0e0f9a8dcc8f@linux.ibm.com> On 9/12/19 4:14 PM, Carlos O'Donell wrote: > On 9/12/19 8:16 AM, Stefan Liebler wrote: >> Hi, >> >> the test creates 15 threads which are trying 5000x to pthread_rwlock_rdlock >> a modified lock where the number of readers is set to max - 5.  If locked >> successfully, it sleeps for 1ms. >> >> The test succeeds if the lock was rdlock'ed successfully for at least >> one time and it has failed at least once with EAGAIN and the >> number of readers needs to be max - 5 again after all threads have joined. >> >> The test is currently running for 5 seconds.  Thus this patch reduces >> the READTRIES from 5000 to 100 and is increasing the DELAY from 1ms to 5ms. >> Then the test runs for roughly 0.5 seconds. > > Why do we need to limit the retries? > > The point of the test is to run until we see a successful lock, and a failed > lock with EAGAIN. > > It should be possible to make this test robust and so that when we run it > on slower i686 it should jus run until it sees the events it needs to see, > or fail from timeout (indicating a problem). > > I'm worried that by limiting the retires we'll see failures on slower or > loaded hardware in the lab, and then we'll have to go back and bump up the > retries again. > > The optimal test in my mind is: > > - Run forever. > - Look for events of interest. > - Exit success when those events are seen. > - Fail if we timeout. > This sounds great. I've adjusted the patch and READTRIES is now removed. Bye Stefan commit a2f7492f5ef5faaf038df49f4f8d4b5a5b0395a3 Author: Stefan Liebler Date: Thu Sep 12 09:19:01 2019 +0200 Speedup nptl/tst-rwlock19. The test creates 15 threads which are trying 5000x to pthread_rwlock_rdlock a modified lock where the number of readers is set to max - 5. If locked successfully, it sleeps for 1ms. The test succeeds if the lock was rdlock'ed successfully for at least one time and it has failed at least once with EAGAIN and the number of readers needs to be max - 5 again after all threads have joined. The test is currently running for 5 seconds. Thus this patch is now running as long as both rdlock contitions are met or the test times out. This saves nearly 5 seconds of "make check". ChangeLog: * nptl/tst-rwlock19.c (READTRIES): Remove macro. (do_test) Move checks to reader_thread. (reader_thread): Replace for loop by while loop with checks. diff --git a/nptl/tst-rwlock19.c b/nptl/tst-rwlock19.c index 19d40c11ca..91ee89a7ae 100644 --- a/nptl/tst-rwlock19.c +++ b/nptl/tst-rwlock19.c @@ -26,7 +26,6 @@ #define NREADERS 15 -#define READTRIES 5000 #define DELAY 1000000 @@ -38,12 +37,12 @@ static void * reader_thread (void *nr) { struct timespec delay; - int n; delay.tv_sec = 0; delay.tv_nsec = DELAY; - for (n = 0; n < READTRIES; ++n) + while (atomic_load_relaxed (&eagain_returned) == 0 + || atomic_load_relaxed (&success_returned) == 0) { int err = pthread_rwlock_rdlock (&lock); if (err == EAGAIN) @@ -101,18 +100,6 @@ do_test (void) exit (1); } - if (atomic_load_relaxed (&eagain_returned) == 0) - { - puts ("EAGAIN has never been returned"); - exit (1); - } - - if (atomic_load_relaxed (&success_returned) == 0) - { - puts ("rdlock was never successfully acquired"); - exit (1); - } - if (lock.__data.__readers != readers) { puts ("__readers in rwlock differs from initial value");