From: Peter Zijlstra Date: Wed, 25 Mar 2009 11:48:31 +0000 (+0100) Subject: perf_counter: allow and require one-page mmap on counting counters X-Git-Tag: v2.6.31-rc1~383^2~430 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7730d8655880f41f2ea519aca2ca6a1413dfd2c9;p=karo-tx-linux.git 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 Signed-off-by: Peter Zijlstra Orig-LKML-Reference: <1237981712.7972.812.camel@twins> Signed-off-by: Ingo Molnar --- 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) 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))