The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Zi Yan <ziy@nvidia.com>, Usama Arif <usamaarif642@gmail.com>,
	 Yang Shi <shy828301@gmail.com>,
	Wei Yang <richard.weiyang@gmail.com>,
	 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	 Matthew Wilcox <willy@infradead.org>,
	David Hildenbrand <david@redhat.com>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	 Baolin Wang <baolin.wang@linux.alibaba.com>,
	 Barry Song <baohua@kernel.org>,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	 Ryan Roberts <ryan.roberts@arm.com>,
	Nhat Pham <nphamcs@gmail.com>,  Chris Li <chrisl@kernel.org>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	 linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH hotfix] mm/thp: fix deferred split queue not partially_mapped: fix
Date: Sun, 10 Nov 2024 13:11:21 -0800 (PST)	[thread overview]
Message-ID: <3c995a30-31ce-0998-1b9f-3a2cb9354c91@google.com> (raw)
In-Reply-To: <6fcaaa72-4ef6-ebda-cf37-b6f49874d966@google.com>

Though even more elusive than before, list_del corruption has still been
seen on THP's deferred split queue.

The idea in commit e66f3185fa04 was right, but its implementation wrong.
The context omitted an important comment just before the critical test:
"split_folio() removes folio from list on success."  In ignoring that
comment, when a THP split succeeded, the code went on to release the
preceding safe folio, preserving instead an irrelevant (formerly head)
folio: which gives no safety because it's not on the list. Fix the logic.

Fixes: e66f3185fa04 ("mm/thp: fix deferred split queue not partially_mapped")
Signed-off-by: Hugh Dickins <hughd@google.com>
---
 mm/huge_memory.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 03fd4bc39ea1..5734d5d5060f 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3790,7 +3790,9 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
 		 * in the case it was underused, then consider it used and
 		 * don't add it back to split_queue.
 		 */
-		if (!did_split && !folio_test_partially_mapped(folio)) {
+		if (did_split) {
+			; /* folio already removed from list */
+		} else if (!folio_test_partially_mapped(folio)) {
 			list_del_init(&folio->_deferred_list);
 			removed++;
 		} else {
-- 
2.35.3

  reply	other threads:[~2024-11-10 21:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-27 19:59 [PATCH hotfix v2 1/2] mm/thp: fix deferred split queue not partially_mapped Hugh Dickins
2024-10-27 20:02 ` [PATCH hotfix v2 2/2] mm/thp: fix deferred split unqueue naming and locking Hugh Dickins
2024-10-28 10:43   ` David Hildenbrand
2024-10-28 17:19     ` Hugh Dickins
2024-10-28 17:26       ` David Hildenbrand
2024-10-28 18:39   ` Yang Shi
2024-10-27 20:06 ` [PATCH hotfix v2 1/2] mm/thp: fix deferred split queue not partially_mapped Zi Yan
2024-11-10 21:08   ` Hugh Dickins
2024-11-10 21:11     ` Hugh Dickins [this message]
2024-11-10 21:22       ` [PATCH hotfix] mm/thp: fix deferred split queue not partially_mapped: fix Usama Arif
2024-11-11  3:10       ` Zi Yan
2024-11-12  1:36       ` Baolin Wang
2024-11-13 22:57       ` Chris Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c995a30-31ce-0998-1b9f-3a2cb9354c91@google.com \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chrisl@kernel.org \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=richard.weiyang@gmail.com \
    --cc=ryan.roberts@arm.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shy828301@gmail.com \
    --cc=usamaarif642@gmail.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox