Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp325435ybg; Tue, 28 Jul 2020 07:05:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx1EqnhxUfuPGypKzKTwtOQIxHU/NoIgQCeFXkoRN0f+ZcDUkos3OOUM0AuDTAK8V8op5T X-Received: by 2002:a17:906:d217:: with SMTP id w23mr26350060ejz.292.1595945134041; Tue, 28 Jul 2020 07:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595945134; cv=none; d=google.com; s=arc-20160816; b=p1z9stJf50/+o79Wa1vsDu7Id8ZhqzgM0LTkWsTirIW2TKzni1m1hzYz9kWucv4174 2iSIjEpUwXj0SHXtQkCCqAWl18CKN3j4Cptvwnf9z0EISDq3KDtHwOBYbBhj5Lt1KSH8 IddWU25+TSoHQmbi1VKvhl5LGfXAxu/0QTm/TqTlQ7emwx98c+l9hUfQeF+WYkkzKT7A whHn9qvYKJxNgXhpkHU1z/O961dcIm4RJ1rUen1Csw9P/N0AkwqSpLvo1Q603zGucPf0 Axf8DrNfAr8bvBo3DXvu3X64oDB/CNpQLW4sHUYmgXbNO8co9YsxPLD4M5xGceJBtm5v bquw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=wtUJoAU3tUfEL9T9cQSSm0kOvfpqd5zA3bOrch+lJ64=; b=UXYulrvob4plYge5sz8DIwHEp1Z9OPyb3oLh52rm9WXmvndE77qwKnfHT+OVYSWF52 HI28y1llM8tN2OMNFtf6TwH6Xo6QRh2J+l+BleJ8lrx4yJ04fFcitFjxZ/kY/kWOcutA 23LtuGKPYMd6XEoaZG2ykDK7mX4k20rlMh7cEgz2qVR+HInSjhaQSI28VEvh52IIlLxq xgoGK0qA1rAVP65cPax8BUeOkZ3W3uYjRXwUEe9/m9oBk52/Jc48RicU7Lct0athZdmU keIPNR8bcMSxk/9NoCyUlqj+4PfWSM7ubZ+bGpZ+vtiKBAE8yaiyrtYU20/hcsT/uA4/ 4w8w== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si7800338edx.581.2020.07.28.07.05.11; Tue, 28 Jul 2020 07:05:34 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730291AbgG1OB3 (ORCPT + 99 others); Tue, 28 Jul 2020 10:01:29 -0400 Received: from mga05.intel.com ([192.55.52.43]:4697 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730248AbgG1OB3 (ORCPT ); Tue, 28 Jul 2020 10:01:29 -0400 IronPort-SDR: AdXN3RxOhYXkZI+w16hAX+xx3zJz2eAnjSg4c7UKMJKkF5oIWDj8wkHACL/nccQJWXAIfLZ8Dl 4vREmwOLlfCA== X-IronPort-AV: E=McAfee;i="6000,8403,9695"; a="236073205" X-IronPort-AV: E=Sophos;i="5.75,406,1589266800"; d="scan'208";a="236073205" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2020 07:01:28 -0700 IronPort-SDR: w2etQZcEy/vnSpL4WuObiNTD4tpbcHE+V6FMLmCy8iibX5rsq1MxwmUIov44AtE1MjSSrwZ4tE SkXEbQGQ/Cgg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,406,1589266800"; d="scan'208";a="328348023" Received: from linux.intel.com ([10.54.29.200]) by FMSMGA003.fm.intel.com with ESMTP; 28 Jul 2020 07:01:28 -0700 Received: from [10.252.128.28] (kliang2-mobl.ccr.corp.intel.com [10.252.128.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 715F7580295; Tue, 28 Jul 2020 07:01:27 -0700 (PDT) Subject: Re: [PATCH V7 08/14] perf/x86/intel: Generic support for hardware TopDown metrics To: peterz@infradead.org 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 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> <20200728134412.GX119549@hirez.programming.kicks-ass.net> From: "Liang, Kan" Message-ID: <4313ed1f-03b2-48e7-36fe-6a112fa6c70f@linux.intel.com> Date: Tue, 28 Jul 2020 10:01:25 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200728134412.GX119549@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/28/2020 9:44 AM, peterz@infradead.org wrote: > 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? Kind of, because a metric event must be in a group with the leader slots event. If a user reads (treats) the metric event as a singleton event, an invalid value should be expected. > 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'. I will update the perf tool document to force the PERF_FORMAT_GROUP flag for each metric events. Thanks, Kan