linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Harry Yoo <harry.yoo@oracle.com>,
	David Rientjes <rientjes@google.com>,
	Christoph Lameter <cl@gentwo.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [GIT PULL] slab fix for 6.18-rc7
Date: Thu, 20 Nov 2025 20:11:08 +0000	[thread overview]
Message-ID: <aR913JM35YDVSCjF@casper.infradead.org> (raw)
In-Reply-To: <CAHk-=whUBuZmRNGCxjnAkFQLO_HVV8SgWEAUg+3z4EARD9MM3Q@mail.gmail.com>

On Thu, Nov 20, 2025 at 10:58:13AM -0800, Linus Torvalds wrote:
> On Thu, 20 Nov 2025 at 10:45, Vlastimil Babka <vbabka@suse.cz> wrote:
> >
> > * Fix mempool poisoning order>0 pages with CONFIG_HIGHMEM (Vlastimil Babka)
> 
> I've pulled this, but honestly, CONFIG_HIGHMEM should be considered a
> dying breed, and I'd have been happier with just not adding extra code
> for that thing.

Would you rather see something like this that hides the fact it's
dealing with HIGHMEM?


diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 0091ad1986bf..68b952e68176 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -623,8 +623,10 @@ PAGEFLAG_FALSE(HighMem, highmem)
 /* Does kmap_local_folio() only allow access to one page of the folio? */
 #ifdef CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP
 #define folio_test_partial_kmap(f)	true
+#define PagePartialKmap(p)		true
 #else
 #define folio_test_partial_kmap(f)	folio_test_highmem(f)
+#define PagePartialKmap(p)		PageHighMem(p)
 #endif
 
 #ifdef CONFIG_SWAP
diff --git a/mm/mempool.c b/mm/mempool.c
index 1c38e873e546..b1f5d81d70c6 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -67,11 +67,19 @@ static void check_element(mempool_t *pool, void *element)
 		__check_element(pool, element, kmem_cache_size(pool->pool_data));
 	} else if (pool->free == mempool_free_pages) {
 		/* Mempools backed by page allocator */
-		int order = (int)(long)pool->pool_data;
-		void *addr = kmap_local_page((struct page *)element);
-
-		__check_element(pool, addr, 1UL << (PAGE_SHIFT + order));
-		kunmap_local(addr);
+		size_t len = 1UL << (long)pool->pool_data;
+		do {
+			struct page *page = (struct page *)element;
+			void *addr = kmap_local_page(page);
+			size_t chunk = len;
+
+			if (PagePartialKmap(page) && chunk > PAGE_SIZE)
+				chunk = PAGE_SIZE;
+			__check_element(pool, addr, chunk);
+			kunmap_local(addr);
+			len -= chunk;
+			element += chunk;
+		} while (len > 0);
 	}
 }
 
(not actually tested, but based on memcpy_from_folio())


  reply	other threads:[~2025-11-20 20:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20 18:45 Vlastimil Babka
2025-11-20 18:58 ` Linus Torvalds
2025-11-20 20:11   ` Matthew Wilcox [this message]
2025-11-20 21:37     ` Linus Torvalds
2025-11-20 21:55       ` Linus Torvalds
2025-11-20 19:00 ` pr-tracker-bot

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=aR913JM35YDVSCjF@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=harry.yoo@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    /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