All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: "Liang, Kan" <kan.liang@intel.com>
Cc: "a.p.zijlstra@chello.nl" <a.p.zijlstra@chello.nl>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"acme@kernel.org" <acme@kernel.org>,
	"eranian@google.com" <eranian@google.com>,
	"ak@linux.intel.com" <ak@linux.intel.com>,
	"Hunter, Adrian" <adrian.hunter@intel.com>,
	"dsahern@gmail.com" <dsahern@gmail.com>,
	"jolsa@kernel.org" <jolsa@kernel.org>,
	"namhyung@kernel.org" <namhyung@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/9] perf/x86: Add is_hardware_event
Date: Fri, 17 Jul 2015 16:47:26 +0100	[thread overview]
Message-ID: <20150717154726.GF26091@leverpostej> (raw)
In-Reply-To: <37D7C6CF3E00A74B8858931C1DB2F0770188DD5E@SHSMSX103.ccr.corp.intel.com>

On Fri, Jul 17, 2015 at 04:03:36PM +0100, Liang, Kan wrote:
> > 
> > On Thu, Jul 16, 2015 at 09:33:45PM +0100, kan.liang@intel.com wrote:
> > > From: Kan Liang <kan.liang@intel.com>
> > >
> > > Using is_hardware_event to replace !is_software_event to indicate a
> > > hardware event.
> > 
> > Why...?
> 
> First, the comments of is_software_event is not correct. 
> 0 or !is_software_event is not for a hardware event.
> is_hardware_event is for a hardware event.

Circular logic is fantastic.

> Also, the following patch make mix core_misc event be part of hw/sw
> event, !is_software_event could be either hw event or core_misc event.

!is_software_event is also true for an uncore event currently, and the
code relies on this fact. Blindly replacing !is_software_event with
is_hardware_event changes the behaviour of the code for uncore events.

> > For an uncore event e, is_hardware_event(e) != !is_software_event(e),
> > so this will be a change of behaviour...
> 
> Uncore event cannot be part of hw/sw event group. So it doesn't change the behavior. 

My complaint had _nothing_ to do with groups. It had to do with the
accounting for throttling, where it _does_ change the behaviour.

However, now that you mention the group logic...

> > >  /*
> > > - * Return 1 for a software event, 0 for a hardware event
> > > + * Return 1 for a software event, 0 for other event
> > >   */
> > >  static inline int is_software_event(struct perf_event *event)  {
> > >  	return event->pmu->task_ctx_nr == perf_sw_context;  }
> > >
> > > +static inline int is_hardware_event(struct perf_event *event) {
> > > +	return event->pmu->task_ctx_nr == perf_hw_context; }
> > > +
> > >  extern struct static_key
> > perf_swevent_enabled[PERF_COUNT_SW_MAX];
> > >
> > >  extern void ___perf_sw_event(u32, u64, struct pt_regs *, u64); diff
> > > --git a/kernel/events/core.c b/kernel/events/core.c index
> > > d3dae34..9077867 100644
> > > --- a/kernel/events/core.c
> > > +++ b/kernel/events/core.c
> > > @@ -1347,7 +1347,7 @@ static void perf_group_attach(struct
> > perf_event *event)
> > >  	WARN_ON_ONCE(group_leader->ctx != event->ctx);
> > >
> > >  	if (group_leader->group_flags & PERF_GROUP_SOFTWARE &&
> > > -			!is_software_event(event))
> > > +			is_hardware_event(event))
> > >  		group_leader->group_flags &= ~PERF_GROUP_SOFTWARE;
> > >

...this changes the behaviour of attaching an uncore event to a software
group.

Before, we'd correctly clear the PERF_GROUP_SOFTWARE flag on the leader.
After this patch, we don't. That is a bug.

My original complaint was with the changes below.

