public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf_counter: allow and require one-page mmap on counting counters
Date: Wed, 25 Mar 2009 10:14:48 +0100	[thread overview]
Message-ID: <1237972488.7972.658.camel@twins> (raw)
In-Reply-To: <20090325090336.GC2341@elte.hu>

On Wed, 2009-03-25 at 10:03 +0100, Ingo Molnar wrote:
> * Paul Mackerras <paulus@samba.org> wrote:
> 
> > Ingo Molnar writes:
> > 
> > > * Paul Mackerras <paulus@samba.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;
> > 
> > To answer your question below... this:    ^^^
> > 
> > > >  
> > > > -	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
> > 
> > We have one page as a header that contains the info for reading 
> > the counter value in userspace plus the head pointer, followed by 
> > (for a sampling counter) 2^N pages of ring buffer.
> 
> ah - ok. Morning confusion. (any email from me that comes at single 
> digit hour local time should be considered fundamentally suspect ;-)
> 
> Wouldnt it still be better to keep the symmetry between counting and 
> sampling counters? In theory we could transit between these stags 
> and 'switch off' a sampling counter or 'switch on' a counting 
> counter - via an ioctl or so. Shouldnt counting counters be sampling 
> counters that were created while disabled temporarily?

I think I initially intended 0 pages to be ok, even for sampling
counters. I just messed up that if stmt.

if (nr_pages != 0 && !is_power_of_2(nr_pages))
  return -EINVAL;

would I think, do what I intended.




  reply	other threads:[~2009-03-25  9:18 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 [this message]
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

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=1237972488.7972.658.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    /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