From patchwork Tue Jun 13 18:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 107507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp752876vqr; Tue, 13 Jun 2023 11:39:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ724FjQQz8mFLj+pxBITtFshki3AZjRYt11PJ1hOVyCmwT6uYV+aJmDg7WQN3jCy6NqMd23 X-Received: by 2002:a05:6a00:14c2:b0:658:12ca:385b with SMTP id w2-20020a056a0014c200b0065812ca385bmr15548121pfu.22.1686681546951; Tue, 13 Jun 2023 11:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686681546; cv=none; d=google.com; s=arc-20160816; b=XRf8OiqdtXWYFyCwivtMdurEL5aQo5z0eChG3KPI6amXhveYkdbwb2dw7wJrUgmHZ4 CRl74en0DkdFRC+ZctJmV0YyDtu4JCQzKL7tf09wpFEZEx811PIFkJE5f2l8/R5r8SMx gnOJLmKt+HcUWj4J771jM4rcODY7PZXqr8lkpjP19AfLjxdJaQ5h9g2ISSBuDWbo7NyO VKm7w3UJfUu8te4zhDln6rwffRTRZ5ovkmmE56lVBX8c65uMoW7qX8IRyIjVh0aGJvz6 nP79KkMDQTpL77OyMFwmPnq4oG67U+1BBPZInVzn+UbqZGNaTHWCHc/hWwPIqxbAy7tm LkzA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V2+P0FxQ8sw5Qzc3xYODPHVgQfNkPFiKHBj/m94GwH8=; b=HA2tWBYfACyMv47euIdgVgsFcy3upf86P5/C35XBnvxWkMTWkj+S2PqJA7Ns4kiIlH H7p9GXaUJSggt6fqEIfQov2AfWO/yWJsFo+bmWWCMJXPwWND3BIWaCT9Iy6wrYlbM+gP ruB5Kak95HmxgigHN0ginggB8t154+dOiHjeiT38uc31601nHpB9IUZ2WExi6hyUk4vy kBCGDAowVyyl2wUdkFBnhl1M3Jt9fDZ68kxCZV4j7y9WUVl65iTQkIW4jyj0dHKQYyFJ zyMD9lDQm0tMvROLYPLCDnj+EUl8h2XLim5+xOPDDHrc1J9qvS3SrzWGMzP0XQm3+cKw tpXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NLe1oDvv; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c27-20020a056a00009b00b0063b8ab7f91csi9125872pfj.365.2023.06.13.11.38.55; Tue, 13 Jun 2023 11:39:06 -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=@kernel.org header.s=k20201202 header.b=NLe1oDvv; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239718AbjFMSYu (ORCPT + 99 others); Tue, 13 Jun 2023 14:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239242AbjFMSYm (ORCPT ); Tue, 13 Jun 2023 14:24:42 -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 17F30E41; Tue, 13 Jun 2023 11:24:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9D23C62F59; Tue, 13 Jun 2023 18:24:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78518C43331; Tue, 13 Jun 2023 18:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686680680; bh=8QtwSYO8fDJCyX3Iukfsqd/4jzpKwmY5DKHH76v+mD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NLe1oDvvlDNZZOS+fcGdvyQGzbtGAu6o52EhnNihiyzLUr40EX0ESaFKJ+C8VUGm7 3B2ao510PdqLceIpEBAQHFLcjZDj+ibxFG7xGS2v0dddzUw3h9BDOlOh2aekouM0Nu 8nsaioUIkdfb8YTTx0QtWEsnKUwW++YXrqthph+T0P/yjJ2eynVkbejNRgItTykowt zbA5omcQSINpvyzkw4GpVzcHGp7DyKDrdU0DHhG+EsP9vghbx5JdekUGLUkIMmTQxY CzLuNzhTNlmKdzbqMJA2pAABmPikZJ6HKDqArYJF1d8BIAl7ySLIT4H3rHAUxInWDp 9J5JMtL7eFIzQ== From: SeongJae Park To: paulmck@kernel.org Cc: SeongJae Park , joel@joelfernandes.org, mmpgouride@gmail.com, corbet@lwn.net, rcu@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] Docs/RCU/rculist_nulls: Assign 'obj' before use from the examples Date: Tue, 13 Jun 2023 18:24:32 +0000 Message-Id: <20230613182434.88317-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230613182434.88317-1-sj@kernel.org> References: <20230613182434.88317-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768613789785246269?= X-GMAIL-MSGID: =?utf-8?q?1768613789785246269?= 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) --- 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 253ecd869fc2..94a8bfe9f560 100644 --- a/Documentation/RCU/rculist_nulls.rst +++ b/Documentation/RCU/rculist_nulls.rst @@ -54,7 +54,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; @@ -66,7 +66,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;