Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp477269pxk; Wed, 9 Sep 2020 10:09:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYkkJJbxAW3gl93aBSEalvtTQnbPbDlAXDMU8zo/R7idQHIIENCKjIRLvhRjcdc0I8pXpP X-Received: by 2002:a17:906:194b:: with SMTP id b11mr4541950eje.159.1599671370255; Wed, 09 Sep 2020 10:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599671370; cv=none; d=google.com; s=arc-20160816; b=mpM8iPecloNCSk9XYjZ5gDzn5R5Df91dhTS3MZAU1uj/mDkpFOtqgmN/Ue4vdf98dw RokRPZiLKSp6raB2E0DgnI2IFCpzU8PsXGgK9eoyvOduNspriRj87zFUKz4D5CGEUoDz V6dvkUkTjAOvwQPr8PwhRS8bSHTp2uzGPU6mnArVmsumsvqnMq65E0dA3/cFtE44bmgP 0rmIDMT7kyds2YldmjzIMpJN6KsMa3ipYuUhxEAxoyKmNCNW1x7rgfaQmb5XBhtLb5QB ski7EtnOFPXjyL7Pl0cfMdL/OJAi8MFzyjmrYvqZEsIvq2aXpG+v/rMAqzSbaJwYy3QQ DUSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6BdBPXJ8XQ6dfeqF8dncKUjTFopmPuRS/B/dl8JZcac=; b=bFSvfaYnPNKq3rqCEjwPgXy1+hdOg8SxdwB3gKZ2j8IkKhdNcYJujP0iwieWYLAAgN xu5p/3ic73p9iUBpMjKJd68V/ywHQtBnFK2JVwx5QbOeQWJawq21J0auwu7iSlcqt4bV nbMDVbrymRPMxi8a/uQYkJ0KnSxrpvuuEgBxLfJ/31oCcOHu5O8rPst3xKUkvBlvYgcJ FZ6wYs6w8mjkWJs365qs03SgwgigsOWBnOLCZTCTA1XANK7sO9Y4PY5pMlA2cZul0jUI yiAm/8Y4zXDSfS9dAq0ecbbICECYaXQBqwVzUKCsUJUs1/fcqMJIPAhvi66z8W08rnyO FlYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=hfgEADwy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si1968278ejz.365.2020.09.09.10.09.07; Wed, 09 Sep 2020 10:09:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=hfgEADwy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730704AbgIIRIG (ORCPT + 99 others); Wed, 9 Sep 2020 13:08:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729479AbgIIRHv (ORCPT ); Wed, 9 Sep 2020 13:07:51 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D00DC061573; Wed, 9 Sep 2020 10:07:51 -0700 (PDT) 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==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kG3Yz-0008CM-44; Wed, 09 Sep 2020 17:07:17 +0000 Date: Wed, 9 Sep 2020 18:07:17 +0100 From: Matthew Wilcox 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@vger.kernel.org, Shakeel Butt , Joonsoo Kim , Wei Yang , "Kirill A. Shutemov" , Rong Chen , Michal Hocko , Vladimir Davydov , shy828301@gmail.com, Alexander Duyck Subject: Re: [PATCH v18 31/32] mm: Add explicit page decrement in exception path for isolate_lru_pages 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.