Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5651333img; Wed, 27 Mar 2019 12:28:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxEIkK4UN9WC9xf/pEbJ85js9NVumiVBQk7vZizd7R+g09qxQlRSkVP+bBGWVl6TVmjEjW X-Received: by 2002:a17:902:2e83:: with SMTP id r3mr21215752plb.153.1553714891392; Wed, 27 Mar 2019 12:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714891; cv=none; d=google.com; s=arc-20160816; b=jv+fN9zZfHUta3ZxzKQStt/2wKeFUnL8sQzZ6+sPHgqE571X4yJ5toQuQREPlQ8e82 WyUobeMWwMwutzmAPPR98ESKWuPFz9RkJIWampyvo0thAyNeWtxnQvd+qQLrUFzH2fA/ GPaM2Cseja/TL9vnsEqLjUIMBkRziKiM5RG+ELxWSjosepn4/N0bI2cLk1NovCsx6Oej 3gv40PxLAn7yjwCD/QJSBqqyqtmj1b4yEp3mhGtrBPq17ZO2IaksSZV8o3OAZJeN1BU7 /JLmPeke8R41kP6+sa9UVi2MORUkn934Pu4xHsPe1EIEDMyHWeHQKOZv9AytyZLaN5fm 6Euw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+7IgRADzmLkxKM3kTXi9nePQFyYf4oUCTVM2W9EkfJ0=; b=ysizcoxgkh9Znk2NA+wjoNqRSBCIvA1dZHQdwtvq7PkvsPeQYfqKwfNlwuJQRLEEaw qMZtM4RMHeFaQT1A1ok88GIJt0m8rflEEwfgCENwq//zAFSCrqb9xxSN7w4m2vqgFOt7 P6YOMrRMLmXLczIfzVyupgbkmZJxrsYQvEBz+CTa4lkzndsL+l5tEQX8oLqdfx1dxrbi 756qI96VHV7pL4E7bp77E1oNmIealbW+mvi84tzXCxcfrQ5rP5GTN63fACHd7Qkz9CMt y9hgF+ZEYrV4r64ZjgThQII6dipHXUQhURynScVijFjH2fL5NOeByoMoI6X7ays9zVPv Qjpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="xjd/wZGj"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u37si778591pga.301.2019.03.27.12.27.56; Wed, 27 Mar 2019 12:28:11 -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; dkim=pass header.i=@kernel.org header.s=default header.b="xjd/wZGj"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387720AbfC0T1W (ORCPT + 99 others); Wed, 27 Mar 2019 15:27:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:45570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731614AbfC0SEq (ORCPT ); Wed, 27 Mar 2019 14:04:46 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 47222217F5; Wed, 27 Mar 2019 18:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709885; bh=a/R98ag9Z/zJEGQ59q3ginxprmNPH1EFgKSJeldXw/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xjd/wZGjiiGGS3/9Q4ysfdhQ+RdaPOvWp6xbYaoJ15A+ShkCbDM2zM3FVaBcjG/e7 PC2bEai0Ahw0xQeW3YELErRBKnjhJVsor9BCYMfDW+nTP4rGMLLxpxilGFLQP7pJL5 fJGwqeX6m3gu7fGluHa2yV2MwTe6EqBnUaeLd0Xk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andi Kleen , Jiri Olsa , Namhyung Kim , Stephane Eranian , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 5.0 089/262] perf script: Handle missing fields with -F +.. Date: Wed, 27 Mar 2019 13:59:04 -0400 Message-Id: <20190327180158.10245-89-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen [ Upstream commit 4b6ac811bce46c83811b83cdf87b41251596b9fc ] 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 Tested-by: Arnaldo Carvalho de Melo Acked-by: Jiri Olsa Cc: Jiri Olsa Cc: Namhyung Kim Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20190224153722.27020-2-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- 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 ac221f137ed2..cff4d10daf49 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -148,6 +148,7 @@ static struct { unsigned int print_ip_opts; u64 fields; u64 invalid_fields; + u64 user_set_fields; } output[OUTPUT_TYPE_MAX] = { [PERF_TYPE_HARDWARE] = { @@ -344,7 +345,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); @@ -2627,10 +2628,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.19.1