Received: by 10.223.185.116 with SMTP id b49csp1075195wrg; Fri, 23 Feb 2018 11:28:16 -0800 (PST) X-Google-Smtp-Source: AH8x2259257edv4b76l3eZgqgqKHla7E6kaQrwwihQzh+wypdnlvLPSZHbt0gbXbImdK4OpknmIw X-Received: by 2002:a17:902:61:: with SMTP id 88-v6mr2726826pla.428.1519414096793; Fri, 23 Feb 2018 11:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519414096; cv=none; d=google.com; s=arc-20160816; b=IrZrIV/ZDBSmzAQZWB+mCpEQY7ovqePN9ckOIVJb0UXyi0NXJECVy3IgiGEMQyDbRd d9KrbYuuVu6vE0+aPS7jApTOG+cuwFQqCyjKnlWUJzlMnOqF0p8WMdiw+XEhJwjG6btt 9M2WqoNte2a0YhUVbuhtiuOv3K+GiMfN47caMtRrZkt87Tqd2oNxIEUqjk3xjlhzVs9i rABrAhUEFgIwwAAy0ay6qsUEHwfc7hPBkVyNiLsJAX9K8Kdz0aJttQ2cRB8o4vgqoyIv PDcdDPgkfzn0cPxz9L/G1Ont85R+FMtXttMEqcKZ+FoiXEhwCFmdsGRApYcdOWm+v+Nm mc9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=FLxqOXJEKncgnzj21E0g8ABwQFCR66R9cbzNc07GFI8=; b=i3VKrziX7oIdVg50AA178OsTTQzHqLGR+5wROUqcwZUpiEjn9jHLuZK/xd7LRisYPQ 1o1W8c4uc6+GUa7GDc8PkJdAolcoie+gUu8VRHCMZY5HH99n6ayyg0EiAvIzs4aeRAvr OUOy55dAyypOwToTqdNgHRIgowgE5o2x+afR2t6xIPf3LDqh/wXdpVx9c4u7eW6VcCj3 WmwEit+4vktoCKCYyM5rMv5bxFSkHQSOp02P01L/cneGGuoctQtpDSY7kAstMKBvrOYi Oi4/j6b1tW42W8cYCNIHn788T9eVDV7dRovVwY8zsLTls0xAcchMdinXkOfVRynJ9/Ok a2ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3-v6si2165861plm.224.2018.02.23.11.28.02; Fri, 23 Feb 2018 11:28:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935128AbeBWSwZ (ORCPT + 99 others); Fri, 23 Feb 2018 13:52:25 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46876 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754173AbeBWSwV (ORCPT ); Fri, 23 Feb 2018 13:52:21 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 981DCF7D; Fri, 23 Feb 2018 18:52:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andi Kleen , Jiri Olsa , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.14 068/159] perf record: Fix -c/-F options for cpu event aliases Date: Fri, 23 Feb 2018 19:26:16 +0100 Message-Id: <20180223170751.864174674@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andi Kleen [ Upstream commit 59622fd496a3175c7bf549046e091d81c303ecff ] The Intel PMU event aliases have a implicit period= specifier to set the default period. Unfortunately this breaks overriding these periods with -c or -F, because the alias terms look like they are user specified to the internal parser, and user specified event qualifiers override the command line options. Track that they are coming from aliases by adding a "weak" state to the term. Any weak terms don't override command line options. I only did it for -c/-F for now, I think that's the only case that's broken currently. Before: $ perf record -c 1000 -vv -e uops_issued.any ... { sample_period, sample_freq } 2000003 After: $ perf record -c 1000 -vv -e uops_issued.any ... { sample_period, sample_freq } 1000 Signed-off-by: Andi Kleen Acked-by: Jiri Olsa Link: http://lkml.kernel.org/r/20171020202755.21410-2-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/evsel.c | 12 ++++++++---- tools/perf/util/evsel.h | 1 + tools/perf/util/parse-events.c | 2 ++ tools/perf/util/parse-events.h | 3 +++ tools/perf/util/pmu.c | 5 +++++ 5 files changed, 19 insertions(+), 4 deletions(-) --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -733,12 +733,16 @@ static void apply_config_terms(struct pe list_for_each_entry(term, config_terms, list) { switch (term->type) { case PERF_EVSEL__CONFIG_TERM_PERIOD: - attr->sample_period = term->val.period; - attr->freq = 0; + if (!(term->weak && opts->user_interval != ULLONG_MAX)) { + attr->sample_period = term->val.period; + attr->freq = 0; + } break; case PERF_EVSEL__CONFIG_TERM_FREQ: - attr->sample_freq = term->val.freq; - attr->freq = 1; + if (!(term->weak && opts->user_freq != UINT_MAX)) { + attr->sample_freq = term->val.freq; + attr->freq = 1; + } break; case PERF_EVSEL__CONFIG_TERM_TIME: if (term->val.time) --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -67,6 +67,7 @@ struct perf_evsel_config_term { bool overwrite; char *branch; } val; + bool weak; }; /** struct perf_evsel - event selector --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1115,6 +1115,7 @@ do { \ INIT_LIST_HEAD(&__t->list); \ __t->type = PERF_EVSEL__CONFIG_TERM_ ## __type; \ __t->val.__name = __val; \ + __t->weak = term->weak; \ list_add_tail(&__t->list, head_terms); \ } while (0) @@ -2395,6 +2396,7 @@ static int new_term(struct parse_events_ *term = *temp; INIT_LIST_HEAD(&term->list); + term->weak = false; switch (term->type_val) { case PARSE_EVENTS__TERM_TYPE_NUM: --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -101,6 +101,9 @@ struct parse_events_term { /* error string indexes for within parsed string */ int err_term; int err_val; + + /* Coming from implicit alias */ + bool weak; }; struct parse_events_error { --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -404,6 +404,11 @@ static int pmu_alias_terms(struct perf_p parse_events_terms__purge(&list); return ret; } + /* + * Weak terms don't override command line options, + * which we don't want for implicit terms in aliases. + */ + cloned->weak = true; list_add_tail(&cloned->list, &list); } list_splice(&list, terms);