From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 5CB673314B9 for ; Fri, 27 Mar 2026 02:16:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577766; cv=none; b=WNxMMS9OiJp8Y0JPJ7EjvndjPaeX7eDe6jrwbTUS3n4dQP5mdLt1qwMUJ+s+1qxyESUMlpLc6xN8pRAF8aPR/zHnBVAiAIpshHEEOUDLm8ltFwPNZEpWzKcfaACBHYNX0Cdf0ryakmbEzxbMip2o0Sr+XClYq9OZ1jww8/hi0IA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577766; c=relaxed/simple; bh=YTVu15v3L47S7CtoTWxdOrYIq1Zja+qpb/5AizlA7DY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vBEz6s8yUGMSlR5hkmNDa89CpZ2nWsI9bHL1RHZ9BcYTx877K0bvYBNQqVTLsk70VgJev4WP4zo7mPVeWwAq5WA6afIZ1MIcwhkyNa1G0GdVJr/Du5MyK7sQcbXvVAVHg0T2hizSiEOWZOdoldx8mPb+OA8eRqpQv4bubSiWTI0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=DjzOCy7C; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="DjzOCy7C" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774577763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sRAVBAAGLIHNuPxenAu6Zv4mVQpIwOINutBDBMSDYBI=; b=DjzOCy7CYYN46My00Xi1fs3rAUMoskKmV/KpehE3GWn6mX4MPqoLYrTNgfZYBGEzLR8iqX SjzK869MdpGpt78ig/FnB50pdDMBRhVufNL3A3S6FY7A6Fna4cqbAKf1pwbFNITcjpiouQ IsF7YtJduydG7B8wGDwJ7Ww4Rl22lmg= From: Usama Arif To: Andrew Morton , david@kernel.org, Lorenzo Stoakes , willy@infradead.org, linux-mm@kvack.org Cc: fvdl@google.com, hannes@cmpxchg.org, riel@surriel.com, shakeel.butt@linux.dev, kas@kernel.org, baohua@kernel.org, dev.jain@arm.com, baolin.wang@linux.alibaba.com, npache@redhat.com, Liam.Howlett@oracle.com, ryan.roberts@arm.com, Vlastimil Babka , lance.yang@linux.dev, linux-kernel@vger.kernel.org, kernel-team@meta.com, maddy@linux.ibm.com, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, linux-s390@vger.kernel.org, Usama Arif Subject: [v3 19/24] mm: thp: add THP_SPLIT_PMD_FAILED counter Date: Thu, 26 Mar 2026 19:09:01 -0700 Message-ID: <20260327021403.214713-20-usama.arif@linux.dev> In-Reply-To: <20260327021403.214713-1-usama.arif@linux.dev> References: <20260327021403.214713-1-usama.arif@linux.dev> Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Add a vmstat counter to track PTE allocation failures during PMD split. This enables monitoring of split failures due to memory pressure after the lazy PTE page table allocation change. The counter is incremented in three places: - __split_huge_pmd(): Main entry point for splitting a PMD - try_to_unmap_one(): When reclaim needs to split a PMD-mapped THP - try_to_migrate_one(): When migration needs to split a PMD-mapped THP Signed-off-by: Usama Arif --- include/linux/vm_event_item.h | 1 + mm/huge_memory.c | 1 + mm/rmap.c | 7 +++++++ mm/vmstat.c | 1 + 4 files changed, 10 insertions(+) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 03fe95f5a0201..ce696cf7d6321 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -98,6 +98,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, THP_DEFERRED_SPLIT_PAGE, THP_UNDERUSED_SPLIT_PAGE, THP_SPLIT_PMD, + THP_SPLIT_PMD_FAILED, THP_SCAN_EXCEED_NONE_PTE, THP_SCAN_EXCEED_SWAP_PTE, THP_SCAN_EXCEED_SHARED_PTE, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 48c4884a6f386..b93718931e729 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3347,6 +3347,7 @@ int __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, if (vma_is_anonymous(vma) && !arch_needs_pgtable_deposit()) { pgtable = pte_alloc_one(vma->vm_mm); if (!pgtable) { + count_vm_event(THP_SPLIT_PMD_FAILED); mmu_notifier_invalidate_range_end(&range); return -ENOMEM; } diff --git a/mm/rmap.c b/mm/rmap.c index efbcdd3b32632..a0180f62d9f69 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2087,8 +2087,12 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, pgtable_t pgtable = prealloc_pte; prealloc_pte = NULL; + if (!arch_needs_pgtable_deposit() && !pgtable && vma_is_anonymous(vma)) { +#if defined(CONFIG_TRANSPARENT_HUGEPAGE) + count_vm_event(THP_SPLIT_PMD_FAILED); +#endif page_vma_mapped_walk_done(&pvmw); ret = false; break; @@ -2491,6 +2495,9 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, prealloc_pte = NULL; if (!arch_needs_pgtable_deposit() && !pgtable && vma_is_anonymous(vma)) { +#if defined(CONFIG_TRANSPARENT_HUGEPAGE) + count_vm_event(THP_SPLIT_PMD_FAILED); +#endif page_vma_mapped_walk_done(&pvmw); ret = false; break; diff --git a/mm/vmstat.c b/mm/vmstat.c index 2370c6fb1fcd6..b8df9c7296d8a 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1409,6 +1409,7 @@ const char * const vmstat_text[] = { [I(THP_DEFERRED_SPLIT_PAGE)] = "thp_deferred_split_page", [I(THP_UNDERUSED_SPLIT_PAGE)] = "thp_underused_split_page", [I(THP_SPLIT_PMD)] = "thp_split_pmd", + [I(THP_SPLIT_PMD_FAILED)] = "thp_split_pmd_failed", [I(THP_SCAN_EXCEED_NONE_PTE)] = "thp_scan_exceed_none_pte", [I(THP_SCAN_EXCEED_SWAP_PTE)] = "thp_scan_exceed_swap_pte", [I(THP_SCAN_EXCEED_SHARED_PTE)] = "thp_scan_exceed_share_pte", -- 2.52.0