From patchwork Tue Dec 13 09:27:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071856 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 D71DFC4167B for ; Tue, 13 Dec 2022 09:11:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8163F8E000A; Tue, 13 Dec 2022 04:11:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E014900002; Tue, 13 Dec 2022 04:11:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 473328E000C; Tue, 13 Dec 2022 04:11:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2C1598E000B for ; Tue, 13 Dec 2022 04:11:28 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 03854140D53 for ; Tue, 13 Dec 2022 09:11:28 +0000 (UTC) X-FDA: 80236714656.16.D237EE8 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf24.hostedemail.com (Postfix) with ESMTP id 057CE18000D for ; Tue, 13 Dec 2022 09:11:25 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1670922686; a=rsa-sha256; cv=none; b=Iifo5B9Rokl/xsDQexi1uHZqEnLBGpauDamZrrP9XU5h5zDWEnnxDQssyXEtuH0IFvbTCV /A8Z244YV8ZWKR8CsEzPfD3JFF2vCqJd5PXk6JC57TL8kwCEOIOwgeyR7IPlmj4Qqjw3bw aVOl0rZouxscgyFPneXj6/ndcyOIrCE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1670922686; 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=rpGar6yYxGQk2dS/4N9g3ug54zU5QpgTYEqpA2yJk0U=; b=Whbn1him6T1QJbySKDspa0bfO6dKvCkvxkpfprdYnQUV4jSnBAU/o41i8M3xfPiyaW67Ku P1xAJpd4d7FZNSwiNxoL8Pi9qbvNezFA65e2YfgpH4tu9hAWjQAZPeUsxk9t+Nj2/EVdPC LU3uCcNfXg9CzgOow23aJf5HQr7rN6Y= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NWXlP4CWPz15NQL; Tue, 13 Dec 2022 17:10:25 +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.2375.34; Tue, 13 Dec 2022 17:11:21 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next 7/8] mm: damon: vaddr: convert damon_young_pmd_entry() to use folio Date: Tue, 13 Dec 2022 17:27:34 +0800 Message-ID: <20221213092735.187924-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221213092735.187924-1-wangkefeng.wang@huawei.com> References: <20221213092735.187924-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Queue-Id: 057CE18000D X-Rspamd-Server: rspam01 X-Stat-Signature: sn47hxwkmeq5cob53xfid5tfyjym3cpa X-HE-Tag: 1670922685-415267 X-HE-Meta: U2FsdGVkX1+2NdGqBJC5U1mtSF/S8+cCMiFeIcttTnyfH/QYnSBiJHFkhGi9mDBs4Jnyer9BEbtFtoe/8Z7FBCmLUwb1fwjgMrHLITTBrCPsad4+r9ElMhpHvqyHj7AZ+3P/9DSR2TxF5EnAU5LAnrwJdjBRgaDagENML+gjQ2zXKZZaQTGMyA3o6T0Yj6X/IX8/YNKvlxn0J1jSAg1QWYIZTQruVwQjx5mneY/NioZbTq7fCwlam2M6Jk2p5QXWDRhRzWwE8xNpohpNN19aXjew05CNBsBkAAmJLxd2TzIPQoBIG1qNMKsZ68pIpFlX/jWXWQhmGQQJaxzDIU8WEuiH+etbW0zXjYMq/9AfmtH43a14HC8Per0LFfrunTl2vlJ995TL1d8OzYHnNM5HL94I83gzMHOCZz7bjoc/NQDgLHYymwvz9B1N95ywYMcED1v7yyrq1/TafsEMzgli1rAPCgWMxf0G3ZqkZHQnmQuvImHAtBJrv0l/CPJpMLa5iXbfnOMBckYfsLQcWBmoNmNxYf1ym99vCGRXzAqTK028jnw+rsMWERoA6iF22bbNQ6vM6gU4ac6YkKpSCmmHctzLWF2HFilazkCCISe8OmAaErF5I7hp+KtSPIF6jKfkMoLl/+p+DQwwOYKoyr0BlHtFEYMKWTuA6ap2ijMkuT+ydi+s8JrTfmJ8Mg0xlDKkSWsOBwDG+G2gQRNV232/W99IK0U+yVFD/YOu39qSvvCJHuOghUNdTI3oflc5qBQ4QafuwSyZGela/tW/gqepNZFo12HygSbt+arf7jjgtgckqfUXJ6dpJ0+WN4HBg0hFGsjC933+6A/M7zFirk9GRcCfuFtZP7UfJW4yz8AJ/tsLTGSsY4kcFcIhOwdvguqEctvTJCSeFn+mY5WV5bfhM5H+tKlVvK9QcXF088fIqvFXgAouNUYI8PnsMDAcNMZ7kdGeRYVc2z/PNGxOFVs 1K0NVxNH TL9P1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With damon_get_folio(), let's convert damon_young_pmd_entry() to use folios. Signed-off-by: Kefeng Wang --- mm/damon/vaddr.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 15f03df66db6..2fab7241aa04 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -431,7 +431,7 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, { pte_t *pte; spinlock_t *ptl; - struct page *page; + struct folio *folio; struct damon_young_walk_private *priv = walk->private; #ifdef CONFIG_TRANSPARENT_HUGEPAGE @@ -446,16 +446,16 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, spin_unlock(ptl); goto regular_page; } - page = damon_get_page(pmd_pfn(*pmd)); - if (!page) + folio = damon_get_folio(pmd_pfn(*pmd)); + if (!folio) goto huge_out; - if (pmd_young(*pmd) || !page_is_idle(page) || + if (pmd_young(*pmd) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, addr)) { *priv->page_sz = HPAGE_PMD_SIZE; priv->young = true; } - put_page(page); + folio_put(folio); huge_out: spin_unlock(ptl); return 0; @@ -469,15 +469,15 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); if (!pte_present(*pte)) goto out; - page = damon_get_page(pte_pfn(*pte)); - if (!page) + folio = damon_get_folio(pte_pfn(*pte)); + if (!folio) goto out; - if (pte_young(*pte) || !page_is_idle(page) || + if (pte_young(*pte) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, addr)) { - *priv->page_sz = PAGE_SIZE; + *priv->page_sz = PAGE_SIZE * folio_nr_pages(folio); priv->young = true; } - put_page(page); + folio_put(folio); out: pte_unmap_unlock(pte, ptl); return 0;