Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E90FF3ECBF9 for ; Mon, 15 Jun 2026 14:20:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781533218; cv=none; b=g8yFO8GcgYE7wg0U3QkuOlwqOmb8d5PJzfBOaHBTwJ4Y5EA6+0nFMHJtaurXtNwEMz6x/7P+/dYF3061nw2MO22GPC3aENQ9uqIyq8jRAnm6gKJsuLybWzoGrCULdVx6tukm1LHnkCxZS4kAFcYdhPpW1vVkePA8mkbPfTvvjok= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781533218; c=relaxed/simple; bh=juYASjf1D6ugQPBkomhXKA/ydwaIGM6WXocmCJQW2fo=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=J4G4h+anBleVUbRwHtjeQquSpMmHzI19up11nWleNoY12JzU1up6P/jUtA8f6sCtvSvIVZ5IHaBCB6Es2tVUKIivdyD4ZbxWs/6A+hHGHExm6/MuReky1qeq3r4XmvrWSSlJMVAoq7E69mdvK+YKqvEUlNEv4diCYMP4nIQl+y0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RxPzfdqb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="RxPzfdqb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82C4C1F000E9; Mon, 15 Jun 2026 14:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781533216; bh=nztbE1Ly6FSDAcZtgZf2zMKuYFmr+f8oaBd9xXZHO2A=; h=Subject:To:Cc:From:Date; b=RxPzfdqbBmvU0az62tinWGHFR6Q4gOOmlqLzMZO+PgldSNmQR3aBJksHuHFaVETAr 36qOnItbh0oEQQsLTBqB0AUQ8UVs7dX2C2UWBe9qUJXfnukyul+LgJC6/i87//+KuC t7/YCaY7gw952zQ+kfgQ+wnWNSR2oEdNKt85QV2o= Subject: FAILED: patch "[PATCH] mm/huge_memory: update file PMD counter before folio_put()" failed to apply to 6.6-stable tree To: yintirui@huawei.com,akpm@linux-foundation.org,baohua@kernel.org,baolin.wang@linux.alibaba.com,chenjun102@huawei.com,david@kernel.org,dev.jain@arm.com,lance.yang@linux.dev,liam@infradead.org,ljs@kernel.org,npache@redhat.com,ryan.roberts@arm.com,stable@vger.kernel.org,vbabka@kernel.org,wangkefeng.wang@huawei.com,yang.shi@linux.alibaba.com,ziy@nvidia.com Cc: From: Date: Mon, 15 Jun 2026 16:19:08 +0200 Message-ID: <2026061508-robin-cupid-c1e8@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x 8d878059924f12c1bc24556a92ec56add74de3c8 # git commit -s git send-email --to '' --in-reply-to '2026061508-robin-cupid-c1e8@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ From 8d878059924f12c1bc24556a92ec56add74de3c8 Mon Sep 17 00:00:00 2001 From: Yin Tirui Date: Tue, 26 May 2026 18:13:37 +0800 Subject: [PATCH] mm/huge_memory: update file PMD counter before folio_put() __split_huge_pmd_locked() updates the file/shmem RSS counter after dropping the PMD mapping's folio reference. If folio_put() drops the last reference, mm_counter_file() can later read freed folio state via folio_test_swapbacked(). Move the counter update before folio_put(). Link: https://lore.kernel.org/20260526101337.1984081-1-yintirui@huawei.com Fixes: fadae2953072 ("thp: use mm_file_counter to determine update which rss counter") Signed-off-by: Yin Tirui Reviewed-by: Lorenzo Stoakes Acked-by: David Hildenbrand (arm) Reviewed-by: Lance Yang Reviewed-by: Dev Jain Cc: Baolin Wang Cc: Barry Song Cc: Chen Jun Cc: Kefeng Wang Cc: Liam R. Howlett Cc: Nico Pache Cc: Ryan Roberts Cc: Vlastimil Babka Cc: Yang Shi Cc: Zi Yan Cc: Signed-off-by: Andrew Morton diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1f78b73a0ca4..653f2dc03403 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3133,7 +3133,9 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, if (!folio_test_referenced(folio) && pmd_young(old_pmd)) folio_set_referenced(folio); folio_remove_rmap_pmd(folio, page, vma); + add_mm_counter(mm, mm_counter_file(folio), -HPAGE_PMD_NR); folio_put(folio); + return; } add_mm_counter(mm, mm_counter_file(folio), -HPAGE_PMD_NR); return;