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=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 22F59C433DF for ; Wed, 19 Aug 2020 14:52:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9F7612083B for ; Wed, 19 Aug 2020 14:52:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VNV2FDB4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F7612083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 33CA16B00B8; Wed, 19 Aug 2020 10:52:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EA926B00BA; Wed, 19 Aug 2020 10:52:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DA826B00BB; Wed, 19 Aug 2020 10:52:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 073AE6B00B8 for ; Wed, 19 Aug 2020 10:52:22 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B832C2489 for ; Wed, 19 Aug 2020 14:52:21 +0000 (UTC) X-FDA: 77167608882.13.scent80_4515bf727028 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 84AF118140B60 for ; Wed, 19 Aug 2020 14:52:21 +0000 (UTC) X-HE-Tag: scent80_4515bf727028 X-Filterd-Recvd-Size: 6145 Received: from mail-il1-f195.google.com (mail-il1-f195.google.com [209.85.166.195]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Aug 2020 14:52:20 +0000 (UTC) Received: by mail-il1-f195.google.com with SMTP id k4so20870963ilr.12 for ; Wed, 19 Aug 2020 07:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=tScvbNwkYnRqhhATPJ7UjpnLY9tTLi+iAPlBc9rB3iY=; b=VNV2FDB4prOhD7krvEKqNRccc1tIE3ic5uWeIuDwt90ZWFOeL9havI3q4VWlHeDNlD uX4QctT6sFkcZWlNwOUZBAhC/iupzupsuaErPhzT+hlDNLUmnr4kgfjEGWXt8gMext8c cwcsyhcty5Qifn13F1KfJQf+979yllT0BJpyWnMYHpQWw+goI30FSA2OJ9jnDoHnwrvx idKl3jZ7EBFt5GgiHIEFz8JalGse5Hvwjr4tsZsSU9/99CqD/yc0FyUux/NERNg/tT9L /GQFmg6aYSFpKCG/utfJlBNzWbz8PKJEZx5Th8eOvf+1KdoanUNVoXNh55++qa10pIl2 gQIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tScvbNwkYnRqhhATPJ7UjpnLY9tTLi+iAPlBc9rB3iY=; b=kKXQbCnuMxCqjd4dSqjQTGobB3vobBaXfm4BgSnq8PRo40D5WqKmxiUl8ztk6G3duN SsL2zcyS5Wm3rsu8UU20mPKGrw45T2Mm36w5OlkhMVbEbv5O5PH8VmJrel6re4suwqKw snfEwb6gevpQ2WFFLSrX0DAFZBgER3rOOoxCSEhiFFaW8+BJLxaNaCAQl7/2agGWQInf kfyYkaoh9F6vy/nslMtZXIimzSxmqMeIkz/QTEtNsp77ZNs5w+hSQ9a4rzDDxmmDsqPS f+jFAOLWxhg/ujiUSP+lGL4Y4yL9xNNKrrBJxdV9K7jjoJmQ+VZf652Q+nUsMYwUr5i4 tacw== X-Gm-Message-State: AOAM532Ks8Rp4wDHvvtjaZ1DX5LaameJwfwGDCjcmZuWAy0DQYTHxYI4 yqBkJNXuSxiUsuO1PAr2Txf6UBlYexu2XbIbaM0dLiozVh4= X-Google-Smtp-Source: ABdhPJwvaKUYj/VF7zowJ3yR+UvMpeYHKVrq9VBPQWNGDV7+EQoQY7JPDmxtWwhYzHg4fV4XNvZfKGYiYzHpxjt6gnM= X-Received: by 2002:a92:99d4:: with SMTP id t81mr10297363ilk.95.1597848740262; Wed, 19 Aug 2020 07:52:20 -0700 (PDT) MIME-Version: 1.0 References: <20200819041852.23414.95939.stgit@localhost.localdomain> <20200819042722.23414.2654.stgit@localhost.localdomain> In-Reply-To: From: Alexander Duyck Date: Wed, 19 Aug 2020 07:52:09 -0700 Message-ID: Subject: Re: [RFC PATCH v2 3/5] mm: Add explicit page decrement in exception path for isolate_lru_pages To: Alex Shi Cc: Yang Shi , kbuild test robot , Rong Chen , Konstantin Khlebnikov , "Kirill A. Shutemov" , Hugh Dickins , LKML , Daniel Jordan , linux-mm , Shakeel Butt , Matthew Wilcox , Johannes Weiner , Tejun Heo , cgroups@vger.kernel.org, Andrew Morton , Wei Yang , Mel Gorman , Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 84AF118140B60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 Wed, Aug 19, 2020 at 12:52 AM Alex Shi wrot= e: > > > > =E5=9C=A8 2020/8/19 =E4=B8=8B=E5=8D=8812:27, Alexander Duyck =E5=86=99=E9= =81=93: > > 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 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. > > > > 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. Th= e > > + * other thread must be holding a referen= ce > > + * 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 Yeah, it is always enabled however it should never be triggered. I had considered just putting a page_ref_dec here since in theory this path should never be triggered but I thought as a debug catch I add the WARN_ON and put_page_testzero. If we ever do encounter this being triggered then it will leak a page of memory which isn't the end of the world but I thought would warrant a WARN_ON.