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=-12.6 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_SANE_1 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 B54F1C433DF for ; Wed, 19 Aug 2020 07:52:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7166120772 for ; Wed, 19 Aug 2020 07:52:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7166120772 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1440F8D0007; Wed, 19 Aug 2020 03:52:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F6428D0001; Wed, 19 Aug 2020 03:52:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0320F8D0007; Wed, 19 Aug 2020 03:52:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id E09B38D0001 for ; Wed, 19 Aug 2020 03:52:09 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A7331362E for ; Wed, 19 Aug 2020 07:52:09 +0000 (UTC) X-FDA: 77166549978.15.match97_2a0b7a727026 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 75FA11814B0C8 for ; Wed, 19 Aug 2020 07:52:09 +0000 (UTC) X-HE-Tag: match97_2a0b7a727026 X-Filterd-Recvd-Size: 3551 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Aug 2020 07:52:08 +0000 (UTC) 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 X-Rspamd-Queue-Id: 75FA11814B0C8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 Content-Transfer-Encoding: quoted-printable 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: =E5=9C=A8 2020/8/19 =E4=B8=8B=E5=8D=8812:27, Alexander Duyck =E5=86=99=E9= =81=93: > From: Alexander Duyck >=20 > In isolate_lru_pages we have an exception path where if we call > get_page_unless_zero and that succeeds, but TestClearPageLRU fails we c= all > put_page. Normally this would be problematic but due to the way that th= e > 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 w= e > 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 s= ee > if we ever leak a page as a result of the reference count somehow hitti= ng > zero when it shouldn't, and can avoid the overhead and confusion of usi= ng > the full put_page call. >=20 > Signed-off-by: Alexander Duyck > --- > mm/vmscan.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) >=20 > 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, > =20 > 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; > } > =20 >=20