From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65ED9284678 for ; Thu, 9 Oct 2025 21:26:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760045161; cv=none; b=imA+fQxN05G/XbcUxR0x54rCIhsQUYXKkhOrAeEeSRPT+RveSZDaThND89cUXpYdOuH3ACSoDgtcoiwumYKZPwe9uY7NP+zG1GnngsqDK9ulvKLpYO8z387pRd6wIflK7Hjx0oZpq3wPwN/ax65xKp6+ejUCnpp6s+ZbGodeFI0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760045161; c=relaxed/simple; bh=zhTC74MU9xxXqQBxxnC/WXQJ8Fj2MRxKFKJciodPmHo=; h=Date:To:From:Subject:Message-Id; b=sgIwahOeQ14FPvRkk2L6lRErfBMlTZ1PM7ItiUP+7FkP0Qd8hh/6oUbeFuzEDZGikf2n5GFwRyiOFw3OsyV4zEaqbAuh6l01aY1tMcrx5bJNFPG4jAjvVLxuY8a8ftLz0zqUXilFc9S0jcV8pJPd47Nq4xW0A+dkBvYGMmIfzr0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=vUsUeEww; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="vUsUeEww" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06584C4CEE7; Thu, 9 Oct 2025 21:26:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1760045161; bh=zhTC74MU9xxXqQBxxnC/WXQJ8Fj2MRxKFKJciodPmHo=; h=Date:To:From:Subject:From; b=vUsUeEwwBg18MnCg03QIQczNMLcm7wIOCGcV54mBQVXFLvV235d/gXU5C4IrNXVSA QLsRkTanvbDopCrVsnou2TEz9OdUoEnJHWqzIm1gZEjMXuF3vN9Z7VKWGQmqzjjpmA H6i+c7VnmPqlAtVORnb4zQ/hu0AmmbEhMb9+rnV8= Date: Thu, 09 Oct 2025 14:26:00 -0700 To: mm-commits@vger.kernel.org,sj@kernel.org,shakeel.butt@linux.dev,riel@surriel.com,osalvador@suse.de,muchun.song@linux.dev,hannes@cmpxchg.org,david@redhat.com,usamaarif642@gmail.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-hugetlb-allow-overcommitting-gigantic-hugepages.patch added to mm-new branch Message-Id: <20251009212601.06584C4CEE7@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/hugetlb: allow overcommitting gigantic hugepages has been added to the -mm mm-new branch. Its filename is mm-hugetlb-allow-overcommitting-gigantic-hugepages.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb-allow-overcommitting-gigantic-hugepages.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Usama Arif Subject: mm/hugetlb: allow overcommitting gigantic hugepages Date: Thu, 9 Oct 2025 18:24:31 +0100 Currently, gigantic hugepages cannot use the overcommit mechanism (nr_overcommit_hugepages), forcing users to permanently reserve memory via nr_hugepages even when pages might not be actively used. The restriction was added in 2011 [1], which was before there was support for reserving 1G hugepages at runtime. Remove this blanket restriction on gigantic hugepage overcommit. This will bring the same benefits to gigantic pages as hugepages: - Memory is only taken out of regular use when actually needed - Unused surplus pages can be returned to the system - Better memory utilization, especially with CMA backing which can significantly increase the changes of hugepage allocation Without this patch: echo 3 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages bash: echo: write error: Invalid argument With this patch: echo 3 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_overcommit_hugepages ./mmap_hugetlb_test Successfully allocated huge pages at address: 0x7f9d40000000 cat mmap_hugetlb_test.c ... unsigned long ALLOC_SIZE = 3 * (unsigned long) HUGE_PAGE_SIZE; addr = mmap(NULL, ALLOC_SIZE, // 3GB PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_HUGE_1GB, -1, 0); if (addr == MAP_FAILED) { fprintf(stderr, "mmap failed: %s\n", strerror(errno)); return 1; } printf("Successfully allocated huge pages at address: %p\n", addr); ... Link: https://lkml.kernel.org/r/20251009172433.4158118-2-usamaarif642@gmail.com Link: https://git.zx2c4.com/linux-rng/commit/mm/hugetlb.c?id=adbe8726dc2a3805630d517270db17e3af86e526 [1] Signed-off-by: Usama Arif Cc: David Hildenbrand Cc: Johannes Weiner Cc: Muchun Song Cc: Oscar Salvador Cc: Rik van Riel Cc: Shakeel Butt Cc: SeongJae Park Signed-off-by: Andrew Morton --- mm/hugetlb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/mm/hugetlb.c~mm-hugetlb-allow-overcommitting-gigantic-hugepages +++ a/mm/hugetlb.c @@ -2243,7 +2243,7 @@ static struct folio *alloc_surplus_huget { struct folio *folio = NULL; - if (hstate_is_gigantic(h)) + if (hstate_is_gigantic_no_runtime(h)) return NULL; spin_lock_irq(&hugetlb_lock); @@ -4305,7 +4305,7 @@ static ssize_t nr_overcommit_hugepages_s unsigned long input; struct hstate *h = kobj_to_hstate(kobj, NULL); - if (hstate_is_gigantic(h)) + if (hstate_is_gigantic_no_runtime(h)) return -EINVAL; err = kstrtoul(buf, 10, &input); @@ -5192,7 +5192,7 @@ static int hugetlb_overcommit_handler(co tmp = h->nr_overcommit_huge_pages; - if (write && hstate_is_gigantic(h)) + if (write && hstate_is_gigantic_no_runtime(h)) return -EINVAL; ret = proc_hugetlb_doulongvec_minmax(table, write, buffer, length, ppos, _ Patches currently in -mm which might be from usamaarif642@gmail.com are mm-hugetlb-create-hstate_is_gigantic_no_runtime-helper.patch mm-hugetlb-allow-overcommitting-gigantic-hugepages.patch