Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp313027ybg; Tue, 28 Jul 2020 06:46:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwaP6aVV6eKBvITySLZhOzCfpVnWZUV5lfopGZxjM3q3OGvVXGcfppEeJZJDLk3RhMyVvg X-Received: by 2002:a17:906:3009:: with SMTP id 9mr25146347ejz.220.1595944018947; Tue, 28 Jul 2020 06:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595944018; cv=none; d=google.com; s=arc-20160816; b=cZtkcBs+xLcoJ9hGoKiIuACH/oD0s9tYctQqAgejES5wkFikWQQ0sK+a+8da0kzCw/ Fr1SAEdxnLVdoC50lT8uaUw3p1r4D3m0WNDL6r2zmDj74WVdsoVKEN+BzUkR72qd2q1h 2wyjULcU1I4MTiSsIOj3BI7Z3uQQcbQ7MEr+f8vjA1mpzesvUeZcM0bH/zK79MNPQqbt 99L+C/gijmR61CH1ZKXYH6Utc/FehurXVJLuhdUTFR7zF7CJwxm04XsPXVKLpmH8aXPO +G5wrnzYmEoTIlY9atBT8ZGxwSEpIzlwLneJihtBFk24p1GPg8BggEfcn3SZ3SaC8iMG f6AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=mUjI21PfdGbJqznXKz6eDDRzmbMl77dKG/X1NGmjf5k=; b=c//FLqV59R0u2L5TRdZsa7SGoD4GSsIMM7M4/k1ZQ4fCMySrs5znyPK7fI7GeUp4Tc OTVTdebmOzCsP5qvn99SEiZ0LIrWQWReC2c1pLm+5/ddUs291pjuFr70STCYhBSv16gW RWYmx3MstGbC/lNM6+3alRab7Z8MrlrvNHgOMm04d9arZHhTVMA3BNJlOKxe1jIScdLm tM4/3nS26U1S6d4gUWNkHFpRSw90JyrKXoX5jI0/nrVDwB2CfY7gRt/V1OjwVbLPcLlJ DsnnAz1MJWco8VcuJnxKvmP9+cmoX7DpED66EusBJRwZXZ+4YlDKp+hD6PJD7A/iKxRn u2aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=zIBWk+4g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si7521610edx.261.2020.07.28.06.46.37; Tue, 28 Jul 2020 06:46:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=zIBWk+4g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730138AbgG1NoX (ORCPT + 99 others); Tue, 28 Jul 2020 09:44:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730012AbgG1NoX (ORCPT ); Tue, 28 Jul 2020 09:44:23 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBA3FC061794 for ; Tue, 28 Jul 2020 06:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mUjI21PfdGbJqznXKz6eDDRzmbMl77dKG/X1NGmjf5k=; b=zIBWk+4gHAK/rpRWW0yzYbaO6y slsNV2S7ol+vTIKyRrEXQhlC+KWibRmDBKqAeTssNl0IrjqIPH0MFfs7CQG8bA6HtXhv/Jx0oSWYX 44TDAZTJawUbVCCKvzZt5qC+J0wmVkq72beLCgpY2fdV2l261fzcX28sZrbBU04RgfUhg0mPkDbS/ yyJaFQe6hhq9erqDYE4mK1oeylCqWUXR96cHguRh8wIa9O5m0aAKRYyxNAbQhktL3S43+U6/Xrdqx tiWjGoXqxQFxbmZ+FfpD1wy7QJ3IjWQyb/l2Ow8L5Vwom0vrI415prN1DQYsxYmTVzCPMBveh/owL O3YaKcpQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0Ptw-0001U8-LC; Tue, 28 Jul 2020 13:44:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 08B3C3013E5; Tue, 28 Jul 2020 15:44:13 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E4EBB2B7AB914; Tue, 28 Jul 2020 15:44:12 +0200 (CEST) Date: Tue, 28 Jul 2020 15:44:12 +0200 From: peterz@infradead.org To: "Liang, Kan" Cc: acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, eranian@google.com, alexander.shishkin@linux.intel.com, ak@linux.intel.com, like.xu@linux.intel.com Subject: Re: [PATCH V7 08/14] perf/x86/intel: Generic support for hardware TopDown metrics Message-ID: <20200728134412.GX119549@hirez.programming.kicks-ass.net> References: <20200723171117.9918-1-kan.liang@linux.intel.com> <20200723171117.9918-9-kan.liang@linux.intel.com> <20200724131906.GW119549@hirez.programming.kicks-ass.net> <20200724152755.GK43129@hirez.programming.kicks-ass.net> <20200728130956.GK10769@hirez.programming.kicks-ass.net> <25a630c6-2fa2-5dfd-bcd3-92e809c51d61@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25a630c6-2fa2-5dfd-bcd3-92e809c51d61@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 28, 2020 at 09:28:39AM -0400, Liang, Kan wrote: > > > On 7/28/2020 9:09 AM, Peter Zijlstra wrote: > > On Fri, Jul 24, 2020 at 03:10:52PM -0400, Liang, Kan wrote: > > > > > diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c > > > index 6cb079e0c9d9..010ac74afc09 100644 > > > --- a/arch/x86/events/intel/core.c > > > +++ b/arch/x86/events/intel/core.c > > > @@ -2405,27 +2405,18 @@ static u64 icl_update_topdown_event(struct > > > perf_event *event) > > > return slots; > > > } > > > > > > -static void intel_pmu_read_topdown_event(struct perf_event *event) > > > +static void intel_pmu_read_event(struct perf_event *event) > > > { > > > - struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); > > > - > > > - /* Only need to call update_topdown_event() once for group read. */ > > > - if ((cpuc->txn_flags & PERF_PMU_TXN_READ) && > > > - !is_slots_event(event)) > > > return; > > > > > > - perf_pmu_disable(event->pmu); > > > - x86_pmu.update_topdown_event(event); > > > - perf_pmu_enable(event->pmu); > > > -} > > > - > > > -static void intel_pmu_read_event(struct perf_event *event) > > > -{ > > > if (event->hw.flags & PERF_X86_EVENT_AUTO_RELOAD) > > > intel_pmu_auto_reload_read(event); > > > - else if (is_topdown_count(event) && x86_pmu.update_topdown_event) > > > - intel_pmu_read_topdown_event(event); > > > - else > > > + else if (is_slots_count(event) && x86_pmu.update_topdown_event) { > > > + perf_pmu_disable(event->pmu); > > > + x86_pmu.update_topdown_event(event); > > > + perf_pmu_enable(event->pmu); > > > + } else > > > x86_perf_event_update(event); > > > } > > > > I'm a little puzzled by this; what happens if you: > > > > fd = sys_perf_event_open(&attr_slots); > > fd1 = sys_perf_event_open(&attr_metric, .group_fd=fd); > > > > read(fd1); > > > > ? > > > > I did a quick test. It depends on the .read_format of attr_metric. > If PERF_FORMAT_GROUP is applied for attr_metric, perf_read_group() will be > invoked. The value of fd1 is updated correctly. > If the flag is not applied, 0 will be returned. Exactly :-), was that intentional? Because prior to this change that would've worked just fine. Now, I agree it's a daft thing, because that value is pretty useless without also having the slots value, but I feel we should be explicit in our choices here. If for example, we would've had hardware provide us the raw metric counters, instead of us having to reconstruct them, this would've been a semi useful thing. So I'm tempted to leave things as it, and keep this 'working'.