Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp285505pxa; Wed, 19 Aug 2020 00:53:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuyW/Hz1BX8Kt8qk7BfkanvWkNDmFgI2jMZhc5PGSJ+WlP2oixA1iOtjVuJocfa+wMeGx8 X-Received: by 2002:a17:906:a4b:: with SMTP id x11mr25250911ejf.83.1597823593884; Wed, 19 Aug 2020 00:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597823593; cv=none; d=google.com; s=arc-20160816; b=vi9FLQQ5l6j0nskC/7yEKuQJjYlK6IK3KUANI+YPQRExHHbp+xcX5XXqEq21sZ4K3O qqPxPPaWBGdnLw+MaYoAgXD+eUypHnMKCfYjYkFhyPF1e7WPcDzNTOwh90EOeSNyTEl6 02uqaPmyN7Q/llTKXx17iirNycs7pvHDjVrZUeiMyxkUEfpbQjmQnQrSM37Z04SwwDsc Xl5gTRnEGBzBEAR5b4t0lHwUhqJ1Czt7Imq8eU+rwUTsah+NN5nNleAKkfl9yVuXjrpN WJuNHLcHjhn/cv+l4Hzv8l7a2Vh2nonhxZkeDwpPJaD4L2HVWrxKbFx//a+nKmeV7uYn 6hiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=dGU8YX5ZeuKU6NCZU/jHHASNHHPlvDTgViPgJHU14KA=; b=Rtjh74VByzPly8rnPOnt1CQ1w1UrE1dPVGXTfhFIxuQUvVi5ulMLAyOEa4ayj1q2Uo ucu5J8cLaQpklQKIb4RLrKXzX19Aib/c5FHYgQh8gOaxKOF1vwl5oOZ7hifaM6RLOh+v ZsqfRaGhdnGVNbmhKeoNHR6YFsufRyyteZqpXe0Qkl9ZvUI4o7vhaqHIB9phYSQPs4mG hUVRwqSgXbEBowk9pJHWXHo0lTUu8Sv53qjfPvllyDtWxEvmE47DzpYVxPbgfVoOGu3r IYwQV9Rr9Sln6tetnPkxoyMjjhF9B5bcRkCrJraqQAoL45xemVkpsA/hEsftvhEeYsu8 Oy9g== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si14318099edi.330.2020.08.19.00.52.50; Wed, 19 Aug 2020 00:53:13 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726750AbgHSHwL (ORCPT + 99 others); Wed, 19 Aug 2020 03:52:11 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:37520 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbgHSHwJ (ORCPT ); Wed, 19 Aug 2020 03:52:09 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R991e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0U6D1B9t_1597823522; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U6D1B9t_1597823522) by smtp.aliyun-inc.com(127.0.0.1); Wed, 19 Aug 2020 15:52:03 +0800 Subject: Re: [RFC PATCH v2 3/5] mm: Add explicit page decrement in exception path for isolate_lru_pages To: Alexander Duyck Cc: yang.shi@linux.alibaba.com, lkp@intel.com, rong.a.chen@intel.com, khlebnikov@yandex-team.ru, kirill@shutemov.name, hughd@google.com, linux-kernel@vger.kernel.org, daniel.m.jordan@oracle.com, linux-mm@kvack.org, shakeelb@google.com, willy@infradead.org, hannes@cmpxchg.org, tj@kernel.org, cgroups@vger.kernel.org, akpm@linux-foundation.org, richard.weiyang@gmail.com, mgorman@techsingularity.net, iamjoonsoo.kim@lge.com References: <20200819041852.23414.95939.stgit@localhost.localdomain> <20200819042722.23414.2654.stgit@localhost.localdomain> From: Alex Shi Message-ID: Date: Wed, 19 Aug 2020 15:50:50 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200819042722.23414.2654.stgit@localhost.localdomain> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/8/19 下午12:27, Alexander Duyck 写道: > From: Alexander Duyck > > In isolate_lru_pages we have an exception path where if we call > get_page_unless_zero and that succeeds, but TestClearPageLRU fails we call > put_page. Normally this would be problematic but due to the way that the > calls are ordered and the fact that we are holding the LRU lock we know > that the caller must be holding another reference for the page. Since we > can assume that we can replace the put_page with a call to > put_page_testzero contained within a WARN_ON. By doing this we should see > if we ever leak a page as a result of the reference count somehow hitting > zero when it shouldn't, and can avoid the overhead and confusion of using > the full put_page call. > > Signed-off-by: Alexander Duyck > --- > mm/vmscan.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 5bc0c2322043..3ebe3f9b653b 100644 > --- a/mm/vmscan.c > +++ 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)); seems WARN_ON is always enabled. Reviewed-by: Alex Shi > goto busy; > } > >