From patchwork Thu Sep 1 12:00: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: 12962356 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 5B876ECAAD3 for ; Thu, 1 Sep 2022 12:01:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF32B8D0001; Thu, 1 Sep 2022 08:01:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA2198D0003; Thu, 1 Sep 2022 08:01:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D42ED8D0001; Thu, 1 Sep 2022 08:01:06 -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 B289B8D0005 for ; Thu, 1 Sep 2022 08:01:06 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8C39B1C6811 for ; Thu, 1 Sep 2022 12:01:06 +0000 (UTC) X-FDA: 79863375732.30.9DA5AE9 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id 0BC32160067 for ; Thu, 1 Sep 2022 12:01:05 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJKLy1n84znTTk; Thu, 1 Sep 2022 19:58:34 +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; Thu, 1 Sep 2022 20:01:01 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 01/10] hugetlb: make hugetlb_cma_check() static Date: Thu, 1 Sep 2022 20:00:21 +0800 Message-ID: <20220901120030.63318-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033666; a=rsa-sha256; cv=none; b=opE15Hn23JIz6V4FxbO+QPeWtTVU/lV/BB0Eg+Oi4B33S6Lzybk5hrSfY3gHFIOKaVgDop N2irxAEdJOMEUrYC6MpUvuXzLDZdt7dWqnqMm6ElosSQhBS0X2WBCIcXA8kTHdOuo+1wQA f+7Q0eEB6iAhFRPCTnITWMRqUpvs+0c= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1662033666; 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=6/TqSICitb5+dQPRO3lvgO3tB+myBwuXV3uM5zCIes0=; b=0GdX5ATCX/LTc9kidjwRBuiTDx2wUqE7D41vXxKJ16SSXYTe2U4jQE7sBlBRQvpGqsjndv hFUMzt+Aaqw3OFwMNBCA8qPKsQCFqYwedF4Bb6gXXjF69vW2sZzVYd0NUyUy6SgeyQnPpF FNWTGQDxetixP3CTF6peWoeGd/6H6Dg= X-Rspamd-Server: rspam09 Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Stat-Signature: mm6i8kosgt6pwpmr61g6ar89tfopycca X-Rspamd-Queue-Id: 0BC32160067 X-HE-Tag: 1662033665-941784 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 d0617d64d718..2f5008c67624 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 Thu Sep 1 12:00: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: 12962361 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 3B34BECAAD3 for ; Thu, 1 Sep 2022 12:01:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF7768D0008; Thu, 1 Sep 2022 08:01:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7BD18D0003; Thu, 1 Sep 2022 08:01:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1CF78D0008; Thu, 1 Sep 2022 08:01:09 -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 B38268D0003 for ; Thu, 1 Sep 2022 08:01:09 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9383CA1029 for ; Thu, 1 Sep 2022 12:01:09 +0000 (UTC) X-FDA: 79863375858.07.B10079E Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id 88FED20063 for ; Thu, 1 Sep 2022 12:01:05 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJKKY3NN6zkWTX; Thu, 1 Sep 2022 19:57: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; Thu, 1 Sep 2022 20:01:02 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 02/10] hugetlb: Use helper macro SZ_1K Date: Thu, 1 Sep 2022 20:00:22 +0800 Message-ID: <20220901120030.63318-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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=1662033665; 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=xcmegM78RyOPBi6hJlbnUA6x1pSNavTpOf3rXlq9SdA=; b=IB0Fo3J86pFbkq57y+vuLJxps5Bzkze2HDnCSMo3WZ8SilgI/1FgXxWuUoqfunfSgUvdVW 9//Kr7qs/4FuDvfXrHfs8NAdr+nLPX6vkbvqQ94RHK8tUR3zQgGDQIW+YcEO/4EVVUvQQR kaRIxtt0X2mrLZI8m6TkqcNL3miOutY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033665; a=rsa-sha256; cv=none; b=oxK/1kKxfgfBv0BQk7hPaOvpUui5YG71ZiZcEKP/oiMqsuW9pqNbVi2b5OXjlo0+6MdpQ6 OoLU1kS8WcbeCd4BL9jwFkV6m6XFs5jaqcxAwVbkAb6DsIzviTt5RSKtKkDdzsidxzkWDP SC72EAQmkJNz5dMIfTX1yl3CUxDb2QI= X-Stat-Signature: 988is7wpyezztnr9gbbiwgeuoc74e38n X-Rspamd-Queue-Id: 88FED20063 Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.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-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1662033665-221619 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 2f5008c67624..0d63a7fda1d9 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 Thu Sep 1 12:00:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12962357 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 9F9F3ECAAD1 for ; Thu, 1 Sep 2022 12:01:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 221808D0005; Thu, 1 Sep 2022 08:01:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BB9B8D0003; Thu, 1 Sep 2022 08:01:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB9248D0005; Thu, 1 Sep 2022 08:01:06 -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 AD6B98D0003 for ; Thu, 1 Sep 2022 08:01:06 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 779D5A9A1D for ; Thu, 1 Sep 2022 12:01:06 +0000 (UTC) X-FDA: 79863375732.06.B9BFC26 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf20.hostedemail.com (Postfix) with ESMTP id 9D0B41C0074 for ; Thu, 1 Sep 2022 12:01:05 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJKLz17V4znTZ8; Thu, 1 Sep 2022 19:58:35 +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; Thu, 1 Sep 2022 20:01:02 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 03/10] hugetlb: Use LIST_HEAD() to define a list head Date: Thu, 1 Sep 2022 20:00:23 +0800 Message-ID: <20220901120030.63318-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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=1662033665; 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=yoxS4EhpxQucgKKY61vAF7r82tsD8i3zshGspWNGFnk=; b=xI+tejmQLlpFmOmLu9nlvggLFEztMBWQJZh4ufCyBq9kl8MWStfzLH9lXFmuIBF51TRGJ/ HfhM/WFl0cOGTjnmv4aQyNqC7UbbvnG9ym6hvV8Qf14fhOpkEfwQh0W6Tennd7aYTpO+k3 1ajbaH6y6gMwLllck6ITS4JQ4HwyNE0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033665; a=rsa-sha256; cv=none; b=W/xMDA5As4m7uIW6QxXPam7lKkmGJgWSpyIE3BbPUcJeidpG0UUIMj1qiDX2TufbVdLM2C SUmVXCLhNipyEZnCFaMJTkl2QQbaWnH/gvnCfIz7fC5pwBQrwufaJYOf4p/dqNXiv8p0Gj yohRzhwu0SV7TlP1cFBQ3MM3oEnnQLY= Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.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: rspam11 X-Stat-Signature: rwnhajr9ikk1ubuihot3an7kjeamdfsp X-Rspamd-Queue-Id: 9D0B41C0074 X-Rspam-User: X-HE-Tag: 1662033665-532861 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 LIST_HEAD() directly to define a list head to simplify the code. No functional change intended. 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 0d63a7fda1d9..94cb81e9b4df 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 Thu Sep 1 12:00:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12962358 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 78435ECAAD1 for ; Thu, 1 Sep 2022 12:01:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 669DE8D0007; Thu, 1 Sep 2022 08:01:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52D798D0003; Thu, 1 Sep 2022 08:01:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CE1F8D0007; Thu, 1 Sep 2022 08:01:08 -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 210298D0003 for ; Thu, 1 Sep 2022 08:01:08 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DFB6C40F1A for ; Thu, 1 Sep 2022 12:01:07 +0000 (UTC) X-FDA: 79863375774.15.A042DC2 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf05.hostedemail.com (Postfix) with ESMTP id EE5D8100037 for ; Thu, 1 Sep 2022 12:01:06 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJKKZ2hZwzkWV1; Thu, 1 Sep 2022 19:57:22 +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; Thu, 1 Sep 2022 20:01:02 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 04/10] hugetlb: Use sizeof() to get the array size Date: Thu, 1 Sep 2022 20:00:24 +0800 Message-ID: <20220901120030.63318-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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=1662033667; 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=ow/14YyLfK/pFXE2D0ITb1fAoA0tErEQlcn5xqZRT2M=; b=5/8G+MqEJKXtjQeQgpILLiHXSXejt7AAIAbN74cBrm5OfD4pUZKsXEyOIWGO4qiz504Pm3 Z0Xg5SQdgbRIMeiczPkbKxX6gjw1h+QCz5jEUW/TfpYN+H0P6x5IQqApwxESTL5MpJqF3q nx7EgS4F0r9M3F8NdV70O5Pc7V+rKD0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033667; a=rsa-sha256; cv=none; b=qz+CrPbewZuWZCCXlAER8xL35NNBurNaLLbCEtw520fdGUt982uDUug3poYyRPtvthmCUh lHRsTzWaHERZ0MZxRnfSMte9z58PCy96XYvGDko8+Y0B/9K3XJvMHo4hiTWpiV2CRtn5Zc LVYgA1Jt4UHjPplNGP/+YmAO/gC+r1A= Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.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-Rspam-User: X-Stat-Signature: 5qcdwtu75dxcwuajrsfdsh63twgdmo19 X-Rspamd-Queue-Id: EE5D8100037 X-Rspamd-Server: rspam05 X-HE-Tag: 1662033666-652586 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 94cb81e9b4df..c29b444a5515 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 Thu Sep 1 12:00:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12962363 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 96F3EECAAD3 for ; Thu, 1 Sep 2022 12:01:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B00DE8D0009; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9ECD98D000C; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 666D68D0003; Thu, 1 Sep 2022 08:01:11 -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 3FBB58D0009 for ; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1DB80121011 for ; Thu, 1 Sep 2022 12:01:11 +0000 (UTC) X-FDA: 79863375942.19.F48BB13 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf07.hostedemail.com (Postfix) with ESMTP id 236AA40077 for ; Thu, 1 Sep 2022 12:01:06 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJKM00RcLznTvS; Thu, 1 Sep 2022 19:58:36 +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; Thu, 1 Sep 2022 20:01:03 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 05/10] hugetlb: Use helper {huge_pte|pmd}_lock() Date: Thu, 1 Sep 2022 20:00:25 +0800 Message-ID: <20220901120030.63318-6-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033667; a=rsa-sha256; cv=none; b=TsMF5YA3vDUP7oY0hPvcT1+6Q8/RGEmiV2GvMqYMG8bR45ugGOjV7CGqBfPofVJJ7Uq1bF pNxNcAw0ErJnxqdYSmhhOR+TdmTR1tzHjiNDAlsSFEGFRCGOXu8ALNzF4BFuB9SFili3IU tSNgboIHRMWABysW+4G4ux9dDPHcrvI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.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=1662033667; 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=eZsJgNC1fSK4UeCPmIT8G8sqOcUNpggy0/NAGgeBvMA=; b=EalPIbmnUtUz+/vfjXFJEQXwRBwsUNqMjIjJfh/E0/lwF4AS37IyaPo4evRliNZMi97iDc oHRBO21etayINmpwiufIbFyYulBGKfuLTHvC7PVGROzSxUl0L6fk8qG00U95rP6xoxu7SD CgY/7BoWpiUzKWzj6iYtvYkY3oAP/c4= X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 236AA40077 X-Stat-Signature: zph134jat48j7wsa5rt6xhbsim81nc7x Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.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: 1662033666-113987 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 c29b444a5515..d35381de90c3 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 Thu Sep 1 12:00:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12962359 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 C5BA3C0502C for ; Thu, 1 Sep 2022 12:01:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A617C8D0006; Thu, 1 Sep 2022 08:01:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0F2D8D0003; Thu, 1 Sep 2022 08:01:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 839E38D0006; Thu, 1 Sep 2022 08:01:07 -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 73E418D0003 for ; Thu, 1 Sep 2022 08:01:07 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 49D7D16054A for ; Thu, 1 Sep 2022 12:01:07 +0000 (UTC) X-FDA: 79863375774.18.80BC181 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id 9FF2F2004B for ; Thu, 1 Sep 2022 12:01:06 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MJKKt0LyrzlWdW; Thu, 1 Sep 2022 19:57: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; Thu, 1 Sep 2022 20:01:03 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 06/10] hugetlb: pass NULL to kobj_to_hstate() if nid is unused Date: Thu, 1 Sep 2022 20:00:26 +0800 Message-ID: <20220901120030.63318-7-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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=1662033666; 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=E5T/LQQVnJzxbj87ZXz9RrpAIPDwSBKqs8GyxnBwM/U=; b=44/kM7WjlxeyebPJxQ5lcWaYhcpjNN4DwlQon7b+W8/fX/s2FoA7OTy64Y0oQXcfvaga7F rYNc+0gttU2HJhchDMY0uWbFNTEHgu3SdCPUfW+mNm3p/sdoazcsVfgdtWBMbOMffblzrm rtgRmlgERaetLzh4Cudo0kxeVBPTb7c= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.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=1662033666; a=rsa-sha256; cv=none; b=0cqinfq0xycp3CvhFvlRD7D0l6NtXCUZoZ/dnY2w8/SerCeCim9gxYoMo3oWFvihDabPKS J4kvE4/9+YtCas89rKWJfExSFPxy9f96dazwrjl2Ohi0GGLL2d7cXCyLnIU9WfEfTfCvj/ CweLUlKhM33XPhLxz4p1wYn+ovyu/fg= Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Queue-Id: 9FF2F2004B X-Stat-Signature: egibg6aefwr5qrmhwzi8q14fzajihs1j X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1662033666-179985 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 d35381de90c3..bb65b7fdca25 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 Thu Sep 1 12:00:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12962360 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 64557C0502C for ; Thu, 1 Sep 2022 12:01:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F1798D000A; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A0738D000B; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 556858D000A; Thu, 1 Sep 2022 08:01:11 -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 3F56E8D0003 for ; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EA6F8C0F73 for ; Thu, 1 Sep 2022 12:01:10 +0000 (UTC) X-FDA: 79863375900.26.A4140CB Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf07.hostedemail.com (Postfix) with ESMTP id 7AA3140057 for ; Thu, 1 Sep 2022 12:01:07 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MJKKt3TQ9zlWdm; Thu, 1 Sep 2022 19:57: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; Thu, 1 Sep 2022 20:01:04 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 07/10] hugetlb: kill hugetlbfs_pagecache_page() Date: Thu, 1 Sep 2022 20:00:27 +0800 Message-ID: <20220901120030.63318-8-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033667; a=rsa-sha256; cv=none; b=aWJO2BE42533fKn1MOjQ68cfNggB+po2G9jTYLdJ0DTa2QGNupvwj1wsel42QTOASFnaF+ ElxhukUXQThtJhhvU+KKpA22htqkss/hx74jk84Apcy/XMiAV5YCSDwj0YasY2qHDYWITa QWrhoL+WjKNGIarthauJufX1hUXhLzQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 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=1662033667; 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=Htnv6Hzzg0SvtUVeGO5PQPXzObqnReFRT1XowUTteJk=; b=7Vz39lfMcYB8PFRf5rEWhbxjfi/fiUZ1llQOLgolW8/OjrYjYBzGqg5vonILIdvgxxaiZl RPcdMsbxtF55WduS9YIGXT3/f4+F9wAxdDvGgfDo3pjF5t59OttXufps2NePsDITy3vLGJ +QYXaXrp9hHxqGu6HmTBtD1wiCfT++8= X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 7AA3140057 X-Stat-Signature: sbmoha1rotzyps8kgabfdwfo4qk6ewx8 Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1662033667-821304 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 bb65b7fdca25..26bcc85715eb 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 Thu Sep 1 12:00:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12962364 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 846D8ECAAD1 for ; Thu, 1 Sep 2022 12:01:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E5BA8D0003; Thu, 1 Sep 2022 08:01:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 271778D000B; Thu, 1 Sep 2022 08:01:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECD198D0003; Thu, 1 Sep 2022 08:01:11 -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 CDA858D000B for ; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5B8ACA1024 for ; Thu, 1 Sep 2022 12:01:11 +0000 (UTC) X-FDA: 79863375942.18.5FE408C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf24.hostedemail.com (Postfix) with ESMTP id 667A1180077 for ; Thu, 1 Sep 2022 12:01:09 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MJKKt6g44zlWfF; Thu, 1 Sep 2022 19:57: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; Thu, 1 Sep 2022 20:01:04 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 08/10] hugetlb: add comment for subtle SetHPageVmemmapOptimized() Date: Thu, 1 Sep 2022 20:00:28 +0800 Message-ID: <20220901120030.63318-9-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033670; a=rsa-sha256; cv=none; b=Tfjiqch1RzbYOpdcykRFN9WgylDWruXmbpfTfOIRsIS52RBhwDR8KGgr4EEQpmEm1OvDTv rqUg3rmNKkCbe17r4jEpE63+m6N1XXoh3PZ9l6bRJ2PRXLeW1DGuDCULrZ2vYabzDC1FsG 2j66PSj2iSEnvIgYYJPBam6rT9C17tA= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 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=1662033670; 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=LVRf6GuQViEPAShfXGY3zmTtiIrvgN+LFI97apstIh8=; b=7VAQoPGLeHbKDKCrbQ5sgoes2b/6df0aigscklqhFho2Dx1E35qf+mh1GoB68kVjyMEzYJ P16g+TdvdbCSBH+LO7kXx0hzbiIl2d8AoztCtllkcHS4jwZm6i1ziN0kC9rNdfAQhC6Tcd BOqfq6yadl/wjg5GolVXrLvOj0mrav4= Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 667A1180077 X-Stat-Signature: oxqtgtt1a53iueopbsgbqaxezqoxe9fq X-HE-Tag: 1662033669-335256 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: The SetHPageVmemmapOptimized() called here seems unnecessary as it's assumed to be set when calling this function. But it's indeed cleared by above set_page_private(page, 0). Add a comment to avoid possible future confusion. Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song --- mm/hugetlb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 26bcc85715eb..2ba45addcdeb 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1520,6 +1520,10 @@ static void add_hugetlb_page(struct hstate *h, struct page *page, set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); set_page_private(page, 0); + /* + * We have to set HPageVmemmapOptimized again as above + * set_page_private(page, 0) cleared it. + */ SetHPageVmemmapOptimized(page); /* From patchwork Thu Sep 1 12:00:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12962365 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 0CC4BECAAD3 for ; Thu, 1 Sep 2022 12:01:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF7148D000C; Thu, 1 Sep 2022 08:01:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA66C8D000B; Thu, 1 Sep 2022 08:01:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1C8E8D000C; Thu, 1 Sep 2022 08:01:12 -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 B609E8D000B for ; Thu, 1 Sep 2022 08:01:12 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8FE0680C81 for ; Thu, 1 Sep 2022 12:01:12 +0000 (UTC) X-FDA: 79863375984.16.0B90CDB Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf29.hostedemail.com (Postfix) with ESMTP id 789A812008D for ; Thu, 1 Sep 2022 12:01:09 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MJKKd12W2z1N7f0; Thu, 1 Sep 2022 19:57:25 +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; Thu, 1 Sep 2022 20:01:05 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 09/10] hugetlb: remove meaningless BUG_ON(huge_pte_none()) Date: Thu, 1 Sep 2022 20:00:29 +0800 Message-ID: <20220901120030.63318-10-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033669; a=rsa-sha256; cv=none; b=OXc/0Dz4PnX3J9CB3N1t6ftChR2NUXpe6pis4kBG+Xo2Cj9tAfz+5YtrCGdfO/OiLiNBSP XtL95p1LDjBqVKuBn172566pdMrt23Q1DW8qBD7dbzDIdwVWP8uKR6lqUEWN6E9dMwjOMw HsLQzufWZkixllriJ8zmWWCOiJ/qfEI= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662033669; 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=1CS8U1c8a0BLxClvhy1qGLyMJbinkFE44JjvCtvPpsw=; b=Lv/0IDo8snmuMu9nJ97/Z7huqzggFIyvCAbqZ93V42I4KYW415OZcm7Ld4KxRFDBRvUBWX jg05ptbzBNy5vdSsnhrwOfBX2PL6405xDxFBaVWzNI2kLsUzRV48zlm6Va9pyNlHEZoiSO Em2RkPzEsNpDcCwfSKt4PtrGj6TRh1c= X-Rspamd-Queue-Id: 789A812008D Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.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-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: npxe8hxjes93urpt58hbw9seq8sqtm9f X-HE-Tag: 1662033669-345978 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 2ba45addcdeb..9178ab521c74 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5379,7 +5379,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 Thu Sep 1 12:00:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12962362 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 F0D5AECAAD1 for ; Thu, 1 Sep 2022 12:01:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECDF48D000D; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE8FA8D000C; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFA768D0003; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 746A38D0009 for ; Thu, 1 Sep 2022 08:01:11 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3EE63140FC9 for ; Thu, 1 Sep 2022 12:01:11 +0000 (UTC) X-FDA: 79863375942.05.27F2CB2 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf09.hostedemail.com (Postfix) with ESMTP id 73217140095 for ; Thu, 1 Sep 2022 12:01:08 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJKM22D0KznTw3; Thu, 1 Sep 2022 19:58: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; Thu, 1 Sep 2022 20:01:05 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH v2 10/10] hugetlb: make hugetlb depends on SYSFS or SYSCTL Date: Thu, 1 Sep 2022 20:00:30 +0800 Message-ID: <20220901120030.63318-11-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220901120030.63318-1-linmiaohe@huawei.com> References: <20220901120030.63318-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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=1662033668; 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=fQKNuEYsr36aymjldWDmU1Kflf/KdP6ACTriYqjvZmM=; b=ORBCPDrkobTsRq5FPoDsrCChN7Hv5DxnIqDdNAZjLskg5Jp2TKGumlrAqJD0cpywCF5+eP 8pdrtE3uok/VEEAwbDrLK4Qt1ET6+ZGSmAHNioreOzj+BdQlP30+FAaINWa/goy1pbAGmz zmqrYXs4f+t5lxaVULImaIDkhM8Szl4= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662033668; a=rsa-sha256; cv=none; b=IIceVjHvdHv3DI4XJFofitPDlg+UCYqBVbgGDp/QsjYr3m/6OViQgefmm95CYEedw7aQTj yoTSZ39uJUPZfTyzLIVhKF2NczYrpUz73BeKOSe5d4DQYdZtzdS2lXnlepz4buYGuOgAG6 zradFYvbPld/3bhli2GOpzG9BURE7nE= Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.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-Rspam-User: X-Stat-Signature: qnxpaimky817ez7mgz1s1yr4izgp3hjy X-Rspamd-Queue-Id: 73217140095 X-Rspamd-Server: rspam05 X-HE-Tag: 1662033668-570673 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..2685a4d0d353 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 + depends on (SYSFS || SYSCTL) help hugetlbfs is a filesystem backing for HugeTLB pages, based on ramfs. For architectures that support it, say Y here and read