> > >  	list_add_tail(&event->group_entry, &group_leader->sibling_list);
> > @@
> > > -1553,7 +1553,7 @@ event_sched_out(struct perf_event *event,
> > >  	event->pmu->del(event, 0);
> > >  	event->oncpu = -1;
> > >
> > > -	if (!is_software_event(event))
> > > +	if (is_hardware_event(event))
> > >  		cpuctx->active_oncpu--;
> > >  	if (!--ctx->nr_active)
> > >  		perf_event_ctx_deactivate(ctx);

Previously we'd call perf_event_ctx_deactivate() for an uncore PMU's
contexts, but now we never will.

> > > @@ -1881,7 +1881,7 @@ event_sched_in(struct perf_event *event,
> > >  		goto out;
> > >  	}
> > >
> > > -	if (!is_software_event(event))
> > > +	if (is_hardware_event(event))
> > >  		cpuctx->active_oncpu++;
> > >  	if (!ctx->nr_active++)
> > >  		perf_event_ctx_activate(ctx);

Similarly for perf_event_ctx_deactivate().

As I mention below, That means we will no longer perform throttling for
an uncore PMU's cpu context (see perf_event_task_tick()).

> > ... whereby we won't accuont uncore events as active, and thereforef will
> > never perform throttling.
> > 
> > That doesn't sound right.
> 
> I think active_oncpu should only impact if the group is exclusive.
> The changes will make pure perf_invalid_context event group never exclusive.
> If that's a problem, I will change this part back.

I'm not sure what you mean here -- I can't see what a group being
exclusive has to do with any of the points above.

What am I missing?

Thanks,
Mark.

  reply	other threads:[~2015-07-17 15:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 20:33 [PATCH 0/9] Intel core misc PMUs support kan.liang
2015-07-16 20:33 ` [PATCH 1/9] perf/x86: Add " kan.liang
2015-07-16 20:33 ` [PATCH 2/9] perf/x86: core_misc PMU disable and enable support kan.liang
2015-07-17 12:11   ` Mark Rutland
2015-07-17 13:46     ` Peter Zijlstra
2015-07-17 13:51       ` Peter Zijlstra
2015-07-17 15:35         ` Liang, Kan
2015-07-17 17:01           ` Andy Lutomirski
2015-07-17 17:52             ` Liang, Kan
2015-07-17 17:58               ` Andy Lutomirski
2015-07-17 18:15                 ` Liang, Kan
2015-07-17 18:56                   ` Andy Lutomirski
2015-07-17 21:11                   ` Peter Zijlstra
2015-07-16 20:33 ` [PATCH 3/9] perf/x86: Add is_hardware_event kan.liang
2015-07-17 10:48   ` Mark Rutland
2015-07-17 15:03     ` Liang, Kan
2015-07-17 15:47       ` Mark Rutland [this message]
2015-07-17 16:11         ` Mark Rutland
2015-07-16 20:33 ` [PATCH 4/9] perf/x86: special case per-cpu core misc PMU events kan.liang
2015-07-17 12:21   ` Mark Rutland
2015-07-17 12:55     ` Peter Zijlstra
2015-07-17 18:11       ` Stephane Eranian
2015-07-17 20:17     ` Andi Kleen
2015-07-20 16:12       ` Mark Rutland
2015-07-16 20:33 ` [PATCH 5/9] perf,tools: open event with it's own cpus and threads kan.liang
2015-07-16 20:33 ` [PATCH 6/9] perf,tools: Dump per-sample freq in report -D kan.liang
2015-07-16 20:33 ` [PATCH 7/9] perf,tools: save APERF/MPERF/TSC in struct perf_sample kan.liang
2015-07-16 20:33 ` [PATCH 8/9] perf,tools: caculate and save tsc/avg/bzy freq in he_stat kan.liang
2015-07-17 20:25   ` Andi Kleen
2015-07-17 20:57     ` Liang, Kan
2015-07-17 21:27       ` Andi Kleen
2015-07-16 20:33 ` [PATCH 9/9] perf,tools: Show freq in perf report --stdio kan.liang
2015-07-17 11:39 ` [PATCH 0/9] Intel core misc PMUs support Ingo Molnar

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=20150717154726.GF26091@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.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 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.