Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp805977lqs; Tue, 5 Mar 2024 18:17:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLEVHjRg5GvvfnmyMfY9ghJP4Oqmfk6FIK/tDX7JuEf0eZfT85RsQRThlMNTwIKSdUcNmY1OZ35DDCsF8kgos7Uzc9j8JQ9NIjWf31Pg== X-Google-Smtp-Source: AGHT+IGwXrbVQT5LwrCMYR6cvdF0LELAzsTKDde9DWNwHewQ6lXx5RgYGIG2VpNXdhADtCXvEC19 X-Received: by 2002:a05:6808:15a1:b0:3c1:e3fb:6c35 with SMTP id t33-20020a05680815a100b003c1e3fb6c35mr4310217oiw.31.1709691422717; Tue, 05 Mar 2024 18:17:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709691422; cv=pass; d=google.com; s=arc-20160816; b=ULSGEQjzTPaiqVyag3E5vW3nKeQ5EfNZQnwvflwJ+qkG1gpCVrgHThfo/tSi5cRTVs yaOSD3cCEEKnuwjxh12u775THLtHSQDL8a82XRYlYAtTbzJhX6QbmmokpsgaS88kU1tL 50UMeY8itje9MmLFWez52Gu5zRN/8P+B6VXAg1ZW0rBTV6D/vLvx0+RTNTACdSqAKgwr dB9xBQdwisA34RvrHUBIwjhaBhtkFxfFgaWiW8Wp3jaghenWca3wCOhewGgNKdHgV9PH lM4VGpGio3AquOCQk7LSeFIL2yWpt2eOdrxP9xQgBzGFNfi8w9fbf2Vwj+jcMDE7qGgy 0WQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:subject:cc:to:from :message-id:dkim-signature; bh=PWmk73R2PGj1OEAHYbuSO5yqqiAnHgDbDoSjsb+aNVQ=; fh=siR13ortnF2c1Rh/Emo/VNhfOhU1g3gndagiaJg2ze8=; b=CIuvW0j9Os1qig+uGclcttd38pb+RfyXvLMju/tPc2k8C0FTOBDWTsItF3HTxYzYyV DkEOQASnPhEBwwhVskRRv/YkzGMLQ2ue0SrHEDzUKsZQ0oM1JCLBNRvCzChtGW7/5jNy CTARV4SqGHTBITCSIWokmnWGkO1HQGfbhqb4D9JcOHRW9gImtxcg5m1v0YCtn2fzzOSV PEop7p+9eTkWdvWLmHhstBGt5Y7/on3+1F+FvnWA1DgJdld0qsuiW/xLf3XLwJeuIRbn SRPJy4W+Gd29usLJXelGx1ur10nSvvT6a8dn6oSxU0D9Wszi5x1YatyuQ73mUcXLnGjk xQjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=lfi6C+sx; arc=pass (i=1 spf=pass spfdomain=qq.com dkim=pass dkdomain=qq.com dmarc=pass fromdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-93230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93230-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c6-20020a6566c6000000b005c658bf30aasi10916718pgw.412.2024.03.05.18.17.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 18:17:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=lfi6C+sx; arc=pass (i=1 spf=pass spfdomain=qq.com dkim=pass dkdomain=qq.com dmarc=pass fromdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-93230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93230-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 410FFB24625 for ; Wed, 6 Mar 2024 02:11:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0681D29E; Wed, 6 Mar 2024 02:11:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="lfi6C+sx" Received: from out203-205-221-236.mail.qq.com (out203-205-221-236.mail.qq.com [203.205.221.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07FCCD272; Wed, 6 Mar 2024 02:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.205.221.236 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709691095; cv=none; b=TOTUrjG/SCzjv32hshwe5F5iMJGHfd8JohyGzIUskzwiSBewEzY9TuWeS+pl5qI44pyw/kYSNnn5v9bdoyOi+tBubNxnGILINMIYdgWlG6lrWMlLCHdzSy4S1IG3Qa/2llSUYXKYqNri0MyAfeZdRAKnzqsabcTIuZFUZ/QwpGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709691095; c=relaxed/simple; bh=Z+/9ljkeSU0oZW5bdtyR6B/2/tSLJ/OhxBOyXh/VRjg=; h=Message-ID:From:To:Cc:Subject:Date:MIME-Version; b=JuIPNI4sIV8s2IXP4YT0FxQbQLL0aetofJu8uBaCf+r3rruIH8FJebMC9V1zDQ//6KoeFntsztf3AG3RWPJ/7BFUB7bSNGY1H5YgRsPnC7Jq/tJePvIzd2/iWCCul0mQ8ZFlp8AJ13HkA414JCDSUX7VWPMyJvcsMBherbmCe24= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b=lfi6C+sx; arc=none smtp.client-ip=203.205.221.236 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1709691090; bh=PWmk73R2PGj1OEAHYbuSO5yqqiAnHgDbDoSjsb+aNVQ=; h=From:To:Cc:Subject:Date; b=lfi6C+sxf2JHJHY1RdKZsPobtRE/7AeVjPQdeFRpO3qmjICLwzFyHzScU+HpXNF22 cjQJbHvF4E0pXku3VUEjS8+DqWOLxG2J8Sg79L7+JScllXridbNFqd4Brqt5jZL7Cn 4lAI/Bi+LdaLaIAUPAwMq5Efz7IUaNFL451TVDLU= Received: from localhost.localdomain ([218.94.142.74]) by newxmesmtplogicsvrsza1-0.qq.com (NewEsmtp) with SMTP id 1562C877; Wed, 06 Mar 2024 10:05:22 +0800 X-QQ-mid: xmsmtpt1709690722twb7dafhj Message-ID: X-QQ-XMAILINFO: NwIPvWX4YDagXilQRA9dEGsmt258n+FOi34HuLOiBHx+Qs9Yjy+ik06aad1BT8 SLb11g9yqhYganyejj6G7p411BRbl/dD9PPFrszEaU2R1on2maRETiQ6oLiFqva/YrGqxg6mgNOe ziFlQ4Efbm/gMdG/xZXDlvdMw5nielgeEKO6bO1QC3iVWdV2QwiMIXU5kyUy2H8O9LAYcuV1wBAh Ojwkkxadq7p1cPzO3+r4PYVwHSYH3gda0zv1OsmONVwW9MKzpyi1OJJmRYcVC8Pfyf1CwiFN5rIV irWtlTkHyYkATUkxCF5GM/8oGvz2k27TLI1nOLd87oiyb5X/IGqGhZL9j+66wjQQ7fHDStjsQifY SPya9anWo604GCu/f7FwI0Jfmr7IvQEoetGBN62ffTxV8NoiTxnkcSnbQJ1lHv3jkUjFizgr3cKd 0NezBsoeifmjD0/eQLWtlGixTla1y5ell4C/nqAPJPfXR58vk11n3QzPzfYuqlsi6oPFGznbINCm Z0F9th4jKwydIzaajJBoHme6MGDgDUogxaPEjakiXTqyYum5JmT0v9nQacWz0cyPbXwmNqNbLh6M 9ARyG/sv1PmKhQD38M6Ms9wHYA/ldYXH0UKbe063tUi79EcLaYUs28ljZON6oNxMyKTDpTKk7xX8 Oee94Q4vG2kMnn502F9pkxfjv33UOKGJDmzA/pbGsZiRrmmQ/gS9lVYte0pMuTXPatxbft5TXwdw Hd38fUAAf+fYN8ay3D9/rsvXAuIWSgUcWb99AWd5dge5RvJ016R8K+aD6a/h7iNdzkVnn48GeK8J I+W5CryCR4zjHFfC+DkDm0OnPejjyewGMiZ8UZACeIBMxRJ7BRFvWqy40IoLsOa5tdkbXjH4hZ6G M8vk64SWPsbuEhSHU/EBKzCsH4asm6Yn9Gxc2pDHRk8bzaz4Nkfzt4YbNkzvmAFN6zHmyyVN6wPU ur53HDRK3F0tlYT335duK9VX99w8Y73g+OU45QIRwC+EizJB8Ml7vnJASXdVHxiMXDeh7G2kiAzk aXZYZALpDt7is7etZ+ueBcf87ZnmvwvN32BlbO62dU0QTaxKDN X-QQ-XMRINFO: NyFYKkN4Ny6FSmKK/uo/jdU= From: linke li To: Cc: lilinke99@qq.com, Joel Fernandes , Davidlohr Bueso , "Paul E. McKenney" , Josh Triplett , Frederic Weisbecker , Neeraj Upadhyay , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , linux-kernel@vger.kernel.org, rcu@vger.kernel.org Subject: [PATCH v2] rcutorture: Reuse value read using READ_ONCE instead of re-reading it Date: Wed, 6 Mar 2024 10:05:20 +0800 X-OQ-MSGID: <20240306020520.40589-1-lilinke99@qq.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit rp->rtort_pipe_count is modified concurrently by rcu_torture_writer(). To prevent a data race, reuse i which is read using READ_ONCE before instead of re-reading it. Signed-off-by: linke li Reviewed-by: Joel Fernandes (Google) --- v1 -> v2: change the patch to focus on data race in rcu_torture_pipe_update_one ; update change log kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 7567ca8e743c..53415121be39 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -466,7 +466,7 @@ rcu_torture_pipe_update_one(struct rcu_torture *rp) i = RCU_TORTURE_PIPE_LEN; atomic_inc(&rcu_torture_wcount[i]); WRITE_ONCE(rp->rtort_pipe_count, i + 1); - if (rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) { + if (i + 1 >= RCU_TORTURE_PIPE_LEN) { rp->rtort_mbtest = 0; return true; } -- 2.39.3 (Apple Git-145)