Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8196780rwd; Tue, 20 Jun 2023 11:30:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68NEu/xrV5zyC5QNgwghdF9aDwdhjmU8JvzrN9YTDzo7VlMx1LYkDVIRlUGqm4fyf4KWod X-Received: by 2002:a17:90a:7388:b0:25b:d96b:e87b with SMTP id j8-20020a17090a738800b0025bd96be87bmr8113897pjg.1.1687285805090; Tue, 20 Jun 2023 11:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687285805; cv=none; d=google.com; s=arc-20160816; b=NJnNGEbZtm2cNcCTk0kkVkoL4kJ4FCuwqby4GumXTpx42C49RSqpOps53OEm0Ks0Vs PIGYT98bxcs/f5GFg1d/E6Zg6Rm6Fua1rwcF4Oz7yAVeaxwhvgchywyGfAnZY53RRXwU 6TRqchPh2ZRyT3g1afQbmQPDfjCtGfl+KJTixAB3SJmk2j84ruX1ejOQDeC1V2ScTMPb vVh1dch3JUV9gQ/XZ2Jjr5u0tgL9dENJyQWGcXRppqg48rOKtLTxMHWkIRi49/FzHGa6 vGkNSfCpvKXbiTx+cFH8dn0r9Zuc4HSxA8T8SUPqwzbLay9b6RWE+h3ALPbfQz+Gyhit VBAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=FQVL+8eaCaxsNitQJJf0YFTeFjPE8938pH+IXJDEavY=; b=DYwfvlfyYPiRhFdWrap7ZPpfymlLDdHfVTFXizCm5aTBbBY6y+mlJrxxsTm/Vf1tpw x7s2CtDdXnBh3BUM5Y39GEekU0rtMODt4TtHrNe29O1c0dBip4xdHwwfzY9X9E89XUoV iCWHtW4wBgnC/wYYrDd0UNN5FsANaFrrCmAVVz0k8MEwzFMTqN2oJRNIFADxxsQ7CP7p nL3ejx4+xy/KBwA7PBbWRTdjmko/cB2KwqjuWVcEe87N9/yOj01jjGylbVh/6yM9be79 V+zRy6tlpsyeGLo4frqwgJLfrjWtppBoRLX6F9hanQbnJzZNSEjKA42MTQDbAHshdJsr BtIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BgPTfp4V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a17090a694900b00250a4d72bc9si2470345pjm.108.2023.06.20.11.29.52; Tue, 20 Jun 2023 11:30:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BgPTfp4V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbjFTROA (ORCPT + 99 others); Tue, 20 Jun 2023 13:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbjFTRN6 (ORCPT ); Tue, 20 Jun 2023 13:13:58 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E6A1726; Tue, 20 Jun 2023 10:13:55 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1b52bf6e659so22620185ad.3; Tue, 20 Jun 2023 10:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687281235; x=1689873235; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FQVL+8eaCaxsNitQJJf0YFTeFjPE8938pH+IXJDEavY=; b=BgPTfp4VPb6Brq698keka1gTnQc7c/3ZzVTj6QAeTMusvfziGWN6FtMN35aBzq3IOf qpcwjm/C+dSzrCO7b7gXNX3jkiAg2CJ+AfrHbdKPr2yGVr71uzlUiqPPrT3eXiAqMMHD UTGXjYr8ev561lbNB035DKZNoK3IV0sVKWD+aK0jE095BkQhW1w5KqklPyrR8FZeRu2J LPOX0td7AsaSilXfGAjXjlzkuMUtKWh5Ykn9DpskMqM6QrUkDMIQgGYybQFk1WlMNMBx l92zcvLg/mRIIxFhkTucNSjJhivbcUwpZAwZhklapxLZJ7NEDMtrqcdqOhBVdTwL1wgD qdmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687281235; x=1689873235; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FQVL+8eaCaxsNitQJJf0YFTeFjPE8938pH+IXJDEavY=; b=G2iulcgwKoxgqkYQmIJ7n+GW39oRAnLdgWoDimBVbeN9ns4K9+Qitxjij81U26RvwR GjYybqFsVbdPfx8b6Dh6//Xc4CYzxScVInuisgXmihWO1W+dMxcXzlEdDWIC/kj4Xbaz IMvfIbx25STZ3VZKeubieNTlROy6DSRE0yuGNQD55L1AfiCB6aiqwJ0AJaLPxWaWRo2y /7mO5I6X5YhercSUFJyt2BhbOHD0NNx8IHWq2LRrXFr3ssBWnpSowNbw4GekBFzvF5df 7ku9ohZkwmH5HUyEvWalG4aVQhEXvR0FzveaE5LxjvC7AaCxpw4/BSi78bieloumK0Dx 53Rw== X-Gm-Message-State: AC+VfDxFXQ9X9Y9d56dPjXD6GKI52EyZFh6zihL1oD4G9VetBqr5iBy5 UEbdPfyJzm5+AYoKQAU39WDh11FMj74= X-Received: by 2002:a17:902:ea01:b0:1ad:e633:ee96 with SMTP id s1-20020a170902ea0100b001ade633ee96mr8123222plg.55.1687281234782; Tue, 20 Jun 2023 10:13:54 -0700 (PDT) Received: from localhost ([2402:d0c0:2:a2a::1]) by smtp.gmail.com with ESMTPSA id n13-20020a170902d2cd00b001b1866f7b5csm1872888plc.138.2023.06.20.10.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 10:13:54 -0700 (PDT) From: Alan Huang To: paulmck@kernel.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Huang Subject: [PATCH v2] rcu: Add necessary WRITE_ONCE() Date: Tue, 20 Jun 2023 17:13:46 +0000 Message-Id: <20230620171346.207076-1-mmpgouride@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit c54a2744497d("list: Add hlist_unhashed_lockless()") and commit 860c8802ace1("rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls") added various WRITE_ONCE() to pair with the READ_ONCE() in hlist_unhashed_lockless(), but there are still some places where WRITE_ONCE() was not added, this commit adds that. Also add WRITE_ONCE() to pair with the READ_ONCE() in hlist_empty(). Signed-off-by: Alan Huang --- Changelog: V1 -> V2: Add WRITE_ONCE in hlist_del_init to pair with READ_ONCE in hlist_unhashed_lockless. include/linux/list.h | 9 +++++---- include/linux/list_nulls.h | 2 +- include/linux/rculist_nulls.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/linux/list.h b/include/linux/list.h index ac366958ea..3a29b95bfe 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -912,7 +912,7 @@ static inline void hlist_del(struct hlist_node *n) { __hlist_del(n); n->next = LIST_POISON1; - n->pprev = LIST_POISON2; + WRITE_ONCE(n->pprev, LIST_POISON2); } /** @@ -925,7 +925,8 @@ static inline void hlist_del_init(struct hlist_node *n) { if (!hlist_unhashed(n)) { __hlist_del(n); - INIT_HLIST_NODE(n); + n->next = NULL; + WRITE_ONCE(n->pprev, NULL); } } @@ -1026,8 +1027,8 @@ static inline void hlist_move_list(struct hlist_head *old, { new->first = old->first; if (new->first) - new->first->pprev = &new->first; - old->first = NULL; + WRITE_ONCE(new->first->pprev, &new->first); + WRITE_ONCE(old->first, NULL); } #define hlist_entry(ptr, type, member) container_of(ptr,type,member) diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h index fa6e8471bd..b63b0589fa 100644 --- a/include/linux/list_nulls.h +++ b/include/linux/list_nulls.h @@ -95,7 +95,7 @@ static inline void hlist_nulls_add_head(struct hlist_nulls_node *n, n->next = first; WRITE_ONCE(n->pprev, &h->first); - h->first = n; + WRITE_ONCE(h->first, n); if (!is_a_nulls(first)) WRITE_ONCE(first->pprev, &n->next); } diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h index ba4c00dd80..c65121655b 100644 --- a/include/linux/rculist_nulls.h +++ b/include/linux/rculist_nulls.h @@ -138,7 +138,7 @@ static inline void hlist_nulls_add_tail_rcu(struct hlist_nulls_node *n, if (last) { n->next = last->next; - n->pprev = &last->next; + WRITE_ONCE(n->pprev, &last->next); rcu_assign_pointer(hlist_nulls_next_rcu(last), n); } else { hlist_nulls_add_head_rcu(n, h); -- 2.34.1