From patchwork Tue Dec 13 09:27:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071852 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 834FBC4167B for ; Tue, 13 Dec 2022 09:11:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 891FD8E0006; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6163F8E0003; Tue, 13 Dec 2022 04:11:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A5B48E0003; Tue, 13 Dec 2022 04:11:27 -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 0BC8A8E0006 for ; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 614D11C6543 for ; Tue, 13 Dec 2022 09:11:26 +0000 (UTC) X-FDA: 80236714572.28.B3E5301 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf16.hostedemail.com (Postfix) with ESMTP id 35765180003 for ; Tue, 13 Dec 2022 09:11:22 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.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=1670922684; 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=bcUHycRfTmcc149UJSRLAItdiMHwuy/uxCqLn6VIdfA=; b=WC3moNjG1tZZMR0twxV9ySTgy6VeVghFnetRGJ3FLKbnciKywRMbEd8TFoQR8ACq3NOZsK WrLatfOLKjfLhcK9d4wRvybZzWDnlzLQ9uPIB2CsIywlJUmrYrNWFS5ngpbVKnpiKebP2R bbBBmoP8jMeLn5Q5hc9Qi6l69Qd4sLo= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.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=1670922684; a=rsa-sha256; cv=none; b=nmyzBoEUSFmqmbu8aaZq+GeD7iTcXBCsqT3WERQB0hVRmKYbFnfes3CFggJ9zXrNxVMrxu e5bEhZfvxrk+lo1XuCC7xmrf7p8W5Tb1zwGBGm+K6+vjsd1se9FhX55bD4PYUj2zVoLZw7 p7XXrgRw8hXNPDBJyV+SPTQmoKh6Jq8= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NWXlL3417z15NBs; Tue, 13 Dec 2022 17:10:22 +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:18 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next 1/8] mm: memory_hotplug: add pfn_to_online_folio() Date: Tue, 13 Dec 2022 17:27:28 +0800 Message-ID: <20221213092735.187924-2-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-Rspamd-Queue-Id: 35765180003 X-Stat-Signature: eg4utea8e7jtnsmecdosdu4h1iz9ey15 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1670922682-778950 X-HE-Meta: U2FsdGVkX19jgrwozwn9hDSFadAEUJK0Cx2qANEM2LRrgnJvjlWzOI0G/mH/3DxfiRqHvLHhZypcJzaxo3UV7eV+2DNQw32rVe2j/wFD2u0vdcZvhIgRyCEREOFBrN1HHMLLzwJzd9MJjsoPM8ksx3jXU6bzIumjQCR1X75Czi21ZeEZ/3+58OGdIKiBIP7Ky1bDRdEYP4z4O8GhKm2p7gBw3xF+wp2Me47aIAMmulTux0tobel113rhlEb9JdslMcqUu39lCu0S5PkjhY78WN4tDGvo7IzgHcHWIZV9XVJ/yKPloLhL15fWmqS/7DUR8rgel401pEENXbWF9Um5kpOWyxiN+8c2jWV55H2AAw/xXBzEFshiOM0DT9kWqIwtO5GX7rK18A4woFJsE5mjnpEzyXNmF5er2gWT67SqU4IkES/br4hbQejhTJWc0uEi7fGy5tjmR2pLqM2B/rk2YsZOyPoRO0I2hpeeaBdEKxqSlfYyifMBR8t6M90eqzSKGl8CmsZ21riw1/+QyCv6RvESoPsFPlu1mDQ6V0ZqTltTYUNZDtWXeojwJ1s7kMR20N1Gzhrt8QfwTXF3ADpCTzYCDiZnZ/RL2aaeb+YShSjpwXA5x6UtX1QihhForfmpUSynhvTAwvg7LVq5C/fzen4hW8YptZ+iDBKPBXL6CemHONkjal5Eo20yAqGdtWORO9ZF1du3gLbuQ2k1pK71B8JhR3yX/85ogPj9M+Btd0cL4I/vVTIsix1/SUtrero/HN9ayJouDg+fLOsL3GK4bdyNIca0pq0bOtatiGftTAZy4b9DXB8MlYuopHqi9UdgofPvtibrhrpi2g8V1E2tupGOFChvRbODpN6AL1XHhs6nU2DM/4oAgnHNR471ET/FGQrJtN1L14rf6AyGhhHaJAFOpPazjze2wCbUzvmBrWgPIDBfWOaDEuQLL3+fia+ME9s9sN79JBgq1W4iHui C2qSHhM/ gzLQP 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: Introduce a wrapper function pfn_to_online_folio(), which calls pfn_to_online_page() and returns the folio of the page found, or null if no page. Signed-off-by: Kefeng Wang --- include/linux/memory_hotplug.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 9fcbf5706595..e841e4fb52a7 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -265,6 +265,13 @@ static inline void pgdat_kswapd_unlock(pg_data_t *pgdat) {} static inline void pgdat_kswapd_lock_init(pg_data_t *pgdat) {} #endif /* ! CONFIG_MEMORY_HOTPLUG */ +static inline struct folio *pfn_to_online_folio(unsigned long pfn) +{ + struct page *page = pfn_to_online_page(pfn); + + return page ? page_folio(page) : NULL; +} + /* * Keep this declaration outside CONFIG_MEMORY_HOTPLUG as some * platforms might override and use arch_get_mappable_range() From patchwork Tue Dec 13 09:27:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071850 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 C3C56C4167B for ; Tue, 13 Dec 2022 09:11:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A24758E0002; Tue, 13 Dec 2022 04:11:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7003B8E0006; Tue, 13 Dec 2022 04:11:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CD648E0002; Tue, 13 Dec 2022 04:11:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1BBB48E0006 for ; Tue, 13 Dec 2022 04:11:26 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DA529140D46 for ; Tue, 13 Dec 2022 09:11:25 +0000 (UTC) X-FDA: 80236714530.09.020CCB3 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf12.hostedemail.com (Postfix) with ESMTP id 47AF440005 for ; Tue, 13 Dec 2022 09:11:22 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1670922684; 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=dUXwDIxyAE99qPFcVmtGA/Gfbue+3uIg4UM27pTsTzo=; b=YRIZa4tC3vfqyZcwnH28m9l1/hOVSsaDO8TuDYTWSS7gQAv5CbU6QPqjwBY1wiCmyGqldy kuaOukGYg9Stq+v4dMGnLro5ii9jgizpZ06aud44w1suy9SoR1Eiv0zjdr4Yk95GoQ+29h zfHKeBFnOtXU/Qmy7APdgvNNPkCIJPs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670922684; a=rsa-sha256; cv=none; b=IvkJjc6PHRLM2sNEs8L0F43DpSiHSNY5N5ZdJjw4AgzFlChVTlVs7iTkAhKaHw7ygxC6Rl Itm4Z6gxyEkM+sxgTjQkYLLvPf5jGVFWWMUBQPCNYNEFpTbnDHDY0AYWsl+laqSS6rLEG0 2x8Kp3w7D/u36KkI+5FJ9YVZ/y+1Cww= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NWXgW3V50zqT0X; Tue, 13 Dec 2022 17:07:03 +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:19 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next 2/8] mm: page_idle: Convert page idle to use folios Date: Tue, 13 Dec 2022 17:27:29 +0800 Message-ID: <20221213092735.187924-3-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-Rspamd-Queue-Id: 47AF440005 X-Stat-Signature: zp9sohit53phjosihqk4skzgcm37zps9 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1670922682-285278 X-HE-Meta: U2FsdGVkX1+R37bT1/PsrywemRR+tIGHBUkFos5WR532x4ucBNRe1AqwckTrjSRU7L6cvSQ4LdAeqrdYgzm2QhvGPffbonWHxaHGwyZ3i5WYXoKKgU3tu/MlrKbtPLOpDwnUCeDdDMh38TWhHIUssemK4GAXAxwEyCj6jN6+p49liu2XEFgUSWc/6uRrREIF6VnPTLbIhK7c3zyuKIoNTU6A6EGtBUGNByZV/Mj8kwfnqbKN4zQNpMZgMSaQYM82asf3/w7JX0qk3s2Xu1Rx1KthQJMMtW8W3/HNhPFqKVOF52OpllliiLp7XopNu5dI3Y3hNp0S227UlYNzmC6YeGCdzCWPWEzde9cHCcQTpgsogUAEDtI8OS+l9DPvSWavks6D2OjSvQBd5tU7gJgTrkTnj8o+2u3NFwqUZZnNskipeZY34+NErYgoA+fKcUYyZ57v+BJzuJUakWSq8hk3h6w41H50XN3UJ9Zmp8wiUx5tZWzDAasvVrgrW+vPDNlYldlRRIzJMQrKXOWC+bN1ArLB7125bl9DSdgJYirry6IM0N0a2w2G4eJjqOyOWbecaNOvmB4tHf41QwLtXwSY8lBgKzLbyKAhejwmabEWHT2j2QhqWn8MpqX2NgNKg6UlR7qKgVxt3BqqXbFChxpS28Kxc0qi/d1Sd5X6FHfmYod5OC0m7/InEgDhCIxYHQDnRPPal7zY7QFf2xH/NX+4M0Zo5dg4LTDlfZIkgh3VNkjIOz5TJu/+2KfQkTlri1XFTEAlGT80EvsHxBC7umMS1cWlBnI9zLD4rh/jQGLdhK2meydV/cAuxVpYTRXRYkwDhYNuMxUvn/aejsul8ipkMyKpbNG/l48V+LUKj2bXWvd496CmPsC7hddGLa2PlFJ/1XOFBggtG012ty/FozVlVN2ER1HfezPOQMcUJ963pP8ENw4/tRWIE7IJxpH6pBrK3Wwzi8WuWVUqUmAC70X aLqoXYWo E4oKss8kSJwBN/o0= 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: This change and rename all page related function to use folio, which save many compound_head() calls and kernel text. Signed-off-by: Kefeng Wang --- mm/page_idle.c | 91 ++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/mm/page_idle.c b/mm/page_idle.c index bc08332a609c..38641f94cf49 100644 --- a/mm/page_idle.c +++ b/mm/page_idle.c @@ -19,34 +19,33 @@ #define BITMAP_CHUNK_BITS (BITMAP_CHUNK_SIZE * BITS_PER_BYTE) /* - * Idle page tracking only considers user memory pages, for other types of - * pages the idle flag is always unset and an attempt to set it is silently + * Idle folio tracking only considers user memory folios, for other types of + * folios the idle flag is always unset and an attempt to set it is silently * ignored. * - * We treat a page as a user memory page if it is on an LRU list, because it is - * always safe to pass such a page to rmap_walk(), which is essential for idle - * page tracking. With such an indicator of user pages we can skip isolated - * pages, but since there are not usually many of them, it will hardly affect + * We treat a folio as a user memory folio if it is on an LRU list, because it is + * always safe to pass such a folio to rmap_walk(), which is essential for idle + * folio tracking. With such an indicator of user folios we can skip isolated + * folios, but since there are not usually many of them, it will hardly affect * the overall result. * - * This function tries to get a user memory page by pfn as described above. + * This function tries to get a user memory folio by pfn as described above. */ -static struct page *page_idle_get_page(unsigned long pfn) +static struct folio *folio_idle_get_folio(unsigned long pfn) { - struct page *page = pfn_to_online_page(pfn); + struct folio *folio = pfn_to_online_folio(pfn); - if (!page || !PageLRU(page) || - !get_page_unless_zero(page)) + if (!folio || !folio_test_lru(folio) || !folio_try_get(folio)) return NULL; - if (unlikely(!PageLRU(page))) { - put_page(page); - page = NULL; + if (unlikely(!folio_test_lru(folio))) { + folio_put(folio); + folio = NULL; } - return page; + return folio; } -static bool page_idle_clear_pte_refs_one(struct folio *folio, +static bool folio_idle_clear_pte_refs_one(struct folio *folio, struct vm_area_struct *vma, unsigned long addr, void *arg) { @@ -74,8 +73,8 @@ static bool page_idle_clear_pte_refs_one(struct folio *folio, if (referenced) { folio_clear_idle(folio); /* - * We cleared the referenced bit in a mapping to this page. To - * avoid interference with page reclaim, mark it young so that + * We cleared the referenced bit in a mapping to this folio. To + * avoid interference with folio reclaim, mark it young so that * folio_referenced() will return > 0. */ folio_set_young(folio); @@ -83,16 +82,14 @@ static bool page_idle_clear_pte_refs_one(struct folio *folio, return true; } -static void page_idle_clear_pte_refs(struct page *page) +static void folio_idle_clear_pte_refs(struct folio *folio) { - struct folio *folio = page_folio(page); - /* * Since rwc.try_lock is unused, rwc is effectively immutable, so we * can make it static to save some cycles and stack. */ static struct rmap_walk_control rwc = { - .rmap_one = page_idle_clear_pte_refs_one, + .rmap_one = folio_idle_clear_pte_refs_one, .anon_lock = folio_lock_anon_vma_read, }; bool need_lock; @@ -110,12 +107,12 @@ static void page_idle_clear_pte_refs(struct page *page) folio_unlock(folio); } -static ssize_t page_idle_bitmap_read(struct file *file, struct kobject *kobj, +static ssize_t folio_idle_bitmap_read(struct file *file, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t pos, size_t count) { u64 *out = (u64 *)buf; - struct page *page; + struct folio *folio; unsigned long pfn, end_pfn; int bit; @@ -134,19 +131,19 @@ static ssize_t page_idle_bitmap_read(struct file *file, struct kobject *kobj, bit = pfn % BITMAP_CHUNK_BITS; if (!bit) *out = 0ULL; - page = page_idle_get_page(pfn); - if (page) { - if (page_is_idle(page)) { + folio = folio_idle_get_folio(pfn); + if (folio) { + if (folio_test_idle(folio)) { /* - * The page might have been referenced via a + * The folio might have been referenced via a * pte, in which case it is not idle. Clear * refs and recheck. */ - page_idle_clear_pte_refs(page); - if (page_is_idle(page)) + folio_idle_clear_pte_refs(folio); + if (folio_test_idle(folio)) *out |= 1ULL << bit; } - put_page(page); + folio_put(folio); } if (bit == BITMAP_CHUNK_BITS - 1) out++; @@ -155,12 +152,12 @@ static ssize_t page_idle_bitmap_read(struct file *file, struct kobject *kobj, return (char *)out - buf; } -static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj, +static ssize_t folio_idle_bitmap_write(struct file *file, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t pos, size_t count) { const u64 *in = (u64 *)buf; - struct page *page; + struct folio *folio; unsigned long pfn, end_pfn; int bit; @@ -178,11 +175,11 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj, for (; pfn < end_pfn; pfn++) { bit = pfn % BITMAP_CHUNK_BITS; if ((*in >> bit) & 1) { - page = page_idle_get_page(pfn); - if (page) { - page_idle_clear_pte_refs(page); - set_page_idle(page); - put_page(page); + folio = folio_idle_get_folio(pfn); + if (folio) { + folio_idle_clear_pte_refs(folio); + folio_set_idle(folio); + folio_put(folio); } } if (bit == BITMAP_CHUNK_BITS - 1) @@ -192,29 +189,29 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj, return (char *)in - buf; } -static struct bin_attribute page_idle_bitmap_attr = +static struct bin_attribute folio_idle_bitmap_attr = __BIN_ATTR(bitmap, 0600, - page_idle_bitmap_read, page_idle_bitmap_write, 0); + folio_idle_bitmap_read, folio_idle_bitmap_write, 0); -static struct bin_attribute *page_idle_bin_attrs[] = { - &page_idle_bitmap_attr, +static struct bin_attribute *folio_idle_bin_attrs[] = { + &folio_idle_bitmap_attr, NULL, }; -static const struct attribute_group page_idle_attr_group = { - .bin_attrs = page_idle_bin_attrs, +static const struct attribute_group folio_idle_attr_group = { + .bin_attrs = folio_idle_bin_attrs, .name = "page_idle", }; -static int __init page_idle_init(void) +static int __init folio_idle_init(void) { int err; - err = sysfs_create_group(mm_kobj, &page_idle_attr_group); + err = sysfs_create_group(mm_kobj, &folio_idle_attr_group); if (err) { pr_err("page_idle: register sysfs failed\n"); return err; } return 0; } -subsys_initcall(page_idle_init); +subsys_initcall(folio_idle_init); From patchwork Tue Dec 13 09:27:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071849 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 88817C4708E for ; Tue, 13 Dec 2022 09:11:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 704708E0007; Tue, 13 Dec 2022 04:11:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C7498E0003; Tue, 13 Dec 2022 04:11:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E6FF8E0007; Tue, 13 Dec 2022 04:11:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0B4AE8E0002 for ; Tue, 13 Dec 2022 04:11:26 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D9FF440C60 for ; Tue, 13 Dec 2022 09:11:25 +0000 (UTC) X-FDA: 80236714530.03.830217E Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id A6CC0160014 for ; Tue, 13 Dec 2022 09:11:23 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1670922684; 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=2NjTt0zSqwbWYip1Pe5Mvj8edW/6o+lHqhbbkVuLtQ0=; b=VgVihzB8G7dvLNIyUzvHxQRC5YkttxdXEyr5kfhZaUVT8nETBZW2euAbsM/H4OzUIulsH3 IWGGiMJY3at77Z4ViUQBj57Ky0vPiwFhgXCTD2IWH262INBF9mcHpU70IcNpuaSBGrao4h plI/lwECfRVHTSLevUU3N9sezANs0U0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670922684; a=rsa-sha256; cv=none; b=gRD3YiWVMHj0biSm41X0mbN8t6B1P2Vrnr+K2uptf2orkgo+AywzGgc2MZyyg3XB/Juc0v hCtmshrQDioP4TNelphy0+VG2zLIf3YjxtOYYhd64JX+wRap+6p+FK32klkGjwkCTOc6Bb l3j83Nm85vS4PqTwkuvcKEcMrLa5Tv0= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NWXlL52MTzlVjH; Tue, 13 Dec 2022 17:10:22 +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:19 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next 3/8] mm: huge_memory: convert split_huge_pages_all() to use folios Date: Tue, 13 Dec 2022 17:27:30 +0800 Message-ID: <20221213092735.187924-4-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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A6CC0160014 X-Stat-Signature: m8kqjfnjj8owt73ua8nw6raeznm8af8s X-Rspam-User: X-HE-Tag: 1670922683-680195 X-HE-Meta: U2FsdGVkX19AI3Ed9gp1PZJwLnhRCsjNKL/tp53cTeUR3Dg/ItXPrYRCQloXvquwBm7+TW24JXEqjdKGVg9upvLxMC/u4XvaSmKjrxFT8H50a/1LU+HLm9zA1TNNB3qBPRcKcaFUwi0593IIeCv6HJgP580S/xJ3T03nMzgU+YxkGfYUXjsCd4jMOJYmhRX3MPyQSQW3CGWo32zkht3wnhE6Wly19daNRTkDt8QFACo8avEmJw6D9PKw3cYCsATt0Y9kU4SKtvoJ7vq8SC6CvH7Gq6K/dRXpSA02jHEwTqi/Hsi8QOHr6qkfRSbcIucssteUuLbc+sh1u3AnNdrtYN7Y8PE6qKVwcLNfWo5t1yVFthijObDbRvkynPQXrChvJcd0pKNjhYyPasEpR/yvZ3jfhhZmPkBs2o6n8lntp9z4SHI8/6Hn/laLPc9Lb5531XwJMf35obfz1GyiXWamndzeMCyVzVZ2DVuItbHPWfxYQqX+F6ch926pOEFvt3uqnkmRkvhFuqmG4MtH+G4M/ulzNe4uvNq0naJ/FLk2ZRYGZdWt19MZOFniI75nD7jiFwj7udHv25C+IHJPzCaCrD2Ufq133RI82nt3fsynJP8cHhwWItrazxWB7EJhSNPI4ETfnGDGDXFxZGsFU1mAUTxLlFctqQVxINeFBCw0JJ3YJjcZ+OSbaTX5rgQbJjtUYruU0q7ki6T2BpyyN+TgspOHpFtorYoYlUbwmTkfYQ3hch2jdfmebjGfTJw58AY5d6TnXClxJZ+IQ8LgZ5iYXuP7N/4G81nqPE1C3c/moFYFfRzoiMGbM0QH337PtaR8sK+CBYFmz06saYTrBnT/uuyg2UgbEfQeyrpVHb+7VKEpKIu+zSRoaqGW6+6Gk+YG/7Htdd9XmOe2PHtmdo0egSHdHcg6ge41YDlYt6ahCWQJDb6QZNxQbtuLV0nnY6SKXnNTPI6Ds8My/4uHD+X wU9X4YCi 3Myaix/iTSC2Wx+o= 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: Straightforwardly convert split_huge_pages_all() to use folio function. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index abe6cfd92ffa..02092dd10aa4 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2933,7 +2933,7 @@ static struct shrinker deferred_split_shrinker = { static void split_huge_pages_all(void) { struct zone *zone; - struct page *page; + struct folio *folio; unsigned long pfn, max_zone_pfn; unsigned long total = 0, split = 0; @@ -2945,25 +2945,27 @@ static void split_huge_pages_all(void) for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) { int nr_pages; - page = pfn_to_online_page(pfn); - if (!page || !get_page_unless_zero(page)) + folio = pfn_to_online_folio(pfn); + if (!folio || !folio_try_get(folio)) continue; - if (zone != page_zone(page)) + if (zone != folio_zone(folio)) goto next; - if (!PageHead(page) || PageHuge(page) || !PageLRU(page)) + if (!folio_test_large(folio) + || folio_test_hugetlb(folio) + || !folio_test_lru(folio)) goto next; total++; - lock_page(page); - nr_pages = thp_nr_pages(page); - if (!split_huge_page(page)) + folio_lock(folio); + nr_pages = folio_nr_pages(folio); + if (!split_folio(folio)) split++; pfn += nr_pages - 1; - unlock_page(page); + folio_unlock(folio); next: - put_page(page); + folio_put(folio); cond_resched(); } } From patchwork Tue Dec 13 09:27:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071851 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 456CDC4332F for ; Tue, 13 Dec 2022 09:11:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61A1D8E0009; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A2FC8E0008; Tue, 13 Dec 2022 04:11:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E31F8E0009; Tue, 13 Dec 2022 04:11:27 -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 079D08E0003 for ; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DE4931204D7 for ; Tue, 13 Dec 2022 09:11:26 +0000 (UTC) X-FDA: 80236714572.24.5240665 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf25.hostedemail.com (Postfix) with ESMTP id E275EA0021 for ; Tue, 13 Dec 2022 09:11:24 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1670922685; 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=XhEJCxjv8xyhfFluc497FhExe2oqNp6HjtY3lhcHhh0=; b=H1hhCqwnvlsOIyAUBoeq6BOSbbaXPREobbgdqbCwhqDbzQqVRlEzrNtgcBkjr8uwGC6oOr 7m1G9em3a1Q3oSFhK1njm+/rRM/6kp9MxUNxrISZvx517j7IesJYk+Hfxnu2RigldUDX34 +CFHYuKiN5wOTp2j/oiksWC1htegdP8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670922685; a=rsa-sha256; cv=none; b=vVxtzjVYpyyqWTjin7MdofGeaAMeSxIbsQSG/X6CtOJrKD0ZCfIGhXg31TgNn7jZRMLQus D+SpGmJ+kmRwin5S+opbP9OfdZLnS+ZuqevN3zDTLpufPX3cil9iomWvylCEaB8TiDB5dG kXG3BiUhGeDd/k2/UMej59WqoQ1wWhI= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NWXgX3slFzqSsf; Tue, 13 Dec 2022 17:07:04 +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:20 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next 4/8] mm: damon: add temporary damon_get_folio() Date: Tue, 13 Dec 2022 17:27:31 +0800 Message-ID: <20221213092735.187924-5-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E275EA0021 X-Rspam-User: X-Stat-Signature: hatmpzxtexji8jig5cp8na3u8t5s4c9r X-HE-Tag: 1670922684-679786 X-HE-Meta: U2FsdGVkX1+UtGcFTSXM99ZIePcDnVQM5EojXsEIpVKHX6WmJAEJ1S4URySkCcd+JTAkq9BfjEbwzgTuBb/NKKXeF8tappNKz2aGocTUGFTvrWrR4PrIYo3Mrrjp1zc7t6B2uaQVeGi9PpEW0AutPuz2kr+LKtC8lftDvV3ZCgGzoPrUKFdymnFpEU0qWpT5GACW8H9+kYlR/F1nWjXtB8MWlzMYNujKvYPFXJpMNqW8YfnYN0t3O+sXiLZ8rWUMu2S+X/WqHB4vmCEXnC9kAN+A8csM2II+4DXRhZEYgvM0XIvwHdec2NgLThoNwok8ahvPOyYOHb+XHST7ad+ToSyWZgJj9+jJllCaw9WJ8PcwxuopEpc2iDTm0d+ZRlN954kQNvkGWH53Hf4362fPWnco4wuRrYkIc9mWP58H+IQcODRHHtmNoMAz3fO7HQai3NqSV6LKG2zTXGxUxHbVzAJdhH+cjBPMEPS1bPMCfjRm0aLh9JTIqEwDYeORtbAM5AqcQaPVOSEjZgX3Ne2cF34tLWUSlkOE0D65quOADEgcv1fLmXB2+gkECUzvYhx8YdFbBN3H+XbPQu8gsuOaUQlHebusIXTfSm2KdTh+/QQ2EIaB1knXoVYP/Y3nzN44En6hl0VJSttusSkprWVZngaNgohZqcg7I35O9Dw3eV4jDpWNP/hv7sGi9syn5vysSZRHDvMt8zkAqFVqCurOCLIGJFakWigQngZDTFOs2vab94L8kjYedk9wFWPRX/UQl867LZhKQuO2jP08gsRDwpKgL/Z1VYQtV5Zwg9/345/1DS9dXTY5GM961BoFc0FxdWcEbUbsDY3GF1dZrNi530vEeE3b8kJPKVaUtLQJWA/q3oXrt6uLs0Mi0psV2ts5j4mVasw7EkkMMz/mm361gKeoLOCK94hMvw+wjzIaJp3LaK9owRpl4oMa82VhMWEQMuBn3UO6Y/WMWPeZA5T BI4jPPC7 SoKh19WkEG1BBVFg= 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: Introduce a temporary wrapper function damon_get_folio(), which help us to convert damon related function to use folios, and it will be droped once the conversion is completed. Signed-off-by: Kefeng Wang --- mm/damon/ops-common.c | 18 +++++++++--------- mm/damon/ops-common.h | 8 +++++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index 75409601f934..40b79b022129 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -13,24 +13,24 @@ #include "ops-common.h" /* - * Get an online page for a pfn if it's in the LRU list. Otherwise, returns + * Get an online folio for a pfn if it's in the LRU list. Otherwise, returns * NULL. * - * The body of this function is stolen from the 'page_idle_get_page()'. We + * The body of this function is stolen from the 'folio_idle_get_folio()'. We * steal rather than reuse it because the code is quite simple. */ -struct page *damon_get_page(unsigned long pfn) +struct folio *damon_get_folio(unsigned long pfn) { - struct page *page = pfn_to_online_page(pfn); + struct folio *folio = pfn_to_online_folio(pfn); - if (!page || !PageLRU(page) || !get_page_unless_zero(page)) + if (!folio || !folio_test_lru(folio) || !folio_try_get(folio)) return NULL; - if (unlikely(!PageLRU(page))) { - put_page(page); - page = NULL; + if (unlikely(!folio_test_lru(folio))) { + folio_put(folio); + folio = NULL; } - return page; + return folio; } void damon_ptep_mkold(pte_t *pte, struct mm_struct *mm, unsigned long addr) diff --git a/mm/damon/ops-common.h b/mm/damon/ops-common.h index 8d82d3722204..4ee607813981 100644 --- a/mm/damon/ops-common.h +++ b/mm/damon/ops-common.h @@ -7,7 +7,13 @@ #include -struct page *damon_get_page(unsigned long pfn); +struct folio *damon_get_folio(unsigned long pfn); +static inline struct page *damon_get_page(unsigned long pfn) +{ + struct folio *folio = damon_get_folio(pfn); + + return &folio->page; +} void damon_ptep_mkold(pte_t *pte, struct mm_struct *mm, unsigned long addr); void damon_pmdp_mkold(pmd_t *pmd, struct mm_struct *mm, unsigned long addr); From patchwork Tue Dec 13 09:27:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071854 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 BD45DC4167B for ; Tue, 13 Dec 2022 09:11:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECE1B8E0008; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E54B78E000A; Tue, 13 Dec 2022 04:11:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACED58E0008; Tue, 13 Dec 2022 04:11:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 62F988E000A for ; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2242280C13 for ; Tue, 13 Dec 2022 09:11:27 +0000 (UTC) X-FDA: 80236714614.24.F1AF61B Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id 0760E4000D for ; Tue, 13 Dec 2022 09:11:24 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.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=1670922685; a=rsa-sha256; cv=none; b=acyChoDpbhJkpjVspGtKSH+yP9oI6uxvGlnT1fbwOH1U+FaDJICaXpaM3FhzKyfHAn3gbX CkO92bVHFJptyGFk673tCxYLo8Lc7iQjyIno4IDTZLgwq8oPVmOQQS5jz3b4Ik6uYKgz7H Eri8hwJYShmIC6jxTZP5izytyrU01Hg= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.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=1670922685; 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=NGLBaVoq8syZrmzm7kFd7RxKDvGHASJjaj05Zac8jEI=; b=DnbfCdk9iGC3pBAmpspzwJyALwib+OxaZi3Uq4AwiblWzvd+kbWrXSfZmlEzIQa06HT3kz 2X7PxCcGVdF5O2pxNwvD5Ssh/peu3zpMi0ZAfMi4K/r8J8NtePThH4RFHEfklht1VcNgyp hwdp9CvGFR9WjLc2+jfyVSfOR1XguyI= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NWXlR60YRzJqT4; Tue, 13 Dec 2022 17:10:27 +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:20 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next 5/8] mm: damon: convert damon_ptep/pmdp_mkold() to use folios Date: Tue, 13 Dec 2022 17:27:32 +0800 Message-ID: <20221213092735.187924-6-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: 0760E4000D X-Rspamd-Server: rspam01 X-Stat-Signature: ysajkngfsbyhe4ngtteyr56e6whhnugs X-HE-Tag: 1670922684-310130 X-HE-Meta: U2FsdGVkX19irq3oS7WlVrBGvA0/g1JwX3MR6hHu7CZuebR0TLERsVctPpVyvAnvZX4YXM+TGHFXY9M5tqPxwhECmK+XCh9BC+nns5HEGoyFU7r4wfb3eVdyHyTlJJwlXQhgm0Uxgl8dJredYpzvYVPjhRaLhlTmM5DG6hXeiNKyUvccKjpqiIMGQG9kVManLvG4fAy6mZCkdmmsTLiSjDpIG0iFzDRRBVGItf6LyaTWD6fUFdxcE/I3iI6KYWK1LnHo5zvcUp8ddIBLBuIyh7t0Fq8UfmEryjc/NOReUy9W1s14h+sJPRF97oWW5sjcnmA59JyGeKMT9tJCfVvO4y3uAKVJFCow/rYXqQ4O4Ih3CzPvfVMo1GW8v4uLi0bLBB26QhC/8GQ2zS4dSznBQDcPXyOXExJt8yvT46UZBjWO5HMlnAmQcWUprli0HkQPxzBwb9ihhwvE9Hg+OkKt5lxPh60Ya7kW1aSBRUBbL8S8ycQgcxXPZw+VL5bTm5hHQbeN8voZLKG/16jrGGiKdhqLWjbIuKhlMNmR8N2cCyugIdSwC9Uq97ueLc4QkMsUe30B2h2TLHm0Spzx4KP1jcD+PsqPDkn9eSa71m66RvaJgx9xSEsGt0uhw/Jluovx3XLv9CR3FJfJFjrdpTuyikoh0yB8rl7nLVWyTaGcJ9mbfyfrDR8ZPk5vDFh6L8WpIHGNdf/3fDFUP2PIrSKcXBpmPwqUdyhlAl/lmljfjXFr5/rU/jEXC1TImr3F1lgEwhIfBXIoq6BJ8KbHr2OycdcuaIF8x63IlmQZzxenfoAJ1/GU94tNH6DY71yt1FyaQfhWgREzlcmmGDtl9P7lthUjGoWV3ijpu2Sew4dAlHxJ0PnbQNux26nEPLrb1vmA1BI2bBsPQtLrsRULBfHQbheg3uEIEGoPvRK06vJoV2H1BnwlHE5Q9i6ym/EG5kqM0aaqtBiwUcOO9NKTOpJ 6h1yocoK lDQSxBXa6c61Sfl0= 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_ptep_mkold() and damon_pmdp_mkold() to use folios. Signed-off-by: Kefeng Wang --- mm/damon/ops-common.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index 40b79b022129..40ea39fe204d 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -36,9 +36,9 @@ struct folio *damon_get_folio(unsigned long pfn) void damon_ptep_mkold(pte_t *pte, struct mm_struct *mm, unsigned long addr) { bool referenced = false; - struct page *page = damon_get_page(pte_pfn(*pte)); + struct folio *folio = damon_get_folio(pte_pfn(*pte)); - if (!page) + if (!folio) return; if (pte_young(*pte)) { @@ -52,19 +52,19 @@ void damon_ptep_mkold(pte_t *pte, struct mm_struct *mm, unsigned long addr) #endif /* CONFIG_MMU_NOTIFIER */ if (referenced) - set_page_young(page); + folio_set_young(folio); - set_page_idle(page); - put_page(page); + folio_set_idle(folio); + folio_put(folio); } void damon_pmdp_mkold(pmd_t *pmd, struct mm_struct *mm, unsigned long addr) { #ifdef CONFIG_TRANSPARENT_HUGEPAGE bool referenced = false; - struct page *page = damon_get_page(pmd_pfn(*pmd)); + struct folio *folio = damon_get_folio(pmd_pfn(*pmd)); - if (!page) + if (!folio) return; if (pmd_young(*pmd)) { @@ -78,10 +78,10 @@ void damon_pmdp_mkold(pmd_t *pmd, struct mm_struct *mm, unsigned long addr) #endif /* CONFIG_MMU_NOTIFIER */ if (referenced) - set_page_young(page); + folio_set_young(folio); - set_page_idle(page); - put_page(page); + folio_set_idle(folio); + folio_put(folio); #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ } From patchwork Tue Dec 13 09:27:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071853 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 B372DC4332F for ; Tue, 13 Dec 2022 09:11:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B13438E0003; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C6408E000B; Tue, 13 Dec 2022 04:11:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4905C8E0006; Tue, 13 Dec 2022 04:11:27 -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 1BBE58E0008 for ; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D650612013A for ; Tue, 13 Dec 2022 09:11:26 +0000 (UTC) X-FDA: 80236714572.27.0A0C832 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf25.hostedemail.com (Postfix) with ESMTP id 9332AA001E for ; Tue, 13 Dec 2022 09:11:24 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1670922685; 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=zMxQGK/WPnyJiINoa0WutuLvpioCRlCbJYFWSCp8tO8=; b=ChS9gWl2LkjW9T7ETQXM8k7f5KmiIK+rmlfHIst1u4YjQoqILD907DAPG9AjTGahCEQwtE dOON4EHmUrNtEIkaShvOjY2z7CQVY7wDrA40mtDxwC5S2KMCD2O9WequgpOwdm5hHjAs7M 4nwBFNUH7hRjIgkX2ysc1JK/uZBvRG4= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670922685; a=rsa-sha256; cv=none; b=c3/Lx321hSvK0IP6Peh409sqH7XG1KEGn7ggDShsQi87ApHidHTNkVfNpBzVNXyKBjB5Fd 4pzM6wMcwQIKlKOszyzfP95D280NoG/SlY38dEZocyn+h2/iz7oERwU/dgsfrRPBFdv6vr +5EtBPhsM8Cbg03IJHh6dD1DUymVjVw= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NWXlL3283zRptt; Tue, 13 Dec 2022 17:10:22 +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 6/8] mm: damon: paddr: convert damon_pa_*() to use folios Date: Tue, 13 Dec 2022 17:27:33 +0800 Message-ID: <20221213092735.187924-7-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9332AA001E X-Rspam-User: X-Stat-Signature: 3n5we5m7jguwp16ipyukhqbu6h61e7t4 X-HE-Tag: 1670922684-256282 X-HE-Meta: U2FsdGVkX18rzqJNQMJybJLQBlbOxj4/y0R/L+GAc5B10VElDCqDEV96Ag2pn7vq2U5tmeWBZIDqx9nGCj5VQYz9qdfp6sfX5Yu9v4zZ8hjmoqjywPfrCA7UQt+Z/jqSFppHaRm4tLyx+ADfXOYJwboULxuec6pV90OAMWHp/QjJhizzPxJbi+kCexKQZ2bnhSllpPIzbvNwF/HnMBgzZJygsOd+jjjiTqsLCAzFjlrdxBk93CNEc6hlMZbEQaZaH0PtdWVkLa0vzYiwdZEE7A1jetdMuCRHZ79yY26b3vebE/mL8ivLEHVIo0AaXC7B8FF2HVl2CewjtGIPgCdwgSqB4VRDU0wyj470Y35oMBdC4Z96czisxh7m+G1/l8jLMVpnXmCQWaY61z1i9S3FejQOrAdHjkvSFOqnz6dVABFKpEUlvLX7ASzW8CwEGpeu31YCkadWmK8n0/RG/Tvzk3N69Vj1qtVF9KEk37zNkJnwuQD1qvNVK6Ko0FDa7P3sVpw5OxPZX8WvfykcRZw+xDjTUJV8JEtoj2BDaSPkXaRllmwM1OLt6Ljf9Mo8kJADafLiHcg7Gla++3Wyj7/LFxNAJsd43pZKTqAOfM2uYRAxtR/YFGR+yai1zr68e07Mpj0zK2FwyFM8ZssfAySJXdsAXVCBCRsCaSna/aM1frBimBB0GJiJjTgWZ+4fW9A7gxPA7W0zvz7kUGT7t+1eAHV9EptMsmOXUClRI/7Tu9Ev6ERI7XOkarTLd6GjsmOfgStd9zzjEggaLRFdhmXaVMVxkVbWk9GkuG+H7MrDpPYd1G6sURlLp8Ka5OlaGJpj+AkoB9o4e+FrXbrFfOJ/EQ1t3DydN5DhnHCPzGEaB5IR18WO/uZEQFyWq0eVVUWU1ecIpJyuu7nkM9WQudAqqMGSFfQB5NM4b5SlG3GS5MbQIv+wUdQ8c9Jw4zLMtZDhtlUOKMz4VdEmjVKxSsb eRDT4lPR oMo/OFmrNaTxLjgA= 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_ptep_mkold() and damon_pmdp_mkold() to use folios. Signed-off-by: Kefeng Wang --- mm/damon/paddr.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 6b36de1396a4..95d4686611a5 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); @@ -93,7 +91,7 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, addr, 0); result->accessed = false; - result->page_sz = PAGE_SIZE; + result->page_sz = PAGE_SIZE * folio_nr_pages(folio); while (page_vma_mapped_walk(&pvmw)) { addr = pvmw.address; if (pvmw.pte) { @@ -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)) @@ -205,28 +201,28 @@ static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) static unsigned long damon_pa_pageout(struct damon_region *r) { 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; - 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; } @@ -237,12 +233,10 @@ 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 (mark_accessed) folio_mark_accessed(folio); 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; From patchwork Tue Dec 13 09:27:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071855 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 C8BCFC4332F for ; Tue, 13 Dec 2022 09:11:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 507908E000B; Tue, 13 Dec 2022 04:11:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DF258E000A; 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 2944B8E000A; Tue, 13 Dec 2022 04:11:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 002538E000B for ; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C579E40C47 for ; Tue, 13 Dec 2022 09:11:27 +0000 (UTC) X-FDA: 80236714614.20.B92D37B Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf01.hostedemail.com (Postfix) with ESMTP id 9147F40003 for ; Tue, 13 Dec 2022 09:11:25 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=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=8qosV3W6IHkx3Rmeq9UAZAog4KdF5MSwe+gmY/5tPtA=; b=3/LCPfu9RSfpqw0P3ETVat6meVq1LDix0BYgwk+Swvp9HnN6jhl0hTx0iSNTUhf3Hhl+mw Fx4Mt+gpWIdrpISz58/9itON95R8162oG1RCgkGTWYYSjv1IeJM5YIf8y7f1JtG9AYKgH0 FUt4MNa+n5vbbmJ99vDlq66jwoF0fRg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670922686; a=rsa-sha256; cv=none; b=bOa7wehCl7LKem1OqVTsePf4mWOsCj8bf/Z2t4UnvFl/8omIFJDyAhAB6+4hWLbT0R1+2f ZXB1PnYkuQ/St+hVa6eLN/2SSOENGKtv/AVkBZahHB1YBaprBsGKLCJWXjMoi3d+3+tV8D JacnYCs9a3Cp1hCw+n0A8mMUXS3speI= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NWXlM2s0HzRpws; Tue, 13 Dec 2022 17:10:23 +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:22 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next 8/8] mm: damon: remove unneed damon_get_page() Date: Tue, 13 Dec 2022 17:27:35 +0800 Message-ID: <20221213092735.187924-9-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-Server: rspam02 X-Rspamd-Queue-Id: 9147F40003 X-Stat-Signature: ed9h9sqbtx9sny3oyn74iwf3up7bf6p8 X-HE-Tag: 1670922685-30987 X-HE-Meta: U2FsdGVkX1+/Y+9p3VSOxYnd88ftdSdgonWYjGvW7LgOkJD6vBNqovsJO4wBkM1LoZX0noCEzp9ywwR4T5TSjaosjYQR2I1p/FBtVrrQ2m9CRo1IDMJV1COuRwkDRu1HFYE/r0nMG6c4MzBoZQhqEoZt5qy90Lpa8XTNgbwgHLAb0C0G3GQW0FoobO8WGR87oMpXqQAoLhWfAn5lfEBha/DF5df5XXjwrw8Adcc0Ga7oRpTpRlVBYN7PnigJypSI4pMLwDjA8QxCqgoasoIh2Jd1HYp2icW7LRBP40nv8Ki2jbcLG05x6xpfMyHKKl0bvwKa94TG1HOcYUIXLWcuWGDglIror+fl0qmvLK+VB3StegB7SH0obkGBBauUpZYzRZziiafQG/c0L3ktWzvwUS5oGUQz3IX+es5qEYbykfVRLGilU1+SOppkogcwIeLGMyayjQ8WL2NSsIIFeFQY3PFQ6iPtmraTWm+9SdaSQbxTVAUy+T+4l+XHtBN1/yaSm8ko9yhTK9o9JnYeUOjYw0wfAIAbl70guc0rF7RbX0rGVU2D/iqS0JUcRZ4y1MmNPUrlEqv+rJ5SixUnK2OSRkzQ0ooSx4nDHY+ImoCfHu3FO7iOXJYsufm4QPglAZXILvPGi0DUD1MamIgtti/v8uK4z0aJb8Sh95I/gl3enm9DRsT0SB665EtAqkF8glVrg7KGnHKO8heQcusnia9ZZ3uJY2smSwQNeGzxWjc9bS0KzxVDCFPfQfiDYIxcO6e2ju0QXJHD5w9TSUM4JpJk4418h+7+YbUK5nnYcCJXSwqHKvo54sgmNAqYeX0VTBDI/BcFfamahQUNyQuXfQ42jaBXQdsuQkCao85F+cvCkdf3IkyhMK9byhQ2Mgb+3OarNw9arx45H010M1WEWKsmi5wNOvHvGsVK6hSqOosL61md6BVthQHP7ELLjV0S95PhD2+fI5nwS//XyQh0eY5 ndug/iE3 NNywYeTRSnCRN7MQ= 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: After all damon_get_page() callers are converted to damon_get_folio(), remove unneed wrapper damon_get_page(). Signed-off-by: Kefeng Wang --- mm/damon/ops-common.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mm/damon/ops-common.h b/mm/damon/ops-common.h index 4ee607813981..35a2e42a27da 100644 --- a/mm/damon/ops-common.h +++ b/mm/damon/ops-common.h @@ -8,13 +8,6 @@ #include struct folio *damon_get_folio(unsigned long pfn); -static inline struct page *damon_get_page(unsigned long pfn) -{ - struct folio *folio = damon_get_folio(pfn); - - return &folio->page; -} - void damon_ptep_mkold(pte_t *pte, struct mm_struct *mm, unsigned long addr); void damon_pmdp_mkold(pmd_t *pmd, struct mm_struct *mm, unsigned long addr);