From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org, hpa@zytor.com,
mingo@redhat.com, a.p.zijlstra@chello.nl, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:perfcounters/core] perf_counter: allow and require one-page mmap on counting counters
Date: Wed, 25 Mar 2009 12:07:20 GMT [thread overview]
Message-ID: <tip-bb0ad4e22511e7caa715362945ad0766c7cca37e@git.kernel.org> (raw)
In-Reply-To: <1237981712.7972.812.camel@twins>
Commit-ID: bb0ad4e22511e7caa715362945ad0766c7cca37e
Gitweb: http://git.kernel.org/tip/bb0ad4e22511e7caa715362945ad0766c7cca37e
Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Wed, 25 Mar 2009 12:48:31 +0100
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 25 Mar 2009 13:02:54 +0100
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>
LKML-Reference: <1237981712.7972.812.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/perf_counter.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index f3e1b27..95e0257 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))
prev parent reply other threads:[~2009-03-25 12:09 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
2009-03-25 11:52 ` Ingo Molnar
2009-03-25 12:07 ` 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=tip-bb0ad4e22511e7caa715362945ad0766c7cca37e@git.kernel.org \
--to=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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