From patchwork Fri Aug 26 09:24:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955705 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 E4765ECAAD2 for ; Fri, 26 Aug 2022 09:24:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51A5E6B0075; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A57F6B0078; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36D1D940007; Fri, 26 Aug 2022 05:24:56 -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 2612B6B0074 for ; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F34B21C5EC5 for ; Fri, 26 Aug 2022 09:24:55 +0000 (UTC) X-FDA: 79841209350.11.F9BC90A Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id 7EBD21C001A for ; Fri, 26 Aug 2022 09:24:55 +0000 (UTC) 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 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505895; a=rsa-sha256; cv=none; b=NjVC508C3TsuPURoRpSWWhwkVcxD6TTKaDJArW2MreaeSrfFEIowBlx9ywf9uWArLBCjMr cO+d5yOD16mVx6IyktNX9Fw23Y0keLiY4iX8kML5IWP6hPStbRWdxZK0u1GeCK95vXAPqH iUb5gZf/OPB1ehl2itCrfnbjM9fiub4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@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=1661505895; 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=AMLGWRpr+uPHEbRIPV0PM2msElUgkg5Uvb2bm+kZyV8=; b=ubbIRyESnGA7FWVBvSk8UONEyIuTka08Q+MgUzPla3yi55wGr/ivk1kP2R1RtmbQSdyduH wFXay/rATI65CnuNLZEJ379+4f8pgPhQk7tr1ljvzcHoEGObo/SDL94EBYQ8Nu05lx5D7O PLQ+HWr6xxQwb/2pA90/mhaGdnt6Q/M= Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: jie5nzyk1rmgif4k5b77q8jdczkspzpg X-Rspamd-Queue-Id: 7EBD21C001A X-HE-Tag: 1661505895-630683 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: 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 hstate *h, #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 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) { } #endif +#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 = 0; } -void __init hugetlb_cma_check(void) +static void __init hugetlb_cma_check(void) { if (!hugetlb_cma_size || cma_reserve_called) return; From patchwork Fri Aug 26 09:24:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955706 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 BA72AECAAD6 for ; Fri, 26 Aug 2022 09:24:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73F8B6B0078; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DDED6B007D; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EFB66B0074; Fri, 26 Aug 2022 05:24:56 -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 2ACB36B0075 for ; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 042801C64F6 for ; Fri, 26 Aug 2022 09:24:55 +0000 (UTC) X-FDA: 79841209392.09.CE2BC9C Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf12.hostedemail.com (Postfix) with ESMTP id 3E56B4001F for ; Fri, 26 Aug 2022 09:24:55 +0000 (UTC) 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 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505895; a=rsa-sha256; cv=none; b=eh+vyGM+Mn06t5ZgK+DxI33G6rb7G+1YjIUDm6PffV6erla8LBdkeCiI1t2FV3r+TwhTbI Xe6c0g6rxCS4XjGalMOUbSfXWcPmZQ3piedBXT02qdyLuizyJAFk2pAv1XK5M8Y+fOHYcE qHl18DmHyJE38foP/DKXp0N0JNnaDg0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@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=1661505895; 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=ZLKsEjT5ukyCF/Hpu+6tbpoTWWUzpg99p6NSaZMn8ng=; b=aUbDnG8PbDeskTJd7OYK99zSVZheyUWs4GROql7Mj8QamwGROcJvnuQrn2Nc+J/Zcs1oYu 4B5j9ifqr5gVJaTRmel8CXWx6jkgP6X8xZmV2qvIrDrY9ZBJ4eWaMbGi8g2XAzuBK6D/t0 /P9+okKEJy61pC8c5YfjMS3W8fiYMw8= X-Stat-Signature: b8qogdx3uc5398ik1or4wmuwwf51yoe4 X-Rspamd-Queue-Id: 3E56B4001F X-Rspam-User: X-Rspamd-Server: rspam06 Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1661505895-665647 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: 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 = first_memory_node; h->next_nid_to_free = first_memory_node; snprintf(h->name, HSTATE_NAME_LEN, "hugepages-%lukB", - huge_page_size(h)/1024); + huge_page_size(h)/SZ_1K); parsed_hstate = h; } From patchwork Fri Aug 26 09:24:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955708 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 AE483ECAAD7 for ; Fri, 26 Aug 2022 09:25:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 014906B007B; Fri, 26 Aug 2022 05:24:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE017940009; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6053940008; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) 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 A53826B007D for ; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 80118A0240 for ; Fri, 26 Aug 2022 09:24:56 +0000 (UTC) X-FDA: 79841209392.20.42E1BE7 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf06.hostedemail.com (Postfix) with ESMTP id B6D32180012 for ; Fri, 26 Aug 2022 09:24:55 +0000 (UTC) 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 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 ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505896; a=rsa-sha256; cv=none; b=s6rwoYEjozjmIczkFIZTBskf+W9PEiNQrx4J+IKmA6I7YDbfdkve+ANCP9dybXsEe31nUj L9622bufed8ry1zyIZwxEDVamp2QSKI990uSBDbtNSOzewkls3MYlVpWOa2MjEXya1ilQd SxQc6tfZ20DE0byoggBWMprw+sYxnEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661505896; 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=/cv/3Untk4ett7TjGDJvl9rabcbQytVHHmjea0c/Bxc=; b=RoKY1G9hm+J3Bv0mesBP3H2UG8f7L4znHjK+PoV7MGqul2dRcptqXs/8zNg9vlBX4RpziB yOXrUsBZeq/73YGCzLCC/azhJIAB3jqg9ZIJwkTfCUJK7FxLLCXEO5aA1RBj8Hl0p7sjdk Z0J9fovIxo67ML7RXH5MtGmZtuy0F4E= X-Rspam-User: X-Rspamd-Queue-Id: B6D32180012 X-Stat-Signature: ft7irtx5nzc4s75zj9nxdu9ebn8g75ib Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam01 X-HE-Tag: 1661505895-729645 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: 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_map *resv, int regions_needed) __must_hold(&resv->lock) { - struct list_head allocated_regions; + LIST_HEAD(allocated_regions); int to_allocate = 0, i = 0; struct file_region *trg = NULL, *rg = NULL; VM_BUG_ON(regions_needed < 0); - 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, struct 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, long delta) } allocated = 0; - INIT_LIST_HEAD(&surplus_list); ret = -ENOMEM; retry: From patchwork Fri Aug 26 09:24:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955707 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 6DE28ECAAD2 for ; Fri, 26 Aug 2022 09:24:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B38FF6B0074; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A249D6B007B; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9157C940007; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 66C8D6B0074 for ; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 407B5C02D5 for ; Fri, 26 Aug 2022 09:24:56 +0000 (UTC) X-FDA: 79841209392.28.B0D58F6 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf07.hostedemail.com (Postfix) with ESMTP id A538640012 for ; Fri, 26 Aug 2022 09:24:55 +0000 (UTC) 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 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 ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505895; a=rsa-sha256; cv=none; b=RrUyuHCj9KDhgdUIz6Ci7mb/xq+dVXOI+5NTmbwL4gNp2BeVVW1RYJ5iLbxWAf07R2TSaQ oEoAu6/PfIrU6lTAb9khGDQu1B1015hjDAnnSwpIB63bDKoy17pymkx4wrb3yHHkoP6KLe EQN3kDPKP5QsOOmEoflRJTxAFCIFHSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661505895; 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=kd7TPK0HU0ONq4CeM378iX7C7BW7JTy+h0iF3zRN5yQ=; b=xEziSYdIyQz/CJjG0y9puRDz/N+/pzPwwr08bQh5yX85d3XLRMt5zk8Uu4LJMfbe/q6WLq 3rvpZU49IqwxElP3lMK6C47sU8riGqSVvX0muUF2M2MdKOKCSQxvG2GjSH0swc9vl4dCo4 LICPd5I6x//Ipr5/B/YhZqWWVAUHc6g= X-Stat-Signature: on1y5myn57fba59nbea89hs3rw3zc136 Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A538640012 X-Rspam-User: X-HE-Tag: 1661505895-685359 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: 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(void) if (!hugetlb_max_hstate) { default_hstate_max_huge_pages = 0; memset(default_hugepages_in_node, 0, - MAX_NUMNODES * sizeof(unsigned int)); + sizeof(default_hugepages_in_node)); } else { parsed_hstate->max_huge_pages = 0; memset(parsed_hstate->max_huge_pages_node, 0, - MAX_NUMNODES * sizeof(unsigned int)); + sizeof(parsed_hstate->max_huge_pages_node)); } } From patchwork Fri Aug 26 09:24:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955710 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 546ABECAAD2 for ; Fri, 26 Aug 2022 09:25:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 590A66B007D; Fri, 26 Aug 2022 05:24:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CF2D6B0085; Fri, 26 Aug 2022 05:24:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20EC06B007D; Fri, 26 Aug 2022 05:24:57 -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 D035A940007 for ; Fri, 26 Aug 2022 05:24:56 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B214B1A0226 for ; Fri, 26 Aug 2022 09:24:56 +0000 (UTC) X-FDA: 79841209392.06.7B5F1C5 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id 37F1A2000F for ; Fri, 26 Aug 2022 09:24:56 +0000 (UTC) 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 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505896; a=rsa-sha256; cv=none; b=x1m3LJDhzi8HH+StXEVfY2gB7w+r3+biW8sHJZWfIq/LDOgtOSmIh4tDMiQh1Va2fykMjU FZV+dCLh3fp6NutO3CF+R5GRq/cU67JDH7RF5uN3vyn5LfGPztQee/oziyJ8S3EGwNycpu tEAFiGLWs3QqMwHv0Coguqcc+OS9mOg= 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 linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661505896; 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=j0PEXFRxO14uZcf8BruBDTLxJoiNvn6qS4uW3Axl0B8=; b=gRqUfD77UjOsNhk9CoPAD0tJ2//reYgsjpJIDMi0poJevzrf0aNrj0kbjz/XAc/CK5loSH BkP1HQgOo0zVHOt9J1SShpznOSUzPYl65m440jgboHZRz4jTa3kXIZDIuhLO4oLmWzpsNg U3bRCxDkiHF3Dcn4w1bYkmnIgHDWYeA= Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Queue-Id: 37F1A2000F X-Rspamd-Server: rspam08 X-Stat-Signature: tqr1izqr1m6ko154jg97z86s66tbfojn X-HE-Tag: 1661505896-864527 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: 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 = true; } - ptl = huge_pte_lockptr(h, dst_mm, dst_pte); - spin_lock(ptl); + ptl = huge_pte_lock(h, dst_mm, dst_pte); /* * 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 address, return NULL; retry: - ptl = pmd_lockptr(mm, pmd); - spin_lock(ptl); + ptl = pmd_lock(mm, pmd); /* * make sure that the address range covered by this pmd is not * unmapped from other threads. From patchwork Fri Aug 26 09:24:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955711 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 861A1ECAAA3 for ; Fri, 26 Aug 2022 09:25:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F93F6B007E; Fri, 26 Aug 2022 05:24:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EE1A940007; Fri, 26 Aug 2022 05:24:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F32E6B0082; Fri, 26 Aug 2022 05:24:57 -0400 (EDT) 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 272676B007E for ; Fri, 26 Aug 2022 05:24:57 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 101B81A0226 for ; Fri, 26 Aug 2022 09:24:57 +0000 (UTC) X-FDA: 79841209434.17.2A94D35 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf23.hostedemail.com (Postfix) with ESMTP id 83670140029 for ; Fri, 26 Aug 2022 09:24:56 +0000 (UTC) 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 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505896; a=rsa-sha256; cv=none; b=qz9Rdjm/3SNHuILLV4Q2uITM289E/XxunLaAqRg9c/ic5HaCuEGPPbaPXsa77cIPfGzH+C Rqm87wgczV+X84F0BnkDZi5LPj2SFYbbxObfhtv4+ItsUXt4diFa4rPosN0gVy5k0BG341 Fz3soI1NebKfSEaP0i2/8nuSAyvZ92Y= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@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=1661505896; 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=knH/tRTfSRspIeQ8YGY2vcZirI8R+GDqYyoFf5+Z+J0=; b=gQDnGmk0+LzMRElre1Tnw0lPSWavmyxlNRbXIyLh/VoE609NHuNul4UUJYrjO/edsi8I7b TXfF9RRM/m7ovGaQGrHlHJiqXygpFNQFQUT4WXNMw9d1sLkBxhFyFnvgcclEHoigwUE5Eu KotrA+nCMujLg2xnZkdpYEN0PjPPoAc= X-Stat-Signature: kqkd5jfyatypkwi379r3i41kmxsseafx X-Rspamd-Queue-Id: 83670140029 X-Rspam-User: X-Rspamd-Server: rspam06 Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1661505896-799170 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: 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 = kobj_to_hstate(kobj, &nid); + struct hstate *h = kobj_to_hstate(kobj, NULL); unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K; 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; demote_size = (unsigned long)memparse(buf, NULL); @@ -3805,7 +3803,7 @@ static ssize_t demote_size_store(struct kobject *kobj, return -EINVAL; /* demote order must be smaller than hstate order */ - h = kobj_to_hstate(kobj, &nid); + h = kobj_to_hstate(kobj, NULL); if (demote_order >= h->order) return -EINVAL; From patchwork Fri Aug 26 09:24:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955713 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 C1F29ECAAD2 for ; Fri, 26 Aug 2022 09:25:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E60C36B0081; Fri, 26 Aug 2022 05:24:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAE13940007; Fri, 26 Aug 2022 05:24:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D7336B0083; Fri, 26 Aug 2022 05:24:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8AD006B0082 for ; Fri, 26 Aug 2022 05:24:58 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6EA8080240 for ; Fri, 26 Aug 2022 09:24:58 +0000 (UTC) X-FDA: 79841209476.28.286C54E Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf10.hostedemail.com (Postfix) with ESMTP id D8A9BC0003 for ; Fri, 26 Aug 2022 09:24:57 +0000 (UTC) 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 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 ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505898; a=rsa-sha256; cv=none; b=5vKXrpCJOHctSj6eQ8Lmp0YyKvYkT6DpZsgpELf/KbkJYO00a1YiUaErUw9RHyGvAdmS8U BzJ5lPkqjLuy7asxErYFXv2aDF4DZ55fVUk50HpZb2sE5UiyVBaPY5zkJScmvt4GxfxRRZ 2ZwsZftzSfq5F3CmYRPwxYuGpw6bjck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661505898; 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=+Xk64KVAAaYQPUxAuR1Wybyf4dlQ4Z+TVC25hHLkgkk=; b=Rb/UDQDv0HQ56Nr2dkPj1O8Xn4yP5g1sOZYsQrgqUcPBaHsNnlYLG2BUSEdkhsVofts99U gc3XMwoKwZr8o2Ze/U8BImOqDOJxI1Whh5gIsbnFqbK6Yeb91w3adxCCet80DZ7sLRYhnq AVuplJcTa/Qa0OXXagaFBj3kknaOyW4= Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: r1argnd4zc3m6ghs4j8iye3zb4eanuii X-Rspamd-Queue-Id: D8A9BC0003 X-Rspamd-Server: rspam04 X-HE-Tag: 1661505897-988701 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: 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, struct vm_area_struct *vma, return ret; } -/* 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 = vma->vm_file->f_mapping; - idx = vma_hugecache_offset(h, vma, address); - - return find_lock_page(mapping, idx); -} - /* * Return whether there is a pagecache page to back given address within VMA. * Caller follow_hugetlb_page() holds page_table_lock so we cannot lock_page. @@ -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); - pagecache_page = hugetlbfs_pagecache_page(h, vma, haddr); + pagecache_page = find_lock_page(mapping, idx); } ptl = huge_pte_lock(h, mm, ptep); From patchwork Fri Aug 26 09:24:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955712 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 B06AAECAAD6 for ; Fri, 26 Aug 2022 09:25:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B60486B0082; Fri, 26 Aug 2022 05:24:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A9AA86B0081; Fri, 26 Aug 2022 05:24:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93CEE940007; Fri, 26 Aug 2022 05:24: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 7F2F06B0081 for ; Fri, 26 Aug 2022 05:24:58 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 63BD6140B89 for ; Fri, 26 Aug 2022 09:24:58 +0000 (UTC) X-FDA: 79841209476.24.49B5349 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id D66AF14000C for ; Fri, 26 Aug 2022 09:24:57 +0000 (UTC) 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 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 ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505898; a=rsa-sha256; cv=none; b=dCGWEu8xe97mBa9EcCVtkYxIhl0WIM8sgUiKdnPaI+elzQiiJeCdijsqy0YQ+VJWsvEMRE RvIb8P86s7kHl3DssaCWbWCpbpCt5xVaAwkBKx27WWvBR7sxNz3Fsq7f65NevCmxu+RwxS z4Q+qkSwzlAZh8K560cSPhA6B0OLHZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661505898; 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=sVrGduauAbIJnqDxFQV5DRsFmhTP5LjDkuzvsh/lZVA=; b=4uNbUi130Ro5evdckDQ3mBGz0Bcp1pmG5Kt9pu1E7OtjYeuGebdWMJdW89CJpAsg1PDYPq IASHj2gKfmQc+sVEnwLcb1ZYIJjFQ8iJ+kTlKBt/3TOssaium/E9wQoCGE7a1+ok9EeS4U R16X7NxMjhETSb/h6mObdeLu5t0K9wk= X-Rspam-User: X-Rspamd-Queue-Id: D66AF14000C X-Stat-Signature: dabkcmfxizs9948tb4toh5idggd33bd1 Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam01 X-HE-Tag: 1661505897-201609 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: 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, set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); set_page_private(page, 0); - SetHPageVmemmapOptimized(page); /* * This page is about to be managed by the hugetlb allocator and From patchwork Fri Aug 26 09:24:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955715 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 1BBBFECAAD2 for ; Fri, 26 Aug 2022 09:25:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BE386B0085; Fri, 26 Aug 2022 05:25:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 36DFC6B0087; Fri, 26 Aug 2022 05:25:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C0BB6B0088; Fri, 26 Aug 2022 05:25:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 087396B0085 for ; Fri, 26 Aug 2022 05:25:00 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D7439A0E85 for ; Fri, 26 Aug 2022 09:24:59 +0000 (UTC) X-FDA: 79841209518.02.D44D2D2 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf21.hostedemail.com (Postfix) with ESMTP id 4F0951C001C for ; Fri, 26 Aug 2022 09:24:59 +0000 (UTC) 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 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 ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505899; a=rsa-sha256; cv=none; b=CCQVwtybMZNXaSANJqPrbMyfKauIy6YsuGoBDcZbonqjGMezdMu3fTrQULkb60VgmK8RfS mCrUauiv1NJq1dQmGPld9+30nimARxw0Vz2KLjKZ2/LEI9J2zOWRSEggk6X6HurU24P9aF 6dcz35P3I5Rdu3j8IZCKbqCSncTNUVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661505899; 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=4/Q1dzTsEtXdXQGQHwX+EJ1/GUlZJBOJJYfJqlK3H+U=; b=vdStXTj5ikzEMX+z6MCcmgJDf2nn1nc+yanvrSR/djz5+SPbdBjkRpBKN7RAeohpQ5/FkE svin5nyteNu9Ocfzy67d7JPg+wja3MOfUqKi/ASYYXREGfqd5DOZIy6dAgDQVxu0zLzWzR 1O7oPGqOVn/KI60ZISyTeYFIbMYjDi8= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4F0951C001C X-Rspam-User: X-Stat-Signature: 9ckrbispwifijyfuzcib34mtam1odupg Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1661505899-82161 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: 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, struct vm_area_struct *vma, u32 hash; 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 From patchwork Fri Aug 26 09:24:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12955714 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 E70D5ECAAD7 for ; Fri, 26 Aug 2022 09:25:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD7406B0083; Fri, 26 Aug 2022 05:24:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5CBD940007; Fri, 26 Aug 2022 05:24:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8512F6B0087; Fri, 26 Aug 2022 05:24: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 72E166B0083 for ; Fri, 26 Aug 2022 05:24:59 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 52E72A0EA7 for ; Fri, 26 Aug 2022 09:24:59 +0000 (UTC) X-FDA: 79841209518.21.AB96134 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf14.hostedemail.com (Postfix) with ESMTP id D52F4100019 for ; Fri, 26 Aug 2022 09:24:58 +0000 (UTC) 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 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661505899; 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=JpQzFCj5j8N05ez9gfTI6B3oyWTxVmfJOVLQilhQau4=; b=25RQpAIxj5KOKQ06+keWI00nXFqPE4ezTP9nEv69NYropyOGoW6lkkhDjs/b9hGXwUZMi9 CH1twd5AaUO8CGkUYlfH92MNWdEhW0xDBwEfXSr97gD723W8xdSKbgnktUc3xkASr/VyW/ e36kBNdwQyAV+J1fpG98N6ojdZg6bgs= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661505899; a=rsa-sha256; cv=none; b=qxbdzEWMCGIBF6zu1jofwn1EI4/dapqFGIjE/XkIrLAy8rtILl5ZL6cDE1/W9v9ua5b3aM 3czdJgP2fD7u2/3mhKDnmYjXa9kzzd4s6df+g0ORT5k1z85f5NDvyxrJAj9cGYL2lshTxK KFgGjZI4faIV6/KV0lDdHBZpj1dkoUo= Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Queue-Id: D52F4100019 X-Rspamd-Server: rspam10 X-Stat-Signature: fp5corjta1h44tkej7yzgt5niwfc9udk X-HE-Tag: 1661505898-733291 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: 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