Message ID | 20230302144926.40012-1-wangkefeng.wang@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4265754wrd; Thu, 2 Mar 2023 06:34:55 -0800 (PST) X-Google-Smtp-Source: AK7set9KAAn/MsFjnwdZuwid2PDU4GqhU88IRzK8VCPkSVL0km3cTuuiOfsUe+GYzV5vozbcYCDx X-Received: by 2002:aa7:cc0e:0:b0:4af:5ff1:8756 with SMTP id q14-20020aa7cc0e000000b004af5ff18756mr10621431edt.0.1677767695211; Thu, 02 Mar 2023 06:34:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677767695; cv=none; d=google.com; s=arc-20160816; b=Bkf0I9XUCrTPGm4nJY3xMqxmA9grnLDo4qpjLe16ql+ZdB9lw8V6HtjUQ8zTpMWfIS DyKtpq76otXDGDI44AwWsg94Zv3xc9zAKD9KYIumgkO+M11Od2RZ46XdrhvWdzqut799 P1D/XsDusH3RHeNhaK2wYBEAb2bMZpSWzXkU3upBKj7cMz3FguhfyyqNMI3wUHA0yVe3 lV3GnGthtc2L5NdOfTO/EnhGMWCvEuxHxQ0Uciu7+WKwpFahvXFETwVS19dXs4A0BNUa vkgR1hlafqxiLVciGo1idjmxndPZx2mJ68/Jn4E5E2d7bEg1HnCZwFaQvNk+VDzpywlE wodQ== 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=Z2VtlejJQUVI6btVxDqpwb24r7VVC9zOmonVzo8yC2E=; b=Zu3FLqyf+vnOma4g7jlk45G4WPrStzAwcrhGM88pLda6tv8rmUP8G67RiB8ZQqR/FJ koHTtEUCxMJ4QNcQJRZEcOe8y82bxPpNAOswty9JNvODRvtSNdzgsc6/D9KI5a1SCPYX V1yvQLL1mpbWsTcDofE0xJK/Qm99lvRb7njcnlvEYtPw6FP/+Wj2KtIP813pbpaSBKi9 vSCl+IF5s1lGYDLxRlVRPcAsWqXrb1iFz5wqxbIzTJkA0mNv73N+ZjVtBOiagU8I5lHI iKDkICPNbvybIKHQPFYExN4Cutruxq6n3/I6iXcUhnQN/ayIUsOUCRBh8J0eU5jtOjmy Gu4A== 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 n2-20020a170906118200b008cc4457c734si9891058eja.783.2023.03.02.06.34.32; Thu, 02 Mar 2023 06:34:55 -0800 (PST) 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 S229780AbjCBO3S (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Thu, 2 Mar 2023 09:29:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbjCBO3Q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Mar 2023 09:29:16 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE0D119698 for <linux-kernel@vger.kernel.org>; Thu, 2 Mar 2023 06:29:07 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4PSCyq3R4pzKmK3; Thu, 2 Mar 2023 22:24:03 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 2 Mar 2023 22:29:03 +0800 From: Kefeng Wang <wangkefeng.wang@huawei.com> To: SeongJae Park <sj@kernel.org>, Andrew Morton <akpm@linux-foundation.org> CC: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>, <damon@lists.linux.dev>, Kefeng Wang <wangkefeng.wang@huawei.com> Subject: [PATCH -next] mm/damon/paddr: minor refactor of damon_pa_pageout() Date: Thu, 2 Mar 2023 22:49:26 +0800 Message-ID: <20230302144926.40012-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) 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 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?1759266938524612890?= X-GMAIL-MSGID: =?utf-8?q?1759266938524612890?= |
Series |
[-next] mm/damon/paddr: minor refactor of damon_pa_pageout()
|
|
Commit Message
Kefeng Wang
March 2, 2023, 2:49 p.m. UTC
Omit two lines by converting if(!folio_isolate_lru()) to
if(folio_isolate_lru()).
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/damon/paddr.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
Comments
Hi Kefeng, On Thu, 2 Mar 2023 22:49:26 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > Omit two lines by converting if(!folio_isolate_lru()) to > if(folio_isolate_lru()). > > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > --- > mm/damon/paddr.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > index 6c655d9b5639..a557f3c9300f 100644 > --- a/mm/damon/paddr.c > +++ b/mm/damon/paddr.c > @@ -246,14 +246,12 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) > > folio_clear_referenced(folio); > folio_test_clear_young(folio); > - if (!folio_isolate_lru(folio)) { > - folio_put(folio); > - continue; > + if (folio_isolate_lru(folio)) { > + if (folio_test_unevictable(folio)) > + folio_putback_lru(folio); > + else > + list_add(&folio->lru, &folio_list); > } > - if (folio_test_unevictable(folio)) > - folio_putback_lru(folio); > - else > - list_add(&folio->lru, &folio_list); > folio_put(folio); > } This looks ok to me, thank you for your effort! Nevertheless, I don't like increasing depth as much as number of lines. The more-than-3-levels-of-indentation[1] warning is not always right, but this 4 levels of indentation is not making me so exciting. What do you think about adding put_continue label and using it, not only here, but also above part? For example: --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -239,21 +239,18 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) if (!folio) continue; - if (damos_pa_filter_out(s, folio)) { - folio_put(folio); - continue; - } + if (damos_pa_filter_out(s, folio)) + goto put_continue; folio_clear_referenced(folio); folio_test_clear_young(folio); - if (!folio_isolate_lru(folio)) { - folio_put(folio); - continue; - } + if (!folio_isolate_lru(folio)) + goto put_continue; if (folio_test_unevictable(folio)) folio_putback_lru(folio); else list_add(&folio->lru, &folio_list); +put_continue: folio_put(folio); } applied = reclaim_pages(&folio_list); It omits three lines. $ git diff --stat mm/damon/paddr.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) [1] https://docs.kernel.org/process/coding-style.html#indentation Thanks, SJ > applied = reclaim_pages(&folio_list); > -- > 2.35.3 > >
On 2023/3/3 0:47, SeongJae Park wrote: > Hi Kefeng, > > On Thu, 2 Mar 2023 22:49:26 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > >> Omit two lines by converting if(!folio_isolate_lru()) to >> if(folio_isolate_lru()). >> >> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> >> --- >> mm/damon/paddr.c | 12 +++++------- >> 1 file changed, 5 insertions(+), 7 deletions(-) >> >> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c >> index 6c655d9b5639..a557f3c9300f 100644 >> --- a/mm/damon/paddr.c >> +++ b/mm/damon/paddr.c >> @@ -246,14 +246,12 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) >> >> folio_clear_referenced(folio); >> folio_test_clear_young(folio); >> - if (!folio_isolate_lru(folio)) { >> - folio_put(folio); >> - continue; >> + if (folio_isolate_lru(folio)) { >> + if (folio_test_unevictable(folio)) >> + folio_putback_lru(folio); >> + else >> + list_add(&folio->lru, &folio_list); >> } >> - if (folio_test_unevictable(folio)) >> - folio_putback_lru(folio); >> - else >> - list_add(&folio->lru, &folio_list); >> folio_put(folio); >> } > > This looks ok to me, thank you for your effort! Nevertheless, I don't like > increasing depth as much as number of lines. The > more-than-3-levels-of-indentation[1] warning is not always right, but this 4 > levels of indentation is not making me so exciting. > > What do you think about adding put_continue label and using it, not only here, > but also above part? For example: > > --- a/mm/damon/paddr.c > +++ b/mm/damon/paddr.c > @@ -239,21 +239,18 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) > if (!folio) > continue; > > - if (damos_pa_filter_out(s, folio)) { > - folio_put(folio); > - continue; > - } > + if (damos_pa_filter_out(s, folio)) > + goto put_continue; > > folio_clear_referenced(folio); > folio_test_clear_young(folio); > - if (!folio_isolate_lru(folio)) { > - folio_put(folio); > - continue; > - } > + if (!folio_isolate_lru(folio)) > + goto put_continue; > if (folio_test_unevictable(folio)) > folio_putback_lru(folio); > else > list_add(&folio->lru, &folio_list); > +put_continue: > folio_put(folio); > } > applied = reclaim_pages(&folio_list); > > It omits three lines. It looks good, will update, thanks > > $ git diff --stat > mm/damon/paddr.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > [1] https://docs.kernel.org/process/coding-style.html#indentation > > > Thanks, > SJ > >> applied = reclaim_pages(&folio_list); >> -- >> 2.35.3 >> >>
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 6c655d9b5639..a557f3c9300f 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -246,14 +246,12 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) folio_clear_referenced(folio); folio_test_clear_young(folio); - if (!folio_isolate_lru(folio)) { - folio_put(folio); - continue; + if (folio_isolate_lru(folio)) { + if (folio_test_unevictable(folio)) + folio_putback_lru(folio); + else + list_add(&folio->lru, &folio_list); } - if (folio_test_unevictable(folio)) - folio_putback_lru(folio); - else - list_add(&folio->lru, &folio_list); folio_put(folio); } applied = reclaim_pages(&folio_list);