* [PATCH v2 RESEND] intel_th: avoid using deprecated page->mapping, index fields
@ 2025-03-31 12:56 Lorenzo Stoakes
2025-03-31 15:47 ` Matthew Wilcox
0 siblings, 1 reply; 6+ messages in thread
From: Lorenzo Stoakes @ 2025-03-31 12:56 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Alexander Shishkin, Matthew Wilcox, linux-kernel, linux-mm,
David Hildenbrand
The struct page->mapping, index fields are deprecated and soon to be only
available as part of a folio.
It is likely the intel_th code which sets page->mapping, index is was
implemented out of concern that some aspect of the page fault logic may
encounter unexpected problems should they not.
However, the appropriate interface for inserting kernel-allocated memory is
vm_insert_page() in a VM_MIXEDMAP. By using the helper function
vmf_insert_mixed() we can do this with minimal churn in the existing fault
handler.
By doing so, we bypass the remainder of the faulting logic. The pages are
still pinned so there is no possibility of anything unexpected being done
with the pages once established.
It would also be reasonable to pre-map everything on fault, however to
minimise churn we retain the fault handler.
We also eliminate all code which clears page->mapping on teardown as this
has now become unnecessary.
The MSU code relies on faulting to function correctly, so is by definition
dependent on CONFIG_MMU. We avoid spurious reports about compilation
failure for unsupported platforms by making this requirement explicit in
Kconfig as part of this change too.
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
Resending, as not taken for 6.15 merge window as promised. Sending direct
to Greg for expediency.
I rebased on tip Linus's tree and applies fine.
Greg, as we're late in merge window obviously now, could you roll up into
6.15-rc1? Thanks!
This does not require backporting, as this is a critical change for mm
moving forward, as page->index,mapping are deprecated and will be entirely
removed extremely soon.
Adding Acked-by based on [0] where Alexander explicitly stated he was fine with
providing this - Alex - if this is a problem, please indicate so.
[0]: https://lore.kernel.org/all/87v7tyyrvb.fsf@ubik.fi.intel.com/
v2:
* Make the MSU driver dependent on CONFIG_MMU to avoid spurious compilation
failure reports.
https://lore.kernel.org/all/20241203080001.12341-1-lorenzo.stoakes@oracle.com/
v1:
https://lore.kernel.org/all/20241202122127.51313-1-lorenzo.stoakes@oracle.com/
drivers/hwtracing/intel_th/Kconfig | 1 +
drivers/hwtracing/intel_th/msu.c | 31 +++++++-----------------------
2 files changed, 8 insertions(+), 24 deletions(-)
diff --git a/drivers/hwtracing/intel_th/Kconfig b/drivers/hwtracing/intel_th/Kconfig
index 4b6359326ede..4f7d2b6d79e2 100644
--- a/drivers/hwtracing/intel_th/Kconfig
+++ b/drivers/hwtracing/intel_th/Kconfig
@@ -60,6 +60,7 @@ config INTEL_TH_STH
config INTEL_TH_MSU
tristate "Intel(R) Trace Hub Memory Storage Unit"
+ depends on MMU
help
Memory Storage Unit (MSU) trace output device enables
storing STP traces to system memory. It supports single
diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index bf99d79a4192..7163950eb371 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -19,6 +19,7 @@
#include <linux/io.h>
#include <linux/workqueue.h>
#include <linux/dma-mapping.h>
+#include <linux/pfn_t.h>
#ifdef CONFIG_X86
#include <asm/set_memory.h>
@@ -976,7 +977,6 @@ static void msc_buffer_contig_free(struct msc *msc)
for (off = 0; off < msc->nr_pages << PAGE_SHIFT; off += PAGE_SIZE) {
struct page *page = virt_to_page(msc->base + off);
- page->mapping = NULL;
__free_page(page);
}
@@ -1158,9 +1158,6 @@ static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win)
int i;
for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) {
- struct page *page = msc_sg_page(sg);
-
- page->mapping = NULL;
dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE,
sg_virt(sg), sg_dma_address(sg));
}
@@ -1601,22 +1598,10 @@ static void msc_mmap_close(struct vm_area_struct *vma)
{
struct msc_iter *iter = vma->vm_file->private_data;
struct msc *msc = iter->msc;
- unsigned long pg;
if (!atomic_dec_and_mutex_lock(&msc->mmap_count, &msc->buf_mutex))
return;
- /* drop page _refcounts */
- for (pg = 0; pg < msc->nr_pages; pg++) {
- struct page *page = msc_buffer_get_page(msc, pg);
-
- if (WARN_ON_ONCE(!page))
- continue;
-
- if (page->mapping)
- page->mapping = NULL;
- }
-
/* last mapping -- drop user_count */
atomic_dec(&msc->user_count);
mutex_unlock(&msc->buf_mutex);
@@ -1626,16 +1611,14 @@ static vm_fault_t msc_mmap_fault(struct vm_fault *vmf)
{
struct msc_iter *iter = vmf->vma->vm_file->private_data;
struct msc *msc = iter->msc;
+ struct page *page;
- vmf->page = msc_buffer_get_page(msc, vmf->pgoff);
- if (!vmf->page)
+ page = msc_buffer_get_page(msc, vmf->pgoff);
+ if (!page)
return VM_FAULT_SIGBUS;
- get_page(vmf->page);
- vmf->page->mapping = vmf->vma->vm_file->f_mapping;
- vmf->page->index = vmf->pgoff;
-
- return 0;
+ get_page(page);
+ return vmf_insert_mixed(vmf->vma, vmf->address, page_to_pfn_t(page));
}
static const struct vm_operations_struct msc_mmap_ops = {
@@ -1676,7 +1659,7 @@ static int intel_th_msc_mmap(struct file *file, struct vm_area_struct *vma)
atomic_dec(&msc->user_count);
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
- vm_flags_set(vma, VM_DONTEXPAND | VM_DONTCOPY);
+ vm_flags_set(vma, VM_DONTEXPAND | VM_DONTCOPY | VM_MIXEDMAP);
vma->vm_ops = &msc_mmap_ops;
return ret;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 RESEND] intel_th: avoid using deprecated page->mapping, index fields
2025-03-31 12:56 [PATCH v2 RESEND] intel_th: avoid using deprecated page->mapping, index fields Lorenzo Stoakes
@ 2025-03-31 15:47 ` Matthew Wilcox
2025-03-31 16:15 ` Greg Kroah-Hartman
0 siblings, 1 reply; 6+ messages in thread
From: Matthew Wilcox @ 2025-03-31 15:47 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: Greg Kroah-Hartman, Alexander Shishkin, linux-kernel, linux-mm,
David Hildenbrand
On Mon, Mar 31, 2025 at 01:56:08PM +0100, Lorenzo Stoakes wrote:
> Greg, as we're late in merge window obviously now, could you roll up into
> 6.15-rc1? Thanks!
>
> This does not require backporting, as this is a critical change for mm
> moving forward, as page->index,mapping are deprecated and will be entirely
> removed extremely soon.
"extremely soon" as in "There are four places in the kernel which
currently use page->index, and three of them are gone once Andrew
sends his pull requests". So this will be the last user, assuming
nobody else decides to add a user of page->index in the meantime.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 RESEND] intel_th: avoid using deprecated page->mapping, index fields
2025-03-31 15:47 ` Matthew Wilcox
@ 2025-03-31 16:15 ` Greg Kroah-Hartman
2025-04-14 14:33 ` Matthew Wilcox
0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2025-03-31 16:15 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Lorenzo Stoakes, Alexander Shishkin, linux-kernel, linux-mm,
David Hildenbrand
On Mon, Mar 31, 2025 at 04:47:37PM +0100, Matthew Wilcox wrote:
> On Mon, Mar 31, 2025 at 01:56:08PM +0100, Lorenzo Stoakes wrote:
> > Greg, as we're late in merge window obviously now, could you roll up into
> > 6.15-rc1? Thanks!
> >
> > This does not require backporting, as this is a critical change for mm
> > moving forward, as page->index,mapping are deprecated and will be entirely
> > removed extremely soon.
>
> "extremely soon" as in "There are four places in the kernel which
> currently use page->index, and three of them are gone once Andrew
> sends his pull requests". So this will be the last user, assuming
> nobody else decides to add a user of page->index in the meantime.
I'll get to it after -rc1 is out, thanks.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 RESEND] intel_th: avoid using deprecated page->mapping, index fields
2025-03-31 16:15 ` Greg Kroah-Hartman
@ 2025-04-14 14:33 ` Matthew Wilcox
2025-04-15 11:29 ` Greg Kroah-Hartman
0 siblings, 1 reply; 6+ messages in thread
From: Matthew Wilcox @ 2025-04-14 14:33 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Lorenzo Stoakes, Alexander Shishkin, linux-kernel, linux-mm,
David Hildenbrand
On Mon, Mar 31, 2025 at 06:15:14PM +0200, Greg Kroah-Hartman wrote:
> On Mon, Mar 31, 2025 at 04:47:37PM +0100, Matthew Wilcox wrote:
> > On Mon, Mar 31, 2025 at 01:56:08PM +0100, Lorenzo Stoakes wrote:
> > > Greg, as we're late in merge window obviously now, could you roll up into
> > > 6.15-rc1? Thanks!
> > >
> > > This does not require backporting, as this is a critical change for mm
> > > moving forward, as page->index,mapping are deprecated and will be entirely
> > > removed extremely soon.
> >
> > "extremely soon" as in "There are four places in the kernel which
> > currently use page->index, and three of them are gone once Andrew
> > sends his pull requests". So this will be the last user, assuming
> > nobody else decides to add a user of page->index in the meantime.
>
> I'll get to it after -rc1 is out, thanks.
-rc2 is now out.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 RESEND] intel_th: avoid using deprecated page->mapping, index fields
2025-04-14 14:33 ` Matthew Wilcox
@ 2025-04-15 11:29 ` Greg Kroah-Hartman
2025-04-15 11:34 ` Lorenzo Stoakes
0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2025-04-15 11:29 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Lorenzo Stoakes, Alexander Shishkin, linux-kernel, linux-mm,
David Hildenbrand
On Mon, Apr 14, 2025 at 03:33:57PM +0100, Matthew Wilcox wrote:
> On Mon, Mar 31, 2025 at 06:15:14PM +0200, Greg Kroah-Hartman wrote:
> > On Mon, Mar 31, 2025 at 04:47:37PM +0100, Matthew Wilcox wrote:
> > > On Mon, Mar 31, 2025 at 01:56:08PM +0100, Lorenzo Stoakes wrote:
> > > > Greg, as we're late in merge window obviously now, could you roll up into
> > > > 6.15-rc1? Thanks!
> > > >
> > > > This does not require backporting, as this is a critical change for mm
> > > > moving forward, as page->index,mapping are deprecated and will be entirely
> > > > removed extremely soon.
> > >
> > > "extremely soon" as in "There are four places in the kernel which
> > > currently use page->index, and three of them are gone once Andrew
> > > sends his pull requests". So this will be the last user, assuming
> > > nobody else decides to add a user of page->index in the meantime.
> >
> > I'll get to it after -rc1 is out, thanks.
>
> -rc2 is now out.
Sorry for the delay, now applied.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 RESEND] intel_th: avoid using deprecated page->mapping, index fields
2025-04-15 11:29 ` Greg Kroah-Hartman
@ 2025-04-15 11:34 ` Lorenzo Stoakes
0 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Stoakes @ 2025-04-15 11:34 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Matthew Wilcox, Alexander Shishkin, linux-kernel, linux-mm,
David Hildenbrand
On Tue, Apr 15, 2025 at 01:29:44PM +0200, Greg Kroah-Hartman wrote:
> On Mon, Apr 14, 2025 at 03:33:57PM +0100, Matthew Wilcox wrote:
> > On Mon, Mar 31, 2025 at 06:15:14PM +0200, Greg Kroah-Hartman wrote:
> > > On Mon, Mar 31, 2025 at 04:47:37PM +0100, Matthew Wilcox wrote:
> > > > On Mon, Mar 31, 2025 at 01:56:08PM +0100, Lorenzo Stoakes wrote:
> > > > > Greg, as we're late in merge window obviously now, could you roll up into
> > > > > 6.15-rc1? Thanks!
> > > > >
> > > > > This does not require backporting, as this is a critical change for mm
> > > > > moving forward, as page->index,mapping are deprecated and will be entirely
> > > > > removed extremely soon.
> > > >
> > > > "extremely soon" as in "There are four places in the kernel which
> > > > currently use page->index, and three of them are gone once Andrew
> > > > sends his pull requests". So this will be the last user, assuming
> > > > nobody else decides to add a user of page->index in the meantime.
> > >
> > > I'll get to it after -rc1 is out, thanks.
> >
> > -rc2 is now out.
>
> Sorry for the delay, now applied.
>
> greg k-h
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-04-15 11:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31 12:56 [PATCH v2 RESEND] intel_th: avoid using deprecated page->mapping, index fields Lorenzo Stoakes
2025-03-31 15:47 ` Matthew Wilcox
2025-03-31 16:15 ` Greg Kroah-Hartman
2025-04-14 14:33 ` Matthew Wilcox
2025-04-15 11:29 ` Greg Kroah-Hartman
2025-04-15 11:34 ` Lorenzo Stoakes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).