From patchwork Wed Dec 28 11:34:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13082866 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 DA962C4708E for ; Wed, 28 Dec 2022 11:18:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86BAE8E0008; Wed, 28 Dec 2022 06:18:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E7B98E0003; Wed, 28 Dec 2022 06:18:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 290938E000A; Wed, 28 Dec 2022 06:18:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E2E0E8E0009 for ; Wed, 28 Dec 2022 06:18:32 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AE329AAF36 for ; Wed, 28 Dec 2022 11:18:32 +0000 (UTC) X-FDA: 80291466864.21.0E0B2B2 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf13.hostedemail.com (Postfix) with ESMTP id 59A3520005 for ; Wed, 28 Dec 2022 11:18:28 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672226310; 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=KRyOhLV8t/viDPD1r/fMCP1wCfer/Ov11lFql4Kb3JQ=; b=y/qG/D+pjk8SxssLfHb8IBBylqgpOB3ddshMyeOcVUwUUlUNyJRB+oee0c3JMV+LSuofWD vhGqAFBzEZJfsHRb2D0PSDOCx7xLj3wuunv/kZhrkfaI4Z47bKETI/6P1Mq5VvXSOOfZvR 1fPs/+FQETPlOYS4fPr+34nxECGnvMI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672226310; a=rsa-sha256; cv=none; b=T3zpEB8UrvPUXZ7ZnwlmPXBdnYFuaJCp5ctATY/hoZK7u6HZP6EBrXHoDalPO+GPZHMUsK a+4DRKJhGhltTG++btz7fXQArxeIFXXxPck83nGhM/TKA2WIhHkh9bKwDSNsZBOB+XOG+n c5N+04q7SQheLQqCOreQ2VHHcZKI0PA= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Nhprj0Jltz16LrW; Wed, 28 Dec 2022 19:17:09 +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; Wed, 28 Dec 2022 19:18:25 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v3 4/7] mm/damon/paddr: convert damon_pa_*() to use folios Date: Wed, 28 Dec 2022 19:34:10 +0800 Message-ID: <20221228113413.10329-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221228113413.10329-1-wangkefeng.wang@huawei.com> References: <20221228113413.10329-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 59A3520005 X-Stat-Signature: qgxf17nii3fz7m9g3w1rmmxbryjwyqfp X-HE-Tag: 1672226308-832325 X-HE-Meta: U2FsdGVkX18M4W/zu85X0Ov+PiRudCJ2eNpb6x3zIoJv4pgUs0jVYK9SN+sg0SJdOA1cl/YESxAvVqr83BNH5kuqjK524DsSMM1/PC3XzxQu3t5/B379WQfyuoLdaGk6Nc1lQjx0O2EB7lX0S/mi/tjGuzV9gJEwwtQ3I8sJ1yiXSf+fIMOWjllGHUzn7klnUBere4i5wKjBmaWh5862k2jvgBDtYuzdj83HbPrg+3XQ11ZjQbzcgKNR3Ct8tbZ/AY0E/Np+GbRvRxBjhSjQCp9px43Vc4uqVBYfUZ6XuxW8jfYCddb6GJBACKZRS5H9M7eMiyC/pmAoyj78kjBGcdIht5GcG212mSqQ1Oa1b5apur3Up8FU/UL4fkmNK+7Om59NVbZBnf0AUPOerUPiS8lfvRVfQbBJM7KTCQamUNpDiTA2j4l1bH9EOfr7O24/8Ibdpy59OBvL5eqDENve9auugFVsHGz1w9EZEeOZnSqsy9T3+b5KhInXXi9B5tH7C/LMrZiy0XtDpbOXOP9dJz8qfFYxLXsI+R6vZhIWHVQXYDuD34x+UoRKZpQz2FZdMey3zzyOTtU7iIp74lwYiP/+jbFiCIuAkc/zVPl+B0HEWfhKkqGKM+7dryh49nVK7k24wa+3unWKeKKazcVyCPMhIcf+yqPEIlEuPoZfK4GNPkLKvv875ex3nHd3Yx5f5+K880/3KBOZ749C/Tvr41ZBb6lf3oLFC48jw1pn8q2w2plfUT10QGPr/aX9N4XkFmoKzFvSu4adRWSatCZWGVhTIKk3tieFABjo6sjo66W3D0uP9A1MH0gBQojT2anftSjvHQvV5FkcQpEuWQFHs9J02vMavSYKXf5zCCQsluks4FWfarn7IhaWi3d9m/wYkY6EkDOzDEJ5S4GsNwGuv32BznITumybhN39CY+gdpdrOgLbCgjR5L+tAVx/tCa/T+6HRlYz9OqfSExDWU9 NypNrqYK 9Exai 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 all the damon_pa_*() to use folios. Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- mm/damon/paddr.c | 58 ++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 6334c99e5152..fbfd66199f3f 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -33,17 +33,15 @@ static bool __damon_pa_mkold(struct folio *folio, struct vm_area_struct *vma, static void damon_pa_mkold(unsigned long paddr) { - struct folio *folio; - struct page *page = damon_get_page(PHYS_PFN(paddr)); + struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); struct rmap_walk_control rwc = { .rmap_one = __damon_pa_mkold, .anon_lock = folio_lock_anon_vma_read, }; bool need_lock; - if (!page) + if (!folio) return; - folio = page_folio(page); if (!folio_mapped(folio) || !folio_raw_mapping(folio)) { folio_set_idle(folio); @@ -122,8 +120,7 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, static bool damon_pa_young(unsigned long paddr, unsigned long *page_sz) { - struct folio *folio; - struct page *page = damon_get_page(PHYS_PFN(paddr)); + struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); struct damon_pa_access_chk_result result = { .page_sz = PAGE_SIZE, .accessed = false, @@ -135,9 +132,8 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *page_sz) }; bool need_lock; - if (!page) + if (!folio) return false; - folio = page_folio(page); if (!folio_mapped(folio) || !folio_raw_mapping(folio)) { if (folio_test_idle(folio)) @@ -203,18 +199,18 @@ static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) } static bool __damos_pa_filter_out(struct damos_filter *filter, - struct page *page) + struct folio *folio) { bool matched = false; struct mem_cgroup *memcg; switch (filter->type) { case DAMOS_FILTER_TYPE_ANON: - matched = PageAnon(page); + matched = folio_test_anon(folio); break; case DAMOS_FILTER_TYPE_MEMCG: rcu_read_lock(); - memcg = page_memcg_check(page); + memcg = page_memcg_check(folio_page(folio, 0)); if (!memcg) matched = false; else @@ -231,12 +227,12 @@ static bool __damos_pa_filter_out(struct damos_filter *filter, /* * damos_pa_filter_out - Return true if the page should be filtered out. */ -static bool damos_pa_filter_out(struct damos *scheme, struct page *page) +static bool damos_pa_filter_out(struct damos *scheme, struct folio *folio) { struct damos_filter *filter; damos_for_each_filter(filter, scheme) { - if (__damos_pa_filter_out(filter, page)) + if (__damos_pa_filter_out(filter, folio)) return true; } return false; @@ -245,33 +241,33 @@ static bool damos_pa_filter_out(struct damos *scheme, struct page *page) static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) { unsigned long addr, applied; - LIST_HEAD(page_list); + LIST_HEAD(folio_list); for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { - struct page *page = damon_get_page(PHYS_PFN(addr)); + struct folio *folio = damon_get_folio(PHYS_PFN(addr)); - if (!page) + if (!folio) continue; - if (damos_pa_filter_out(s, page)) { - put_page(page); + if (damos_pa_filter_out(s, folio)) { + folio_put(folio); continue; } - ClearPageReferenced(page); - test_and_clear_page_young(page); - if (isolate_lru_page(page)) { - put_page(page); + folio_clear_referenced(folio); + folio_test_clear_young(folio); + if (folio_isolate_lru(folio)) { + folio_put(folio); continue; } - if (PageUnevictable(page)) { - putback_lru_page(page); + if (folio_test_unevictable(folio)) { + folio_putback_lru(folio); } else { - list_add(&page->lru, &page_list); - put_page(page); + list_add(&folio->lru, &folio_list); + folio_put(folio); } } - applied = reclaim_pages(&page_list); + applied = reclaim_pages(&folio_list); cond_resched(); return applied * PAGE_SIZE; } @@ -282,14 +278,12 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( unsigned long addr, applied = 0; for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { - struct page *page = damon_get_page(PHYS_PFN(addr)); - struct folio *folio; + struct folio *folio = damon_get_folio(PHYS_PFN(addr)); - if (!page) + if (!folio) continue; - folio = page_folio(page); - if (damos_pa_filter_out(s, &folio->page)) { + if (damos_pa_filter_out(s, folio)) { folio_put(folio); continue; }