Message ID | 20230303084343.171958-3-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 v21csp292862wrd; Fri, 3 Mar 2023 00:33:04 -0800 (PST) X-Google-Smtp-Source: AK7set/QVLruA0ZQENWmVGGQSAURZ3szIuXWV1KpmmndsS3XA9HKwkq9Va6f/Ftnmmdv5/cb7CJc X-Received: by 2002:aa7:c90f:0:b0:4af:6a7e:9286 with SMTP id b15-20020aa7c90f000000b004af6a7e9286mr1175595edt.6.1677832384141; Fri, 03 Mar 2023 00:33:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677832384; cv=none; d=google.com; s=arc-20160816; b=PmnfXTkuWM2ihDCNf0IVvJZT5YnJvJsVqKOiXU+SN/f/Q02JI/2UQ2xRpRFjy+okVC uzBeqSbB3jz+2prxIur30BwqArkPTTBEFJCQrr1IlEIhFOrXPUFeXdvE4ikHje8rQQty l002PBI9IRn3yBk6gx6JBGt/OgcAIxZI5F098klZI0NxiuWGaU0MdUQVmzN5mAj3B/dP kht8TqyCXsh/azwbslsFNDxH8ZymYZeU6No6RD0jHV03ZHnXG6om8ssX7aQXMEKyP/Cg 3mlwH5mMn28IZ/W3f72pB3Scz+cQ2BfucJmh3R3FLzbMDQ5CxBKEH0lIQHErfABtH6Np 6WyQ== 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=F7kRQcf8rYI3p2XX72xLIeZ9I3gh+WTwueyptmTV+AM=; b=WF+4ifkHn8ahCD9YP0g416Eu0iWfE4XltYo0JTj5GJ+JtqpIjYcqFFMZ+lfQ1H6mga DofyPKh60QPJwVKP3S3s0hf2OY60Db4wnAkZGdxD6iG58v78cPOHEnWxHMfX65ARcbP9 E+CeXTs8owNpgslojhcj/r4ad9/N5IW2tpqoJYitllFSORVJuapACW2GFKQcyk147jQ0 c+ua34a9WA8ZA9km3lwweiYWWRTGdr5Wf+dsg5HbzA+vAC9Xzhng3Ydw4DtbcKCVCYaj PG81wwWwtkgMVLZIc3MoaQUqXso9Rr32habYjaYV1p8Swgo6AwW9bbAxXThJr8LchIcR pwjg== 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 g12-20020a056402180c00b004c0e86b203bsi2097472edy.646.2023.03.03.00.32.41; Fri, 03 Mar 2023 00:33:04 -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 S230105AbjCCIZK (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Fri, 3 Mar 2023 03:25:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjCCIZE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 3 Mar 2023 03:25:04 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC87E65BC for <linux-kernel@vger.kernel.org>; Fri, 3 Mar 2023 00:23:33 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PSgsH2FF9z9tKK; 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 2/3] mm/damon/paddr: minor refactor of damon_pa_young() Date: Fri, 3 Mar 2023 16:43:42 +0800 Message-ID: <20230303084343.171958-3-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?1759334770100435956?= X-GMAIL-MSGID: =?utf-8?q?1759334770100435956?= |
Series |
mm/damon/paddr: minor code improvement
|
|
Commit Message
Kefeng Wang
March 3, 2023, 8:43 a.m. UTC
Omit three lines by unified folio_put(), and make code more clear.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/damon/paddr.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Comments
Hi Kefeng, On Fri, 3 Mar 2023 16:43:42 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > Omit three lines by unified folio_put(), and make code more clear. > > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > --- > mm/damon/paddr.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > index 3fda00a0f786..2ef9db0189ca 100644 > --- a/mm/damon/paddr.c > +++ b/mm/damon/paddr.c > @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) > accessed = false; > else > accessed = true; > - folio_put(folio); > goto out; Because you moved 'out' label to not include *folio_sz setting, folio_sz will not set in this case. It should be set. > } > > need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); > - if (need_lock && !folio_trylock(folio)) { > - folio_put(folio); > - return false; > - } > + if (need_lock && !folio_trylock(folio)) > + goto out; > > rmap_walk(folio, &rwc); > > if (need_lock) > folio_unlock(folio); > - folio_put(folio); > > -out: > *folio_sz = folio_size(folio); > +out: > + folio_put(folio); Before this change, folio_size() is called after folio_put(). Shouldn't it be called before folio_put()? If so, could we make a separate fix for that first, and then make this change on top of it, so that it can be easily applied to relevant stable kernels? Thanks, SJ > return accessed; > } > > -- > 2.35.3 > >
On 2023/3/4 2:39, SeongJae Park wrote: > Hi Kefeng, > > On Fri, 3 Mar 2023 16:43:42 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > >> Omit three lines by unified folio_put(), and make code more clear. >> >> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> >> --- >> mm/damon/paddr.c | 11 ++++------- >> 1 file changed, 4 insertions(+), 7 deletions(-) >> >> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c >> index 3fda00a0f786..2ef9db0189ca 100644 >> --- a/mm/damon/paddr.c >> +++ b/mm/damon/paddr.c >> @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) >> accessed = false; >> else >> accessed = true; >> - folio_put(folio); >> goto out; > > Because you moved 'out' label to not include *folio_sz setting, folio_sz will > not set in this case. It should be set. oh, it should be fixed. > >> } >> >> need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); >> - if (need_lock && !folio_trylock(folio)) { >> - folio_put(folio); >> - return false; >> - } >> + if (need_lock && !folio_trylock(folio)) >> + goto out; >> >> rmap_walk(folio, &rwc); >> >> if (need_lock) >> folio_unlock(folio); >> - folio_put(folio); >> >> -out: >> *folio_sz = folio_size(folio); >> +out: >> + folio_put(folio); > > Before this change, folio_size() is called after folio_put(). Shouldn't it be > called before folio_put()? If so, could we make a separate fix for that first, > and then make this change on top of it, so that it can be easily applied to > relevant stable kernels? > Yes, I could separate it, after folio_put(), the folio could be re-allocated and the folio_size calculation is not right. > > Thanks, > SJ > >> return accessed; >> } >> >> -- >> 2.35.3 >> >>
On 2023/3/6 9:10, Kefeng Wang wrote: > > > On 2023/3/4 2:39, SeongJae Park wrote: >> Hi Kefeng, >> >> On Fri, 3 Mar 2023 16:43:42 +0800 Kefeng Wang >> <wangkefeng.wang@huawei.com> wrote: >> >>> Omit three lines by unified folio_put(), and make code more clear. >>> >>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> >>> --- >>> mm/damon/paddr.c | 11 ++++------- >>> 1 file changed, 4 insertions(+), 7 deletions(-) >>> >>> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c >>> index 3fda00a0f786..2ef9db0189ca 100644 >>> --- a/mm/damon/paddr.c >>> +++ b/mm/damon/paddr.c >>> @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, >>> unsigned long *folio_sz) >>> accessed = false; >>> else >>> accessed = true; >>> - folio_put(folio); >>> goto out; >> >> Because you moved 'out' label to not include *folio_sz setting, >> folio_sz will >> not set in this case. It should be set. > oh, it should be fixed. >> >>> } >>> need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); >>> - if (need_lock && !folio_trylock(folio)) { >>> - folio_put(folio); >>> - return false; >>> - } Hi SJ, apart from above issue, it looks that this branch need the folio_size() setting, right? Thanks >>> + if (need_lock && !folio_trylock(folio)) >>> + goto out; >>> rmap_walk(folio, &rwc); >>> if (need_lock) >>> folio_unlock(folio); >>> - folio_put(folio); >>> -out: >>> *folio_sz = folio_size(folio); >>> +out: >>> + folio_put(folio); >> >> Before this change, folio_size() is called after folio_put(). >> Shouldn't it be >> called before folio_put()? If so, could we make a separate fix for >> that first, >> and then make this change on top of it, so that it can be easily >> applied to >> relevant stable kernels? >> > Yes, I could separate it, after folio_put(), the folio could be > re-allocated and the folio_size calculation is not right. >> >> Thanks, >> SJ >> >>> return accessed; >>> } >>> -- >>> 2.35.3 >>> >>>
Hi Kefeng, On Mon, 6 Mar 2023 09:56:49 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > > > On 2023/3/6 9:10, Kefeng Wang wrote: > > > > > > On 2023/3/4 2:39, SeongJae Park wrote: > >> Hi Kefeng, > >> > >> On Fri, 3 Mar 2023 16:43:42 +0800 Kefeng Wang > >> <wangkefeng.wang@huawei.com> wrote: > >> > >>> Omit three lines by unified folio_put(), and make code more clear. > >>> > >>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > >>> --- > >>> mm/damon/paddr.c | 11 ++++------- > >>> 1 file changed, 4 insertions(+), 7 deletions(-) > >>> > >>> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > >>> index 3fda00a0f786..2ef9db0189ca 100644 > >>> --- a/mm/damon/paddr.c > >>> +++ b/mm/damon/paddr.c > >>> @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, > >>> unsigned long *folio_sz) > >>> accessed = false; > >>> else > >>> accessed = true; > >>> - folio_put(folio); > >>> goto out; > >> > >> Because you moved 'out' label to not include *folio_sz setting, > >> folio_sz will > >> not set in this case. It should be set. > > oh, it should be fixed. > >> > >>> } > >>> need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); > >>> - if (need_lock && !folio_trylock(folio)) { > >>> - folio_put(folio); > >>> - return false; > >>> - } > > Hi SJ, apart from above issue, it looks that this branch need the > folio_size() setting, right? folio_sz is effectively used by caller of damon_pa_young() only if this function returns true, so this branch doesn't need to set folio_sz. Thanks, SJ > > Thanks > > >>> + if (need_lock && !folio_trylock(folio)) > >>> + goto out; > >>> rmap_walk(folio, &rwc); > >>> if (need_lock) > >>> folio_unlock(folio); > >>> - folio_put(folio); > >>> -out: > >>> *folio_sz = folio_size(folio); > >>> +out: > >>> + folio_put(folio); > >> > >> Before this change, folio_size() is called after folio_put(). > >> Shouldn't it be > >> called before folio_put()? If so, could we make a separate fix for > >> that first, > >> and then make this change on top of it, so that it can be easily > >> applied to > >> relevant stable kernels? > >> > > Yes, I could separate it, after folio_put(), the folio could be > > re-allocated and the folio_size calculation is not right. > >> > >> Thanks, > >> SJ > >> > >>> return accessed; > >>> } > >>> -- > >>> 2.35.3 > >>> > >>> >
On 2023/3/7 5:27, SeongJae Park wrote: > Hi Kefeng, > > On Mon, 6 Mar 2023 09:56:49 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > >> >> >> On 2023/3/6 9:10, Kefeng Wang wrote: >>> >>> >>> On 2023/3/4 2:39, SeongJae Park wrote: >>>> Hi Kefeng, >>>> >>>> On Fri, 3 Mar 2023 16:43:42 +0800 Kefeng Wang >>>> <wangkefeng.wang@huawei.com> wrote: >>>> >>>>> Omit three lines by unified folio_put(), and make code more clear. >>>>> >>>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> >>>>> --- >>>>> mm/damon/paddr.c | 11 ++++------- >>>>> 1 file changed, 4 insertions(+), 7 deletions(-) >>>>> >>>>> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c >>>>> index 3fda00a0f786..2ef9db0189ca 100644 >>>>> --- a/mm/damon/paddr.c >>>>> +++ b/mm/damon/paddr.c >>>>> @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, >>>>> unsigned long *folio_sz) >>>>> accessed = false; >>>>> else >>>>> accessed = true; >>>>> - folio_put(folio); >>>>> goto out; >>>> >>>> Because you moved 'out' label to not include *folio_sz setting, >>>> folio_sz will >>>> not set in this case. It should be set. >>> oh, it should be fixed. >>>> >>>>> } >>>>> need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); >>>>> - if (need_lock && !folio_trylock(folio)) { >>>>> - folio_put(folio); >>>>> - return false; >>>>> - } >> >> Hi SJ, apart from above issue, it looks that this branch need the >> folio_size() setting, right? > > folio_sz is effectively used by caller of damon_pa_young() only if this > function returns true, so this branch doesn't need to set folio_sz. __damon_pa_check_access() store last_addr, last_accessed and last_folio_sz, even damon_pa_young() return false, the following check still use last_folio_sz, ALIGN_DOWN(last_addr, last_folio_sz) == ALIGN_DOWN(r->sampling_addr, last_folio_sz) but last_folio_sz is not up to date, so I think it need to update, and update last_folio_sz is harmless, which could let's unify the return path, correct me if I am wrong.
On Tue, 7 Mar 2023 09:22:33 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > > > On 2023/3/7 5:27, SeongJae Park wrote: > > Hi Kefeng, > > > > On Mon, 6 Mar 2023 09:56:49 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > > > >> > >> > >> On 2023/3/6 9:10, Kefeng Wang wrote: > >>> > >>> > >>> On 2023/3/4 2:39, SeongJae Park wrote: > >>>> Hi Kefeng, > >>>> > >>>> On Fri, 3 Mar 2023 16:43:42 +0800 Kefeng Wang > >>>> <wangkefeng.wang@huawei.com> wrote: > >>>> > >>>>> Omit three lines by unified folio_put(), and make code more clear. > >>>>> > >>>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> > >>>>> --- > >>>>> mm/damon/paddr.c | 11 ++++------- > >>>>> 1 file changed, 4 insertions(+), 7 deletions(-) > >>>>> > >>>>> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c > >>>>> index 3fda00a0f786..2ef9db0189ca 100644 > >>>>> --- a/mm/damon/paddr.c > >>>>> +++ b/mm/damon/paddr.c > >>>>> @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, > >>>>> unsigned long *folio_sz) > >>>>> accessed = false; > >>>>> else > >>>>> accessed = true; > >>>>> - folio_put(folio); > >>>>> goto out; > >>>> > >>>> Because you moved 'out' label to not include *folio_sz setting, > >>>> folio_sz will > >>>> not set in this case. It should be set. > >>> oh, it should be fixed. > >>>> > >>>>> } > >>>>> need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); > >>>>> - if (need_lock && !folio_trylock(folio)) { > >>>>> - folio_put(folio); > >>>>> - return false; > >>>>> - } > >> > >> Hi SJ, apart from above issue, it looks that this branch need the > >> folio_size() setting, right? > > > > folio_sz is effectively used by caller of damon_pa_young() only if this > > function returns true, so this branch doesn't need to set folio_sz. > > __damon_pa_check_access() store last_addr, last_accessed and > last_folio_sz, even damon_pa_young() return false, the following check > still use last_folio_sz, > > ALIGN_DOWN(last_addr, last_folio_sz) == ALIGN_DOWN(r->sampling_addr, > last_folio_sz) > > but last_folio_sz is not up to date, so I think it need to update, and > update last_folio_sz is harmless, which could let's unify the return > path, correct me if I am wrong. Ah, you're right. Thank you for kind explanation. I was out of my mind for some reason. Maybe we could just do 'goto out' in the branch. Thanks, SJ
On 2023/3/8 2:00, SeongJae Park wrote: > On Tue, 7 Mar 2023 09:22:33 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > >> >> >> On 2023/3/7 5:27, SeongJae Park wrote: >>> Hi Kefeng, >>> >>> On Mon, 6 Mar 2023 09:56:49 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: >>> >>>> >>>> >>>> On 2023/3/6 9:10, Kefeng Wang wrote: >>>>> >>>>> >>>>> On 2023/3/4 2:39, SeongJae Park wrote: >>>>>> Hi Kefeng, >>>>>> >>>>>> On Fri, 3 Mar 2023 16:43:42 +0800 Kefeng Wang >>>>>> <wangkefeng.wang@huawei.com> wrote: >>>>>> >>>>>>> Omit three lines by unified folio_put(), and make code more clear. >>>>>>> >>>>>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> >>>>>>> --- >>>>>>> mm/damon/paddr.c | 11 ++++------- >>>>>>> 1 file changed, 4 insertions(+), 7 deletions(-) >>>>>>> >>>>>>> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c >>>>>>> index 3fda00a0f786..2ef9db0189ca 100644 >>>>>>> --- a/mm/damon/paddr.c >>>>>>> +++ b/mm/damon/paddr.c >>>>>>> @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, >>>>>>> unsigned long *folio_sz) >>>>>>> accessed = false; >>>>>>> else >>>>>>> accessed = true; >>>>>>> - folio_put(folio); >>>>>>> goto out; >>>>>> >>>>>> Because you moved 'out' label to not include *folio_sz setting, >>>>>> folio_sz will >>>>>> not set in this case. It should be set. >>>>> oh, it should be fixed. >>>>>> >>>>>>> } >>>>>>> need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); >>>>>>> - if (need_lock && !folio_trylock(folio)) { >>>>>>> - folio_put(folio); >>>>>>> - return false; >>>>>>> - } >>>> >>>> Hi SJ, apart from above issue, it looks that this branch need the >>>> folio_size() setting, right? >>> >>> folio_sz is effectively used by caller of damon_pa_young() only if this >>> function returns true, so this branch doesn't need to set folio_sz. >> >> __damon_pa_check_access() store last_addr, last_accessed and >> last_folio_sz, even damon_pa_young() return false, the following check >> still use last_folio_sz, >> >> ALIGN_DOWN(last_addr, last_folio_sz) == ALIGN_DOWN(r->sampling_addr, >> last_folio_sz) >> >> but last_folio_sz is not up to date, so I think it need to update, and >> update last_folio_sz is harmless, which could let's unify the return >> path, correct me if I am wrong. > > Ah, you're right. Thank you for kind explanation. I was out of my mind for > some reason. Maybe we could just do 'goto out' in the branch. Yes, will update this patchset with this change. > > > Thanks, > SJ
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 3fda00a0f786..2ef9db0189ca 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -130,24 +130,21 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) accessed = false; else accessed = true; - folio_put(folio); goto out; } need_lock = !folio_test_anon(folio) || folio_test_ksm(folio); - if (need_lock && !folio_trylock(folio)) { - folio_put(folio); - return false; - } + if (need_lock && !folio_trylock(folio)) + goto out; rmap_walk(folio, &rwc); if (need_lock) folio_unlock(folio); - folio_put(folio); -out: *folio_sz = folio_size(folio); +out: + folio_put(folio); return accessed; }