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: 13158397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1FC2C7EE32 for ; Fri, 3 Mar 2023 08:23:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44D3E6B0074; Fri, 3 Mar 2023 03:23:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CEC16B007B; Fri, 3 Mar 2023 03:23:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FA5A6B0074; Fri, 3 Mar 2023 03:23:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0BE486B0073 for ; Fri, 3 Mar 2023 03:23:00 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C57311411DB for ; Fri, 3 Mar 2023 08:22:59 +0000 (UTC) X-FDA: 80526896478.09.6BB2946 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf30.hostedemail.com (Postfix) with ESMTP id 90CD180006 for ; Fri, 3 Mar 2023 08:22:56 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677831778; a=rsa-sha256; cv=none; b=n53Qtpkjp/LME/pZws31Ww3T+qw8GU2/pk/QSswQGkfpL3E9yzbmmiwcfZPRy0sSE3XVr9 8fz6GPeMv3fVHSjLJaxiINuXyoaHlrpA8kk2kbUiiIIPAID/HH0yhzv5yqdxMOAy0aPjs4 s2aK+6MGC5X4L02R+VQMnlkSd9Who8k= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677831778; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F7kRQcf8rYI3p2XX72xLIeZ9I3gh+WTwueyptmTV+AM=; b=VKaAeOyuy8KvSxF/4VPUt+niaQYYOFbhYGYK7FTduLITlT95Nehj2tikDnYDJAtZxDjHaT fKVB4PkwL8EoUYkhBNwKRK7KZ+jr1etmoMbkGRW070XDRRcFhFByv0UEGZfr+2ljqhkq1l 5ir9rac61tCviHps0zYKTNbnUggYXwc= 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-Rspam-User: X-Rspamd-Queue-Id: 90CD180006 X-Rspamd-Server: rspam01 X-Stat-Signature: 739o3hextugqhnkue6yybte9n7e7f7mu X-HE-Tag: 1677831776-424121 X-HE-Meta: U2FsdGVkX18D4i0mLG3ENrGi6IYMVb91mOr3ta+Mzb4BqxFwfp3K4Swr4EpZTLxRAzlcoRsPXA8jEgVXIYx+K+6CIHS2d0jmsCQI7ZrPvGqRNqNaMBbBz1NM8sA4kUzwsd+iensjOsb2vTEVoR4vP0fjUmOt7FoEqYeE3BmxzSosptCQqEPiNUmr/dMGEE1bGVCYgsKLZ6jwvT7GQkhTMHerpJ2CfQhj7EOBFYRCPAPhzVVVaWBS0nILGw+xaaPeNuxzU+jnf9+7hkX8PMDxvralkGoThnbrsoNkXghxUuF/HgqtLiNUF9dHljH7TuvUs2DYbPGGhZPeczNAHb3WhUlj+T9TasgOrn4qcxJG++KhaOfIAk8vnkwVibpAsgnI2t8YmhBNeFmYY6XGvYeIwvPQqm2Woz39Fk+AWWp0i0IGN+9tNnlXHrduTblbs6/nSHX8RtnFvuV+e7pCCA0DbOVX2uaWySSZaIKkozg+HgXIxsrZFA7lzNBKu/k4blBIYEryEwh3mPOGyp0jjlh4Y1B/HH9NHBAnYJX/VSxfgA90URiguCC6q5YmPlv4/QUqI8z3wunC/pzqsDp4AooALU59KKPhok1W4T3epbG3wacc2IBEBoKIoZOCTVgppy6XNqyVKC+Rcw2zU9IVWGPwT96cGuNILhE7b4HWKKNFT+/Hyg+n8ujgNYtvV8IkM+u/BGTB69IDxFfZnOgFxlXVkw2S/LWfdXrACWr5x2nmuvIVTfDDW52x+kGwWqoHn+ZiU0TAFUrvNhYeQll6JCRPnBjAFSFT5xzt5QaQIc/3O7xLkSDZAbHiaSUzRy5tUPMxoKdszzrX6eCipUY8pSFLhCDTq6SQlvdMIOMIBfj5mjOE8LLoSn+mvsTldc6NK+X0D+kTtBBk1HgBaSrWOjvwITeQov4kKwCJL36MrZXi/zXh55RbjsQngZZBIfazNn2IV1Go8YWqRZnHWs6uc0p ErBOwPCm pfRR1ifI8rU1oS7VcDgwPHrpcnEk3oqhXpBX3uOewCIF61IdEGi5KkPqz2qa2emh5CVyUxS2mqvC6hIOmXUuI3DGKZkqPA3PWbKZLjReNd38acT/f8IEfUnHipAkzHzY5Sr1ha7fDNj8pXQem2oWKe27xqM6D4M4hL13/LWN8pjUU9aRNCwMJbLu7AfKf0AnZsPFXpDveyKr+1SbwbdyUVVJ1UQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000038, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; }