Message ID | 20230303084343.171958-4-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 v21csp292650wrd; Fri, 3 Mar 2023 00:32:15 -0800 (PST) X-Google-Smtp-Source: AK7set+81wto/jaZCqIshgfDxvpHaY6gb5/iF+6LcYap6oL4/jF32Mz+dy0QPRwB8pmQ+4vM0oOO X-Received: by 2002:aa7:d496:0:b0:4b3:32a9:eda0 with SMTP id b22-20020aa7d496000000b004b332a9eda0mr1187600edr.32.1677832334741; Fri, 03 Mar 2023 00:32:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677832334; cv=none; d=google.com; s=arc-20160816; b=m0NkBZDHoTjEVe1hznSv+oUMGosWwwgjiyEMh+ebscCHoVQPC4yfZSdYelYAmlKcNT yItbf03oivI4W4ztunlnFLY30ulEkv7ZV8VhSxVM7YUXZXe9csQXEFcNe9QVl/G7GMpN oY1tVV4G/TiEpa4TzRiV8oNfMzxreok2lOq98bJcHHEiwEIe9jluBYaNjEDoI8s2xDP4 AMk4LD4VhIFX2rD1T9RzSHXFRjVb3OVIg94a7R4ab6WG9vhgyFR8PjYgBdm1ToWR8wZR mRm3Cc7Uci/xGHIWUv6RMbs6PzttizACCqZ1tCFndJK+4UmBAmBXB6BqzEZNYN8bcIU/ H0dA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nT8uAvYOgS1FhzPAq4yJd4zNvTr6g7LkLszlvw17IDM=; b=gitIbjNn21eGG9eyJ8XBGA3eg/Nlczc3R5Pw1zUeTb4GiEjowC5T4axWhNkQYNTTRL uPhc/Qymzim+mOAtB1hTvDTNbus+Hfh861s8S3rszWVqRIAlqi4nQyvZTSUqXKtKy5Sh MTPlkuYj2+PvfkIwNFp5WPQtwSaZUpOWR58ifse+LTt8ZrgprDal7UXUP9OteTnL7voS Xj+ph/Apqbg55kat+sGuasWEOiuYUMCgv7soJfey+8zOoQcq2rCTeLOkmarIt5DNcVQ1 im3AV2T+2a+MDAVpYg/AvbSf4scapPpT4sdBUgoZwRge6vSj82y/ACTqBavfQ8+sNxnH ex2g== 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 jz13-20020a17090775ed00b008b17b558d68si1471722ejc.229.2023.03.03.00.31.52; Fri, 03 Mar 2023 00:32:14 -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 S230098AbjCCIZG (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Fri, 3 Mar 2023 03:25:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbjCCIZC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Mar 2023 03:25:02 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE24715C9D for <linux-kernel@vger.kernel.org>; Fri, 3 Mar 2023 00:23:32 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PSgsH2VDwz9tKp; Fri, 3 Mar 2023 16:20:51 +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; Fri, 3 Mar 2023 16:22:47 +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 v2 3/3] mm/damon/paddr: minor refactor of damon_pa_mark_accessed_or_deactivate() Date: Fri, 3 Mar 2023 16:43:43 +0800 Message-ID: <20230303084343.171958-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230303084343.171958-1-wangkefeng.wang@huawei.com> References: <20230303084343.171958-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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?1759334718104817037?= X-GMAIL-MSGID: =?utf-8?q?1759334718104817037?= |
Series |
mm/damon/paddr: minor code improvement
|
|
Commit Message
Kefeng Wang
March 3, 2023, 8:43 a.m. UTC
Omit one line by unified folio_put(), and make code more clear.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/damon/paddr.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Comments
On Fri, 3 Mar 2023 16:43:43 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > Omit one line by unified folio_put(), and make code more clear. > > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > --- > mm/damon/paddr.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > index 2ef9db0189ca..6930ebf3667c 100644 > --- a/mm/damon/paddr.c > +++ b/mm/damon/paddr.c > @@ -266,17 +266,16 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( > if (!folio) > continue; > > - if (damos_pa_filter_out(s, folio)) { > - folio_put(folio); > - continue; > - } > + if (damos_pa_filter_out(s, folio)) > + goto put_folio; > > if (mark_accessed) > folio_mark_accessed(folio); > else > folio_deactivate(folio); > - folio_put(folio); > applied += folio_nr_pages(folio); > +put_folio: > + folio_put(folio); I think this change is ok, but shouldn't the 'folio_put()' have called before 'folio_nr_pages()' anyway? If so, could we make the change as a separate fix first, and then make this change, so that it can be easily applied to relevant stable kernels? Thanks, SJ > } > return applied * PAGE_SIZE; > } > -- > 2.35.3 > >
On Fri, 3 Mar 2023 18:26:33 +0000 SeongJae Park <sj@kernel.org> wrote: > On Fri, 3 Mar 2023 16:43:43 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > > > Omit one line by unified folio_put(), and make code more clear. > > > > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > > --- > > mm/damon/paddr.c | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > > index 2ef9db0189ca..6930ebf3667c 100644 > > --- a/mm/damon/paddr.c > > +++ b/mm/damon/paddr.c > > @@ -266,17 +266,16 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( > > if (!folio) > > continue; > > > > - if (damos_pa_filter_out(s, folio)) { > > - folio_put(folio); > > - continue; > > - } > > + if (damos_pa_filter_out(s, folio)) > > + goto put_folio; > > > > if (mark_accessed) > > folio_mark_accessed(folio); > > else > > folio_deactivate(folio); > > - folio_put(folio); > > applied += folio_nr_pages(folio); > > +put_folio: > > + folio_put(folio); > > I think this change is ok, but shouldn't the 'folio_put()' have called before s/before/after/ > 'folio_nr_pages()' anyway? If so, could we make the change as a separate fix > first, and then make this change, so that it can be easily applied to relevant > stable kernels? > > > Thanks, > SJ > > > } > > return applied * PAGE_SIZE; > > } > > -- > > 2.35.3 > > > >
On 2023/3/4 2:37, SeongJae Park wrote: > On Fri, 3 Mar 2023 18:26:33 +0000 SeongJae Park <sj@kernel.org> wrote: > >> On Fri, 3 Mar 2023 16:43:43 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: >> >>> Omit one line by unified folio_put(), and make code more clear. >>> >>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> >>> --- >>> mm/damon/paddr.c | 9 ++++----- >>> 1 file changed, 4 insertions(+), 5 deletions(-) >>> >>> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c >>> index 2ef9db0189ca..6930ebf3667c 100644 >>> --- a/mm/damon/paddr.c >>> +++ b/mm/damon/paddr.c >>> @@ -266,17 +266,16 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( >>> if (!folio) >>> continue; >>> >>> - if (damos_pa_filter_out(s, folio)) { >>> - folio_put(folio); >>> - continue; >>> - } >>> + if (damos_pa_filter_out(s, folio)) >>> + goto put_folio; >>> >>> if (mark_accessed) >>> folio_mark_accessed(folio); >>> else >>> folio_deactivate(folio); >>> - folio_put(folio); >>> applied += folio_nr_pages(folio); >>> +put_folio: >>> + folio_put(folio); >> >> I think this change is ok, but shouldn't the 'folio_put()' have called before > > s/before/after/ > >> 'folio_nr_pages()' anyway? If so, could we make the change as a separate fix >> first, and then make this change, so that it can be easily applied to relevant >> stable kernels? Yes, seem to previous one. >> >> >> Thanks, >> SJ >> >>> } >>> return applied * PAGE_SIZE; >>> } >>> -- >>> 2.35.3 >>> >>>
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 2ef9db0189ca..6930ebf3667c 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -266,17 +266,16 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( if (!folio) continue; - if (damos_pa_filter_out(s, folio)) { - folio_put(folio); - continue; - } + if (damos_pa_filter_out(s, folio)) + goto put_folio; if (mark_accessed) folio_mark_accessed(folio); else folio_deactivate(folio); - folio_put(folio); applied += folio_nr_pages(folio); +put_folio: + folio_put(folio); } return applied * PAGE_SIZE; }