All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf_counter: allow and require one-page mmap on counting counters
Date: Wed, 25 Mar 2009 12:48:31 +0100	[thread overview]
Message-ID: <1237981712.7972.812.camel@twins> (raw)
In-Reply-To: <18889.59409.260586.87939@cargo.ozlabs.ibm.com>

On Wed, 2009-03-25 at 19:15 +1100, Paul Mackerras wrote:
> Impact: bug fix
> 
> Currently the mmap code requires that the length of the mmap be at least
> two pages.  That is fine for sampling counters, but for counting
> counters the second and subsequent pages are just wasted, since counting
> counters don't generate events.
> 
> This changes the code to require that the mmap be one page in length
> for counting counters, and applies the existing check to sampling
> counters.

Does the below work for you Paul?

---
Subject: perf_counter: allow one-page mmap on counters
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Wed Mar 25 12:44:16 CET 2009

A brainfart stopped single page mmap()s working. The rest of the code
should be perfectly fine with not having any data pages.

Reported-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/perf_counter.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -1369,7 +1369,11 @@ static int perf_mmap(struct file *file, 
 	vma_size = vma->vm_end - vma->vm_start;
 	nr_pages = (vma_size / PAGE_SIZE) - 1;
 
-	if (nr_pages == 0 || !is_power_of_2(nr_pages))
+	/*
+	 * If we have data pages ensure they're a power-of-two number, so we
+	 * can do bitmasks instead of modulo.
+	 */
+	if (nr_pages != 0 && !is_power_of_2(nr_pages))
 		return -EINVAL;
 
 	if (vma_size != PAGE_SIZE * (1 + nr_pages))



  parent reply	other threads:[~2009-03-25 11:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-25  8:15 [PATCH] perf_counter: allow and require one-page mmap on counting counters Paul Mackerras
2009-03-25  8:28 ` Ingo Molnar
2009-03-25  8:34   ` Peter Zijlstra
2009-03-25  8:56   ` Paul Mackerras
2009-03-25  9:03     ` Ingo Molnar
2009-03-25  9:14       ` Peter Zijlstra
2009-03-25  9:42       ` Paul Mackerras
2009-03-31 19:15         ` Peter Zijlstra
2009-04-01  2:32           ` Paul Mackerras
2009-04-01  8:13             ` Peter Zijlstra
2009-04-01  9:31               ` Paul Mackerras
2009-03-25 11:48 ` Peter Zijlstra [this message]
2009-03-25 11:52   ` Ingo Molnar
2009-03-25 12:07   ` [tip:perfcounters/core] " Peter Zijlstra

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=1237981712.7972.812.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.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.