From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,m.szyprowski@samsung.com,lorenzo.stoakes@oracle.com,david@redhat.com,akpm@linux-foundation.org
Subject: [merged mm-stable] scatterlist-disallow-non-contigous-page-ranges-in-a-single-sg-entry.patch removed from -mm tree
Date: Sun, 21 Sep 2025 14:23:55 -0700 [thread overview]
Message-ID: <20250921212355.8F420C4CEE7@smtp.kernel.org> (raw)
The quilt patch titled
Subject: scatterlist: disallow non-contigous page ranges in a single SG entry
has been removed from the -mm tree. Its filename was
scatterlist-disallow-non-contigous-page-ranges-in-a-single-sg-entry.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: David Hildenbrand <david@redhat.com>
Subject: scatterlist: disallow non-contigous page ranges in a single SG entry
Date: Mon, 1 Sep 2025 17:03:45 +0200
The expectation is that there is currently no user that would pass in
non-contigous page ranges: no allocator, not even VMA, will hand these
out.
The only problematic part would be if someone would provide a range
obtained directly from memblock, or manually merge problematic ranges. If
we find such cases, we should fix them to create separate SG entries.
Let's check in sg_set_page() that this is really the case. No need to
check in sg_set_folio(), as pages in a folio are guaranteed to be
contiguous. As sg_set_page() gets inlined into modules, we have to export
the page_range_contiguous() helper -- use EXPORT_SYMBOL, there is nothing
special about this helper such that we would want to enforce GPL-only
modules.
We can now drop the nth_page() usage in sg_page_iter_page().
Link: https://lkml.kernel.org/r/20250901150359.867252-25-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/scatterlist.h | 3 ++-
mm/util.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
--- a/include/linux/scatterlist.h~scatterlist-disallow-non-contigous-page-ranges-in-a-single-sg-entry
+++ a/include/linux/scatterlist.h
@@ -158,6 +158,7 @@ static inline void sg_assign_page(struct
static inline void sg_set_page(struct scatterlist *sg, struct page *page,
unsigned int len, unsigned int offset)
{
+ VM_WARN_ON_ONCE(!page_range_contiguous(page, ALIGN(len + offset, PAGE_SIZE) / PAGE_SIZE));
sg_assign_page(sg, page);
sg->offset = offset;
sg->length = len;
@@ -600,7 +601,7 @@ void __sg_page_iter_start(struct sg_page
*/
static inline struct page *sg_page_iter_page(struct sg_page_iter *piter)
{
- return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
+ return sg_page(piter->sg) + piter->sg_pgoffset;
}
/**
--- a/mm/util.c~scatterlist-disallow-non-contigous-page-ranges-in-a-single-sg-entry
+++ a/mm/util.c
@@ -1315,4 +1315,5 @@ bool page_range_contiguous(const struct
return false;
return true;
}
+EXPORT_SYMBOL(page_range_contiguous);
#endif
_
Patches currently in -mm which might be from david@redhat.com are
reply other threads:[~2025-09-21 21:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250921212355.8F420C4CEE7@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=m.szyprowski@samsung.com \
--cc=mm-commits@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.