From patchwork Wed May 15 07:07:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13664662 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 0A9ECC25B75 for ; Wed, 15 May 2024 06:41:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A9D86B0107; Wed, 15 May 2024 02:41:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65B696B0109; Wed, 15 May 2024 02:41:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 523C66B010A; Wed, 15 May 2024 02:41:58 -0400 (EDT) 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 319016B0107 for ; Wed, 15 May 2024 02:41:58 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D59948147B for ; Wed, 15 May 2024 06:41:57 +0000 (UTC) X-FDA: 82119685074.19.BE310EC Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf23.hostedemail.com (Postfix) with ESMTP id E7EBB14000E for ; Wed, 15 May 2024 06:41:54 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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=1715755316; a=rsa-sha256; cv=none; b=ztzfkZ0HI7DpU8Pd4GUyunCUwELOQ8R1l0DNit3IXJImSnVJLVMK2qpevpTLtTNrdSbXB1 A69UfUoR+kZ40BZPzETUBmDlDo/UmTn8RB+gQuczBOxoA40RojlZdyQjW290Lyrkw5DF2U 5m/onDqYfnMrriBaeSpb4L6CY/Uz3Ig= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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=1715755316; 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=4jU7jDNMXqCaPI/zFfaWxFW9Qw4GmEXsVJ1NvR238Ls=; b=omDQS5K6nnP5axB1FqUaz2MIG4AOO5Viuu/0k5Bvy56J+a5/LMR5vU7k9qosVmn0srOXzQ qUzoAZyeIrrpMIQ2GvdmtHwKfEOd/XQv0SLUM7DBkxHSgQhyXi+6rX/k8SaG7azyo0q9dy 4rCpCVpjEJ5hP4akUdOBnzmfBW9MU6c= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4VfNrp5DmHz1HCCh; Wed, 15 May 2024 14:40:26 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id E8EBB14035F; Wed, 15 May 2024 14:41:50 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 15 May 2024 14:41:50 +0800 From: Kefeng Wang To: Andrew Morton CC: Hugh Dickins , , Kefeng Wang Subject: [PATCH 1/4] mm: add folio_alloc_mpol() Date: Wed, 15 May 2024 15:07:06 +0800 Message-ID: <20240515070709.78529-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240515070709.78529-1-wangkefeng.wang@huawei.com> References: <20240515070709.78529-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: E7EBB14000E X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: drggf9cogmkr9a9i431w6cmppj4x433s X-HE-Tag: 1715755314-60103 X-HE-Meta: U2FsdGVkX1/23R52QsGzj62gxA4SQGkf91SWTdezQxtuAxsJPbDIj1vXsWx8YozMA2XoLCSeZeGv1FvR8hFiWgAUzGndW6ABO/1x1cmM8yWZaTqgJKq6e5c468KTpcYeMhpPN6VKI61YmvKsOe8vC1sqkgzfR/zjFwobwz4h8WPX7HJhP3qiunVV6Rl2d2fmkIujRGnVHitFlcz41Lv0diprZK9NCO8qAlO5ItBO02fxnga/7mzl8k6J1mzEf4z41HgvMxtVKNIYNfzjvjvbv6iAqnE42lOOm+q0DC7A/cRmfjEL78ZRMmgO9aera3spIVLwV5yjVx6mfiR/RdHGyqJelbfXUarpuZgoZkGT4YhgAZeJ4V9GweKBjkHswRUdx5lP0Q2ah3vYvfDvSi5VSP5aJTGQPJ6KxhSNaUKUDW1KBiNZrqmZef85xfI4HjWl9uRZs3QSnFePhewUgqLj3VENPmn2TgTzwOibnrXWDVAXSHkHtCPoiLiPCLgdiu2CpuOFNG8gpDgHcZYo0FHLtSc9O53nmHOhvj8ixCb5tuyXu7tc7LAD+BTCtavzpkZdiERIqyufYWKzcA+39aFOZc/JcGbIivRp0wep83EK2YyiVKNMuBLTj6l4Rao82KvPz0KTxAfzENPE3k27fZaNo1BTC9aHD1+1hd4aokCslc7Rp0c9xEzT8QO0uYPetKvMCNfqQeIfPKsOiKV2r66Y4Ge0CiODXdDh1rPPkHztbI0DOt6zsdCW8XUQkZhSKyI06VfvkoOnppChAjgEoeic/HVMCjUsK65LC1YdJqxHi4or1dJNkBPRLWdILJZyCKwH9R/shuhbMQw6pOBMhMuh30DOUiRjJB9ahQ24+M2Vv2YNW5jm6caFapBiM0oPD/80yFBk/znLx0KssfKYzfvwBDpLKr8w22bjNDrdDQjZToRchBX/MiXB2nnY32vdcekx9BxqDzYmf/phjzFjbej zm6uPYUf ABaMhsY2VWQ+/ldeJUdBWuJ+90vqCjHdHu4ptBFQB0LT9D5DK14ctx+IjfhlpyBGrTaPg5wQxIXd2SZtaNVy7uSTgaZlhdE++MOV6e5CcyGuiDsNn0/Vj40Vh/sFevuEbiyPhX6zkh0BCKmL7u0OQeSoxaLw6a4ci102pz5a/Mh5vp+5dfzf3R8wk2nPV6ArSRe3+ 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: List-Subscribe: List-Unsubscribe: This is to add a new folio_alloc_mpol() like folio_alloc() but allocate folio according to NUMA mempolicy. Signed-off-by: Kefeng Wang --- include/linux/gfp.h | 8 ++++++++ mm/mempolicy.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 7f9691d375f0..f53f76e0b17e 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -303,6 +303,8 @@ struct page *alloc_pages_noprof(gfp_t gfp, unsigned int order); struct page *alloc_pages_mpol_noprof(gfp_t gfp, unsigned int order, struct mempolicy *mpol, pgoff_t ilx, int nid); struct folio *folio_alloc_noprof(gfp_t gfp, unsigned int order); +struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned int order, + struct mempolicy *mpol, pgoff_t ilx, int nid); struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order, struct vm_area_struct *vma, unsigned long addr, bool hugepage); #else @@ -319,6 +321,11 @@ static inline struct folio *folio_alloc_noprof(gfp_t gfp, unsigned int order) { return __folio_alloc_node(gfp, order, numa_node_id()); } +static inline struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned int order, + struct mempolicy *mpol, pgoff_t ilx, int nid) +{ + return folio_alloc_noprof(gfp, order); +} #define vma_alloc_folio_noprof(gfp, order, vma, addr, hugepage) \ folio_alloc_noprof(gfp, order) #endif @@ -326,6 +333,7 @@ static inline struct folio *folio_alloc_noprof(gfp_t gfp, unsigned int order) #define alloc_pages(...) alloc_hooks(alloc_pages_noprof(__VA_ARGS__)) #define alloc_pages_mpol(...) alloc_hooks(alloc_pages_mpol_noprof(__VA_ARGS__)) #define folio_alloc(...) alloc_hooks(folio_alloc_noprof(__VA_ARGS__)) +#define folio_alloc_mpol(...) alloc_hooks(folio_alloc_mpol_noprof(__VA_ARGS__)) #define vma_alloc_folio(...) alloc_hooks(vma_alloc_folio_noprof(__VA_ARGS__)) #define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index aec756ae5637..69c431ef15d5 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2277,6 +2277,13 @@ struct page *alloc_pages_mpol_noprof(gfp_t gfp, unsigned int order, return page; } +struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned int order, + struct mempolicy *pol, pgoff_t ilx, int nid) +{ + return page_rmappable_folio(alloc_pages_mpol_noprof(gfp | __GFP_COMP, + order, pol, ilx, nid)); +} + /** * vma_alloc_folio - Allocate a folio for a VMA. * @gfp: GFP flags. From patchwork Wed May 15 07:07:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13664663 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 4494DC25B7A for ; Wed, 15 May 2024 06:42:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D7B46B0109; Wed, 15 May 2024 02:41:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43B3C6B010A; Wed, 15 May 2024 02:41:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B24B6B010F; Wed, 15 May 2024 02:41:59 -0400 (EDT) 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 0E1BA6B0109 for ; Wed, 15 May 2024 02:41:59 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DE85D1613F5 for ; Wed, 15 May 2024 06:41:57 +0000 (UTC) X-FDA: 82119685074.16.42F6092 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf03.hostedemail.com (Postfix) with ESMTP id 108C320013 for ; Wed, 15 May 2024 06:41:54 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1715755316; 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=sVlsRBiViqq6LQYR2Gd0z3+5NVhBvNQDRQi413iU5Xc=; b=LQ+x4NMnrLBxz2iaB9d+kU57spjdBoLpNCfJAtudLHV6jWDt9ZSsdw69bxKSNCRBqumux4 ExF6P7OXXGpu5E2N7GwL3Pep/C20H6oLjqAty5fyy14yesi3LLHLnGkaGWmPebHgoZ/jie izA7x8lVP3wAyotU7ryqZE4oDDQUW5g= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715755316; a=rsa-sha256; cv=none; b=EzyK4Abp2NjPMK8p+hEftFStlPEbFh8IeQXXOP93ZQGnw2GC3XeCz+IM8GzSpsPXuRgC2d OVH+wD3vhVWPtmtk1mT24TsErbBQviZPWGTnrJ0wKT3e7bnHWQdZ4MA4Wl+WYHO04pYXuz 6qxtF9OPXgmtrD1S9SD8bpUNWxX12M8= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VfNpX4ZlXz2Chgv; Wed, 15 May 2024 14:38:28 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 497FE1A0188; Wed, 15 May 2024 14:41:51 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 15 May 2024 14:41:50 +0800 From: Kefeng Wang To: Andrew Morton CC: Hugh Dickins , , Kefeng Wang Subject: [PATCH 2/4] mm: mempolicy: use folio_alloc_mpol_noprof() in vma_alloc_folio_noprof() Date: Wed, 15 May 2024 15:07:07 +0800 Message-ID: <20240515070709.78529-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240515070709.78529-1-wangkefeng.wang@huawei.com> References: <20240515070709.78529-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 108C320013 X-Stat-Signature: 5fcj3ppi4isi4cafu8tk74w5dtpon97i X-HE-Tag: 1715755314-458900 X-HE-Meta: U2FsdGVkX1+z4KkkYAyQheBF6R22S/FW5Lfe9pQnU7xBdRQVOy/EkLvzv7Hxl1GUVfNeo7qT6QLszfQ80fwM9NzUj7fm5TLStb5HQom1ke4BfeQWy5CgJhijOhlikQa/4zd88o/+W27WKy2bZuAYMjFoRI3Dvawn5ptByUwdCDalyr7BH6f3V419SL6JWMFzwOPNgfSTA5nuuxI8v+4fTGkgmd8rLLjHqQhJlvarqQWnnyt2uAGv9VMm1Q50WkF1WURXXn2vlZfz1SKdCxQSaXnQo16qnWXDO5rHeKwm45LbR+8A7IjMkuG4YwZl1Rh5q15m8wo/2peNs3TjwM64/Dv8m53png2ZZv2HXzfnrnQ6jnFbAYpov8SSwVGJwwBYMss/F/tUrZusCnKD0MT+t0emcRd5w4eRvZgTw/A7ae8Sf8YINGV6mwghvOsEqDBS3HTYVSDTr6b14dw9QtN0+LejKLZggH6StMn/Rfynkj92Apr9p7D7dKx8EBxe7HvOhMiNVLxeK2drtAWsgbGHv+lZG9gePqNuStrxtdHIEoqueaKcIioaUAhYuhHTexeHCYOLMiAS0n6T1JX1Ca8Jg1gl4do2/uDS52xHecT8yxaj/9Rx+Acdht7JMq98wpB66tozXSBtSdpvuEQBTvvVZwx6IB4kFS6gZQQHGOVAUyzXXSCOi13HfOOO9bBYC5xyAmIHuok/VLSZ7e/V6I86JWdealIKCEEq3KVa9vesfFEyj2ayZND94noNn8g+E6lIq5W4AUuyIvDMx0pA6j63DC7DnrHIaaHTxOUw2gPCsGRHHTuNdfhqw/Km/u4b9MWEM2/d8sTQXPPIbX83ors8rc7SdYGp6GAh46MVUXXXu/+VHP+G4+tHLVdnUIqOQNaZSV9SnEEC0gvD3UsOKXY71JwjQT2oWNlAxeKl3/u3356/vZT5RuN0FXla+UolsD73WdbdPibg/xo74fJ7DDv QV7iXosy YwBsCvBK5y9M0b5jp3EZpvDrpAPZHKFUQ5OHt1h4/qxliHwFt0EdVoF5a0qCECyiOUykvUhjT2ToWymkkQalrFnUjyGczbMHXDaTq55eplPjcf8DEK54KRzfo0ISybv3JzNCwsbMRUniiZ3VNwBejLWcSuY87zGlq5QxCzlskmB5znIsQgQ6uPJ65Xmg0Yem7T8PW 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: List-Subscribe: List-Unsubscribe: Convert to use folio_alloc_mpol_noprof() to make vma_alloc_folio_noprof() to use folio throughout. Signed-off-by: Kefeng Wang --- mm/mempolicy.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 69c431ef15d5..205d129c6744 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2305,13 +2305,12 @@ struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order, struct vm_area_struct { struct mempolicy *pol; pgoff_t ilx; - struct page *page; + struct folio *folio; pol = get_vma_policy(vma, addr, order, &ilx); - page = alloc_pages_mpol_noprof(gfp | __GFP_COMP, order, - pol, ilx, numa_node_id()); + folio = folio_alloc_mpol_noprof(gfp, order, pol, ilx, numa_node_id()); mpol_cond_put(pol); - return page_rmappable_folio(page); + return folio; } EXPORT_SYMBOL(vma_alloc_folio_noprof); From patchwork Wed May 15 07:07:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13664665 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 9C121C25B75 for ; Wed, 15 May 2024 06:42:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 240B76B010F; Wed, 15 May 2024 02:42:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C6976B0113; Wed, 15 May 2024 02:42:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01E4E6B0116; Wed, 15 May 2024 02:41:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D698B6B0113 for ; Wed, 15 May 2024 02:41:59 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7FD7840182 for ; Wed, 15 May 2024 06:41:59 +0000 (UTC) X-FDA: 82119685158.18.C768FB1 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf15.hostedemail.com (Postfix) with ESMTP id 48163A0005 for ; Wed, 15 May 2024 06:41:56 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1715755317; 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=OrEzahXSibF5mEkCH7RTxkYpnHA8H+rEZt5gJ4KEfE8=; b=FUCCO9EeZJ+g9vXgtyT3w351xkAQrOwg/5eJ3B5EKspuHlB54qG4GzP0jelMPzCxVOXS8h 3YFQzGYhDyd33VUHHsYcsbRDdLXhZ+C0B6I9pDR8c+zzxsDaiEbsLRAUYzogwxj5bzoBlr 1w72ZijkwqNsLAR3f9ioWuuJ/aMOk9E= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715755317; a=rsa-sha256; cv=none; b=SSrOg9a7B+8qtvK9glwzQA8p65K/jM74bE3TqCVIeQWWs5HwVMCUCWvIVhNeRyL3SFi5r6 ysORCqsJxSeEAG44db6Z1Vmt+1NPFfPVGfQwhzYmKGFyxPdxLmeuMFMcdhECWCayRuAil7 C7gAa+zgQwLN6JFPH8Q+/dDArqK6Dgc= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VfNq568XFz1ypH1; Wed, 15 May 2024 14:38:57 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id A577D180045; Wed, 15 May 2024 14:41:51 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 15 May 2024 14:41:51 +0800 From: Kefeng Wang To: Andrew Morton CC: Hugh Dickins , , Kefeng Wang Subject: [PATCH 3/4] mm: mempolicy: use folio_alloc_mpol() in alloc_migration_target_by_mpol() Date: Wed, 15 May 2024 15:07:08 +0800 Message-ID: <20240515070709.78529-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240515070709.78529-1-wangkefeng.wang@huawei.com> References: <20240515070709.78529-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 48163A0005 X-Stat-Signature: e87ik71y4g33igyfshhkf984i44ec3u4 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1715755316-311747 X-HE-Meta: U2FsdGVkX1+IJS0p8H2DOPnHw8FQHxGXVMWN2OgUiLt218CRXoH09MK+94Ws9nOY6mCpmILD6h5tT9MKoEEFCRhCo6cCoQNAsZygc56/sxAbBKZN6I1oZC9P4JGzWNZj0yurs0LA6FuV0omZmRSH0bdmstra56JRLgf/1BepzlpFvc4HClL8GG49O5Z8kp862QVn+bkwQrJsI0q6D5ya3kTFM9644xE1eFXusO2tPSvIJ0JlH8HPXm1wuypFSrTdlWAvRHljH3fnpV7AdPxVz6sEoVFMTHGTAlmfn/ae+xvazxOzSnYoDZEGqtUSfm8KAjzzJsLyznZknBoL1TyISPC3UODlQKzd5OYCxbqyyJ3fnRhTpgnFC4CIIdNQOGuJcjNiFOoK4gXCenZtrrhmhVbREue9DF+5PnQOlLMoZ4JLUNC/orVoB/YhViNPe444OfLXBDA1E6cr55Z7JF9gXVruVtikVZ2vGd+4iQDwIZHivMElRMyGSra0kPW0Q2lDDWm4Gu5NjaicjT3dFi7zkFpDpaihpNWcINzjwZoNU6Nl7BtsUgkMJiHse7EdQM+sDfzuznj+tz9yU0/2IJTefVMac/ZKovVVJonfIzTuSBRa0EOgTDsa+BgOz6WED/JixUP77IbyAFL+HDRbJ921/dsfSpJxDZO/PdOYEtnJCJ0Oyj6znnp8hMLe01TdsJCmvQkWALCGNgb1GgihxoxgRp3sfmaQTlxzc/v3bJglH8KOb1qFwNANwmza7CPazUYCfIdQHCjGQ6ppVue6zup9qDJdrwU1wV6Y8H2Aj2krONwufQ9JiNwlYNdzZJZ4fq4sh/hAuFneGOCHJKqgX1Wix9lTCUgLkro2Okd2xGxwd5TYA/xPfNwkg3zVQOvbrwZxAtF+774T/MP9Ryo1u7dvq7+qnGftwMLcfwn4rGVLqPk2TU8/Chx52SqR3z4Hm+V+2DmFcwl9oVlAW8OKPKk HI7se7mY jYv3fCAm7KHaXnPMB4wEDdb5p95n48wLUy7VZQzTsBvJDw3EB7gxUt2UWObZimzHpyv6upF9UfGlx3xTAoFTHIwXOkx08rLGh92flMoIvMp5OtOqpC+Pa9GHMnB8h3nuCsUuHOuSAIEwk9XEMjOL4r4sXtst89wCcJ23lhfYxVEyDwbQHXtW7l60VqGWuFAf94K55 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: List-Subscribe: List-Unsubscribe: Convert to use folio_alloc_mpol() to make vma_alloc_folio_noprof() to use folio throughout. Signed-off-by: Kefeng Wang --- mm/mempolicy.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 205d129c6744..f73acb01ad45 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1211,7 +1211,6 @@ static struct folio *alloc_migration_target_by_mpol(struct folio *src, struct migration_mpol *mmpol = (struct migration_mpol *)private; struct mempolicy *pol = mmpol->pol; pgoff_t ilx = mmpol->ilx; - struct page *page; unsigned int order; int nid = numa_node_id(); gfp_t gfp; @@ -1235,8 +1234,7 @@ static struct folio *alloc_migration_target_by_mpol(struct folio *src, else gfp = GFP_HIGHUSER_MOVABLE | __GFP_RETRY_MAYFAIL | __GFP_COMP; - page = alloc_pages_mpol(gfp, order, pol, ilx, nid); - return page_rmappable_folio(page); + return folio_alloc_mpol(gfp, order, pol, ilx, nid); } #else From patchwork Wed May 15 07:07:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13664666 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 DD4A2C25B75 for ; Wed, 15 May 2024 06:42:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CC0F6B0113; Wed, 15 May 2024 02:42:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C4936B0117; Wed, 15 May 2024 02:42:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DD836B0115; Wed, 15 May 2024 02:42:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D61F06B010F for ; Wed, 15 May 2024 02:41:59 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B37A112146A for ; Wed, 15 May 2024 06:41:58 +0000 (UTC) X-FDA: 82119685116.04.9E4AA8E Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf18.hostedemail.com (Postfix) with ESMTP id 77E091C0016 for ; Wed, 15 May 2024 06:41:55 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1715755316; a=rsa-sha256; cv=none; b=fLyna+5v6nuPfxu0SpCqPUjSuGrvhgduMjIVC7XT7iwyc2IFAnAduBu0i91WCeTnOPDq8/ 0471ncZmBbyK7SafWpd/Jb3899IiDk68carSDShLKLLw8/JwpQZd3/gQlopGOKYnEAntuJ II3p00iCiAT/MGJjtqv6wUqk7HoA3Ng= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1715755316; 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=QB56pqaRS9pLolXf5kdmi4bFsnwTc4rQp8usiB4b2iw=; b=ARoQaXyTr6fzuDG/Z8Zl6gAK27Ci34TnkS1Jni0gWwhRbtKnfMg1hv2SzxE+GbmGHBSChc Di4FwS+N431ywYT24GpF+qTF8BgDTR3aAGt0vBAH0rEe1YpILmekwo2IdcPiEySr3IVle7 GVmxeCRvp036SbpTwusmWl5dsFlG82I= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VfNs510zCz1xrW2; Wed, 15 May 2024 14:40:41 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id F23F61402CB; Wed, 15 May 2024 14:41:51 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 15 May 2024 14:41:51 +0800 From: Kefeng Wang To: Andrew Morton CC: Hugh Dickins , , Kefeng Wang Subject: [PATCH 4/4] mm: shmem: use folio_alloc_mpol() in shmem_alloc_folio() Date: Wed, 15 May 2024 15:07:09 +0800 Message-ID: <20240515070709.78529-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240515070709.78529-1-wangkefeng.wang@huawei.com> References: <20240515070709.78529-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 77E091C0016 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: qctrqdexhep1yjjiji4fgk77m6o3e4sw X-HE-Tag: 1715755315-811922 X-HE-Meta: U2FsdGVkX19yXez452iKtqF7TUX4gIDVlid5VBGPAMCP9OhZT6R4xaSeYQkFr0clW9x3t3fgxnbIK2Fni+J3FLuiHfVlWqPqsb0ucvrmST71Xzr3VcbbkCawHkVh64ClHAxZ8pF4JtMNzTycDB8rUYgMvpfu4W5XgSLNdVMUz25lAHtFICjvouw9Ak7tdamVGPAZevpNA/ONNq3lnElWVk6qVPLhIe7Nl+vluBcRUmXeAr7I5R4MLzuE5Dd6sUwlhqFqFNG29ruU2IXTjkzJ76XyGk6hwtzKNAp3Bw6jzoWqeA64V0QNCgtEy34dAf7e1JyUFzxJ32II00V1KJ2BlEKRlUYgISseaxiM3WyqIW41oZRFImM9Rrv5s234BcE0c4wNEz5hEeqY4Gu71sDaA4cFt89s0ehhpvf9rxJDXm8JscrtFpclvBXzmYPiZEsoiBuH9PJ6/Uz/wY4f12NbX/YaJhjKqrn2Kt0xpNks6xRTtgkc/cuE8Jmf0vyiMx9iH1LxNPPzGtrOa/ZPJCqoSIGNgGzajJ2RA9ZX36Mt5GptA7FHUhMaqu8Zl4GEEF93GGT09V1PXAT8pq1vlNxHzIc6s6adeV6bmvvgQT8vxe+cB0snmJtUznUbrfWhWzwfNPgPiH/KU5cQTgLG+QQ8AXQmdZNxhYPIfuFFDC8jd0xjWulNt1THcIpz5UI5PWJlajeAg74jbCChk434l5T410fkZ9nXL0xxacAqolp+ssWJc99YBcsa0e9JLqsTl/dM4oT9bcySE3Ejc2Fm+SaJHAjoeKZX4uC3n8xfjuIY8jmDmRrHIhhm+/67BVSTEs4F5CaugR6LmS6LPTj+RHQOQ4V2EuRxtanSnk16RWB1Brf0fx+2WILpAmCo5hhOVk0/RKohBAZjUhiNi5cAAkeOzI7TghSSCK3EN7GVHijUgmgvffqLEBUwVHEcXNO810I903lp9VqeJAQNWkpTV9s 6KFJ600n 90h+HeqkuHMeyhnqcB3KeEuENgfeUXyvT+BLNv9fJTRyMg+tc0U+mFTJ3RAWuxhPRiH1x0l9RntkXthd8l3GzOcN6K0lMQBumHAYxxwZyqNSADVBDzcbBtAvoF0NscTbBPR8qHfGFmJ1EsqHyJlQqTyQoifkXUx8ws7e8ExOtc2UuulUKCQW2Zlbk2yi/1dyFvZkF 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: List-Subscribe: List-Unsubscribe: Let's shmem_alloc_folio() to take a order and use folio_alloc_mpol() helper, then directly use it for normal or large folio to cleanup code. Signed-off-by: Kefeng Wang --- mm/shmem.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index f5d60436b604..c950d4b25338 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1603,32 +1603,18 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp) return result; } -static struct folio *shmem_alloc_hugefolio(gfp_t gfp, +static struct folio *shmem_alloc_folio(gfp_t gfp, int order, struct shmem_inode_info *info, pgoff_t index) { struct mempolicy *mpol; pgoff_t ilx; - struct page *page; - - mpol = shmem_get_pgoff_policy(info, index, HPAGE_PMD_ORDER, &ilx); - page = alloc_pages_mpol(gfp, HPAGE_PMD_ORDER, mpol, ilx, numa_node_id()); - mpol_cond_put(mpol); - - return page_rmappable_folio(page); -} - -static struct folio *shmem_alloc_folio(gfp_t gfp, - struct shmem_inode_info *info, pgoff_t index) -{ - struct mempolicy *mpol; - pgoff_t ilx; - struct page *page; + struct folio *folio; - mpol = shmem_get_pgoff_policy(info, index, 0, &ilx); - page = alloc_pages_mpol(gfp, 0, mpol, ilx, numa_node_id()); + mpol = shmem_get_pgoff_policy(info, index, order, &ilx); + folio = folio_alloc_mpol(gfp, order, mpol, ilx, numa_node_id()); mpol_cond_put(mpol); - return (struct folio *)page; + return folio; } static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, @@ -1660,12 +1646,12 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, index + HPAGE_PMD_NR - 1, XA_PRESENT)) return ERR_PTR(-E2BIG); - folio = shmem_alloc_hugefolio(gfp, info, index); + folio = shmem_alloc_folio(gfp, HPAGE_PMD_ORDER, info, index); if (!folio) count_vm_event(THP_FILE_FALLBACK); } else { pages = 1; - folio = shmem_alloc_folio(gfp, info, index); + folio = shmem_alloc_folio(gfp, 0, info, index); } if (!folio) return ERR_PTR(-ENOMEM); @@ -1765,7 +1751,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, */ gfp &= ~GFP_CONSTRAINT_MASK; VM_BUG_ON_FOLIO(folio_test_large(old), old); - new = shmem_alloc_folio(gfp, info, index); + new = shmem_alloc_folio(gfp, 0, info, index); if (!new) return -ENOMEM; @@ -2633,7 +2619,7 @@ int shmem_mfill_atomic_pte(pmd_t *dst_pmd, if (!*foliop) { ret = -ENOMEM; - folio = shmem_alloc_folio(gfp, info, pgoff); + folio = shmem_alloc_folio(gfp, 0, info, pgoff); if (!folio) goto out_unacct_blocks;