Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755253AbdCaOYP (ORCPT ); Fri, 31 Mar 2017 10:24:15 -0400 Received: from foss.arm.com ([217.140.101.70]:60652 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754687AbdCaOYN (ORCPT ); Fri, 31 Mar 2017 10:24:13 -0400 Date: Fri, 31 Mar 2017 15:23:52 +0100 From: Mark Rutland To: Anurup M Cc: will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, anurup.m@huawei.com, zhangshaokun@hisilicon.com, tanxiaojun@huawei.com, xuwei5@hisilicon.com, sanil.kumar@hisilicon.com, john.garry@huawei.com, gabriele.paoloni@huawei.com, shiju.jose@huawei.com, huangdaode@hisilicon.com, linuxarm@huawei.com, dikshit.n@huawei.com, shyju.pv@huawei.com Subject: Re: [PATCH v6 07/11] drivers: perf: hisi: Add support for Hisilicon SoC event counters Message-ID: <20170331142351.GC6488@leverpostej> References: <1489127311-112778-1-git-send-email-anurup.m@huawei.com> <20170321165252.GA29116@leverpostej> <58DCD47C.2010501@gmail.com> <20170330104607.GC16211@leverpostej> <58DE6400.8030900@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <58DE6400.8030900@gmail.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: 1656 Lines: 41 On Fri, Mar 31, 2017 at 07:43:20PM +0530, Anurup M wrote: > On Thursday 30 March 2017 04:16 PM, Mark Rutland wrote: > >>>>>+ /* > >>>>>> >>>+ * We must NOT create groups containing mixed PMUs, although > >>>>>> >>>+ * software events are acceptable > >>>>>> >>>+ */ > >>>>>> >>>+ if (event->group_leader->pmu != event->pmu && > >>>>>> >>>+ !is_software_event(event->group_leader)) > >>>>>> >>>+ return -EINVAL; > >>>>>> >>>+ > >>>>>> >>>+ list_for_each_entry(sibling, &event->group_leader->sibling_list, > >>>>>> >>>+ group_entry) > >>>>>> >>>+ if (sibling->pmu != event->pmu && !is_software_event(sibling)) > >>>>>> >>>+ return -EINVAL; > >>>> >Please also check the number of counters. > >>> > >>>Sorry, I could not follow this comment correctly. Could you please explain ? > >>>I check the available counters and update used mask in pmu_add --> > >>>get_event_index > >What I meant was that here we should ensure that a group does not > >contain more events than can fit into counters. > > > >For example, if the HW had two counters, we should reject any group with > >more than two events. Such groups can never be scheduled, and make no > >sense. > > I have referred drivers/bus/arm-cci.c and could find validate_group > and validate_event functions, > which create a fake_pmu to check the available counters for the > events in the group. > Is that the same way which is expected here? Please comment. Something like that. I think it's simplest to have a validate_group() function, which counts the number of counters used. See my suggestion in [1]. Thanks, Mark. [1] https://lkml.kernel.org/r/20170331135955.GB6488@leverpostej