From patchwork Thu Jul 23 19:52:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 1335113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BCNJb1GS4z9sRK for ; Fri, 24 Jul 2020 05:51:59 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 24ED73C4D38 for ; Thu, 23 Jul 2020 21:51:55 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 443043C1CB6 for ; Thu, 23 Jul 2020 21:51:53 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 8B42D1A00F43 for ; Thu, 23 Jul 2020 21:51:52 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 153C4AB89 for ; Thu, 23 Jul 2020 19:52:00 +0000 (UTC) From: Cyril Hrubis To: ltp@lists.linux.it Date: Thu, 23 Jul 2020 21:52:15 +0200 Message-Id: <20200723195215.6351-1-chrubis@suse.cz> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH] [COMMITTED] syscalls/futex_wait03: Fix synchronization X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" When I was reviewing changes in the test I noticed that the synchronization was never working as the getppid() returns the test library pid and not the thread that we should wait for. So this fixes the test by passing the correct pid casted to a void* as a parameter to the threaded function. It seems that in practice this cannot be triggered easily, but the test without this fix fails easily when you insert bussy loop such as "for (volatile int i = 0; i < 1000000000; i++);" between the SAFE_PTHRED() and the futex_wait() call. Signed-off-by: Cyril Hrubis --- testcases/kernel/syscalls/futex/futex_wait03.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/syscalls/futex/futex_wait03.c b/testcases/kernel/syscalls/futex/futex_wait03.c index e6e94055b..3e3a7ce23 100644 --- a/testcases/kernel/syscalls/futex/futex_wait03.c +++ b/testcases/kernel/syscalls/futex/futex_wait03.c @@ -26,12 +26,12 @@ static struct test_variants { #endif }; -static void *threaded(void *arg LTP_ATTRIBUTE_UNUSED) +static void *threaded(void *arg) { struct test_variants *tv = &variants[tst_variant]; - long ret; + long ret, pid = (long)arg; - TST_PROCESS_STATE_WAIT(getppid(), 'S', 0); + TST_PROCESS_STATE_WAIT(pid, 'S', 0); ret = futex_wake(tv->fntype, &futex, 1, FUTEX_PRIVATE_FLAG); if (ret != 1) @@ -43,10 +43,10 @@ static void *threaded(void *arg LTP_ATTRIBUTE_UNUSED) static void run(void) { struct test_variants *tv = &variants[tst_variant]; - long res; + long res, pid = getpid(); pthread_t t; - SAFE_PTHREAD_CREATE(&t, NULL, threaded, NULL); + SAFE_PTHREAD_CREATE(&t, NULL, threaded, (void*)pid); res = futex_wait(tv->fntype, &futex, futex, NULL, FUTEX_PRIVATE_FLAG); if (res) {