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 C7A3F35947 for ; Fri, 4 Jul 2025 00:59:25 +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=1751590765; cv=none; b=kXVmbOFhNicJuq5KL4iJdnqcs9PPFbQWzvfLWl9ytyL2WNX2cuQXUwPYtuJtLcetzlpAoSif1sYQFyPHwR6yC0tyRxfB0aWkFsavuPCjTX/UjrSFVaJC0e0Uu1ZOzR6IrDPZDQ1m/stDSSswplTMg1r9nqtkEl9kYv746ORZc3k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751590765; c=relaxed/simple; bh=QWsmX8mfUih5d9V486PhyG/kjKP8PimPfKdPXpxH0ZE=; h=Date:To:From:Subject:Message-Id; b=iYGEVatbo8r+tO5Ot5Ppg+kVf//1WcENVkz1VMkESDolLHIZ/evYEgHQch+3uAjgga5U2f6aq5Wefm7hEZgz+bhVcrx7OBH10DfFzjDtxQnxmdsUJCF1c1kxhG7wfEEG/gG8UUyy6ZbiJVmJ4iSCtE1CpBquhZ1MrOebDshlkKg= 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=cV6RSU7w; 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="cV6RSU7w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9301AC4CEE3; Fri, 4 Jul 2025 00:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1751590765; bh=QWsmX8mfUih5d9V486PhyG/kjKP8PimPfKdPXpxH0ZE=; h=Date:To:From:Subject:From; b=cV6RSU7wNoAtRf9cf5uVCBLBM1IicPOj11ZGt30Spf81HU8JPP/UAJbUcPbcacjZy /zBdrvUqW0/DD/dqqlJqcb2JUKRxpw5oc7slHFJ5R29hC9Tie2AvBhGYe9XR2n/CEA VFIq6kUW8drUMt5XkajLGhOdoJwolodCXAOLYz9w= Date: Thu, 03 Jul 2025 17:59:25 -0700 To: mm-commits@vger.kernel.org,zokeefe@google.com,ziy@nvidia.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,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,lorenzo.stoakes@oracle.com,liam.howlett@oracle.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,bagasdotme@gmail.com,anshuman.khandual@arm.com,aarcange@redhat.com,npache@redhat.com,akpm@linux-foundation.org From: Andrew Morton Subject: + khugepaged-avoid-unnecessary-mthp-collapse-attempts.patch added to mm-new branch Message-Id: <20250704005925.9301AC4CEE3@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: khugepaged: avoid unnecessary mTHP collapse attempts has been added to the -mm mm-new branch. Its filename is khugepaged-avoid-unnecessary-mthp-collapse-attempts.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/khugepaged-avoid-unnecessary-mthp-collapse-attempts.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: Nico Pache Subject: khugepaged: avoid unnecessary mTHP collapse attempts Date: Tue, 1 Jul 2025 23:57:36 -0600 There are cases where, if an attempted collapse fails, all subsequent orders are guaranteed to also fail. Avoid these collapse attempts by bailing out early. Link: https://lkml.kernel.org/r/20250702055742.102808-10-npache@redhat.com Signed-off-by: Nico Pache Cc: Andrea Arcangeli Cc: Anshuman Khandual Cc: Bagas Sanjaya Cc: Baolin Wang Cc: Barry Song Cc: Catalin Marinas Cc: Christoph Lameter (Ampere) Cc: David Hildenbrand Cc: David Rientjes Cc: Dev Jain Cc: Jan Kara Cc: Johannes Weiner Cc: Jonathan Corbet Cc: Kefeng Wang Cc: Kirill A. Shuemov Cc: Liam Howlett Cc: Lorenzo Stoakes 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: Steven Rostedt Cc: Suren Baghdasaryan Cc: Thomas Hellstrom Cc: Usama Arif Cc: Vishal Moola (Oracle) Cc: Will Deacon Cc: Zach O'Keefe Cc: Zi Yan Signed-off-by: Andrew Morton --- mm/khugepaged.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/mm/khugepaged.c~khugepaged-avoid-unnecessary-mthp-collapse-attempts +++ a/mm/khugepaged.c @@ -1358,6 +1358,23 @@ static int khugepaged_scan_bitmap(struct collapsed += (1 << order); continue; } + /* + * Some ret values indicate all lower order will also + * fail, dont trying to collapse smaller orders + */ + if (ret == SCAN_EXCEED_NONE_PTE || + ret == SCAN_EXCEED_SWAP_PTE || + ret == SCAN_EXCEED_SHARED_PTE || + ret == SCAN_PTE_NON_PRESENT || + ret == SCAN_PTE_UFFD_WP || + ret == SCAN_ALLOC_HUGE_PAGE_FAIL || + ret == SCAN_CGROUP_CHARGE_FAIL || + ret == SCAN_COPY_MC || + ret == SCAN_PAGE_LOCK || + ret == SCAN_PAGE_COUNT) + goto next; + else + break; } next: _ Patches currently in -mm which might be from npache@redhat.com are khugepaged-rename-hpage_collapse_-to-khugepaged_.patch introduce-khugepaged_collapse_single_pmd-to-unify-khugepaged-and-madvise_collapse.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-allow-madvise_collapse-to-check-all-anonymous-mthp-orders.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