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 872DB41C63 for ; Thu, 17 Apr 2025 23:22:27 +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=1744932147; cv=none; b=PDGvXMWbicKCbhoz7z6vImVokhhacEziHBuVEyfGJjRBanjTlpvsNgmbv6/XkuWK9BAG8yHd0r8w1YERjvQXhawhlBOKxg59qhc6OiNAVtepqNktJjID/ZLxZ++qgAf4CuRTMqz1zEiVwI5pFGiPKA04KGNY2PAfia75CfIaMAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744932147; c=relaxed/simple; bh=AoyTCCEWTNkqzjGxxk83VrlVZ+nvrZ+gF9VYno/YCNM=; h=Date:To:From:Subject:Message-Id; b=NoBQaEbv0KmtKnwdy4jtXySVZ+s2/V0IHdvi7ajLXFf3Qsag0bMr+bNzF1SKsU2mwtC1vBcHS6+8z2ljID/uijYVVdSbQ+b1jsKK/ZSRw7Ck78QISEGWWlT5dnNQei07QGmE9tPU2sjB0t2Fhv3psm7Nme1TYeKpNRj5klKEJ74= 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=GxOnXxJJ; 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="GxOnXxJJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51908C4CEE4; Thu, 17 Apr 2025 23:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1744932147; bh=AoyTCCEWTNkqzjGxxk83VrlVZ+nvrZ+gF9VYno/YCNM=; h=Date:To:From:Subject:From; b=GxOnXxJJSuLrxuRBC41WZuvhEm2KduBIYO+ccTDfqu8PkxJj801G5bjc3NFj58a4G UGZ+lHNgX3TzC2OI/c15N3ws7fbbUoKTWTADQxejG/kzsQtowV6fdyQnEWN2LXIGmY WWGb/4PLqMwoG6rMCywl4ySvnZBskWMmhWpCdHUE= Date: Thu, 17 Apr 2025 16:22:26 -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-avoid-unnecessary-mthp-collapse-attempts.patch added to mm-new branch Message-Id: <20250417232227.51908C4CEE4@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 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: Wed, 16 Apr 2025 18:02:35 -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/20250417000238.74567-10-npache@redhat.com 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: Dev Jain 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/mm/khugepaged.c~khugepaged-avoid-unnecessary-mthp-collapse-attempts +++ a/mm/khugepaged.c @@ -1366,6 +1366,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 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