Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753375AbbGQPrw (ORCPT ); Fri, 17 Jul 2015 11:47:52 -0400 Received: from foss.arm.com ([217.140.101.70]:49553 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750699AbbGQPrv (ORCPT ); Fri, 17 Jul 2015 11:47:51 -0400 Date: Fri, 17 Jul 2015 16:47:26 +0100 From: Mark Rutland To: "Liang, Kan" Cc: "a.p.zijlstra@chello.nl" , "mingo@redhat.com" , "acme@kernel.org" , "eranian@google.com" , "ak@linux.intel.com" , "Hunter, Adrian" , "dsahern@gmail.com" , "jolsa@kernel.org" , "namhyung@kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 3/9] perf/x86: Add is_hardware_event Message-ID: <20150717154726.GF26091@leverpostej> References: <1437078831-10152-1-git-send-email-kan.liang@intel.com> <1437078831-10152-4-git-send-email-kan.liang@intel.com> <20150717104814.GB26091@leverpostej> <37D7C6CF3E00A74B8858931C1DB2F0770188DD5E@SHSMSX103.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <37D7C6CF3E00A74B8858931C1DB2F0770188DD5E@SHSMSX103.ccr.corp.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4293 Lines: 120 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 > > > > > > 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/