Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3621678rwl; Tue, 27 Dec 2022 12:06:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJ1dAlsm+6gGbm9zAKmbiRMNPDqRrZ1cKlv+QV2D/+aW8fMDoAXJGsyMX5vwWza/tknEsP X-Received: by 2002:a05:6402:7d4:b0:467:f630:7927 with SMTP id u20-20020a05640207d400b00467f6307927mr19734891edy.15.1672171609244; Tue, 27 Dec 2022 12:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672171609; cv=none; d=google.com; s=arc-20160816; b=hjiJtlrZpRElR3LgOI19QZLR9uuI3/1GNY7oYbz3FEC7FI/DLJgOZjSMTg2SzEYbDB Onc9NJZUtOvADFMwJtM3ePjS4p+0+s8+qTWWTdyNcxnwzCXaW6rwvwsGlOrCWol3bT1J 7cmSlYGI61tw6W7CPrWCzJxkXDjw8JJx4S0nz/2kOZ+pCNLuu34HqSWOOtaK4g+M/VWf tVlxx+ag0DCy1S7bWwQLG1uVpNd1gdcZJ6Ja9t67X3m9xeKOUPMz2jBTdU7KneSF4UBF b5rMXmQLTAu3we2+gKdQ8PjYZLwmqyZvTzP94vRUEZlOlShj5WpFipAN4ejRYqTSIali d4lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zpbjvSCk+EA51UMWboDDrs33iyLVu5VoWtLxS3V5gMw=; b=CKd06Nc/4i8XmmjOKOjCBKXgm2Qlzh2qvpfIhGtecc/MbRvreRjEljADIqzp0IVfCC /zPTvPUSz3BvxchGnKJbjhjZu0DwsJZ3tiGrGQwWZDjmt2On/N09aGIpzMtcYlZAzMY+ n4iKzixvqq/+FMQcAu+IBEj3Y/serjj3sYNM94euA+COb7oMaTZI4+g8m1tNnDjBM355 Bwp2XJJKFVx0e18JZM5cKhRCvEtWTSVkD+XcSW3KFYkUqfojaPLYMLMIb4u+EzlYgvBc 4QkiZp/LLrQ71gCi5RM9sEokZ0p3xzcMf3qGYTkiQwKBSjfU7whAvkAhB/rXC88XhrhQ SIfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="f/LnLhtt"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a05640250d300b0046bc9cbd8f0si13013879edb.504.2022.12.27.12.06.26; Tue, 27 Dec 2022 12:06:49 -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=@infradead.org header.s=casper.20170209 header.b="f/LnLhtt"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbiL0TzR (ORCPT + 67 others); Tue, 27 Dec 2022 14:55:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231972AbiL0TzM (ORCPT ); Tue, 27 Dec 2022 14:55:12 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFF3426E0; Tue, 27 Dec 2022 11:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zpbjvSCk+EA51UMWboDDrs33iyLVu5VoWtLxS3V5gMw=; b=f/LnLhttpMtg/qiw0quRr7RVgS tc6p96mH9LqPWEvk93/M7XerMyC+4gENbVshpT2Sed66AubxHDagtrugbFpzn+lmq/jHEGYMVJQVy K1jJaNylZ25/llXQfRQAujlGE2Np/WDAZW7pzg5eHazJ93m4KIfsH3BkYr2Jqf5NdQi90vfoRqbXL FV0tCDN8tMvuyveI9bkl50tDd5WMtYCUmBsszQGXHjCjxdJkOTgS8dY5LnxB+dy92cxAdi3f5cf8A lNXxUu4nDys9QnPmqHekS3P8gjDtvwBoznRZpVOM4gTtgcXb70889+LNUShXfl4/TsZybCidk9EAn NsssFbJQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAG2X-008GpV-Bv; Tue, 27 Dec 2022 19:55:09 +0000 Date: Tue, 27 Dec 2022 19:55:09 +0000 From: Matthew Wilcox To: SeongJae Park Cc: 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() Message-ID: References: <20221227192158.2553-1-sj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221227192158.2553-1-sj@kernel.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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, 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.