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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74378C433EF for ; Sun, 19 Jun 2022 03:49:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D0E06B0071; Sat, 18 Jun 2022 23:49:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97DF56B0073; Sat, 18 Jun 2022 23:49:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86C0C6B0074; Sat, 18 Jun 2022 23:49:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7491A6B0071 for ; Sat, 18 Jun 2022 23:49:47 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4152F34DDC for ; Sun, 19 Jun 2022 03:49:47 +0000 (UTC) X-FDA: 79593606414.16.4E1B2CB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 2FE1A400AC for ; Sun, 19 Jun 2022 03:49:45 +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=n0V/QlpU6hmWIFdXHN46nESAfJQsfOJKchpQNnTZHFk=; b=lB5e51TpUA5Mdiw/oLqx9Wojzj 4VqegTjVCIv8+QY7VhLBz7QLMc2q6Uit4Al/IVpbO7QEV8yq3eyCKE+HTg9V+Vg4IWpNJIODQb+0T PzAGysuubC3g7J7kVXldRZ6O62EvLRe+CegcNSXSYGCProa4R0/YrMu0JUNuAui5yK9rYjHgvOmqm eIZrSb1SZcULqtGuDbK0VPmD9mUjQZaB9poKaQvDX894BEsanLrTlS4GNkrdqCgl34phyY1LCgewE GpGxEflGAE+cdgTLjjBHAuvXffFfDgRl1L6NGLksyQbdI8r3IOm0iP5CuN6qEM5BPQwTxVXHB+knE 611FfaKw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2lwP-0046RB-4e; Sun, 19 Jun 2022 03:49:37 +0000 Date: Sun, 19 Jun 2022 04:49:37 +0100 From: Matthew Wilcox To: Xiubo Li Cc: Jeff Layton , idryomov@gmail.com, ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] ceph: switch back to testing for NULL folio->private in ceph_dirty_folio Message-ID: References: <20220610154013.68259-1-jlayton@kernel.org> <6189bdb3-6bfa-b85a-8df5-0fe94d7a962a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6189bdb3-6bfa-b85a-8df5-0fe94d7a962a@redhat.com> ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lB5e51Tp; dmarc=none; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655610586; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=n0V/QlpU6hmWIFdXHN46nESAfJQsfOJKchpQNnTZHFk=; b=SiovwjAJ67MotLwC/lkE6Xicrv31xplxm4PKlpI8hxrAJOSd+BGxgwVZGi7YGyp33++5Uy Ya21qgl0+X3poDHgr2O7saP8QRHUlcOvCTSD8WI209XhXVBe8AX9e0YaPo3p+rERqmUgke G9w3TlV+jMEPsX0egFgE7bgeqljWFn0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655610586; a=rsa-sha256; cv=none; b=KQAFucYEBV9aTmEiR10vz+0reCSzEkPTa+coOdkdFWrQq7YP27i96X3xa6RFW432XDfmSl MuAjLmyjTKgW1h2mmLbhTblRDHJsb94AK78y1hiiM5HEPGJnlRaB98BJrBV6onBZ0kpDYN V9uWgvrrPx+okBuhQvyH2nRHvAchanw= X-Stat-Signature: s8aytzsk6zrh8u3jquxfieq6c638mqua X-Rspamd-Queue-Id: 2FE1A400AC X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lB5e51Tp; dmarc=none; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam10 X-HE-Tag: 1655610585-519351 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 Mon, Jun 13, 2022 at 08:48:40AM +0800, Xiubo Li wrote: > > On 6/10/22 11:40 PM, Jeff Layton wrote: > > Willy requested that we change this back to warning on folio->private > > being non-NULl. He's trying to kill off the PG_private flag, and so we'd > > like to catch where it's non-NULL. > > > > Add a VM_WARN_ON_FOLIO (since it doesn't exist yet) and change over to > > using that instead of VM_BUG_ON_FOLIO along with testing the ->private > > pointer. > > > > Cc: Matthew Wilcox > > Signed-off-by: Jeff Layton > > --- > > fs/ceph/addr.c | 2 +- > > include/linux/mmdebug.h | 9 +++++++++ > > 2 files changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c > > index b43cc01a61db..b24d6bdb91db 100644 > > --- a/fs/ceph/addr.c > > +++ b/fs/ceph/addr.c > > @@ -122,7 +122,7 @@ static bool ceph_dirty_folio(struct address_space *mapping, struct folio *folio) > > * Reference snap context in folio->private. Also set > > * PagePrivate so that we get invalidate_folio callback. > > */ > > - VM_BUG_ON_FOLIO(folio_test_private(folio), folio); > > + VM_WARN_ON_FOLIO(folio->private, folio); > > folio_attach_private(folio, snapc); > > return ceph_fscache_dirty_folio(mapping, folio); I found a couple of places where page->private needs to be NULLed out. Neither of them are Ceph's fault. I decided that testing whether folio->private and PG_private are in agreement was better done in folio_unlock() than in any of the other potential places we could check for it. diff --git a/mm/filemap.c b/mm/filemap.c index 8ef861297ffb..acef71f75e78 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1535,6 +1535,9 @@ void folio_unlock(struct folio *folio) BUILD_BUG_ON(PG_waiters != 7); BUILD_BUG_ON(PG_locked > 7); VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); + VM_BUG_ON_FOLIO(!folio_test_private(folio) && + !folio_test_swapbacked(folio) && + folio_get_private(folio), folio); if (clear_bit_unlock_is_negative_byte(PG_locked, folio_flags(folio, 0))) folio_wake_bit(folio, PG_locked); } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 2e2a8b5bc567..af0751a79c19 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2438,6 +2438,7 @@ static void __split_huge_page_tail(struct page *head, int tail, page_tail); page_tail->mapping = head->mapping; page_tail->index = head->index + tail; + page_tail->private = 0; /* Page flags must be visible before we make the page non-compound. */ smp_wmb(); diff --git a/mm/migrate.c b/mm/migrate.c index eb62e026c501..fa8e36e74f0d 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1157,6 +1157,8 @@ static int unmap_and_move(new_page_t get_new_page, newpage = get_new_page(page, private); if (!newpage) return -ENOMEM; + BUG_ON(compound_order(newpage) != compound_order(page)); + newpage->private = 0; rc = __unmap_and_move(page, newpage, force, mode); if (rc == MIGRATEPAGE_SUCCESS)