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 85F0A41C63 for ; Thu, 17 Apr 2025 23:22:26 +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=1744932146; cv=none; b=dD32GguCg342bz4HfHnztDfbU+LeN83XK7c4aaJPzwCqAYpQ6I9o3yC3Gf4ej3uFbRMiaV+nWR/MyREx2ZD8JJh22TziyYifHwepYdtHfdNPnKrwoPsI3vmDwM4KEwGPxKWKqXw/t2sqU1sbo/ioy+dP9CpAKjyoJhmAD+J2j6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744932146; c=relaxed/simple; bh=RjIE/iWY/fnwC+gj0GEWvvj7vyZ/OzQzCG8eywK7EHw=; h=Date:To:From:Subject:Message-Id; b=IWAJaixhWq/e8Yp1zEba+hlRtetOqLSri/wGUgrQNW0jMCLAyQ9CEaKeg3rBlTRrLyvd9IDXxIHbrkJPNObmspW9HtntRnNj7E+6YQAw1kVeAAHsox3UyHPGqjcy3zrusR7aYjC3NuYcA9hT3tTNnhgak4oJ5bMoaXvuIVMlAko= 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=ND9m0MzN; 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="ND9m0MzN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB2EAC4CEE4; Thu, 17 Apr 2025 23:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1744932146; bh=RjIE/iWY/fnwC+gj0GEWvvj7vyZ/OzQzCG8eywK7EHw=; h=Date:To:From:Subject:From; b=ND9m0MzNRDK8Ab2gxqs/Mt6pC1DuPTT0XjvZZfyBcHi5fC/tyCteJseDSIXjQDjv4 Pof9mVF1oF0VUDg4Ksv19P3+8SQGe944QYGT5tDl1Z/jHVi6z5DuqTOXN48wABBvVq Sd79oontqkX4vMAebxNEsTqBtzx8N1YLRDdRKFvM= Date: Thu, 17 Apr 2025 16:22:25 -0700 To: mm-commits@vger.kernel.org,zokeefe@google.com,ziy@nvidia.com,yang@os.amperecomputing.com,willy@infradead.org,will@kernel.org,wangkefeng.wang@huawei.com,vishal.moola@gmail.com,usamaarif642@gmail.com,tiwai@suse.de,thomas.hellstrom@linux.intel.com,surenb@google.com,sunnanyong@huawei.com,shuah@kernel.org,ryan.roberts@arm.com,rostedt@goodmis.org,rientjes@google.com,rdunlap@infradead.org,raquini@redhat.com,peterx@redhat.com,mhocko@suse.com,mhiramat@kernel.org,mathieu.desnoyers@efficios.com,kirill.shutemov@linux.intel.com,jack@suse.cz,hannes@cmpxchg.org,dev.jain@arm.com,david@redhat.com,corbet@lwn.net,cl@gentwo.org,catalin.marinas@arm.com,baolin.wang@linux.alibaba.com,baohua@kernel.org,anshuman.khandual@arm.com,aarcange@redhat.com,npache@redhat.com,akpm@linux-foundation.org From: Andrew Morton Subject: + khugepaged-skip-collapsing-mthp-to-smaller-orders.patch added to mm-new branch Message-Id: <20250417232225.EB2EAC4CEE4@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: khugepaged: skip collapsing mTHP to smaller orders has been added to the -mm mm-new branch. Its filename is khugepaged-skip-collapsing-mthp-to-smaller-orders.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/khugepaged-skip-collapsing-mthp-to-smaller-orders.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm 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: Nico Pache Subject: khugepaged: skip collapsing mTHP to smaller orders Date: Wed, 16 Apr 2025 18:02:34 -0600 khugepaged may try to collapse a mTHP to a smaller mTHP, resulting in some pages being unmapped. Skip these cases until we have a way to check if its ok to collapse to a smaller mTHP size (like in the case of a partially mapped folio). This patch is inspired by Dev Jain's work on khugepaged mTHP support [1]. Link: https://lore.kernel.org/lkml/20241216165105.56185-11-dev.jain@arm.com/ [1] Link: https://lkml.kernel.org/r/20250417000238.74567-9-npache@redhat.com Co-developed-by: Dev Jain Signed-off-by: Dev Jain Signed-off-by: Nico Pache Cc: Andrea Arcangeli Cc: Anshuman Khandual Cc: Baolin Wang Cc: Barry Song Cc: Catalin Marinas Cc: Christoph Lameter (Ampere) Cc: David Hildenbrand Cc: David Rientjes Cc: Jan Kara Cc: Johannes Weiner Cc: Jonathan Corbet Cc: Kefeng Wang Cc: Kirill A. Shuemov Cc: "Masami Hiramatsu (Google)" Cc: Mathieu Desnoyers Cc: Matthew Wilcox (Oracle) Cc: Michal Hocko Cc: Nanyong Sun Cc: Peter Xu Cc: Rafael Aquini Cc: Randy Dunlap Cc: Reported-by:Takashi Iwai Cc: Ryan Roberts Cc: Shuah Khan Cc: Steven Rostedt Cc: Suren Baghdasaryan Cc: Thomas Hellstrom Cc: Usama Arif Cc: Vishal Moola (Oracle) Cc: Will Deacon Cc: Yang Shi Cc: Zach O'Keefe Cc: Zi Yan Signed-off-by: Andrew Morton --- mm/khugepaged.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/mm/khugepaged.c~khugepaged-skip-collapsing-mthp-to-smaller-orders +++ a/mm/khugepaged.c @@ -625,7 +625,12 @@ static int __collapse_huge_page_isolate( folio = page_folio(page); VM_BUG_ON_FOLIO(!folio_test_anon(folio), folio); - /* See hpage_collapse_scan_pmd(). */ + if (order != HPAGE_PMD_ORDER && folio_order(folio) >= order) { + result = SCAN_PTE_MAPPED_HUGEPAGE; + goto out; + } + + /* See khugepaged_scan_pmd(). */ if (folio_maybe_mapped_shared(folio)) { ++shared; if (order != HPAGE_PMD_ORDER || (cc->is_khugepaged && _ Patches currently in -mm which might be from npache@redhat.com are introduce-khugepaged_collapse_single_pmd-to-unify-khugepaged-and-madvise_collapse.patch khugepaged-rename-hpage_collapse_-to-khugepaged_.patch khugepaged-generalize-hugepage_vma_revalidate-for-mthp-support.patch khugepaged-generalize-__collapse_huge_page_-for-mthp-support.patch khugepaged-introduce-khugepaged_scan_bitmap-for-mthp-support.patch khugepaged-add-mthp-support.patch khugepaged-skip-collapsing-mthp-to-smaller-orders.patch khugepaged-avoid-unnecessary-mthp-collapse-attempts.patch khugepaged-improve-tracepoints-for-mthp-orders.patch khugepaged-add-per-order-mthp-khugepaged-stats.patch documentation-mm-update-the-admin-guide-for-mthp-collapse.patch mm-defer-thp-insertion-to-khugepaged.patch mm-document-mthp-defer-usage.patch khugepaged-add-defer-option-to-mthp-options.patch selftests-mm-add-defer-to-thp-setting-parser.patch