Message ID | 20230625113430.2310385-1-linmiaohe@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6867435vqr; Sun, 25 Jun 2023 04:44:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tIQ4JEXRPNxuWva0B+f6Ly00GhcMXSNt/BiDOB7yt3Au8T5LbrH9SbVzuhhWClhewNsC0 X-Received: by 2002:a9d:7a41:0:b0:6b7:431c:15f3 with SMTP id z1-20020a9d7a41000000b006b7431c15f3mr948831otm.28.1687693490340; Sun, 25 Jun 2023 04:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687693490; cv=none; d=google.com; s=arc-20160816; b=qQb/WImQRbM/p2y68MG7QJMwz6ZUfSlbbA8oMZXWrFobBMDIKqBFcfA/vnWvlhppae pyYe+NwawhSEHGWuqefnJ2sL+2qpJc69ruLt77Hy7MG2KYSbMnk5+QKPi9ZyXTuuUsy3 lz+Md544Srt2S67z3RC7Lz7DpA1E9Ldz3CNvANC44g8rrF6bO4goKNzhI6VmXKBqq6mr uMd9peDAvjpWhw+1h5FW7riCSIfeVAYOP96MaUVLqXqlr9WI/mmC27X4lGP2PIwDu+QO IOxQzGnZ540gDMHMN5NrBakx6vJ7OhG/zYt9SEJ7FquTE9ZAkdEx2p7/KHU/B+/sz1RF 1AOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=tOC++tU4W4STc1R30H22nsbSI+PtW50raUlbzJSHYV0=; fh=kP0L7jzW604qIlwIWwCV4xHGxfeYL9qfthvX96QEubA=; b=UWYL5nXRx2OwsG5BYjFTBhC5NkLME4/TdWQCuh0vksADZLotI3nf+/fvPTbz1K4RYm TKi0NtCNFzkiJMln7XqEpROH7cxcnIm0TnTUms68fPDr4ZtXDXmNlZfN32k6xQnx/OoU Lu+pAsXkdfOtB4pn/Lkue75cL1sv0Pcsc+yz7uzlE+9rngNE324OG6MQknipyID5JAM7 IuraotL8i2+BwgUwq/jNiGOZ68j/lqBOu5WnCu1Mqz5MXhMj6I8fiKZnFN30MzmCDhG+ fQGbubQuKCSFpMUDavEm8FicIxjYztJjCWqDlDZH0qiNyagHS/dYTaEtlL3kYbfAlvLG kAlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u34-20020a634722000000b0051b9ce24708si2927492pga.103.2023.06.25.04.44.38; Sun, 25 Jun 2023 04:44:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231970AbjFYLfT (ORCPT <rfc822;duw91626@gmail.com> + 99 others); Sun, 25 Jun 2023 07:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231482AbjFYLfR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 25 Jun 2023 07:35:17 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D569106 for <linux-kernel@vger.kernel.org>; Sun, 25 Jun 2023 04:35:15 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Qppmg6DLJz1HC9K; Sun, 25 Jun 2023 19:34:59 +0800 (CST) Received: from huawei.com (10.175.104.170) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sun, 25 Jun 2023 19:35:11 +0800 From: Miaohe Lin <linmiaohe@huawei.com> To: <akpm@linux-foundation.org>, <naoya.horiguchi@nec.com> CC: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>, <linmiaohe@huawei.com> Subject: [PATCH] mm: memory-failure: remove unneeded page state check in shake_page() Date: Sun, 25 Jun 2023 19:34:30 +0800 Message-ID: <20230625113430.2310385-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.170] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769674889365930036?= X-GMAIL-MSGID: =?utf-8?q?1769674889365930036?= |
Series |
mm: memory-failure: remove unneeded page state check in shake_page()
|
|
Commit Message
Miaohe Lin
June 25, 2023, 11:34 a.m. UTC
Remove unneeded PageLRU(p) and is_free_buddy_page(p) check as slab caches
are not shrunk now. This check can be added back when a lightweight range
based shrinker is available.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/memory-failure.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Comments
On Sun, Jun 25, 2023 at 07:34:30PM +0800, Miaohe Lin wrote: > Remove unneeded PageLRU(p) and is_free_buddy_page(p) check as slab caches > are not shrunk now. This check can be added back when a lightweight range > based shrinker is available. I think your logic is faulty. Based on the reasoning above, this patch should be: > - if (!PageSlab(p)) { > - lru_add_drain_all(); > - if (PageLRU(p) || is_free_buddy_page(p)) > - return; > - } > + if (PageSlab(p)) > + return; > + > + lru_add_drain_all(); + if (PageLRU(p) || is_free_buddy_page(p)) + return; but maybe it's the description that is wrong.
On Sun, Jun 25, 2023 at 07:34:30PM +0800, Miaohe Lin wrote: > Remove unneeded PageLRU(p) and is_free_buddy_page(p) check as slab caches > are not shrunk now. This check can be added back when a lightweight range > based shrinker is available. On further review, I think you've misunderstood the entire situation here and no patch should be applied. > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> > --- > mm/memory-failure.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 5b663eca1f29..92f951df3e87 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -373,11 +373,10 @@ void shake_page(struct page *p) > if (PageHuge(p)) > return; > > - if (!PageSlab(p)) { > - lru_add_drain_all(); > - if (PageLRU(p) || is_free_buddy_page(p)) > - return; > - } > + if (PageSlab(p)) > + return; > + > + lru_add_drain_all(); > > /* > * TODO: Could shrink slab caches here if a lightweight range-based > -- > 2.27.0 > >
On Sun, Jun 25, 2023 at 07:34:30PM +0800, Miaohe Lin wrote: > Remove unneeded PageLRU(p) and is_free_buddy_page(p) check as slab caches > are not shrunk now. This check can be added back when a lightweight range > based shrinker is available. > > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> This looks to me a good cleanup because the result of "if (PageLRU(p) || is_free_buddy_page(p))" check is not used, so the check itself is unneeded. > --- > mm/memory-failure.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 5b663eca1f29..92f951df3e87 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -373,11 +373,10 @@ void shake_page(struct page *p) > if (PageHuge(p)) > return; > > - if (!PageSlab(p)) { > - lru_add_drain_all(); > - if (PageLRU(p) || is_free_buddy_page(p)) > - return; > - } > + if (PageSlab(p)) > + return; > + > + lru_add_drain_all(); > > /* > * TODO: Could shrink slab caches here if a lightweight range-based I think that this TODO comment can be put together with "if (PageSlab)" block. Thanks, Naoya Horiguchi
On 2023/6/26 3:50, Matthew Wilcox wrote: > On Sun, Jun 25, 2023 at 07:34:30PM +0800, Miaohe Lin wrote: >> Remove unneeded PageLRU(p) and is_free_buddy_page(p) check as slab caches >> are not shrunk now. This check can be added back when a lightweight range >> based shrinker is available. > > On further review, I think you've misunderstood the entire situation > here and no patch should be applied. Thanks for your review. I think you might misunderstood the patch. What I want to do here is remove the unneeded if block: if (PageLRU(p) || is_free_buddy_page(p)) return; Because nothing is done after the check. So this check is useless and should be removed. Thanks.
On 2023/6/26 8:52, Naoya Horiguchi wrote: > On Sun, Jun 25, 2023 at 07:34:30PM +0800, Miaohe Lin wrote: >> Remove unneeded PageLRU(p) and is_free_buddy_page(p) check as slab caches >> are not shrunk now. This check can be added back when a lightweight range >> based shrinker is available. >> >> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> > > This looks to me a good cleanup because the result of > "if (PageLRU(p) || is_free_buddy_page(p))" check is not used, so the check > itself is unneeded. > >> --- >> mm/memory-failure.c | 9 ++++----- >> 1 file changed, 4 insertions(+), 5 deletions(-) >> >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >> index 5b663eca1f29..92f951df3e87 100644 >> --- a/mm/memory-failure.c >> +++ b/mm/memory-failure.c >> @@ -373,11 +373,10 @@ void shake_page(struct page *p) >> if (PageHuge(p)) >> return; >> >> - if (!PageSlab(p)) { >> - lru_add_drain_all(); >> - if (PageLRU(p) || is_free_buddy_page(p)) >> - return; >> - } >> + if (PageSlab(p)) >> + return; >> + >> + lru_add_drain_all(); >> >> /* >> * TODO: Could shrink slab caches here if a lightweight range-based > > I think that this TODO comment can be put together with "if (PageSlab)" block. Thanks for your comment and advice. Do you mean something like below? diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5b663eca1f29..66e7b3ceaf2d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -372,17 +372,14 @@ void shake_page(struct page *p) { if (PageHuge(p)) return; - - if (!PageSlab(p)) { - lru_add_drain_all(); - if (PageLRU(p) || is_free_buddy_page(p)) - return; - } - /* * TODO: Could shrink slab caches here if a lightweight range-based * shrinker will be available. */ + if (PageSlab(p)) + return; + + lru_add_drain_all(); } EXPORT_SYMBOL_GPL(shake_page); Thanks.
On Mon, Jun 26, 2023 at 09:43:44AM +0800, Miaohe Lin wrote: > On 2023/6/26 8:52, Naoya Horiguchi wrote: > > On Sun, Jun 25, 2023 at 07:34:30PM +0800, Miaohe Lin wrote: > >> Remove unneeded PageLRU(p) and is_free_buddy_page(p) check as slab caches > >> are not shrunk now. This check can be added back when a lightweight range > >> based shrinker is available. > >> > >> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> > > > > This looks to me a good cleanup because the result of > > "if (PageLRU(p) || is_free_buddy_page(p))" check is not used, so the check > > itself is unneeded. > > > >> --- > >> mm/memory-failure.c | 9 ++++----- > >> 1 file changed, 4 insertions(+), 5 deletions(-) > >> > >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c > >> index 5b663eca1f29..92f951df3e87 100644 > >> --- a/mm/memory-failure.c > >> +++ b/mm/memory-failure.c > >> @@ -373,11 +373,10 @@ void shake_page(struct page *p) > >> if (PageHuge(p)) > >> return; > >> > >> - if (!PageSlab(p)) { > >> - lru_add_drain_all(); > >> - if (PageLRU(p) || is_free_buddy_page(p)) > >> - return; > >> - } > >> + if (PageSlab(p)) > >> + return; > >> + > >> + lru_add_drain_all(); > >> > >> /* > >> * TODO: Could shrink slab caches here if a lightweight range-based > > > > I think that this TODO comment can be put together with "if (PageSlab)" block. > > Thanks for your comment and advice. Do you mean something like below? Yes, this is what I mean. Feel free to add my ack when posting v2. Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Thank you. > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 5b663eca1f29..66e7b3ceaf2d 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -372,17 +372,14 @@ void shake_page(struct page *p) > { > if (PageHuge(p)) > return; > - > - if (!PageSlab(p)) { > - lru_add_drain_all(); > - if (PageLRU(p) || is_free_buddy_page(p)) > - return; > - } > - > /* > * TODO: Could shrink slab caches here if a lightweight range-based > * shrinker will be available. > */ > + if (PageSlab(p)) > + return; > + > + lru_add_drain_all(); > } > EXPORT_SYMBOL_GPL(shake_page); > > Thanks. > >
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5b663eca1f29..92f951df3e87 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -373,11 +373,10 @@ void shake_page(struct page *p) if (PageHuge(p)) return; - if (!PageSlab(p)) { - lru_add_drain_all(); - if (PageLRU(p) || is_free_buddy_page(p)) - return; - } + if (PageSlab(p)) + return; + + lru_add_drain_all(); /* * TODO: Could shrink slab caches here if a lightweight range-based