Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3637831rwl; Tue, 27 Dec 2022 12:23:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJd2PQySVIOrdvMiE5R5xTJm+ktvg0EcpO74srD6qKjTPw2I7i5cjheP8j+F4bRKONfWYZ X-Received: by 2002:a17:902:e889:b0:18e:4a20:5b89 with SMTP id w9-20020a170902e88900b0018e4a205b89mr36671554plg.23.1672172637219; Tue, 27 Dec 2022 12:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672172637; cv=none; d=google.com; s=arc-20160816; b=ybx5ALX0/arEeiW/sK5zrdIIXYRhI9k7akJU6c6SDOYVYaKzyyEN+gn1OKUGwUYVmX KcpxH1ZJhgq072VECOGoMdoQ6oFgI78uz0hWtjzoIpWQdYoT1ZvvFS5tkSVChIroWci7 FhmKW9FYHs6NHTaDulA6Jm+8wxyJBjHIvrabTJIRZMumcj6IHeF6k6v7tyVUPgPS2txA woQl7pI420FmTzUx5cGC94/+fnaYyEzTFqrC1gCxPdTuPfzSfhrM7ROcFqOeFjtHG7Ih w03QmWnLewnPw2nnCn4/QPqLVyLr+FZ1f44x3eF+cgPoMvv5316TX0cY89feyJUQ3Wqt LAOQ== 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=3JhIHkfPXER2LSeOmJbKiWEQW9bfFBjwhiob8Sul5Bk=; b=YoxxOWc1eZWFr1+NQBXbYTQR0w9lQoJW8v7FI6WzaQXXA4VuwKdKRgn43kP4jfTSHu ky/WQeMJg4rdYUE5g+7aWghuhIPBYdLZy3xByLs3Bl7wrBo0EiePvmos6BRMsjDEBQ6a 6XlFge9YtJ6ELrlJ1/j7m6BeU2RHnVITiM4QhxmHmq8U0ux3kY7lnfE3N2BGMoLLYNFP AJyyXLFq9hop8h/GTwVEOXEhv8BLJZc2g/szwmmQGounZ8RqeLbx0sdlHBxqtuIRD4jA TMDvXHkKxpHqGDNf0I6Rz61xCRbZ8eQ7jMX1AKl9XbLg490Kugetn+OEwdhQOz87BUEl xhAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tg4+zMAB; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h17-20020a170902f71100b00189f58ecb7asi14455574plo.151.2022.12.27.12.23.47; Tue, 27 Dec 2022 12:23:57 -0800 (PST) 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=Tg4+zMAB; 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 S230304AbiL0T5H (ORCPT + 66 others); Tue, 27 Dec 2022 14:57:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbiL0T5F (ORCPT ); Tue, 27 Dec 2022 14:57:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D12662B6; Tue, 27 Dec 2022 11:57:04 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 8B8B6B810A9; Tue, 27 Dec 2022 19:57:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92810C433EF; Tue, 27 Dec 2022 19:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672171022; bh=ROrHr4rQEbBVSusuDkPZQbj47+FTbTSpcuR7ZWvb2vc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tg4+zMABiHi8H6Q/nzPqPNkkol1qGThUhsrluFNxfLCFfR5Q9EvR8bmNktoqY8wF6 xsbM1hVhvV0VbwzXriICD6BAA6dKggq4SmM3JqwDDhgei8Q6reYk8I/OUbkZIh9XJH S+RWr/y/TOipoc19PIAfzkhmNZPvjsBsWcUI/3Bs2cpuWU76lIsnU7eG53sIehYv8X WWhMn7gb7Ugxrg/QtPsKDS+ZOXSfWlF46zLRBx8eR2CO4ClGFnHU9GgM6IgO7En7on hEDdJxEs9YjUc1KGjYaA4EdbtMymEq/Y4pv+ERyzRRgUsfY6cJeUFtAbby56pZvgnh A8A7VRvup4NWA== From: SeongJae Park To: Matthew Wilcox Cc: SeongJae Park , akpm@linux-foundation.org, alexander.h.duyck@linux.intel.com, paulmck@kernel.org, linux-mm@kvack.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/page_reporting: replace rcu_access_pointer() with rcu_dereference_protected() Date: Tue, 27 Dec 2022 19:56:59 +0000 Message-Id: <20221227195659.2876-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Tue, 27 Dec 2022 19:55:09 +0000 Matthew Wilcox wrote: > On Tue, Dec 27, 2022 at 07:21:58PM +0000, SeongJae Park wrote: > > +++ b/mm/page_reporting.c > > @@ -356,7 +356,7 @@ int page_reporting_register(struct page_reporting_dev_info *prdev) > > mutex_lock(&page_reporting_mutex); > > > > /* nothing to do if already in use */ > > - if (rcu_access_pointer(pr_dev_info)) { > > + if (rcu_dereference_protected(pr_dev_info, true)) { > > Pretty sure that passing a bare 'true' is an antipattern. > Instead, document _what_ lock protects us, ie: > > if (rcu_dereference_protected(pr_dev_info, > lockdep_is_held(&page_reporting_mutex))) { > > Obviously, we took it just one line up, but if code moves around, it > may save us. Good point, agreed. Will do so in the next version. Thanks, SJ