From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: Re: [PATCH v18 31/32] mm: Add explicit page decrement in exception path for isolate_lru_pages Date: Wed, 9 Sep 2020 18:07:17 +0100 Message-ID: <20200909170717.GK6583@casper.infradead.org> References: <1598273705-69124-1-git-send-email-alex.shi@linux.alibaba.com> <1598273705-69124-32-git-send-email-alex.shi@linux.alibaba.com> <20200909010118.GB6583@casper.infradead.org> Mime-Version: 1.0 Return-path: 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=6BdBPXJ8XQ6dfeqF8dncKUjTFopmPuRS/B/dl8JZcac=; b=hfgEADwyatdZgRCv4HedPewUgr Z5yHyqRWXGgLxnBngNkckmik9vLonqHLyt6/X2g0X64afWCiiVrXixO7LMWLj5L65iwEQ04DOAIqW W0pR5PZbCGyIMkEO713IdjH8mBkU/FmFPGEWPXSQ4hC6jURyfYG6idODxcWpMgdxyrIgUHxZBlLv9 +8rLnXwL1R7IW/voe+UYGk6bwztj7l+VQpqkLfxrHU10aEcahIA7WaxW486c2weui77TBhr9DECJ7 R9nMf6JsMmQTjIHXKEcHK0QPRg1x8DKJJ+iB4U2GbKJNdRsI07LfPl3hXVGRn45fFkhqn6+2MIZzs Xi+cpe4A==; Content-Disposition: inline In-Reply-To: Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Alexander Duyck Cc: Alex Shi , Andrew Morton , Mel Gorman , Tejun Heo , Hugh Dickins , Konstantin Khlebnikov , Daniel Jordan , Johannes Weiner , kbuild test robot , linux-mm , LKML , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Shakeel Butt , Joonsoo Kim , Wei Yang , "Kirill A. Shutemov" , Rong Chen , Michal Hocko , Vladimir Davydov , shy828301-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, Alexander Duyck On Wed, Sep 09, 2020 at 08:43:38AM -0700, Alexander Duyck wrote: > On Tue, Sep 8, 2020 at 6:01 PM Matthew Wilcox wrote: > > > > On Mon, Aug 24, 2020 at 08:55:04PM +0800, Alex Shi wrote: > > > +++ b/mm/vmscan.c > > > @@ -1688,10 +1688,13 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, > > > > > > if (!TestClearPageLRU(page)) { > > > /* > > > - * This page may in other isolation path, > > > - * but we still hold lru_lock. > > > + * This page is being isolated in another > > > + * thread, but we still hold lru_lock. The > > > + * other thread must be holding a reference > > > + * to the page so this should never hit a > > > + * reference count of 0. > > > */ > > > - put_page(page); > > > + WARN_ON(put_page_testzero(page)); > > > goto busy; > > > > I read Hugh's review and that led me to take a look at this. We don't > > do it like this. Use the same pattern as elsewhere in mm: > > > > page_ref_sub(page, nr); > > VM_BUG_ON_PAGE(page_count(page) <= 0, page); > > Actually for this case page_ref_dec(page) would make more sense > wouldn't it? Otherwise I agree that would be a better change if that > is the way it has been handled before. I just wasn't familiar with > those other spots. Yes, page_ref_dec() should be fine. It's hard to remember which of VM_BUG_ON, WARN_ON, etc, compile down to nothing with various CONFIG options, and which ones actually evalauate their arguments. Safer not to put things with side-effects inside macros.