Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp3560198imc; Sun, 24 Feb 2019 07:39:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IYfF7FWjEsBV88LnxEIp6zetMiTzD2yQHILvn8YHrwZ/gLv1DRlMe/UeNlpToAU9kUxa9u+ X-Received: by 2002:a62:864c:: with SMTP id x73mr14915592pfd.49.1551022796431; Sun, 24 Feb 2019 07:39:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551022796; cv=none; d=google.com; s=arc-20160816; b=RgdJ27SGztLZBwbHHBI2wlDSY5nG1pzFeMqqXesmu1nFQUg9V8oOXJVKFmqftFZ6tC iT9HJ6t3V0ebLoRMA59PCRdSdco+Rah+O71hWjkEo1RRjcntCm4zb90oOHvinvIHPeNx QZE0XN9fb3VrXxBLYPOP9sEiC2MBPUJTwyYlSQcy2Cl87KHJe17GmHcu6B3Qt2ybrAvd 9fbUR0j8Nq9z6dp3Sxs0m6P+Sco73gK11T7GMQ5anbnZPsSGxpKppUs3MNiFUx9+QKvL Q4jcUUbdhkJ9c99Gua9zOlXZB0r9k1OnZlQcHRZiTbY77k4fr/oiJ6FcoVkH3wVmUW2W 5tvQ== 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; bh=Hb8wVP4IZTjI1bgnl4kqY4tDp8XlIjjBG3x4nfBEQjg=; b=iOmgaOyU1h6HQIIF9WAIqpMIOOfyDeuML51Xlgo3h2Y7WCW2BjAG4CbsG6yBMnG7i7 fUDvqwMXw3vrxYMG2sxFHoIJ8CjPtA5gvQAJ1n9DfSJGUNQMqzOG4I9EM0x+OvYZX3lp ZKFNHPZ24DYESLd3XX03V90ph0e4eGKwAG2fssGoMQDO23tgcTeUFMaKMrxFHDC84xS/ 2QYfU4jwdQghc3lIMP1zd70sNXh3DBMmi99egikdBZhNpaaluHi1HUzO5EmRf4xYC2ce YCfqsGDUxEwaHNZ2zxtk1LoIikOk49q+9YZiqRQ37t5NIg0D8H3pUdaLZkOTIGiuI3Mk hsmA== 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 h94si7145335plb.51.2019.02.24.07.39.41; Sun, 24 Feb 2019 07:39:56 -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 S1728434AbfBXPir (ORCPT + 99 others); Sun, 24 Feb 2019 10:38:47 -0500 Received: from mga03.intel.com ([134.134.136.65]:30217 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728285AbfBXPhb (ORCPT ); Sun, 24 Feb 2019 10:37:31 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP; 24 Feb 2019 07:37:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,407,1544515200"; d="scan'208";a="124836115" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.137]) by fmsmga007.fm.intel.com with ESMTP; 24 Feb 2019 07:37:30 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id 85100300208; Sun, 24 Feb 2019 07:37:30 -0800 (PST) From: Andi Kleen To: acme@kernel.org, linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jolsa@kernel.org, namhyung@kernel.org, eranian@google.com, Andi Kleen Subject: [PATCH 01/11] perf tools script: Handle missing fields with -F +.. Date: Sun, 24 Feb 2019 07:37:12 -0800 Message-Id: <20190224153722.27020-2-andi@firstfloor.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190224153722.27020-1-andi@firstfloor.org> References: <20190224153722.27020-1-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen When using -F + syntax to add a field the existing defaults are currently all marked user_set. This can cause errors when some field is missing in the perf.data This patch tracks the actually user set fields separately, so that we don't error out in this case. Before: % perf record true % perf script -F +metric Samples for 'cycles:ppp' event do not have CPU attribute set. Cannot print 'cpu' field. % After 5 perf record true % perf script -F +metric perf 28936 278636.237688: 1 cycles:ppp: ffffffff8117da99 perf_event_exec+0x59 (/lib/modules/4.20.0-odilo/build/vmlinux) ... % Signed-off-by: Andi Kleen --- tools/perf/builtin-script.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 8d5fe092525c..29e95a25c6e6 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -149,6 +149,7 @@ static struct { unsigned int print_ip_opts; u64 fields; u64 invalid_fields; + u64 user_set_fields; } output[OUTPUT_TYPE_MAX] = { [PERF_TYPE_HARDWARE] = { @@ -345,7 +346,7 @@ static int perf_evsel__do_check_stype(struct perf_evsel *evsel, if (attr->sample_type & sample_type) return 0; - if (output[type].user_set) { + if (output[type].user_set_fields & field) { if (allow_user_set) return 0; evname = perf_evsel__name(evsel); @@ -2628,10 +2629,13 @@ static int parse_output_fields(const struct option *opt __maybe_unused, pr_warning("\'%s\' not valid for %s events. Ignoring.\n", all_output_options[i].str, event_type(j)); } else { - if (change == REMOVE) + if (change == REMOVE) { output[j].fields &= ~all_output_options[i].field; - else + output[j].user_set_fields &= ~all_output_options[i].field; + } else { output[j].fields |= all_output_options[i].field; + output[j].user_set_fields |= all_output_options[i].field; + } output[j].user_set = true; output[j].wildcard_set = true; } -- 2.17.2