From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D240EC433DF for ; Tue, 21 Jul 2020 11:58:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9988020792 for ; Tue, 21 Jul 2020 11:58:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qe6vaw4p"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="06tuUXfZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9988020792 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+lEAxVLvQZ2V3U2XktsPQ3pmK/SKkZf4ryHomCdzrVQ=; b=qe6vaw4pZVMQa9wrq9NKyUfK1 iLHJDe7RQasdDCKVertARIrVBWs6OB3yJ2NFw2CQBtwXqdCSoE7X7KdK4Vis5tbjwalPjEeEIGiOb rrmB0Xt5lZ72Q2QU7Cxptsk4blNZBMkqu2ty3QlfrThUsbikbKdgctk+PM1wxMUWEwb1g89IVGufU NiugVH2lxR11Bz6N00CPvzBaihcpO61IVfTrJNzIkqRuhWwwg3uIDMMz9nKofAIssFjviIkRSA2kf rP2I3nF+kyJ66QHlGAeOhEMMN3FoQprstYRzcziG8Bp7T9HGhnua8i4srTHBLoBWG2zPReiZZu/j3 RmIqMrKBA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxqtN-0005oc-Pg; Tue, 21 Jul 2020 11:57:05 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxqtL-0005nr-Js for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2020 11:57:04 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7E1720792; Tue, 21 Jul 2020 11:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595332622; bh=Jc4R9EfcmUku/bGpVzYN2JN6kNgbv54O76DGH5tKqus=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=06tuUXfZmQ2npz768uibuPUH6FKmeM1zyxvktFfYffROuF1uGWYRfIoQscKRIZHQe udsWA376Px+BEIFhrBgmBwxsIwHyHRs3RZ29YAcN171BPrikd6K7Rj7/as/axwowEs 9ZDM518xOkgeSs8ut6yLUyApMabb77W31ylU7g9Y= Date: Tue, 21 Jul 2020 12:56:58 +0100 From: Will Deacon To: Shaokun Zhang Subject: Re: [PATCH v5 1/2] arm64: perf: Add support caps in sysfs Message-ID: <20200721115655.GA13327@willie-the-truck> References: <20200721082112.GA13045@willie-the-truck> <1595328573-12751-1-git-send-email-zhangshaokun@hisilicon.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1595328573-12751-1-git-send-email-zhangshaokun@hisilicon.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200721_075703_747748_DDC4E155 X-CRM114-Status: GOOD ( 18.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Shaokun, On Tue, Jul 21, 2020 at 06:49:32PM +0800, Shaokun Zhang wrote: > ARMv8.4-PMU introduces the PMMIR_EL1 registers and some new PMU events, > like STALL_SLOT etc, are related to it. Let's add a caps directory to > /sys/bus/event_source/devices/armv8_pmuv3_0/ and support slots from > PMMIR_EL1 registers in this entry. The user programs can get the slots > from sysfs directly. > > Cc: Will Deacon > Cc: Mark Rutland > Signed-off-by: Shaokun Zhang > --- > ChangeLog in v5: > * Add check STALL_SLOT in PMCEID1_EL0 Thanks. I was just about to apply this, but then I realised that it's completely broken for big.LITTLE :( One CPU might have PMMIR_EL1, but another might not and so code such as: > +static umode_t > +armv8pmu_caps_attr_is_visible(struct kobject *kobj, struct attribute *attr, > + int unused) > +{ > + int pmuver = armv8pmu_get_pmu_version(); > + u32 pmceid1 = read_sysreg(pmceid1_el0); > + > + /* Check the PMU version is >= v8.4 and STALL_SLOT is implemented */ > + if (pmuver >= ID_AA64DFR0_PMUVER_8_4 && (pmceid1 & BIT(31))) > + return attr->mode; > + > + return 0; > +} > + > +static ssize_t slots_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + int slots = read_sysreg_s(SYS_PMMIR_EL1) & 0xFF; > + > + return snprintf(buf, PAGE_SIZE, "%d\n", slots); > +} Is dangerous if you can migrate between the two functions. So I think what we need to do is use the cpu_pmu structure to stash the PMMIR_EL1 register during probe, setting it to zero for CPUs without it, and then you can just report that value on slots_show(), getting rid of armv8pmu_caps_attr_is_visible() entirely. Does that make sense? Sorry I didn't spot this earlier. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel