public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf_counter: allow and require one-page mmap on counting counters
@ 2009-03-25  8:15 Paul Mackerras
  2009-03-25  8:28 ` Ingo Molnar
  2009-03-25 11:48 ` Peter Zijlstra
  0 siblings, 2 replies; 14+ messages in thread
From: Paul Mackerras @ 2009-03-25  8:15 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: linux-kernel

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.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
Ingo, please pull this from the master branch of my perfcounters.git
repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulus/perfcounters.git master

 kernel/perf_counter.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index affe227..0412c7c 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -1362,8 +1362,13 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 	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))
-		return -EINVAL;
+	if (counter->hw_event.record_type == PERF_RECORD_SIMPLE) {
+		if (nr_pages)
+			return -EINVAL;
+	} else {
+		if (nr_pages == 0 || !is_power_of_2(nr_pages))
+			return -EINVAL;
+	}
 
 	if (vma_size != PAGE_SIZE * (1 + nr_pages))
 		return -EINVAL;
-- 
1.5.6.3


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-04-01  9:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-03-25 11:52   ` Ingo Molnar
2009-03-25 12:07   ` [tip:perfcounters/core] " Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox