From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E296ECAAD6 for ; Fri, 26 Aug 2022 09:25:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343695AbiHZJZB (ORCPT ); Fri, 26 Aug 2022 05:25:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245701AbiHZJYz (ORCPT ); Fri, 26 Aug 2022 05:24:55 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F8C63F306 for ; Fri, 26 Aug 2022 02:24:54 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MDZ8H329MzkWjG; Fri, 26 Aug 2022 17:21:19 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:51 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 01/10] hugetlb: make hugetlb_cma_check() static Date: Fri, 26 Aug 2022 17:24:13 +0800 Message-ID: <20220826092422.39591-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Make hugetlb_cma_check() static as it's only used inside mm/hugetlb.c. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- include/linux/hugetlb.h | 4 ---- mm/hugetlb.c | 10 +++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 852f911d676e..c2abbd7950de 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -1155,14 +1155,10 @@ static inline spinlock_t *huge_pte_lock(struct hsta= te *h, =20 #if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_CMA) extern void __init hugetlb_cma_reserve(int order); -extern void __init hugetlb_cma_check(void); #else static inline __init void hugetlb_cma_reserve(int order) { } -static inline __init void hugetlb_cma_check(void) -{ -} #endif =20 bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f1dc80f47dd6..10d84abb1ca7 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4058,6 +4058,14 @@ static void hugetlb_register_all_nodes(void) { } =20 #endif =20 +#ifdef CONFIG_CMA +static void __init hugetlb_cma_check(void); +#else +static inline __init void hugetlb_cma_check(void) +{ +} +#endif + static int __init hugetlb_init(void) { int i; @@ -7546,7 +7554,7 @@ void __init hugetlb_cma_reserve(int order) hugetlb_cma_size =3D 0; } =20 -void __init hugetlb_cma_check(void) +static void __init hugetlb_cma_check(void) { if (!hugetlb_cma_size || cma_reserve_called) return; --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C10F5ECAAA3 for ; Fri, 26 Aug 2022 09:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343739AbiHZJZI (ORCPT ); Fri, 26 Aug 2022 05:25:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343650AbiHZJYz (ORCPT ); Fri, 26 Aug 2022 05:24:55 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 512183F30A for ; Fri, 26 Aug 2022 02:24:54 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MDZ8H3R0MzkWjK; Fri, 26 Aug 2022 17:21:19 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:51 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 02/10] hugetlb: Use helper macro SZ_1K Date: Fri, 26 Aug 2022 17:24:14 +0800 Message-ID: <20220826092422.39591-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use helper macro SZ_1K to do the size conversion to make code more consistent in this file. Minor readability improvement. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 10d84abb1ca7..24f580ddf130 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4165,7 +4165,7 @@ void __init hugetlb_add_hstate(unsigned int order) h->next_nid_to_alloc =3D first_memory_node; h->next_nid_to_free =3D first_memory_node; snprintf(h->name, HSTATE_NAME_LEN, "hugepages-%lukB", - huge_page_size(h)/1024); + huge_page_size(h)/SZ_1K); =20 parsed_hstate =3D h; } --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D325AECAAD7 for ; Fri, 26 Aug 2022 09:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343718AbiHZJZE (ORCPT ); Fri, 26 Aug 2022 05:25:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343652AbiHZJYz (ORCPT ); Fri, 26 Aug 2022 05:24:55 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 891DC402DF for ; Fri, 26 Aug 2022 02:24:54 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MDZBQ5x3XzGprt; Fri, 26 Aug 2022 17:23:10 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:52 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 03/10] hugetlb: Use LIST_HEAD() to define a list head Date: Fri, 26 Aug 2022 17:24:15 +0800 Message-ID: <20220826092422.39591-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We can avoid unneeded WRITE_ONCE() overhead by using LIST_HEAD() to define a list head. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 24f580ddf130..b3e6592247a3 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -459,14 +459,12 @@ static int allocate_file_region_entries(struct resv_m= ap *resv, int regions_needed) __must_hold(&resv->lock) { - struct list_head allocated_regions; + LIST_HEAD(allocated_regions); int to_allocate =3D 0, i =3D 0; struct file_region *trg =3D NULL, *rg =3D NULL; =20 VM_BUG_ON(regions_needed < 0); =20 - INIT_LIST_HEAD(&allocated_regions); - /* * Check for sufficient descriptors in the cache to accommodate * the number of in progress add operations plus regions_needed. @@ -2352,7 +2350,7 @@ struct page *alloc_huge_page_vma(struct hstate *h, st= ruct vm_area_struct *vma, static int gather_surplus_pages(struct hstate *h, long delta) __must_hold(&hugetlb_lock) { - struct list_head surplus_list; + LIST_HEAD(surplus_list); struct page *page, *tmp; int ret; long i; @@ -2367,7 +2365,6 @@ static int gather_surplus_pages(struct hstate *h, lon= g delta) } =20 allocated =3D 0; - INIT_LIST_HEAD(&surplus_list); =20 ret =3D -ENOMEM; retry: --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FF38ECAAD2 for ; Fri, 26 Aug 2022 09:25:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343747AbiHZJZL (ORCPT ); Fri, 26 Aug 2022 05:25:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343656AbiHZJY4 (ORCPT ); Fri, 26 Aug 2022 05:24:56 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2222952090 for ; Fri, 26 Aug 2022 02:24:55 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MDZ8J2VvBzkWj0; Fri, 26 Aug 2022 17:21:20 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:52 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 04/10] hugetlb: Use sizeof() to get the array size Date: Fri, 26 Aug 2022 17:24:16 +0800 Message-ID: <20220826092422.39591-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It's better to use sizeof() to get the array size instead of manual calculation. Minor readability improvement. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b3e6592247a3..06293da96112 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4177,11 +4177,11 @@ static void __init hugepages_clear_pages_in_node(vo= id) if (!hugetlb_max_hstate) { default_hstate_max_huge_pages =3D 0; memset(default_hugepages_in_node, 0, - MAX_NUMNODES * sizeof(unsigned int)); + sizeof(default_hugepages_in_node)); } else { parsed_hstate->max_huge_pages =3D 0; memset(parsed_hstate->max_huge_pages_node, 0, - MAX_NUMNODES * sizeof(unsigned int)); + sizeof(parsed_hstate->max_huge_pages_node)); } } =20 --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3F49ECAAD2 for ; Fri, 26 Aug 2022 09:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343755AbiHZJZP (ORCPT ); Fri, 26 Aug 2022 05:25:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343665AbiHZJY5 (ORCPT ); Fri, 26 Aug 2022 05:24:57 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62EA25727D for ; Fri, 26 Aug 2022 02:24:55 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MDZ9h3QwDzmV7R; Fri, 26 Aug 2022 17:22:32 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:53 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 05/10] hugetlb: Use helper {huge_pte|pmd}_lock() Date: Fri, 26 Aug 2022 17:24:17 +0800 Message-ID: <20220826092422.39591-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use helper huge_pte_lock and pmd_lock to simplify the code. No functional change intended. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 06293da96112..6ea9f73aea84 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6094,8 +6094,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, page_in_pagecache =3D true; } =20 - ptl =3D huge_pte_lockptr(h, dst_mm, dst_pte); - spin_lock(ptl); + ptl =3D huge_pte_lock(h, dst_mm, dst_pte); =20 /* * We allow to overwrite a pte marker: consider when both MISSING|WP @@ -7176,8 +7175,7 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long a= ddress, return NULL; =20 retry: - ptl =3D pmd_lockptr(mm, pmd); - spin_lock(ptl); + ptl =3D pmd_lock(mm, pmd); /* * make sure that the address range covered by this pmd is not * unmapped from other threads. --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C392CECAAD2 for ; Fri, 26 Aug 2022 09:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343700AbiHZJZS (ORCPT ); Fri, 26 Aug 2022 05:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343668AbiHZJY5 (ORCPT ); Fri, 26 Aug 2022 05:24:57 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB34F67452 for ; Fri, 26 Aug 2022 02:24:55 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MDZ8K1yqnzkWh6; Fri, 26 Aug 2022 17:21:21 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:53 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 06/10] hugetlb: pass NULL to kobj_to_hstate() if nid is unused Date: Fri, 26 Aug 2022 17:24:18 +0800 Message-ID: <20220826092422.39591-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We can pass NULL to kobj_to_hstate() directly when nid is unused to simplify the code. No functional change intended. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6ea9f73aea84..58eeae934e09 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3779,8 +3779,7 @@ HSTATE_ATTR_WO(demote); static ssize_t demote_size_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - int nid; - struct hstate *h =3D kobj_to_hstate(kobj, &nid); + struct hstate *h =3D kobj_to_hstate(kobj, NULL); unsigned long demote_size =3D (PAGE_SIZE << h->demote_order) / SZ_1K; =20 return sysfs_emit(buf, "%lukB\n", demote_size); @@ -3793,7 +3792,6 @@ static ssize_t demote_size_store(struct kobject *kobj, struct hstate *h, *demote_hstate; unsigned long demote_size; unsigned int demote_order; - int nid; =20 demote_size =3D (unsigned long)memparse(buf, NULL); =20 @@ -3805,7 +3803,7 @@ static ssize_t demote_size_store(struct kobject *kobj, return -EINVAL; =20 /* demote order must be smaller than hstate order */ - h =3D kobj_to_hstate(kobj, &nid); + h =3D kobj_to_hstate(kobj, NULL); if (demote_order >=3D h->order) return -EINVAL; =20 --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20A53ECAAD2 for ; Fri, 26 Aug 2022 09:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343814AbiHZJZW (ORCPT ); Fri, 26 Aug 2022 05:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343672AbiHZJY6 (ORCPT ); Fri, 26 Aug 2022 05:24:58 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE0E176761 for ; Fri, 26 Aug 2022 02:24:56 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MDZBS4mjmzGps0; Fri, 26 Aug 2022 17:23:12 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:54 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 07/10] hugetlb: kill hugetlbfs_pagecache_page() Date: Fri, 26 Aug 2022 17:24:19 +0800 Message-ID: <20220826092422.39591-8-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Fold hugetlbfs_pagecache_page() into its sole caller to remove some duplicated code. No functional change intended. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 58eeae934e09..7934188bbed0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5467,19 +5467,6 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, s= truct vm_area_struct *vma, return ret; } =20 -/* Return the pagecache page at a given address within a VMA */ -static struct page *hugetlbfs_pagecache_page(struct hstate *h, - struct vm_area_struct *vma, unsigned long address) -{ - struct address_space *mapping; - pgoff_t idx; - - mapping =3D vma->vm_file->f_mapping; - idx =3D vma_hugecache_offset(h, vma, address); - - return find_lock_page(mapping, idx); -} - /* * Return whether there is a pagecache page to back given address within V= MA. * Caller follow_hugetlb_page() holds page_table_lock so we cannot lock_pa= ge. @@ -5885,7 +5872,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct= vm_area_struct *vma, /* Just decrements count, does not deallocate */ vma_end_reservation(h, vma, haddr); =20 - pagecache_page =3D hugetlbfs_pagecache_page(h, vma, haddr); + pagecache_page =3D find_lock_page(mapping, idx); } =20 ptl =3D huge_pte_lock(h, mm, ptep); --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F94FECAAA3 for ; Fri, 26 Aug 2022 09:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343862AbiHZJZZ (ORCPT ); Fri, 26 Aug 2022 05:25:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237130AbiHZJY6 (ORCPT ); Fri, 26 Aug 2022 05:24:58 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E12937960F for ; Fri, 26 Aug 2022 02:24:56 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MDZ8d6qH4zlW3j; Fri, 26 Aug 2022 17:21:37 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:54 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 08/10] hugetlb: remove unneeded SetHPageVmemmapOptimized() Date: Fri, 26 Aug 2022 17:24:20 +0800 Message-ID: <20220826092422.39591-9-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If code reaches here, it's guaranteed that HPageVmemmapOptimized is set for the hugetlb page (or VM_BUG_ON_PAGE() will complain about it). It's unnecessary to set it again. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7934188bbed0..b432a00061e3 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1520,7 +1520,6 @@ static void add_hugetlb_page(struct hstate *h, struct= page *page, =20 set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); set_page_private(page, 0); - SetHPageVmemmapOptimized(page); =20 /* * This page is about to be managed by the hugetlb allocator and --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 639F8ECAAD6 for ; Fri, 26 Aug 2022 09:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343957AbiHZJZd (ORCPT ); Fri, 26 Aug 2022 05:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343685AbiHZJZA (ORCPT ); Fri, 26 Aug 2022 05:25:00 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D4A952090 for ; Fri, 26 Aug 2022 02:24:57 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MDZ8M0VRqz19VLD; Fri, 26 Aug 2022 17:21:23 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:55 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 09/10] hugetlb: remove meaningless BUG_ON(huge_pte_none()) Date: Fri, 26 Aug 2022 17:24:21 +0800 Message-ID: <20220826092422.39591-10-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When code reaches here, invalid page would have been accessed if huge pte is none. So this BUG_ON(huge_pte_none()) is meaningless. Remove it. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b432a00061e3..0ef26dbdc7f8 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5374,7 +5374,6 @@ static vm_fault_t hugetlb_wp(struct mm_struct *mm, st= ruct vm_area_struct *vma, u32 hash; =20 put_page(old_page); - BUG_ON(huge_pte_none(pte)); /* * Drop hugetlb_fault_mutex and vma_lock before * unmapping. unmapping needs to hold vma_lock --=20 2.23.0 From nobody Tue Apr 7 14:54:39 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52FA5ECAAD7 for ; Fri, 26 Aug 2022 09:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343907AbiHZJZ2 (ORCPT ); Fri, 26 Aug 2022 05:25:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343680AbiHZJY7 (ORCPT ); Fri, 26 Aug 2022 05:24:59 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E43F7E039 for ; Fri, 26 Aug 2022 02:24:57 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MDZ8f6JyGzlWP2; Fri, 26 Aug 2022 17:21:38 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 17:24:55 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 10/10] hugetlb: make hugetlb selects SYSFS if !SYSCTL Date: Fri, 26 Aug 2022 17:24:22 +0800 Message-ID: <20220826092422.39591-11-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220826092422.39591-1-linmiaohe@huawei.com> References: <20220826092422.39591-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If CONFIG_SYSFS and CONFIG_SYSCTL are both undefined, hugetlb doesn't work now as there's no way to set max huge pages. Make sure at least one of the above configs is defined to make hugetlb works as expected. Signed-off-by: Miaohe Lin --- fs/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/Kconfig b/fs/Kconfig index a547307c1ae8..b266e7b5de85 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -235,6 +235,7 @@ config ARCH_SUPPORTS_HUGETLBFS config HUGETLBFS bool "HugeTLB file system support" depends on X86 || IA64 || SPARC64 || ARCH_SUPPORTS_HUGETLBFS || BROKEN + select SYSFS if !SYSCTL help hugetlbfs is a filesystem backing for HugeTLB pages, based on ramfs. For architectures that support it, say Y here and read --=20 2.23.0