From patchwork Fri Mar 3 08:43:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 63784 Return-Path: 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 + 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 ); 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 ; 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 To: SeongJae Park , Andrew Morton CC: , , , Kefeng Wang 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 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: 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?= Omit three lines by unified folio_put(), and make code more clear. Signed-off-by: Kefeng Wang --- 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; } 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; }