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.