From patchwork Mon Apr 17 17:32:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 84366 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2292799vqo; Mon, 17 Apr 2023 10:38:33 -0700 (PDT) X-Google-Smtp-Source: AKy350Y4AeCyP545iIEQwIPmdx67naF2FVKuEcX0nGjhTpcTPx22aio5gwyTYXCm9b3IVkNpnmew X-Received: by 2002:a17:902:ec92:b0:19e:500b:517a with SMTP id x18-20020a170902ec9200b0019e500b517amr15078330plg.69.1681753113455; Mon, 17 Apr 2023 10:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681753113; cv=none; d=google.com; s=arc-20160816; b=iDyVBkQC5QeElchdjVde6sqZvy2lpKl43LZMHM/1mS0ZJ7+KKybezuOfX6QvqlAP3i JMJfAP5+5b/xMckZVLYSofKd6GX4b+3ie/ODXLRABmWhAxKpH0wSnsKno8WKCrWFplcw DKWLtLIw24zjr04MEyGcQJrCS0Ju26CrCY4rDozvqpWedylVW/d+ebRSeyYp0oL9Y6mI mfaDcWSiw8BvgnF3HhQEob5RZoEDiOp/lSd4yVY7KB0BvUz+79LrzKc8F+Ih8DQZipVn TBPghL5TWDmfbxIKhJhrA5yuhVjRfVi9DitfIsm8Ghcw7cZuQDwdHdkWEbD2GmV2EqF6 fIqA== 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=ac9HY+UwMkXIl4udhASlu1Iiq0Stde6nwToLb1PxMKM=; b=xSOdMHOnlIDbq4iqBsg09fTGtx6um+6ELhNnzDFNboTEjG2bH00v4UHS4aid1AQzBD X7rbZJ6PKkQcwPp88eH2W7y2WuKOw1QiP+nEK89Nc6MsqZMW5sRwXzhU3mGi9opeQbXn UgtpaSLij3WJf21ilctygJajtWHzYxveeC13H2eaEVOxCkVzGB+Fts7m9DJUQ3JIWtPa TMM3P440OkEyEy/BCZaQixDocF15v/Uq2yGonVIWMQnq3jizAywR8AG9VsxfIa/fvIvM OmwjAlokZPQ0/VxpF+7vxXEyIPLt/JRHL0f9wtbDb3qvDxNW1F6BL+qut+XYCOFXWncw xeaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CzjfofkQ; 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 d9-20020a170903230900b001a6d0a8c713si4108580plh.106.2023.04.17.10.38.20; Mon, 17 Apr 2023 10:38:33 -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=CzjfofkQ; 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 S230355AbjDQRcy (ORCPT + 99 others); Mon, 17 Apr 2023 13:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230308AbjDQRct (ORCPT ); Mon, 17 Apr 2023 13:32:49 -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 ADDDDAF2C for ; Mon, 17 Apr 2023 10:32:48 -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 35CC56103E for ; Mon, 17 Apr 2023 17:32:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E55B4C433D2; Mon, 17 Apr 2023 17:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681752767; bh=HHLa39ETA/u3pWI5BL6sseaRF5jWhnYjA/pmy+XNmas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CzjfofkQ+pPoF44cYauKQrtJKclwDdX4CpSvOCuVuJT+h12RpH2N42m6iz5Cq8D5Z 9p+gTbRcDwF4FSF4jSwBJwI7+2QS/nzO3nEXhVb6Thi3LlJku/EwgVcECSZuRe7Ddl NthKPqW80SkXjBNT2hXuLvUyA4mS+LgRC/MachFhcEgajUP0exf/X0+PwJ5V69sJrz sRYa7ngGRmX3N04NuLePX9INExZaGB++Z57ocFPrMZM4/yZIWfz029dGD7lVqwa+q4 ZftOqD4ytBsZcutFWN8cFSrp2Tn/FAOnrSHsdeyaLPPmLd1DAea9dfrfWCfhR2MUgg Z+FKOP2mO56BA== From: SeongJae Park To: akpm@linux-foundation.org Cc: SeongJae Park , vbabka@suse.cz, willy@infradead.org, paulmck@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] mm/slab: break up RCU readers on SLAB_TYPESAFE_BY_RCU example code Date: Mon, 17 Apr 2023 17:32:38 +0000 Message-Id: <20230417173238.22237-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417173238.22237-1-sj@kernel.org> References: <20230417173238.22237-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?1763445952765105845?= X-GMAIL-MSGID: =?utf-8?q?1763445952765105845?= The SLAB_TYPESAFE_BY_RCU example code snippet uses a single RCU read-side critical section for retries. 'Documentation/RCU/rculist_nulls.rst' has similar example code snippet, and commit da82af04352b ("doc: Update and wordsmith rculist_nulls.rst") has broken it up. Apply the change to SLAB_TYPESAFE_BY_RCU example code snippet, too. Signed-off-by: SeongJae Park --- include/linux/slab.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index b18e56c6f06c..6acf1b7c6551 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -53,16 +53,18 @@ * stays valid, the trick to using this is relying on an independent * object validation pass. Something like: * + * begin: * rcu_read_lock(); - * again: * obj = lockless_lookup(key); * if (obj) { * if (!try_get_ref(obj)) // might fail for free objects - * goto again; + * rcu_read_unlock(); + * goto begin; * * if (obj->key != key) { // not the object we expected * put_ref(obj); - * goto again; + * rcu_read_unlock(); + * goto begin; * } * } * rcu_read_unlock();