Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2954571rdb; Tue, 12 Sep 2023 18:40:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHr9YGw8bhCHFwLCRkUhxde5J7SdOOQXZem7rFT3cQwpetFJnZUR4RvC0IUsVbaXvaglnoY X-Received: by 2002:a05:6a00:c96:b0:68f:d864:596 with SMTP id a22-20020a056a000c9600b0068fd8640596mr1772063pfv.3.1694569217965; Tue, 12 Sep 2023 18:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694569217; cv=none; d=google.com; s=arc-20160816; b=VLVSl79CWwcxNlpp76aHXtnQIHtebRIXkuGJvdFLFXm+8DEfDxfxtuBfN8n2ecQkLS J7zF+l6ubQkusRX2XktRfVVWA6Tl5zmW6UDQS0TbzeaECIVxMNQPbdC6C9uROi5umeaS Oox8tDxyb6kDLG+CkNyAecs9M492NNRyBzD/OsJwYsDp0UMit1dBHqOQ+xZbKaHCMm4m dX73XDLtGNn57pBCK7REYhI9pcOG1pkiuFssHADe4yxxOzl2WNFa3dLaR1MdsVMFdY9e yEgZ/qbA5TohuxFBL5JvqDQHKylemFR4lSjUz7AwiYfjKOhlvXxtGxHkYZlvTJI5MA8y kVIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=Su3tcyVoOXGTvjYADlVUH9iHtW/BbNEgdwa7PWlndEM=; fh=pGLnrHy7I4lRHOfJgcJWH1IZMohDHgoJQTDrv8RDHyA=; b=O4eJwjYpWWGS9z82XI+vR95iIr0bcbfbPwIWYcW9FdiG7tE8VSS/4xIlKy4swGGo4j Bbgbs5WyjJKzn0lzwN9alVVfm+f0uzlQauP65NVjqLMjnQOumAlkYXlTbQOc9VpofUvJ FlAA06//kuYqesmwYlJwdp9Faaqz8Jw9hrXggU3px4w8tSXuksLoFs+qRGwJwnaYkMMK 9rwqAJ7r0KINUu7MLLFVy64Awk7skg3P/QocmWenuMBioNU9IU0XX6ue9+RRa/p5j483 VFr4atiJibRYlI1bl3MuC3OMnUtYai/4/IGk1Vs+Op65fL07UIJnY9LbsBChrCePizgt qIww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vaVDmrEl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id c11-20020a63ef4b000000b0056949c3eda8si8665757pgk.119.2023.09.12.18.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 18:40:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vaVDmrEl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7446381DE6B7; Tue, 12 Sep 2023 14:04:07 -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 S237599AbjILVD6 (ORCPT + 99 others); Tue, 12 Sep 2023 17:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234513AbjILVD4 (ORCPT ); Tue, 12 Sep 2023 17:03:56 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04C2110D8 for ; Tue, 12 Sep 2023 14:03:53 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5958487ca15so65940897b3.1 for ; Tue, 12 Sep 2023 14:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694552632; x=1695157432; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Su3tcyVoOXGTvjYADlVUH9iHtW/BbNEgdwa7PWlndEM=; b=vaVDmrEl26Pep/AtPLPwLv6imtcPN6P9V3il/4xD/fqc6mM62wtTMECYTimaPhIBVH Kbw+IP24D+nqt7+bXwG7SXzes+HOQj0rLGD4uxLgYK99p+Ddvq9rLmaM8EMd4xQOnZJV 5dclwzP6No8swISOJPaRqOxa1gU2JCFUG67adUMcKsPaJF9ATua23b6B5zIZgBECDjpr YnopTDBgC4ahM3ljf6HDxS4Q2tOnLBpxGWA232D+vrHGEJ9JUiIuzaZuSUaSnFxpK3lr apCgYQ5OVUmmjAlx3b3pcwYw06XXp9Mb5s4N8UwZ2sdHJi+fmgX+sO9Xwd2M9/W6YlgE UdEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694552632; x=1695157432; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Su3tcyVoOXGTvjYADlVUH9iHtW/BbNEgdwa7PWlndEM=; b=wKycNVgxl2cHdgODAIFkgDRDvkmDSHqHcfM9dAWXSoA5gBjVtxAztx4uoXhWpm7yXs GHaY+Qy8fzgXqMwZfHay28CxGl0tUTMj/R/XsXmBi9+PgjKk7d7s9dS0wPv72i23RCyh 0zpexZ6G0PMq2QycCrx30oKA3W4GeSqJ2q+bp3Zx5kL8cSbv0ou99sHFkaQOLbh+dY7K WXjfmvqID92/jRxVM6RGBTa40LSBmbBG7Q7rY2oKHQyCVEGI+SFKvhAkQmiUzoHHD9S6 x6dCyoWwrpnUFIwSKsZ54+iryD0v1zlaDOS05D9f99prais5PrPs8elNiS9x53wzuUcT Z7Ew== X-Gm-Message-State: AOJu0YxW3+T3EghwvI82+80Np8UW4i20MveSF3tE/MlRYxR4pn4H6Urc 3CWUgouGnGevy11NBeX2/G9zUKxfw7h93y/SHA== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a81:400c:0:b0:589:a855:7af with SMTP id l12-20020a81400c000000b00589a85507afmr17848ywn.7.1694552632259; Tue, 12 Sep 2023 14:03:52 -0700 (PDT) Date: Tue, 12 Sep 2023 21:03:50 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIADbSAGUC/4WNWw6DIBREt2Lud2l4RKz9ch+NaRSvSKpigJA2h r2XsoH+zZlkzpzg0Rn0cK9OcBiNN3bPwC4VqGXYNRIzZQZOuaAtvZGXx3UO6AM5BjdszxIVYY0 Uo+TYSD5DHh8OZ/Mu4kefeTE+WPcpP5H92r/KyAgjKOpxamnNJ8k6ba1e8arsBn1K6Qv4Q/Odv QAAAA== X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1694552631; l=4723; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=rBvEsviW5uVxRd+NSePgqHcF5aSjOLLvI+7rzhkkIw4=; b=YWVY/Weu/NSS3aIoj+Urk84igcHFCjWw8w12fSj3X9Av24E/Uzm8nDpKQdRL22iqOFzOi+bSg m9up5YJRe7YDO6RlPENJ2k/ZLpyQAWPEF7g/3lhb404Mrq/huWzpBnN X-Mailer: b4 0.12.3 Message-ID: <20230912-kselftest-param_test-c-v1-1-80a6cffc7374@google.com> Subject: [PATCH] selftests/rseq: fix kselftest Clang build warnings From: Justin Stitt To: Mathieu Desnoyers , 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, Justin Stitt Content-Type: text/plain; charset="utf-8" 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, 12 Sep 2023 14:04:07 -0700 (PDT) X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 --- 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