From: Zi Yan Date: Wed, 26 Nov 2025 21:06:18 +0000 (-0500) Subject: mm/huge_memory: fix folio split stats counting X-Git-Tag: v6.19-rc1~9^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9dcdc0c207fe32c576f1359deaf0efece9f36ca2;p=thirdparty%2Flinux.git mm/huge_memory: fix folio split stats counting The "return " statements for error checks at the beginning of __folio_split() skip necessary count_vm_event() and count_mthp_stat() at the end of the function. Fix these by replacing them with "ret = ; goto out;". Link: https://lkml.kernel.org/r/20251126210618.1971206-5-ziy@nvidia.com Signed-off-by: Zi Yan Reviewed-by: Wei Yang Reviewed-by: Lorenzo Stoakes Acked-by: David Hildenbrand (Red Hat) Cc: Balbir Singh Cc: Baolin Wang Cc: Barry Song Cc: Dev Jain Cc: Lance Yang Cc: Liam Howlett Cc: Miaohe Lin Cc: Naoya Horiguchi Cc: Nico Pache Cc: Ryan Roberts Signed-off-by: Andrew Morton --- diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1a3273491cc5..8db0d81fca40 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3942,16 +3942,20 @@ static int __folio_split(struct folio *folio, unsigned int new_order, VM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio); VM_WARN_ON_ONCE_FOLIO(!folio_test_large(folio), folio); - if (folio != page_folio(split_at) || folio != page_folio(lock_at)) - return -EINVAL; + if (folio != page_folio(split_at) || folio != page_folio(lock_at)) { + ret = -EINVAL; + goto out; + } - if (new_order >= old_order) - return -EINVAL; + if (new_order >= old_order) { + ret = -EINVAL; + goto out; + } ret = folio_check_splittable(folio, new_order, split_type); if (ret) { VM_WARN_ONCE(ret == -EINVAL, "Tried to split an unsplittable folio"); - return ret; + goto out; } if (is_anon) {