All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Fleming <matt@console-pimps.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Zhang Rui <rui.zhang@intel.com>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Robert Richter <robert.richter@amd.com>,
	Lin Ming <ming.m.lin@intel.com>,
	Paul Mackerras <paulus@samba.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Don Zickus <dzickus@redhat.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>, Len Brown <lenb@kernel.org>,
	Matthew Garrett <mjg59@srcf.ucam.org>
Subject: Re: [RFC][PATCH 1/5] perf: Check if we should exclude idle thread in perf_exclude_event()
Date: Tue, 31 Aug 2010 16:20:12 +0100	[thread overview]
Message-ID: <20100831152012.GC27532@console-pimps.org> (raw)
In-Reply-To: <20100831145405.GB5259@nowhere>

On Tue, Aug 31, 2010 at 04:54:07PM +0200, Frederic Weisbecker wrote:
> On Mon, Aug 30, 2010 at 01:13:43PM +0100, Matt Fleming wrote:
> > Don't open code the event check for excluding the idle thread. Instead
> > include the check in perf_exclude_event().
> > 
> > Signed-off-by: Matt Fleming <matt@console-pimps.org>
> > ---
> >  kernel/perf_event.c |    8 +++++---
> >  1 files changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> > index 0d38f27..16b0476 100644
> > --- a/kernel/perf_event.c
> > +++ b/kernel/perf_event.c
> > @@ -4310,6 +4310,9 @@ static int perf_exclude_event(struct perf_event *event,
> >  
> >  		if (event->attr.exclude_kernel && !user_mode(regs))
> >  			return 1;
> > +
> > +		if (event->attr.exclude_idle && current->pid == 0)
> > +			return 1;
> 
> 
> 
> Right.
> 
> But one of the problems people have reported is that they can miss
> interrupts samples if they happen in idle. Hence we have decided
> that exclude_idle should exclude events that happen in idle process
> context but not in interrupts interrupting idle.
> 
> So adding an in_interrupt() check would perhaps be better.
> 
> I plan to do this exclusion using the per context exclusion, which is
> a patchset I have in queue. But until then, having this patch is better.
> 
> 
> 
> >  	}
> >  
> >  	return 0;
> > @@ -4512,9 +4515,8 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
> >  	regs = get_irq_regs();
> >  
> >  	if (regs && !perf_exclude_event(event, regs)) {
> > -		if (!(event->attr.exclude_idle && current->pid == 0))
> > -			if (perf_event_overflow(event, 0, &data, regs))
> > -				ret = HRTIMER_NORESTART;
> > +		if (perf_event_overflow(event, 0, &data, regs))
> > +			ret = HRTIMER_NORESTART;
> 
> 
> 
> But yeah if we add an in_interrupt() check in perf_exclude_event(), it
> won't work here. This one needs to check if irqs are nesting :)
> 
> Bah, checking we interrupted softirqs is probably enough. I guess we
> don't care about nesting hardirqs.

This patch isn't really worth it on its own, I only grouped the idle
check into perf_exclude_event() because patch 3/5 introduced a new
caller. As you've said, the semantics at the various callsites are
quite complex. It's probably best to wait for your patchset :)

  reply	other threads:[~2010-08-31 15:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-30 12:13 [RFC][PATCH 0/5] hrtimer group events Matt Fleming
2010-08-30 12:13 ` [RFC][PATCH 1/5] perf: Check if we should exclude idle thread in perf_exclude_event() Matt Fleming
2010-08-31 14:54   ` Frederic Weisbecker
2010-08-31 15:20     ` Matt Fleming [this message]
2010-08-31 15:21       ` Frederic Weisbecker
2010-08-30 12:13 ` [RFC][PATCH 2/5] perf: Turn the group counter values into delta values Matt Fleming
2010-08-30 12:54   ` Peter Zijlstra
2010-08-30 13:21     ` Matt Fleming
2010-08-30 12:13 ` [RFC][PATCH 3/5] perf: Add hrtimer code for PMI-less hardware counters Matt Fleming
2010-08-30 12:55   ` Peter Zijlstra
2010-08-30 13:27     ` Matt Fleming
2010-08-30 14:12       ` Peter Zijlstra
2010-08-30 19:35         ` Matt Fleming
2010-08-30 12:13 ` [RFC][PATCH 4/5] sh: Add support for sampling counters Matt Fleming
2010-08-30 12:13 ` [RFC][PATCH 5/5] perf: Add support for PERF_SAMPLE_READ samples Matt Fleming

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=20100831152012.GC27532@console-pimps.org \
    --to=matt@console-pimps.org \
    --cc=acme@redhat.com \
    --cc=dzickus@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --cc=mingo@elte.hu \
    --cc=mjg59@srcf.ucam.org \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=robert.richter@amd.com \
    --cc=rui.zhang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.