Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2182370rdh; Tue, 26 Sep 2023 15:30:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFCZjZRJ3LE4icvazsxXZncqCVox0H2Pv2+b6Baaw26Uf/TT+kOvn/Nb15rJa42chYApWp X-Received: by 2002:a17:90a:2ac7:b0:274:60c7:e15a with SMTP id i7-20020a17090a2ac700b0027460c7e15amr36798pjg.4.1695767427143; Tue, 26 Sep 2023 15:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695767427; cv=none; d=google.com; s=arc-20160816; b=q3IVGtqaE7uoH/fNXC8+Rh2ySPSGral8tdmyRrfGejhFEm2PoCSOfxHOPSictXNB7/ 56aXe/w0woRfhrZGZtg9kyK5CEZarAKw60MVRepPBgZtIXinAjrxS4qc4R4XoMwObuIR ZNXG1hhsUptfyyX4I2Pi5MJqpvX/weUFFPZVOwSEyYtii1V9Jkn2pUTB/9fjVaNHbsGc socOaIb6MyQDB9qfUS2MiNOpkj5Cl45JBZB/sk6AMFAL3c0mKc4u0CyVeNpwOwDr9acp tahDfIJV4msg0m9tHN+lgKD33gCujUkp2+BmDMx0eOH6nWpaXUHarjR3ma2UwYU3XJFZ 9N2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=MIlsSsrhTexHf0RSHVPHQqutHsx3y7G6QG0o8FgjX9Y=; fh=/DNEQXR8RPMEVhNJLEbxdp9qH6I7aqZAkChwAhx1OCk=; b=WuFtosOCj0aBUCjTwrXt4QYD5+al1EREAKmuWJpEHInwDngOZGSl1l52Mc1sJI5ay2 UQwVHwLB41X0xrP6PEDMc1GGz11FhsBRpWcV5FBLSLmiHjJMRysNRJ9rRO9432DmA7qB p6XLJKybOkSfCw+83xzhE1QJZEYq4daqcgSWdC/f6Xnhw5IFaGNraDGvkvO88mQcMYNd 5cZPhh9/qnBoERpKtSqoJy3Q9mEqbUScZTisPt1EPxRaRjQjoHSI6AhtXDxXNywDWc3F blTQn8xZn19cxVz4vkQ4MNeIBIOAaqrt8U2kt+qRM8gNrKJQgTt4iflG7YUQ0hnuPIqL Ob5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=B2DoCl7Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id mw17-20020a17090b4d1100b00263c4af31f2si3639156pjb.157.2023.09.26.15.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 15:30:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=B2DoCl7Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2E6DB826EE2B; Tue, 26 Sep 2023 12:02:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235681AbjIZTCy (ORCPT + 99 others); Tue, 26 Sep 2023 15:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235677AbjIZTCw (ORCPT ); Tue, 26 Sep 2023 15:02:52 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEA39EB; Tue, 26 Sep 2023 12:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1695754962; bh=HmIGoIS7tEFftF5m3jSoExUboCzt4yAlxx+T1aE5+RM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=B2DoCl7Yc4mTL+EnsQD9Hl16Abru79+HrJ5+747ajtudnzxY9f4c6AqHhVK18Ki+T r3FCJZZOmZSttkkTyvLHFO0XvbKvIUJQZcSAio7NKA7vHdrwSsYlZQoegbz74h9uCf rEOmT8tngH479OIPvLCImbHWTxO3A7Q6aHivp0ZBSNpStevbAgnxTb8O2jMmT47XhZ vzlrIexCY4vB5rt+mYKaD0QbVxNNY01SY30LoXCQt710QFOYmLJEPRdn3yobfiDdzz 9bJHxFk5/BZ9uIiAuf8PlJOQdp65zCd4gKG8JPRK4I/5d4Zn8cSKrRKRHQF2QfKbUU p5SQ70EpQmc6w== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4Rw8JL2gVWz1R9L; Tue, 26 Sep 2023 15:02:42 -0400 (EDT) Message-ID: Date: Tue, 26 Sep 2023 15:02:08 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] selftests/rseq: fix kselftest Clang build warnings Content-Language: en-US To: Justin Stitt , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev References: <20230912-kselftest-param_test-c-v1-1-80a6cffc7374@google.com> From: Mathieu Desnoyers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 26 Sep 2023 12:02:52 -0700 (PDT) On 9/26/23 08:20, Justin Stitt wrote: > Ping. > > Looking to get this patch and [1] slated for 6.7 which fixes some > kselftest builds on older kernels. > > On Wed, Sep 13, 2023 at 6:03 AM Justin Stitt wrote: >> >> When building with Clang, I am getting many warnings from the selftests/rseq tree. >> >> Here's one such example from rseq tree: >> | param_test.c:1234:10: error: address argument to atomic operation must be a pointer to _Atomic type ('intptr_t *' (aka 'long *') invalid) >> | 1234 | while (!atomic_load(&args->percpu_list_ptr)) {} >> | | ^ ~~~~~~~~~~~~~~~~~~~~~~ >> | /usr/local/google/home/justinstitt/repos/tc-build/build/llvm/final/lib/clang/18/include/stdatomic.h:140:29: note: expanded from macro 'atomic_load' >> | 140 | #define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST) >> | | ^ ~~~~~~ >> >> Use compiler builtins `__atomic_load_n()` and `__atomic_store_n()` with >> accompanying __ATOMIC_ACQUIRE and __ATOMIC_RELEASE, respectively. This >> will fix the warnings because the compiler builtins do not expect their >> arguments to have _Atomic type. This should also make TSAN happier. >> >> Link: https://github.com/ClangBuiltLinux/linux/issues/1698 >> Link: https://github.com/ClangBuiltLinux/continuous-integration2/issues/61 >> Suggested-by: Mathieu Desnoyers >> Signed-off-by: Justin Stitt Reviewed-by: Mathieu Desnoyers Peter, should this go through tip ? Shuah, should to go through selftests ? Thanks, Mathieu >> --- >> Note: Previous RFC https://lore.kernel.org/r/20230908-kselftest-param_test-c-v1-1-e35bd9052d61@google.com >> --- >> tools/testing/selftests/rseq/param_test.c | 20 ++++++++++---------- >> 1 file changed, 10 insertions(+), 10 deletions(-) >> >> diff --git a/tools/testing/selftests/rseq/param_test.c b/tools/testing/selftests/rseq/param_test.c >> index bf951a490bb4..20403d58345c 100644 >> --- a/tools/testing/selftests/rseq/param_test.c >> +++ b/tools/testing/selftests/rseq/param_test.c >> @@ -1231,7 +1231,7 @@ void *test_membarrier_worker_thread(void *arg) >> } >> >> /* Wait for initialization. */ >> - while (!atomic_load(&args->percpu_list_ptr)) {} >> + while (!__atomic_load_n(&args->percpu_list_ptr, __ATOMIC_ACQUIRE)) {} >> >> for (i = 0; i < iters; ++i) { >> int ret; >> @@ -1299,22 +1299,22 @@ void *test_membarrier_manager_thread(void *arg) >> test_membarrier_init_percpu_list(&list_a); >> test_membarrier_init_percpu_list(&list_b); >> >> - atomic_store(&args->percpu_list_ptr, (intptr_t)&list_a); >> + __atomic_store_n(&args->percpu_list_ptr, (intptr_t)&list_a, __ATOMIC_RELEASE); >> >> - while (!atomic_load(&args->stop)) { >> + while (!__atomic_load_n(&args->stop, __ATOMIC_ACQUIRE)) { >> /* list_a is "active". */ >> cpu_a = rand() % CPU_SETSIZE; >> /* >> * As list_b is "inactive", we should never see changes >> * to list_b. >> */ >> - if (expect_b != atomic_load(&list_b.c[cpu_b].head->data)) { >> + if (expect_b != __atomic_load_n(&list_b.c[cpu_b].head->data, __ATOMIC_ACQUIRE)) { >> fprintf(stderr, "Membarrier test failed\n"); >> abort(); >> } >> >> /* Make list_b "active". */ >> - atomic_store(&args->percpu_list_ptr, (intptr_t)&list_b); >> + __atomic_store_n(&args->percpu_list_ptr, (intptr_t)&list_b, __ATOMIC_RELEASE); >> if (rseq_membarrier_expedited(cpu_a) && >> errno != ENXIO /* missing CPU */) { >> perror("sys_membarrier"); >> @@ -1324,27 +1324,27 @@ void *test_membarrier_manager_thread(void *arg) >> * Cpu A should now only modify list_b, so the values >> * in list_a should be stable. >> */ >> - expect_a = atomic_load(&list_a.c[cpu_a].head->data); >> + expect_a = __atomic_load_n(&list_a.c[cpu_a].head->data, __ATOMIC_ACQUIRE); >> >> cpu_b = rand() % CPU_SETSIZE; >> /* >> * As list_a is "inactive", we should never see changes >> * to list_a. >> */ >> - if (expect_a != atomic_load(&list_a.c[cpu_a].head->data)) { >> + if (expect_a != __atomic_load_n(&list_a.c[cpu_a].head->data, __ATOMIC_ACQUIRE)) { >> fprintf(stderr, "Membarrier test failed\n"); >> abort(); >> } >> >> /* Make list_a "active". */ >> - atomic_store(&args->percpu_list_ptr, (intptr_t)&list_a); >> + __atomic_store_n(&args->percpu_list_ptr, (intptr_t)&list_a, __ATOMIC_RELEASE); >> if (rseq_membarrier_expedited(cpu_b) && >> errno != ENXIO /* missing CPU*/) { >> perror("sys_membarrier"); >> abort(); >> } >> /* Remember a value from list_b. */ >> - expect_b = atomic_load(&list_b.c[cpu_b].head->data); >> + expect_b = __atomic_load_n(&list_b.c[cpu_b].head->data, __ATOMIC_ACQUIRE); >> } >> >> test_membarrier_free_percpu_list(&list_a); >> @@ -1401,7 +1401,7 @@ void test_membarrier(void) >> } >> } >> >> - atomic_store(&thread_args.stop, 1); >> + __atomic_store_n(&thread_args.stop, 1, __ATOMIC_RELEASE); >> ret = pthread_join(manager_thread, NULL); >> if (ret) { >> errno = ret; >> >> --- >> base-commit: 2dde18cd1d8fac735875f2e4987f11817cc0bc2c >> change-id: 20230908-kselftest-param_test-c-1763b62e762f >> >> Best regards, >> -- >> Justin Stitt >> > > [1]: https://lore.kernel.org/all/20230908-kselftest-09-08-v2-0-0def978a4c1b@google.com/ > > Thanks > Justin -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com