From patchwork Fri Dec 30 07:08:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13084134 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 798DCC4332F for ; Fri, 30 Dec 2022 06:53:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DCB98E0009; Fri, 30 Dec 2022 01:53:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 98E2E8E0008; Fri, 30 Dec 2022 01:53:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CD9C8E0009; Fri, 30 Dec 2022 01:53:11 -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 5457E8E0006 for ; Fri, 30 Dec 2022 01:53:11 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 369824030C for ; Fri, 30 Dec 2022 06:53:11 +0000 (UTC) X-FDA: 80298055782.11.2BA82A6 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf01.hostedemail.com (Postfix) with ESMTP id D818B40007 for ; Fri, 30 Dec 2022 06:53:08 +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.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=1672383189; 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=2QOOhLzD1D8tWmRP04JBkjvhlCiFjNQeUQibqR215Gc=; b=afTaynRwwn4IwX88n2Dj1jEQDBQZn38MG888v6cGe9DVdlFGMbPEMEAg+hxW/NUrGBl76N UqN+SLu9QsJ+rTdH/yic3+2ZuIQQmk+0/dssF/sFhGOYIekxFMJK9VMDK0S1XQt1+P/1mR 3ZiGyJ0/Qsj3CE7zq3pQzlUc5ykyDQ0= 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.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672383189; a=rsa-sha256; cv=none; b=I6aE8AJG80upGF1guBKe3L5nUFl/MAJmjE5yf3GpsK1/MMtBGPFwwUkc7JWiuIWNoUywSN CtTLxARJcja+bKqiLJPKAlCGio6rfwjhWh+n0z+qpGhGu1Vr8hRcZFfd90p+xyHVSJXsOu VARgsEXokPK/QPNI1j2r+nFSjnn7rQc= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NjwsX1WvMz16Lxn; Fri, 30 Dec 2022 14:51:44 +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; Fri, 30 Dec 2022 14:53:02 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v4 1/8] mm: memcg: Add folio_memcg_check() Date: Fri, 30 Dec 2022 15:08:42 +0800 Message-ID: <20221230070849.63358-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221230070849.63358-1-wangkefeng.wang@huawei.com> References: <20221230070849.63358-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-Server: rspam04 X-Rspamd-Queue-Id: D818B40007 X-Stat-Signature: e4467rwah3anrko1fwbnfx3wwur89oq6 X-HE-Tag: 1672383188-909729 X-HE-Meta: U2FsdGVkX19bVOcbB8hgyekacb6clrWMzJnXbK8JKDxdRQ17a7VoyCWI7tFPgS2QSijrOySGskc3ozoc3a11GfY9ndVJ4nw0qfpJ1+XtS7IwTfEICL37wEbS7vIubeTOuWROXaWM+9w6FLYF5dtggWt0EDQlh29+gqwZX/s/I1JgwT7Fb1pjcb6VOsGTUmPUtU3zOPFHop+Rv4ebaf0s4BZYGdZ9qAMV8Rcm2VIMfFUiTbqgOoMxe9VQNCkQV655oTYuI+NjK9H9m4CBfcpeIc3oPwiuooW99M4xyKA7Bale49kEtnX8OUFQUVGmX2pPioj+QYtRkuPyuSV88dYKAe3Gw8OA7xEXov6KjfsT7EcTMUkYk+BhygZiVedu8wElLWtPob7aOlTDMrQvrxrDcWW2xBywLjKT/1T+i/c3TziCxi9dXN3ex5aJ2Aic6XPv1elSCKuW6S9cp1sTokW046LYNP5fGj4uhDhQZ/N7yGHPrWVOeUg9fSG0R0Unuj1ps70H6PL/omW0yF1/xHZsDKOBFlyMt2CcCKVWOY3oPRwg5XjXN+L+0EVDkNWzMq7lV9p2YdQj1nmP4/ku/h20AGD2nAuHJBc5IvdX0riWj9nxiyQdqSQ1UYQpJp7yikIt54O/Ij5viYmpzrdITMHiptG5KON9vfRtWZtTcuxNxVlPDUalFbBvTyZyaVKprcM+XyJDqFUVOW8YG+wqgE5obUqmk4RpJD0z7ZkbYQTnYPbl8VS3H04FlblFfMi23eO7R3IY0Ex/WWRMPhjrms0e2v7MAFFUAR7gOjE+zQqZQsC6tXbPO/5+fb0FcCoqxhwopiBDCsmXkgEVP12lZNaC9vkQM+nd4x1Bft5mQhOE+3Z4B0iVdcmrEPe5RTMmI/DB+R8MQVNRvGx/t7I2gTYVIzGb7HkblPGTvRf1iQ4x2EAuZNSOgpgQh8Xab/9BI4e29BOd8sJjRT7LSSv8t2q m46gxeQQ zvfIX 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: From: Matthew Wilcox Convert page_memcg_check() into folio_memcg_check() and add a page_memcg_check() wrapper. The behaviour of page_memcg_check() is unchanged; tail pages always had a NULL ->memcg_data. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Kefeng Wang --- include/linux/memcontrol.h | 40 +++++++++++++++++++++++++------------- mm/memcontrol.c | 6 +++--- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index d3c8203cab6c..a2ebb4e2da63 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -466,34 +466,34 @@ static inline struct mem_cgroup *folio_memcg_rcu(struct folio *folio) } /* - * page_memcg_check - get the memory cgroup associated with a page - * @page: a pointer to the page struct + * folio_memcg_check - Get the memory cgroup associated with a folio. + * @folio: Pointer to the folio. * - * Returns a pointer to the memory cgroup associated with the page, - * or NULL. This function unlike page_memcg() can take any page - * as an argument. It has to be used in cases when it's not known if a page + * Returns a pointer to the memory cgroup associated with the folio, + * or NULL. This function unlike folio_memcg() can take any folio + * as an argument. It has to be used in cases when it's not known if a folio * has an associated memory cgroup pointer or an object cgroups vector or * an object cgroup. * - * For a non-kmem page any of the following ensures page and memcg binding + * For a non-kmem folio any of the following ensures folio and memcg binding * stability: * - * - the page lock + * - the folio lock * - LRU isolation - * - lock_page_memcg() + * - lock_folio_memcg() * - exclusive reference * - mem_cgroup_trylock_pages() * - * For a kmem page a caller should hold an rcu read lock to protect memcg - * associated with a kmem page from being released. + * For a kmem folio a caller should hold an rcu read lock to protect memcg + * associated with a kmem folio from being released. */ -static inline struct mem_cgroup *page_memcg_check(struct page *page) +static inline struct mem_cgroup *folio_memcg_check(struct folio *folio) { /* - * Because page->memcg_data might be changed asynchronously - * for slab pages, READ_ONCE() should be used here. + * Because folio->memcg_data might be changed asynchronously + * for slabs, READ_ONCE() should be used here. */ - unsigned long memcg_data = READ_ONCE(page->memcg_data); + unsigned long memcg_data = READ_ONCE(folio->memcg_data); if (memcg_data & MEMCG_DATA_OBJCGS) return NULL; @@ -508,6 +508,13 @@ static inline struct mem_cgroup *page_memcg_check(struct page *page) return (struct mem_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); } +static inline struct mem_cgroup *page_memcg_check(struct page *page) +{ + if (PageTail(page)) + return NULL; + return folio_memcg_check((struct folio *)page); +} + static inline struct mem_cgroup *get_mem_cgroup_from_objcg(struct obj_cgroup *objcg) { struct mem_cgroup *memcg; @@ -1165,6 +1172,11 @@ static inline struct mem_cgroup *folio_memcg_rcu(struct folio *folio) return NULL; } +static inline struct mem_cgroup *folio_memcg_check(struct folio *folio) +{ + return NULL; +} + static inline struct mem_cgroup *page_memcg_check(struct page *page) { return NULL; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 92f319ef6c99..259bc0a48d16 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2939,13 +2939,13 @@ struct mem_cgroup *mem_cgroup_from_obj_folio(struct folio *folio, void *p) } /* - * page_memcg_check() is used here, because in theory we can encounter + * folio_memcg_check() is used here, because in theory we can encounter * a folio where the slab flag has been cleared already, but * slab->memcg_data has not been freed yet - * page_memcg_check(page) will guarantee that a proper memory + * folio_memcg_check() will guarantee that a proper memory * cgroup pointer or NULL will be returned. */ - return page_memcg_check(folio_page(folio, 0)); + return folio_memcg_check(folio); } /* From patchwork Fri Dec 30 07:08:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13084136 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 BEB03C10F1B for ; Fri, 30 Dec 2022 06:53:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00EBE8E0008; Fri, 30 Dec 2022 01:53:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E9C3D8E0006; Fri, 30 Dec 2022 01:53:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B90BC8E000A; Fri, 30 Dec 2022 01:53:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 83E388E0003 for ; Fri, 30 Dec 2022 01:53:11 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 50B2D120494 for ; Fri, 30 Dec 2022 06:53:11 +0000 (UTC) X-FDA: 80298055782.15.9F80EB0 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf09.hostedemail.com (Postfix) with ESMTP id 085B3140007 for ; Fri, 30 Dec 2022 06:53:08 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.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=1672383189; a=rsa-sha256; cv=none; b=bI9R6D8dHGM8S7CG+h5VwJ6USdbFDy56Ad6cOcmEtpYKOiTVohOkiiLyySON7hssZe3NMv 34M8bM/MfedMVS+67PD+zXimI+IRWaqIZ9VeWYs0rRK89f+Gybs8orIsOeqnEUroRTopXm pEj+eOk2jk4qFwNI4KLVNZg3YdyMWbA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.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=1672383189; 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=MXF1U/1hHnzGJU3XIUnGF/6X2mLamibc66BOMODvpCs=; b=Fz0FfLXo7atELhs4hoUnqHf0g+gbZNODjJdN4X3rWFm5DaPI5o0iHPv65tziC9Dgy9o2IR QQxekxbPx+sqA8VGTk9JiKnbvRX/uh+skoDa485nrKrmXCxykrAY6Lohrf/88DgbYBV9zH daMAPjjNQKZkJe2Evx6dJ9LeDN3+p30= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Njwsl5lmLzJqpS; Fri, 30 Dec 2022 14:51:55 +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; Fri, 30 Dec 2022 14:53:03 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v4 2/8] mm: page_idle: convert page idle to use a folio Date: Fri, 30 Dec 2022 15:08:43 +0800 Message-ID: <20221230070849.63358-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221230070849.63358-1-wangkefeng.wang@huawei.com> References: <20221230070849.63358-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: 085B3140007 X-Rspamd-Server: rspam01 X-Stat-Signature: 89c4o71rm3ynz8kwxiwuj3ctmitumbp3 X-HE-Tag: 1672383188-53124 X-HE-Meta: U2FsdGVkX19Q6yqtaRF3e9ObIR8HpnV82CMlsjso/1HWM8OtW2yLKbE/QurCrcyNAuTP+cDCBx6lS56mZAWtgT9XlnhRB/2sn5tcN5z2LQr/SOImMOh8iFFql1b6pX4+NwVtaksrIMsaZG5J5g5N0LO4sGB05+mbq3BHIo/sCg0CB1v+Z2xIaSmSyb58LIiB8BSWH5odtzpRbepdTl9HhEntvfuN5K8dADd3E0XDkvihbrf7JWeEgkX5N0B2c+UtI/aLYdEZ9QCcfmG7EtqjeITwo5ViDx0o3EEmRU3NrwVisp4yd1xn+DTWgSNsBRsA+pX7peq6sqEePcqxALU5kcXX4L+tCbT0BG2dB1XI4B8Ue/QYYfEDdCqJ5o4C+cJ14FLpQS1UFLGg+QCseRhUXEq1rAKDr+Phpx60trGcF6p/T7x/6IJt5dqlq7anV5QNgzJowZDDjKSG7OM12/ptDyTt+P10+mD0UhGjz835M4aA7atP7pTM9wr6F6/+W21oD8p0JxbThwTfrHai0czPwN3dewcyO9g1Kg2x465plG9YPy2YYIxQayOGRMOz9s9tHdwmJiufYUlMNjqCDYv7zOu4KYiqrsdS6G3fNlyz6tkiTLbwomQqsEA2MDtAZBbLe0EvocYqER3VU0QMGp0m+jRdAULEbT4bT2nID/N57Zcu4JNw6qrJ0PCpvT4OfWiKr3MDIJNSYzxM2wGL9aDvHzMQ1oUEw+uuan3kSfUdYNBbeBBIhViaiYxCxJ5eyO2WcEQtHv2WzQByQy7+tNqhZAj0WANTMczANJZT+etHRkqvBPTMVjNRMiqM/zywfa7T3mrYKKCWb5tcC3L+i5vMd1nonaVOO3ATAOAuNMyFljYGj7aX/59M89h7oycu/pIzw1jDwZMyGf5qBC0Fud4q+mfJ30eahcXK7p3dRZUaK+R1UIG85nWrBt/R7RybKRT21gB/qqRD4ZWwDin3YqQ /UzFEObw KDvgo 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: Firstly, make page_idle_get_page() return a folio, also rename it to page_idle_get_folio(), then, use it to convert page_idle_bitmap_read() and page_idle_bitmap_write() functions. Reviewed-by: SeongJae Park Signed-off-by: Kefeng Wang --- mm/page_idle.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/mm/page_idle.c b/mm/page_idle.c index bc08332a609c..41ea77f22011 100644 --- a/mm/page_idle.c +++ b/mm/page_idle.c @@ -31,19 +31,22 @@ * * This function tries to get a user memory page by pfn as described above. */ -static struct page *page_idle_get_page(unsigned long pfn) +static struct folio *page_idle_get_folio(unsigned long pfn) { struct page *page = pfn_to_online_page(pfn); + struct folio *folio; - if (!page || !PageLRU(page) || - !get_page_unless_zero(page)) + if (!page || PageTail(page)) return NULL; - if (unlikely(!PageLRU(page))) { - put_page(page); - page = NULL; + folio = page_folio(page); + if (!folio_test_lru(folio) || !folio_try_get(folio)) + return NULL; + if (unlikely(page_folio(page) != folio || !folio_test_lru(folio))) { + folio_put(folio); + folio = NULL; } - return page; + return folio; } static bool page_idle_clear_pte_refs_one(struct folio *folio, @@ -83,10 +86,8 @@ 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 page_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. @@ -115,7 +116,7 @@ static ssize_t page_idle_bitmap_read(struct file *file, struct kobject *kobj, 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 +135,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 = page_idle_get_folio(pfn); + if (folio) { + if (folio_test_idle(folio)) { /* * The page 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)) + page_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++; @@ -160,7 +161,7 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj, 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 +179,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 = page_idle_get_folio(pfn); + if (folio) { + page_idle_clear_pte_refs(folio); + folio_set_idle(folio); + folio_put(folio); } } if (bit == BITMAP_CHUNK_BITS - 1) From patchwork Fri Dec 30 07:08:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13084135 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 AAF35C3DA7C for ; Fri, 30 Dec 2022 06:53:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C836F8E0003; Fri, 30 Dec 2022 01:53:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD6868E000B; Fri, 30 Dec 2022 01:53:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9186E8E0006; Fri, 30 Dec 2022 01:53:11 -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 7132F8E0008 for ; Fri, 30 Dec 2022 01:53:11 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 47B24A048B for ; Fri, 30 Dec 2022 06:53:11 +0000 (UTC) X-FDA: 80298055782.13.6714661 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf25.hostedemail.com (Postfix) with ESMTP id 44C62A000B for ; Fri, 30 Dec 2022 06:53:08 +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=1672383189; 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=8dmIvNeYv2WzwsuX+phCpp3DT1r6ESPMuw4tfvgMB+A=; b=QtBdZ7ZW3muT9ZZ3/6g6os4MXnGGXes2ScC/2jAab5qxu03025oHbPFVrZgHvCjWFRznUw r6ujPEE+VdLfBX1VuaxuVaGwrQWjoJB5Ds6UN+yaL7HlZHWLY4O2uRYtHpAXWzPo2EfmwN O/FUgoDDa2fAQE8TxG2jsLfy20u69bE= 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=1672383189; a=rsa-sha256; cv=none; b=djn/U8+MjSQpf8XE9EEtzwJ2icXSuma/ZtNYOzC/Tb4DJwsov2PVQAGZAUmOWFO/qVQxKs YgcXp7Mx41ZT7Kty+GGWXqqBDHXG3i8poHn1uDrExQRl2WiwJ8nj5T7ld/dXZsTBP1ByFK g3ftHJop8BC8aAlhXE6jorhQqX1z19Q= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NjwsR5CFBzRqPX; Fri, 30 Dec 2022 14:51:39 +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; Fri, 30 Dec 2022 14:53:03 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v4 3/8] mm/damon: introduce damon_get_folio() Date: Fri, 30 Dec 2022 15:08:44 +0800 Message-ID: <20221230070849.63358-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221230070849.63358-1-wangkefeng.wang@huawei.com> References: <20221230070849.63358-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-Server: rspam04 X-Rspamd-Queue-Id: 44C62A000B X-Stat-Signature: e8gxcueb8mxizd7ysim7cbfn491jrrx9 X-HE-Tag: 1672383188-485863 X-HE-Meta: U2FsdGVkX19Tl4RNRCkJcDfK65NhOVP5mxpwFUAq8FLRCGDIRc+4d1pwR0vblwK9uPmDWHoQjen4Riw9ySEBO+ZOH9wKDBJ0K1lHh0WFdMEg+8vZmWMqj++B3VK7eyzpZwWM3nMdVkU0Jgr1qbrBJUSVKVZyQoFI64ENwBYGW8oHpaKhXEJ8BA0GvaV2cFnsR+blqomWXli0TejV5XNGNE2MTy+buvhRG8WIU63+aF2cSt5zxkVLyzLD5h3qL+DTA9P1vR7AItFhCYrqZqTpb2a0vrBzcC6LNj4wM3H6sUDph92nZhEMS5Ysudtq+rSQuMvC+Dpm804otDTBXagNh5pDzCnvmHLETvTE5m5MMvDeJG3EHFpLB2R3S1lgnZbew5dglu1sh1lw83YQ8H+Zrk/sM0a90sM0+SlvksnxQuqG1BZYqkyEVfNtT6bBr8xOLM6i8GkjO+XE+nhmW7Jplrm7NVSTFPQ6ylu6aFDvCTWvOJAtF5eD3CBedBQRADhGfAU83w4w9+hEmIT4W7VlrpevYCr5OVwjl+c5U1l4qtsI6hCq0L2dz8pH0FPcxfbUIUV5dBnmx6Hj3gTh53VeTkzCPDYWGns5+MyQfczoxuT3SC+OWtdjA7gdLkHxwVQFZB7liWh4iQ+IyB3ZAEhoITP9oIUQxFiNQ0o2NxXMz3C4zdI9wwQwhOlvdLBXfao8B7RHqcUlHPHAH0LWVA3Eww/WDkVN8R1osnteZhoHB/q8kgiXwDkP0CTUEamSskkVG3vATYz1fL9gal3zNy174npucgRE2dZJjeav99sLvnyYs7l+4G948SaOqI6jqUEZ9R4m6tu061RxGqKEde+DLg2150PfgEy3BbgDiHdq5R8iM62nTdjgdthbADy0IeyMTxNHJopqH1uHL/5EtRvyC2H+jR3kewSOmrGEdcNybL911K/OzGTJO4tXYK/nLsB12kRCbpEwNpFJ1EHTHZF rHZ0hMQV D1e/W2K3wlDiIZB4= 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 damon_get_folio(), and the temporary wrapper function damon_get_page(), which help us to convert damon related functions to use folios, and it will be dropped once the conversion is completed. Reviewed-by: SeongJae Park Signed-off-by: Kefeng Wang --- mm/damon/ops-common.c | 18 +++++++++++------- mm/damon/ops-common.h | 9 ++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index 75409601f934..1294a256a87c 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -16,21 +16,25 @@ * Get an online page 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 'page_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; - if (!page || !PageLRU(page) || !get_page_unless_zero(page)) + if (!page || PageTail(page)) return NULL; - if (unlikely(!PageLRU(page))) { - put_page(page); - page = NULL; + folio = page_folio(page); + if (!folio_test_lru(folio) || !folio_try_get(folio)) + return NULL; + if (unlikely(page_folio(page) != folio || !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..65f290f0a9d6 100644 --- a/mm/damon/ops-common.h +++ b/mm/damon/ops-common.h @@ -7,7 +7,14 @@ #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); + + /* when folio is NULL, return &(0->page) mean return NULL */ + 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 Fri Dec 30 07:08:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13084131 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 0E60AC3DA7C for ; Fri, 30 Dec 2022 06:53:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 809198E0005; Fri, 30 Dec 2022 01:53:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 790AC8E0001; Fri, 30 Dec 2022 01:53:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 632368E0003; Fri, 30 Dec 2022 01:53:10 -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 531E58E0001 for ; Fri, 30 Dec 2022 01:53:10 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1BAB780516 for ; Fri, 30 Dec 2022 06:53:10 +0000 (UTC) X-FDA: 80298055740.21.6576BC1 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf10.hostedemail.com (Postfix) with ESMTP id F2038C0004 for ; Fri, 30 Dec 2022 06:53:07 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1672383188; 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=Vb0zaefvbfLK4A9norVrKs2w+Zvbed9ZpF7wKUoOSDc=; b=e4b2+2rm2L3XciLkqJ+MxUSYMbg19pq9NlaQtJ1GsxJxW5qY6J/w70mwc75vQBIy03Rm7r JwLjgoo1y6iNSlBwJ+3zAw28DmP2kyTNKUqEeixYKeG5gFNFh9rqCmCx/QoKQhGpTRXteJ f+cD5I8HJz/qB/2FsEzGMXl9JZOUJOc= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1672383188; a=rsa-sha256; cv=none; b=RiPkAbTmCKJ429Xvh9amJbayMGwmkgZ/W2o7RyzNar8pg3OR0TkALCGdbLUgW0KHu0jByt NOg7uLCGtStVQFHmxAqOg9dw9/SGDGEOU4FabnkSMiGx/5gLHiIV/0Dac2k1/BAlHoH41f Yx+z5Cez1Cj/vwGa4DMFSTGN/ZTc1Ik= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NjwsS1PtjzRqPf; Fri, 30 Dec 2022 14:51:40 +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; Fri, 30 Dec 2022 14:53:04 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v4 4/8] mm/damon: convert damon_ptep/pmdp_mkold() to use a folio Date: Fri, 30 Dec 2022 15:08:45 +0800 Message-ID: <20221230070849.63358-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221230070849.63358-1-wangkefeng.wang@huawei.com> References: <20221230070849.63358-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-Server: rspam02 X-Rspamd-Queue-Id: F2038C0004 X-Stat-Signature: ytxitkxprhqjccmwuc3iu9ked5nruihj X-HE-Tag: 1672383187-954769 X-HE-Meta: U2FsdGVkX1/sR9CaUxM3OQ44Ay9l5rfCtra4wprypvEBvgK8NCHkcNfCkqHBkIMtnfnndzZ8AZGNy2E8lFEemdSDP/RHzHf5+c1P2hu5MUWsk5HtYK6OE2XsvYuKU9SNmUWl/kYqzl4GvR3iw0goLUeX7npXEirLW8/w9YXdGmOv+Il6FCmtgyRjo3K+0Y7kznMfsFDlsi1FYkTr/HRKUMl5N+8zY5W2gMKmbnG/WOOV7qKSW+XNKQ3Gm7F/CSVf0j45ouZ9xcTGwanALxM1WFDOreBA/HhWwaxV2+DjgJED17nZmWlNhy/6KRADD529Ox6QhQCRPC05PaQ9LKYZVg3LbfYBcRHXKgQwqKxfvYlruB6YL54pRn49A1G/6IgpEqJnsSQHU+qVAAl4Qz2O/hoCg+hUoZ4E7RwC+wwn46MFPYBMUY2lCRS7EY5xtr9ylnrYb1FTNLp4ecqI6oyvzd16ltLlWcXGZGO3THKUU+pAbL4BZ1TC5a+Vu4gVzgN8wDJhEBHBmh+F0UlcxwVJD8+1t6X0qYButb9Wrst8QKCBp45jFS9G4NP40H2u6Tkk5l7CrAb8Ie/bTamzaz4MGA3eBAnk2SXjYmNcQMtuwZP2X8LTkrvveQ4EieobABvdlV7yGWtJ3pyGCYvWN1Ln6KHDNSdSwKTny8jr9F7S37ZQ2LeEJYyVBKD827IwYA5i2N2xt7BHaQdb7nD9KKxFO2GzO7LpZMvs4H7TFDzc/zQd9sSgroVm7rf56bsdRagogSifE87MJaNwzdqbbq/VJGH05bimbV49VC4N5ahQpQOAaqXSne4fqIT8cNYmM93b+LxDYo9zc0s08XooSdGD0GadcEaTnvtH45y82ioPlJ6E5gtd8uUkztzti0YlIkkHO5zzNwiWUNZpirR5uamuPJOgOiKKSGSWC7K8x4CzoWuw6SoV/zbdQTjzV4qkAVR1wE54Q/K0RELcqTL4su/ nf646FBF 4eglv 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 a folio. Reviewed-by: SeongJae Park 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 1294a256a87c..cc63cf953636 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -40,9 +40,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)) { @@ -56,19 +56,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)) { @@ -82,10 +82,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 Fri Dec 30 07:08:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13084133 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 35174C3DA7C for ; Fri, 30 Dec 2022 06:53:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E9058E0007; Fri, 30 Dec 2022 01:53:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AAD38E0003; Fri, 30 Dec 2022 01:53:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D7288E0006; Fri, 30 Dec 2022 01:53:11 -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 0123E8E0003 for ; Fri, 30 Dec 2022 01:53:10 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BDFA61A05FE for ; Fri, 30 Dec 2022 06:53:10 +0000 (UTC) X-FDA: 80298055740.16.C4ECC05 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf01.hostedemail.com (Postfix) with ESMTP id 55A1540011 for ; Fri, 30 Dec 2022 06:53:07 +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.189 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=1672383189; 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=d8xurHYRqkyzwiIcSquapIXZyDRtX/H4bwbioYUKqMQ=; b=wWd7tRVCYIIhovEapsFBvqgBM9kYBBFQXxqAWG3iE3mJSnYo98phHsSWuK7uBKTm9xaff3 EvjIteep5ocqjIKXEroTGQjLGVuYEL6nPpRlSLgrJrAiFD0/Rkf95Ft9K7YaK2kBg9mL5P 2zWtZLkD5ezoBoYAfCH3NGfV7WxRMdM= 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.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672383189; a=rsa-sha256; cv=none; b=lcKOmBezj4O5ADcQfIEuzD9siuDp7RxTrLs3CjyS4CmUjkU4Ynneb4jMO78lkV0cC3wuN8 O79PMfrX2IAkWYKs/bpurqQfbE6mgl1qQsnlpkOn3QWHmGUk8dX9/l8VwURPW9s4sqfQVn qk2ahAo7FP8ZIpAYjTQjOjpgrQSuClE= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NjwpZ1h2SzJpV1; Fri, 30 Dec 2022 14:49:10 +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; Fri, 30 Dec 2022 14:53:04 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v4 5/8] mm/damon/paddr: convert damon_pa_*() to use a folio Date: Fri, 30 Dec 2022 15:08:46 +0800 Message-ID: <20221230070849.63358-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221230070849.63358-1-wangkefeng.wang@huawei.com> References: <20221230070849.63358-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-Rspamd-Queue-Id: 55A1540011 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: xzme7szqmpfk71y1crprgnu4sy7egeik X-HE-Tag: 1672383187-775932 X-HE-Meta: U2FsdGVkX194CRcLJ/8R6nJvbOxUaKo2W7p9epEeC0MEte1D4R1yucOUfFSECK6V3S3sylgyboOQ/VA4pYLDf3JFAME4VdvhtOVA2ypqYAih3yHSCSHhw78TAY4dpEOY797W30LApKQLyBrCCIIJ28ndDw8LHuXwZKzcpaGncS1uhvRHqcr10sahbl5+RgY+esEhhn1V/4NEHDzCFsHNBv9mjX5LZfDYj/Nf/6pw9Q5A9zoevsHW9QD4NIgXsvWT6RCsgJWxoAjxnMh865z/pVvSE29cY1Oa0XHwPxEK/LMR0PhX4TTFdUMpcQxYkUtd5/adPLLhygKcviZUzZZXFCNI093bfr5NWLsQvzJEN0P+O3OGrw3pM6hLc9xcXMvEa32/2SbT87FIEAUSex2h2v8HfrnMo6T1enujMQry0Sj6kJKxThrXfY+cA851Wej+2EHbhZSzlnIyRCLUesep6ynHl2RlQP7kIthUVAid88SZVktKTplxJ2XJcdrkicFYH+aI7OoZkRV8TwA1qZdQiEpEzzt2dgodkYGvv8ZzGbK5Ifoi1KIXsqI/le2zQpQ4l2yoRzvV16RRReQlDkaWNRvefItTsJIzv0NDht8/Jw1eNM3tbbt7ftTIv+2jirQxBHVg4OfSeFAslk34Sm0kokUuzntNR7gczyH7Ks9MInzIze1ICGAneufK0PeSqYadfOdL396SZoJRw6xN0qDVa89i0yZ6JhWW5a1cJinIDXq5CdXGWnzlhOeYA09zT69mv295+WpwJDqh7lZlR5JXU2fN0UzuO7BFAZ2aX5hyjzPLFl/W2lvOPoVn6ZXiE6KlsWivhyz9dcCl+QANtIIg1RIal+0ESaS2sW7x+N5pFM/En05P033bofDnQUb55DO32dlTs54PwywyUpjIchi2D3QVdRxpjI3KxcOLTHKHwPphcjZ47S7i+EKBkcI6LVIq5tGzEeflLd31/hlENwa +82h/rMc +0GEYvisrGYfTilo= 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 a folio. Reviewed-by: SeongJae Park Signed-off-by: Kefeng Wang --- 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..99d4c357ef2b 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 = folio_memcg_check(folio); 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; } From patchwork Fri Dec 30 07:08:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13084132 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 1C24FC4332F for ; Fri, 30 Dec 2022 06:53:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9C4C8E0001; Fri, 30 Dec 2022 01:53:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C4B398E0003; Fri, 30 Dec 2022 01:53:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEC398E0001; Fri, 30 Dec 2022 01:53:10 -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 7D17D8E0003 for ; Fri, 30 Dec 2022 01:53:10 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4E9AF140281 for ; Fri, 30 Dec 2022 06:53:10 +0000 (UTC) X-FDA: 80298055740.19.9DC827A Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 407D3120002 for ; Fri, 30 Dec 2022 06:53:07 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.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=1672383188; 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=yqxiBDVC+BCWFKGtm3LDCpfc9k4s2e0GuMa/SOb0qGU=; b=cPeXq2nR153npBKgrHMbDIeV0a5kOU+0IwrzCRqFh9XR3RmiPhVO2UH2eYiJOfIo6mgJeU RtK0yeHmQapIEUJnjxAOE5dAoZWdvtj7PutmCl/Mmk/85RXRAJrk0pQI2Tbb1sGXum1cOA lGfUPyes5cdg4Lct1+7mGKne5fwhMQY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.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=1672383188; a=rsa-sha256; cv=none; b=v8ymcAzRBd1v8yolOHMJYMMAoIIYYiN46+pIVWwmW+cEEv8RH3pGAoda5HYx/+gdv5RZY/ d/eW6q8jKwc/4fOY4Cd9ny5NScOcPIuCpTDpfBz8d5tuFR7X4GZrE15x/P95lyVXn85rq3 WhwrSlYjbgy3P9FvKKhtzelcIhMThWc= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NjwsT0wpTzRqP7; Fri, 30 Dec 2022 14:51:41 +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; Fri, 30 Dec 2022 14:53:04 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v4 6/8] mm/damon/vaddr: convert damon_young_pmd_entry() to use a folio Date: Fri, 30 Dec 2022 15:08:47 +0800 Message-ID: <20221230070849.63358-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221230070849.63358-1-wangkefeng.wang@huawei.com> References: <20221230070849.63358-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-Rspamd-Queue-Id: 407D3120002 X-Stat-Signature: kxmnbepk87uzqkpgt1crm4qikwmriqxr X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672383187-892220 X-HE-Meta: U2FsdGVkX18r8D9tE/oNuSURL3BG1ZLyeRQERhh+toHC7PQQRhP1b3R03p+/HHWevltjRIrvSEgjImkrYsa0+WfLvIVTINv9W+p//ewgmKMVNBX3kXJYTA8GLuLv+EDBad9E1JYhJ2bQ5hJAmBzr1RdYBBfB7u0qKepw/sXcKfhFpPy3D/IBZ0ss5SEPMb/iEq5lmnoaX08TemQO11n0UGVWVoEPfrpnUXvYeq5VRfUHyzTJ7EXb+2eG1b4pka3ifWAv4szDcruk6DHDmUSUkfc03t1kkdH3zBI7ofB9Bn7yaHAVfmAayaxld/NuaLTpdbD9LL7UukRkwpNM3Qi00GJDYmVipm5vgj4giw1Z8luAV9oHsQzAzrqdnrs/jjHLBABmsPrETFxqgOATBExkhwCmjU5UHWD9f1Xwuay61HilA2t2cuMb+0FLY6phT9c2ndmfI+aQSSwO5xFBIckC36MHrq48Xl1yopU3DCNiShATY1G0qf+L68LEOn+y05vTZkSAek1WKJwdoc5NkN6F/SiYUp9hkB0M21/FdoKQQMImwRISu1IcXPBl7TqWKHHclXFWQGX/ATBt65Z2B/4NSWA+cZWvw/CmgYpucXlIIGWdVvzaNOtbkDoz3tKsRk1jTqCZwqe0QT5v635afwrm7IkjV5WJRsLrZMwRZMn9IUmrEbIE7aj2frzJ2mL/OCLbH/ZiJ8gqjTZcXdVE2hIMY6kwREz+l1wn3ACBIWm9Cs+4u7kbUkAP2c1NYRgOHynIy8N3XzAMtWtsnJVgwXle7CbyaGHpxOg8Ovtx1xmO6G/mXw3HaI1PO7gwCODUGVJXRS8P3X0CY61e3T2aQ57TUeTHCK3p+6VQKZDbDWT4Xv5xbV1Qn69a8ujtUS9RfPLp8iX08rthXNDTG9fvAol5FB0U2RBMl26f00AAfA0s5TKLfrfZW/Oni4KZwqUUzGSab+qhUAxMpcps6JW4HBM MOnXM1ba yQ3GL7bKGHLrHHFo= 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 a folio. Reviewed-by: SeongJae Park Signed-off-by: Kefeng Wang --- mm/damon/vaddr.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 15f03df66db6..29227b7a6032 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->young = true; } - put_page(page); + folio_put(folio); out: pte_unmap_unlock(pte, ptl); return 0; From patchwork Fri Dec 30 07:08:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13084137 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 E3858C3DA7C for ; Fri, 30 Dec 2022 06:53:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8088D8E000A; Fri, 30 Dec 2022 01:53:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B7B88E0006; Fri, 30 Dec 2022 01:53:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 680E48E000A; Fri, 30 Dec 2022 01:53:12 -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 54EF98E0006 for ; Fri, 30 Dec 2022 01:53:12 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 375A0C050B for ; Fri, 30 Dec 2022 06:53:12 +0000 (UTC) X-FDA: 80298055824.09.2EDC6FD Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf12.hostedemail.com (Postfix) with ESMTP id B99494000B for ; Fri, 30 Dec 2022 06:53:09 +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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672383190; a=rsa-sha256; cv=none; b=e374u9DMQY3lOKLN4V7+ltyUBlHEC6V3GL7z0hcC46OcFXSE/b8Cuqav8B7mndq8l4KCa4 sNeQO6Suj95GDQ9gky54gaQR/PpJormEq47Ld3j+8fF1q57pTaSQzfXak9CqO2/0pgSG2S S+mSgAdWCLyZ1pOM/6T2cc/6IyDUFRc= 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672383190; 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=eMvCCThmAD1ZsyZ6nk+cqAKGcql/5AGf5w8MayiyGY8=; b=yz/92JOMlLBkPjwQcXWlaQYW1u7eJVugyaZisyP6m3POB9mrK/X02jwWPU49wgOeEOq40n CrBg/w9LvagUSITkKi2SYB7PJvXVIh/zEMeOGe96xC6jF3e2THn+Wj74sJ/ZePKKYtqe7b Of++ROThfaB1XaI3bUsCa4HDP0uzP9I= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Njwnr00xQzqTJV; Fri, 30 Dec 2022 14:48:31 +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; Fri, 30 Dec 2022 14:53:05 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v4 7/8] mm/damon: remove unneeded damon_get_page() Date: Fri, 30 Dec 2022 15:08:48 +0800 Message-ID: <20221230070849.63358-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221230070849.63358-1-wangkefeng.wang@huawei.com> References: <20221230070849.63358-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-Server: rspam03 X-Rspamd-Queue-Id: B99494000B X-Stat-Signature: ujrz87r7h1fkec1oodugko4fiux9e5i7 X-HE-Tag: 1672383189-439682 X-HE-Meta: U2FsdGVkX1+Zthm48e47SNq+MH3ljrw2HGJrAjBK/VK6OTf8H9yiMmXAtUWPbTMR08Nm03ZDREJSXBGDnbCDT4InCWmS+Su+p6+h5BALsfHOEd2mFaheRAepAOFAhXakNJs8GOLXMj7dEnQFQ/Ztd0EFIoGVgeNexFbMBSzNCZwrqNunH5uEfEzWt9S0If0x2XOKLQC7pLa7UHPu9AiX1X+lkcLZ/anzy10Q9emN/rnsOgFZ6+jDtVjc/YDubZvknuhJPEHgpRS1T0dQuXGUvZLasxLJwqqXEvH12tfj0+ydoJ5W53g7pi/DKaE+QUYVoUR9eiMQe1Izwc3f5k2kXGdTpozsPx6oT0Hh7Sc0HrCdHxYzlG4Il6x6wmNLO0rHYaOzgFdBLdXLu3GgLFrLvV8PhxKF1tX/CK9soNKZ8wJLN9TPi6Rz7R+yVjZX4xUR2WgLvosnCbV/XCGcNcV59+JDWc4CvC7mNDhsePVMctL3r+J/tUwUkFRGC3yaPbjAx1VY1+IRnv3qjNNZt86KpKwnDTC41MhfyXxe7PLjPUlK/zfmKcSl9FFW1M8KwbXpKU/PnyoIC5J1sd6z+vzo3Rc404e0eMQwEPbJTXgUM6RqynJEkYv0Z7biPYA4bN30dnZ7qktUhMwO7iJaFPMO/XbyHTTngqvMjoi1gkf66eQEF3f6/oxVGdovJEG7ycwfbrnk+Dn2cHACNOpOQHL7ZvyY0ZlcqiEtel2vEIkLXmBIia6i3EX/MasuP3SZ6LysuDvWy2w1cYlrB30pueKsG9OiKGY0ZGR+zUE8SKcVyQpOErUArOQr3aMgIvB7sZ6HOEJd8A8jZRMlPHNZndpfUp/ok2gn5M9Uson7MV2ZnbEAVzcjvXaHzMEAj1wspFVQaOFRT7+cBw+YsT6AmXI8QGfx5SnwQJBU49SQwVq2VNrkmGw55C6OGkFaYuNw2ffe/9cLC7B5uPgnkJ2zIMj oeVccdTP TXNuxtKzw7RXWC+Y= 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 unneeded wrapper damon_get_page(). Reviewed-by: SeongJae Park 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 65f290f0a9d6..14f4bc69f29b 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); - - /* when folio is NULL, return &(0->page) mean return NULL */ - 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 Fri Dec 30 07:08:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13084138 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 03B75C4332F for ; Fri, 30 Dec 2022 06:53:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A796E8E000B; Fri, 30 Dec 2022 01:53:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A2B138E0006; Fri, 30 Dec 2022 01:53:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A2D38E000B; Fri, 30 Dec 2022 01:53:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7B7338E0006 for ; Fri, 30 Dec 2022 01:53:16 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 51A111A0550 for ; Fri, 30 Dec 2022 06:53:16 +0000 (UTC) X-FDA: 80298055992.13.4C81C52 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id 325B81C0007 for ; Fri, 30 Dec 2022 06:53:13 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.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=1672383194; 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=oSpxjdrx5WttBIyn/GUx2UUT2/CnGpbuNERYbxXuj0Y=; b=GDtasib89orBtomwBo0hhxUMt33VdWNjUVeQK9nAnye0lqPe1QviJwTEgduC7UdrPx58KU Iltq7qdIk1MnYax9rylRiJBB/WQk4Z2vJyDD9etWreIujz51rflQ86Dgqys7KRsx6z+e6u IoB8UB/ru+qSOyjMm4GOrFDoK3Q67f8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.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=1672383194; a=rsa-sha256; cv=none; b=K23+n3sJGpS/t2Py56zItrrpXUBcWIu0sB8QizXwTaGyvkYWUhnECKezM7/qW9QupG+bPN uOm8zhk1tomfS4k3jJlJFGVmzy0DKhciHKlKbTWgAIvR9wMLR0PXZhJSIy6we0B4jT0ONw MRwkOqReI5b0W17bjBY8p1NNtpqDt7o= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NjwsZ56w8zbc4G; Fri, 30 Dec 2022 14:51:46 +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; Fri, 30 Dec 2022 14:53:05 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v4 8/8] mm/damon/vaddr: convert hugetlb related functions to use a folio Date: Fri, 30 Dec 2022 15:08:49 +0800 Message-ID: <20221230070849.63358-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221230070849.63358-1-wangkefeng.wang@huawei.com> References: <20221230070849.63358-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 325B81C0007 X-Rspam-User: X-Stat-Signature: autpeoppuhmmd187iu7uqkbaapx1kxxr X-HE-Tag: 1672383193-647741 X-HE-Meta: U2FsdGVkX1+M6Yj52FfpybWna4mHOZkC7JqD4f2122nTBR9pf5VzBP7WURx4BCRnDa4pMY4ZYpBRMUvcYdAqiv8zb0/LXla+J4HY/6RjRzNAqixr31mCO+ihikAWOic5ZH/UBdV7ijrmrR3orozNbSF3XjI5hs75Dz6qE1oeQ2nBAynTr1ba/dmOK7hAggqBHp758Yn+d/9/tjTtN4f3C4/ztXmwT2UPkD74UlGjEdqOiWiBvrX96q1Irp420zVW9aCkJtQ4swioepFmcYs7CWGJYlNmMIl65VPV6yzcD0MlUsh5fLFGzvnOij3vMurnGZXwn+MYfy1CtSkYB2j8QkTtDkw03DtGMJ8iJCr4n7nuN5JS2CA4IActac5YxzMBXGiVSTqkvUsa/KyHeKvAtRvUntZe6mazn+kSdwOVRHwIf/0Ffrk8OXJxgV513Xs1L33UikldFW4A12MG4hOeNbsEM+GnbVi0IN5o27KfSKH6/LKXVrlZbCu44r3EI4Eu1+imRqrnURHbI4iD8ZGOfO5K4qYsC+f/x+nsLT6Cl773eFkuQICTlL0nCelzpQ44Nr12r6QyXYHozplu32JJaCB98O04qTu7VRt9zGmKh6vWfGgkveKOe61TJ/3t7osuA0tnGbqam36qfk47mw8b1W8sCSjvGh+ZsiUsZ671TTWVLYXm+YvsH7OJ6+Rv90bVs/WY1K4docNfaCh1WOF0L5lbxnz/d2iXHj5BnKbL7OBXGK3uKKzCnYR2mood+14EOp1xvruLDds9SxpJjj39ejREpZxanQnHsGILbrMBT7Ima63qAORodzCTCrEP/bxlDjqAgAzTQhSKdNdVvKGSzQ/UyG475gViDg3eaSlqqAxFDLkGRxn1sgvdWJ4fhL6NP18cPSvAeIeEWeDNyeOWMfD9R5Q78Iemy8EOj34CTfVrUMf1C8KSew== 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: Convert damon_hugetlb_mkold() and damon_young_hugetlb_entry() to use a folio. Reviewed-by: SeongJae Park 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 29227b7a6032..9d92c5eb3a1f 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -335,9 +335,9 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm, { bool referenced = false; pte_t entry = huge_ptep_get(pte); - struct page *page = pte_page(entry); + struct folio *folio = pfn_folio(pte_pfn(entry)); - get_page(page); + folio_get(folio); if (pte_young(entry)) { referenced = true; @@ -352,10 +352,10 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm, #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); } static int damon_mkold_hugetlb_entry(pte_t *pte, unsigned long hmask, @@ -490,7 +490,7 @@ static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask, { struct damon_young_walk_private *priv = walk->private; struct hstate *h = hstate_vma(walk->vma); - struct page *page; + struct folio *folio; spinlock_t *ptl; pte_t entry; @@ -499,16 +499,16 @@ static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask, if (!pte_present(entry)) goto out; - page = pte_page(entry); - get_page(page); + folio = pfn_folio(pte_pfn(entry)); + folio_get(folio); - if (pte_young(entry) || !page_is_idle(page) || + if (pte_young(entry) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, addr)) { *priv->page_sz = huge_page_size(h); priv->young = true; } - put_page(page); + folio_put(folio); out: spin_unlock(ptl);