Received: by 10.192.165.148 with SMTP id m20csp882312imm; Wed, 25 Apr 2018 09:04:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx486aSdNL1q9ywbxG4OpmhSjH7WJe8uSmTdwX8Bb+NIf0UWrqbtabSvR1SNI3op2muerVjXH X-Received: by 10.101.74.132 with SMTP id b4mr10573092pgu.36.1524672285326; Wed, 25 Apr 2018 09:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672285; cv=none; d=google.com; s=arc-20160816; b=f745eSS6NLN5vQNe44vd89VRwjfHpNIGOeGf3wThuvmtSvFagl4mMj1OXhYWwRwpAF e1VaFlmKtSa1e2+7IJLu4LqLr9jjhWqxzhu+MWPf8ABI1GIwA1wvs7EDFgVC8tpBAeqk FxxAn12Qtct01eINkCUkdSvEDANwAmBuk+p8DY8ILqqBAUJTC5hTcMwWcl5ZDhiZOffQ UdmorOW+icetk0MJOTu6v48boooW1jtpw+IgPUkhs0W6zYWb9eWAnIxGqvZlLh2boLnW J6AI1DpLl3dT2l0o5HefV1xgYEpyuxaswn7eHNqPLeo3gyAGJmvSfbKxkbq0fxJ/dER/ kyCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=5CP73S450+EYicUv6VfFPo26SXELNUad8GHZ8nmVKiI=; b=pW7DHodbh0pQ6Rs5HcTt879yE8+XvHLNAzl/yQ4lXGPOQRfvt4Kf81AedeDnYdR6N9 JhT0de+nIoRrlQ3ut8jyFur6dWMU1Tyv3JjMX7n0jRVU/2koxwGNEBHfWZC+Mhn6WSSg UKGZYfz1pgk0ndA15qZ1JjWWslGXAJv1DRoT7vzdlEhXqTlHKeJ8ItVeCLXEJdyNpOB0 xC9tMVmOR6YCQmKz8ZbzkWS5iM4BG4pfe+e0JWY5DjENgV2Ad67UY424C59RfxbdvBRE z1z9sNvuHsNb742T8na5GT7T93Ue6geofGPoPZy/4Xjm00JSS/WcLww+4VWz3bThM6KG vQxQ== 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 p27si10786162pfd.76.2018.04.25.09.04.27; Wed, 25 Apr 2018 09:04:45 -0700 (PDT) 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 S1755529AbeDYQDQ (ORCPT + 99 others); Wed, 25 Apr 2018 12:03:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:46936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755186AbeDYQAa (ORCPT ); Wed, 25 Apr 2018 12:00:30 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BAB0E217DF; Wed, 25 Apr 2018 16:00:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BAB0E217DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Jiri Olsa , Alexander Shishkin , David Ahern , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 04/12] perf stat: Keep the / modifier separator in fallback Date: Wed, 25 Apr 2018 13:00:00 -0300 Message-Id: <20180425160008.3407-5-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180425160008.3407-1-acme@kernel.org> References: <20180425160008.3407-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa The 'perf stat' fallback for EACCES error sets the exclude_kernel perf_event_attr and tries perf_event_open() again with it. In addition, it also changes the name of the event to reflect that change by adding the 'u' modifier. But it does not take into account the '/' separator, so the event name can end up mangled, like: (note the '/:' characters) $ perf stat -e cpu/cpu-cycles/ kill ... 386,832 cpu/cpu-cycles/:u Adding the code to check on the '/' separator and set the following correct event name: $ perf stat -e cpu/cpu-cycles/ kill ... 388,548 cpu/cpu-cycles/u Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20180423090823.32309-4-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3e87486c28fe..7eb1e9850abf 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2754,8 +2754,14 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err, (paranoid = perf_event_paranoid()) > 1) { const char *name = perf_evsel__name(evsel); char *new_name; + const char *sep = ":"; - if (asprintf(&new_name, "%s%su", name, strchr(name, ':') ? "" : ":") < 0) + /* Is there already the separator in the name. */ + if (strchr(name, '/') || + strchr(name, ':')) + sep = ""; + + if (asprintf(&new_name, "%s%su", name, sep) < 0) return false; if (evsel->name) -- 2.14.3