From patchwork Mon Jul 17 18:01:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13316149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FC37C001DF for ; Mon, 17 Jul 2023 18:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229870AbjGQSBR (ORCPT ); Mon, 17 Jul 2023 14:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbjGQSBO (ORCPT ); Mon, 17 Jul 2023 14:01:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EBA1115; Mon, 17 Jul 2023 11:01:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E74FF611CE; Mon, 17 Jul 2023 18:01:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5101BC433CB; Mon, 17 Jul 2023 18:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689616872; bh=Y/tGOWx5q4ZXPiE4it7zg9nYO16lZ6O1v/m4xTWMYUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZzwrAmSWJKoFU94kWriauk8IWoBE5TS+HnmT9tykbdY2EHGd4AYQEqu00ysi5aHFl ilwh6BJ0kVhp/tgiuy2qklG84FTHT42EG8indXY6dc4SKsjBRPffbKs+e18ia5PrIc bePSuyefnHyvvqMSMBgyI+vtAnTf4Hfak9p9q+lZYRdv1Dqbaks4EYmmS9t6BHrgvV qfTTWgxs72OwqK6jS+0JYUGn07iRbzAB5m7jaYI+kuQ2rlCASpLmpoDIqfxv0Yq3VD 7UJ+V8ClN6aEQNK70VOvWXDg3rG6EiAAJs70Sczxu4PECyeX7lnsMpUDhnCPWKOmxr B7aU9iDg+nIRQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D8FA2CE0836; Mon, 17 Jul 2023 11:01:11 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, SeongJae Park , Joel Fernandes , "Paul E . McKenney" Subject: [PATCH rcu 4/7] Docs/RCU/rculist_nulls: Assign 'obj' before use from the examples Date: Mon, 17 Jul 2023 11:01:07 -0700 Message-Id: <20230717180110.1097362-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: SeongJae Park Lookup example code snippets in rculist_nulls.rst are using 'obj' without assignment. Fix the code to assign it properly. Signed-off-by: SeongJae Park Reviewed-by: Joel Fernandes (Google) Signed-off-by: Paul E. McKenney --- Documentation/RCU/rculist_nulls.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/RCU/rculist_nulls.rst b/Documentation/RCU/rculist_nulls.rst index 25b739885cfa..4d6f077552ed 100644 --- a/Documentation/RCU/rculist_nulls.rst +++ b/Documentation/RCU/rculist_nulls.rst @@ -56,7 +56,7 @@ but a version with an additional memory barrier (smp_rmb()) struct hlist_node *node, *next; for (pos = rcu_dereference((head)->first); pos && ({ next = pos->next; smp_rmb(); prefetch(next); 1; }) && - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); + ({ obj = hlist_entry(pos, typeof(*obj), member); 1; }); pos = rcu_dereference(next)) if (obj->key == key) return obj; @@ -68,7 +68,7 @@ And note the traditional hlist_for_each_entry_rcu() misses this smp_rmb():: struct hlist_node *node; for (pos = rcu_dereference((head)->first); pos && ({ prefetch(pos->next); 1; }) && - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); + ({ obj = hlist_entry(pos, typeof(*obj), member); 1; }); pos = rcu_dereference(pos->next)) if (obj->key == key) return obj;