Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp53951pxy; Wed, 21 Apr 2021 18:17:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEdVCnHjzPBgGHM4+vuc1AMl4bKKtbvJIOVjrvQVpzyaKKPw8TX3r/FF9m5LANmBY8rRQl X-Received: by 2002:a17:902:b188:b029:e8:bd90:3f99 with SMTP id s8-20020a170902b188b02900e8bd903f99mr774216plr.6.1619054251972; Wed, 21 Apr 2021 18:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619054251; cv=none; d=google.com; s=arc-20160816; b=bPAy2unG1BNpeRbWbNyL2dvC0wVoD12asq5wy1Fx+BV0A50a+s7fyZrSeNZpBfzyza mccJjshA+qCQF8mit6eQu5wbmW9hqtEODhXCzPm+iYNuNQVFEiFhMrYDEpvH5HqHbz2x G1ne477YyLlpJ0pKQUomH1rDHp/SPPZ8UEANu/o8dYgxpIxLoVia9/agghwzw2iDkWN3 i2ES0W3TsiwVAYTNTzxCv1h0R3WCN5BRFVvh+p8O/kLKyfWmTIqUr+7AUM/psjifVKkd BtbJWw4nCcU0cKW/UfoSHPvkBOqQS1aW9FHOsJDeUZwTv0rDIMHGsWmWpJYnOH8/BhjV KpyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LqC2hnmoLe+Mp9Sx+iSdQH6JZyZQEOdUHxY2pQhJxeA=; b=Z674tjBoUCjyHWc0d/EPvKr9OaSck3Gj4viGbKLcnrAmvhsPE9gsniz655Fqk5JMKk S7CGkCSh4hM5xkj1hLywmJL5IKoQRp9EGeeBfJcVPRJh4bPE0Ew7XNBe9UEs7FvxPswI XMYtUN0PAyBMqOsJBMn2iNUHzKEiyy0XdreNJyMxWulGhe7J7z+TJr4tiOG+cuD9ZLYr SIDFxTsLhtppCSt8sQo/04+TjtejGoav5X8C6aKephQKYN8LZ90YUh701YrRkjIJbNfp 8mMk5F2C8Po1+DZsBnCSJB1Mqp5w4IqNuSDkyJqQYa3kSL06HsgyjopDwSh41/pIV3nz XrbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=esWQfCqf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si1259032pfn.246.2021.04.21.18.17.20; Wed, 21 Apr 2021 18:17:31 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=esWQfCqf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245229AbhDUSab (ORCPT + 99 others); Wed, 21 Apr 2021 14:30:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49209 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241918AbhDUSa0 (ORCPT ); Wed, 21 Apr 2021 14:30:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619029793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LqC2hnmoLe+Mp9Sx+iSdQH6JZyZQEOdUHxY2pQhJxeA=; b=esWQfCqfExJccI9OkrUIOzKACvy6bIg2sbaIbjKYY/T1W4DlURakflME/R/nPE4uwnLlbW hlt1VJ8n271PlhnKLqEfVmNzOXodZl1kOxA92T9Fu5OKqfkgZsCegkV+YUvGnZoKaVSuhU A7cOyYHs1GjgtDZj9pgzAJRfPGEv2gY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-QAnSztZWPGyPXwi0fWQV5g-1; Wed, 21 Apr 2021 14:29:51 -0400 X-MC-Unique: QAnSztZWPGyPXwi0fWQV5g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 487876D241; Wed, 21 Apr 2021 18:29:49 +0000 (UTC) Received: from krava (unknown [10.40.195.227]) by smtp.corp.redhat.com (Postfix) with SMTP id 41D595C1B4; Wed, 21 Apr 2021 18:29:47 +0000 (UTC) Date: Wed, 21 Apr 2021 20:29:46 +0200 From: Jiri Olsa To: Jin Yao 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 Subject: Re: [PATCH v4 14/25] perf stat: Add default hybrid events Message-ID: References: <20210416140517.18206-1-yao.jin@linux.intel.com> <20210416140517.18206-15-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210416140517.18206-15-yao.jin@linux.intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 16, 2021 at 10:05:06PM +0800, Jin Yao wrote: SNIP > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index 1255af4751c2..0351b99d17a7 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -1145,6 +1145,13 @@ static int parse_stat_cgroups(const struct option *opt, > return parse_cgroups(opt, str, unset); > } > > +static int add_default_hybrid_events(struct evlist *evlist) > +{ > + struct parse_events_error err; > + > + return parse_events(evlist, "cycles,instructions,branches,branch-misses", &err); > +} > + > static struct option stat_options[] = { > OPT_BOOLEAN('T', "transaction", &transaction_run, > "hardware transaction statistics"), > @@ -1626,6 +1633,12 @@ static int add_default_attributes(void) > { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS }, > { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES }, > > +}; > + struct perf_event_attr default_sw_attrs[] = { > + { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK }, > + { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES }, > + { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CPU_MIGRATIONS }, > + { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS }, hum, why not use default_attrs0, it's the same, no? > }; > > /* > @@ -1863,6 +1876,14 @@ static int add_default_attributes(void) > } > > if (!evsel_list->core.nr_entries) { > + if (perf_pmu__has_hybrid()) { > + if (evlist__add_default_attrs(evsel_list, > + default_sw_attrs) < 0) { > + return -1; > + } > + return add_default_hybrid_events(evsel_list); please do it the same way like when topdown calls parse events, we don't need to check for cycles, but please check result and display the error > + } > + > if (target__has_cpu(&target)) > default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK; also you still want this change for hybrid pmus as well thanks, jirka > > -- > 2.17.1 >