aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-03-25 07:48:31 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-06 03:30:35 -0400
commit7730d8655880f41f2ea519aca2ca6a1413dfd2c9 (patch)
tree2115b531fcc45d22f79828e21cc3f15dd95f01fd
parent00f0ad73ac90e3fba8b4cbe4cf21b2fb9a56cb72 (diff)
perf_counter: allow and require one-page mmap on counting counters
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> Orig-LKML-Reference: <1237981712.7972.812.camel@twins> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--kernel/perf_counter.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index f3e1b27bc1b8..95e02575546b 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -1369,7 +1369,11 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
1369 vma_size = vma->vm_end - vma->vm_start; 1369 vma_size = vma->vm_end - vma->vm_start;
1370 nr_pages = (vma_size / PAGE_SIZE) - 1; 1370 nr_pages = (vma_size / PAGE_SIZE) - 1;
1371 1371
1372 if (nr_pages == 0 || !is_power_of_2(nr_pages)) 1372 /*
1373 * If we have data pages ensure they're a power-of-two number, so we
1374 * can do bitmasks instead of modulo.
1375 */
1376 if (nr_pages != 0 && !is_power_of_2(nr_pages))
1373 return -EINVAL; 1377 return -EINVAL;
1374 1378
1375 if (vma_size != PAGE_SIZE * (1 + nr_pages)) 1379 if (vma_size != PAGE_SIZE * (1 + nr_pages))