From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0630C47082 for ; Tue, 8 Jun 2021 14:33:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1F002610C7 for ; Tue, 8 Jun 2021 14:33:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F002610C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 898B76B006C; Tue, 8 Jun 2021 10:33:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86F5E6B006E; Tue, 8 Jun 2021 10:33:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 737CD6B0070; Tue, 8 Jun 2021 10:33:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 3FF9E6B006C for ; Tue, 8 Jun 2021 10:33:36 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C6E42181AC544 for ; Tue, 8 Jun 2021 14:33:35 +0000 (UTC) X-FDA: 78230799990.25.C4B8DDD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 38C7B801914F for ; Tue, 8 Jun 2021 14:33:32 +0000 (UTC) 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=4gjD/K0RJIVOtwu8+/5+d0vDpUi8ABWWXPFBzL4weg8=; b=UITrtrWpm90OSbQcoyBOBGZa3/ SrJ1Biu7Q+XI522VJu3OFQzRWy8CEPLaLie1ja2zMeyIv12VnfARLe4W32E8qMSJ+XDhSeECxEi4Q ppo327v1ac7wuvd85OwRejz4KLtWcUz7B6S4/ywvIb9ZFJco8gGyA3BYs/uyiiMeKkM0Cu5SxlfzD Y3iIUFcH6PFVZv2n2Q7AVgo1jSxQTJEyTQVtkiFIuS7AyP+v27np25IYD0qPywAiNRoeY+l2Q7i3T X9rcervGoEKO0mCXTl6gAQojwYO7t8LbQbVMzyul7lzuvTl0v3t9qNzPrxzodGilEekqSm2P+kYDB dURgv8Yg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lqcmv-00H1bz-KR; Tue, 08 Jun 2021 14:33:12 +0000 Date: Tue, 8 Jun 2021 15:33:05 +0100 From: Matthew Wilcox To: Liam Howlett Cc: Alex Sierra , "akpm@linux-foundation.org" , "Felix.Kuehling@amd.com" , "linux-mm@kvack.org" , "rcampbell@nvidia.com" , "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "hch@lst.de" , "jgg@nvidia.com" , "jglisse@redhat.com" Subject: Re: [RFC PATCH v2 1/8] ext4/xfs: add page refcount helper Message-ID: References: <20210607204226.7743-1-alex.sierra@amd.com> <20210607204226.7743-2-alex.sierra@amd.com> <20210608002858.gegg6sl2z2dwwstb@revolver> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210608002858.gegg6sl2z2dwwstb@revolver> Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UITrtrWp; dmarc=none; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Stat-Signature: eab6jmhzaj5xgswimfbcja845kmf5jww X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 38C7B801914F X-HE-Tag: 1623162812-180386 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Jun 08, 2021 at 12:29:04AM +0000, Liam Howlett wrote: > * Alex Sierra [210607 16:43]: > > From: Ralph Campbell > > > > There are several places where ZONE_DEVICE struct pages assume a reference > > count == 1 means the page is idle and free. Instead of open coding this, > > add a helper function to hide this detail. > > > > diff --git a/include/linux/dax.h b/include/linux/dax.h > > index b52f084aa643..8909a91cd381 100644 > > --- a/include/linux/dax.h > > +++ b/include/linux/dax.h > > @@ -243,6 +243,16 @@ static inline bool dax_mapping(struct address_space *mapping) > > return mapping->host && IS_DAX(mapping->host); > > } > > > > +static inline bool dax_layout_is_idle_page(struct page *page) > > +{ > > + return page_ref_count(page) == 1; > > +} > > If this races with page_ref_count(page) == 0, then it will return false > that a page is idle when the page is being freed. I don't know the code > well enough to say if this is an issue or not so please let me know. > > For example: > !dax_layout_is_idle_page() will return true in dax_busy_page() above > when the count is 0 and return the page. > > Maybe you are sure to have at least one reference when calling this? It > might be worth adding a comment. You're getting confused by the problem that the next patch fixes, which is that devmap pages were stupidly given an elevated refcount. devmap pages are considered "free" when their refcount is 1. See put_page(), put_devmap_managed_page() and so on.