[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090325082844.GA11217@elte.hu>
Date: Wed, 25 Mar 2009 09:28:44 +0100
From: Ingo Molnar <mingo@...e.hu>
To: Paul Mackerras <paulus@...ba.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf_counter: allow and require one-page mmap on
counting counters
* Paul Mackerras <paulus@...ba.org> wrote:
> +++ 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;
> + }
Hm, is_power_of_2() is buggy then as 1 page is a power of two as
well: 1 == 2^0.
Hm, it seems fine:
static inline __attribute__((const))
bool is_power_of_2(unsigned long n)
{
return (n != 0 && ((n & (n - 1)) == 0));
}
that should return true for an input of 1.
What am i missing?
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists