Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4040779pxf; Tue, 16 Mar 2021 04:25:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7D9rqQQl3HnEl6LcL2AjMlC89KfFYc8Y0BWF6dBZmaKxhNRS2jwdKJ4XIMZ2syoCm7tcG X-Received: by 2002:aa7:dd97:: with SMTP id g23mr35059567edv.154.1615893932719; Tue, 16 Mar 2021 04:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615893932; cv=none; d=google.com; s=arc-20160816; b=YEWblwwtbrmw9BelMpNEygrIy1B2FX5+RhTjZAovEvpBiBHBccCDrC9v5dw7rcin44 gE4r5YD4skW/ypVWU8RrtQR7k15TnfhGi060AhuKGMLEPWwXcImvZRQ2tGkTPk3D+z6d kr/QK18gZdvizZb9EwsdsgZyPl6+1Lf21Ehqun5+Bt1KECdgaLmx8ne5Zn/ZCR4DRaWq ZQupOBR/5iQ6ln9OOstpSZX0qKQg9TX3lJhql+mgS9RU8Z7/fJm0PMCxCEcpnSfFCqv7 KmqAVOPlvVzhBfC1GNXJMhjOtUfadH+r14V5feRUB+DaarMCJ2X1GfmK8bmkLyBKA3Xz CFyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence: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=W4oBaTaHPSTyRpMcvvB82oWDYFVATJ7ZXrw6nPdvt14=; b=Ae1FxBVzwMBIsxHphrGzFWRK28/98Nk09KecGAFVl8rVmtmyKHj3GRBkkZHtxex2k4 +xO3pLfhyhpnjWA/IbJdm5A3f41V28Q67YhpH+mfvdBbjI6o9JtzWg5PAoiZP1D3cVQa LC5aHL+VVrbBpL/OKcPXhufHjAPkTaI1/tnP02DtwORRN7HmXUbPdcexTYWY82mAZMGl 2Qjag7ET13Ow+PbysQBxGLJPwRkrE4uveHB76zuY6dJGuafhMPomEHb95DPLeg8hV4CJ r3UKxAVMRcRKt8qVQAQYFhiKF/VBHIhVhDgwbKZ26QwAy6w6u48c1eNO666iC10x1j00 Rr7g== 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 x26si13296888ejj.525.2021.03.16.04.25.09; Tue, 16 Mar 2021 04:25:32 -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 S232589AbhCPDNd (ORCPT + 99 others); Mon, 15 Mar 2021 23:13:33 -0400 Received: from mga02.intel.com ([134.134.136.20]:39088 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbhCPDNI (ORCPT ); Mon, 15 Mar 2021 23:13:08 -0400 IronPort-SDR: qx9jxrx5UYuEP4/oNDc3C96wpBjgCUtURs0I/dMGDYa0W2bHKFKVn2GCCYZ7760A5sCdqrwX9u JO7ezz7jSXEg== X-IronPort-AV: E=McAfee;i="6000,8403,9924"; a="176322476" X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="176322476" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2021 20:13:08 -0700 IronPort-SDR: 4STfz3LBXwDNim56WUYSBVtRKmcn7YvT5xUJFpFiaO03qbgRygtQiaMqGeID6+tyN4QVTw4NWU hDZZgPDhjGNQ== X-IronPort-AV: E=Sophos;i="5.81,251,1610438400"; d="scan'208";a="449577108" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.238.4.6]) ([10.238.4.6]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2021 20:13:05 -0700 Subject: Re: [PATCH v2 09/27] perf parse-events: Create two hybrid hardware events To: Jiri Olsa Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com References: <20210311070742.9318-1-yao.jin@linux.intel.com> <20210311070742.9318-10-yao.jin@linux.intel.com> From: "Jin, Yao" Message-ID: <98f05e25-51f6-a16b-9bff-c8809c5d549e@linux.intel.com> Date: Tue, 16 Mar 2021 11:13:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiri, On 3/16/2021 7:05 AM, Jiri Olsa wrote: > On Thu, Mar 11, 2021 at 03:07:24PM +0800, Jin Yao wrote: >> For hardware events, they have pre-defined configs. The kernel >> needs to know where the event comes from (e.g. from cpu_core pmu >> or from cpu_atom pmu). But the perf type 'PERF_TYPE_HARDWARE' >> can't carry pmu information. >> >> So the kernel introduces a new type 'PERF_TYPE_HARDWARE_PMU'. >> The new attr.config layout for PERF_TYPE_HARDWARE_PMU is: >> >> 0xDD000000AA >> AA: original hardware event ID >> DD: PMU type ID >> >> PMU type ID is retrieved from sysfs. For example, >> >> cat /sys/devices/cpu_atom/type >> 10 >> >> cat /sys/devices/cpu_core/type >> 4 >> >> When enabling a hybrid hardware event without specified pmu, such as, >> 'perf stat -e cycles -a', two events are created automatically. One >> is for atom, the other is for core. > > ok I think I understand the need for this (and the following) patch > the perf_hw_id counters could be global, so when you specify only > event like: > > -e cycles > > you want all the cycles, which on hybrid system means cycles from > more than one pmus > Yes, on hybrid system it means the cycles from two pmus. One cycle is from cpu_core pmu, another cycles is from cpu_atom pmu. > SNIP > >> @@ -1416,6 +1475,8 @@ int parse_events_add_numeric(struct parse_events_state *parse_state, >> { >> struct perf_event_attr attr; >> LIST_HEAD(config_terms); >> + bool hybrid; >> + int ret; >> >> memset(&attr, 0, sizeof(attr)); >> attr.type = type; >> @@ -1430,6 +1491,18 @@ int parse_events_add_numeric(struct parse_events_state *parse_state, >> return -ENOMEM; >> } >> >> + /* >> + * Skip the software dummy event. >> + */ >> + if (type != PERF_TYPE_SOFTWARE) { >> + if (!perf_pmu__hybrid_exist()) >> + perf_pmu__scan(NULL); > > this could be checked in the following add_hybrid_numeric call > Yes, that should be OK. I will move the check in the next version. >> + >> + ret = add_hybrid_numeric(parse_state, list, &attr, &hybrid); >> + if (hybrid) >> + return ret; >> + } > > could we add this to separate object.. hybrid.c or maybe parse-events-hybrid.c, > > there's already global __add_event wrapper - parse_events__add_event > > > jirka > Use a new parse-events-hybrid.c, hmm, well that's OK. Thanks Jin Yao >> + >> return add_event(list, &parse_state->idx, &attr, >> get_config_name(head_config), &config_terms); >> } >> -- >> 2.17.1 >> >