linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH] perf: map pages in advance
Date: Fri, 29 Nov 2024 09:52:52 +0100	[thread overview]
Message-ID: <20241129085252.GA15382@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <2550a3c6-b0d9-4ad2-ae04-5735d7b4cf5f@lucifer.local>

On Thu, Nov 28, 2024 at 08:47:28PM +0000, Lorenzo Stoakes wrote:
> Peter - not sure whether it's easy for you to make a simple adjustment to this
> patch or if you want me to just send a v2, but I have to pop an #ifdef CONFIG_MMU
> into the code.
> 

> > +static int map_range(struct perf_buffer *rb, struct vm_area_struct *vma)
> > +{
> > +	unsigned long nr_pages = vma_pages(vma);
> > +	int err = 0;
> > +	unsigned long pgoff;
> > +
> > +	for (pgoff = 0; pgoff < nr_pages; pgoff++) {
> > +		unsigned long va = vma->vm_start + PAGE_SIZE * pgoff;
> > +		struct page *page = perf_mmap_to_page(rb, pgoff);
> > +
> > +		if (page == NULL) {
> > +			err = -EINVAL;
> > +			break;
> > +		}
> > +
> > +		/* Map readonly, perf_mmap_pfn_mkwrite() called on write fault. */
> > +		err = remap_pfn_range(vma, va, page_to_pfn(page), PAGE_SIZE,
> > +				      vm_get_page_prot(vma->vm_flags & ~VM_SHARED));
> > +		if (err)
> > +			break;
> > +	}
> > +
> 
> Need a:
> 
> #ifdef CONFIG_MMU
> > +	/* Clear any partial mappings on error. */
> > +	if (err)
> > +		zap_page_range_single(vma, vma->vm_start, nr_pages * PAGE_SIZE, NULL);
> #endif
> 
> Here to work around the wonders of nommu :)

All good, I'll edit the thing.


      reply	other threads:[~2024-11-29  8:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-28 11:37 Lorenzo Stoakes
2024-11-28 13:08 ` David Hildenbrand
2024-11-28 13:20   ` Lorenzo Stoakes
2024-11-28 13:37     ` David Hildenbrand
2024-11-28 14:23       ` Lorenzo Stoakes
2024-11-29 12:12         ` David Hildenbrand
2024-11-29 12:26           ` Peter Zijlstra
2024-11-29 12:45             ` David Hildenbrand
2024-11-29 12:55               ` Lorenzo Stoakes
2024-11-29 12:59                 ` David Hildenbrand
2024-11-29 13:02                   ` Lorenzo Stoakes
2024-11-29 13:12                     ` David Hildenbrand
2024-11-29 13:19                       ` Lorenzo Stoakes
2024-11-29 13:24                         ` David Hildenbrand
2024-11-29 13:38                           ` Lorenzo Stoakes
2024-11-29 13:47                             ` David Hildenbrand
2024-11-29 13:59                               ` Lorenzo Stoakes
2024-11-29 14:09                                 ` David Hildenbrand
2024-11-29 14:35                                   ` Lorenzo Stoakes
2024-11-29 14:48                                     ` David Hildenbrand
2024-11-29 20:42                                       ` Matthew Wilcox
2024-11-29 12:48           ` Lorenzo Stoakes
2024-11-29 13:11             ` David Hildenbrand
2024-11-28 20:47 ` Lorenzo Stoakes
2024-11-29  8:52   ` Peter Zijlstra [this message]

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=20241129085252.GA15382@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox