Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp893926pxb; Wed, 29 Sep 2021 11:55:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW2VFQJCvoc1ebpnHcMR77fK4jNBJbInJgALfL8pDcmM4Guh1hPyyLIF6sme6QCN6dG4yU X-Received: by 2002:a17:90b:1c8e:: with SMTP id oo14mr8209499pjb.224.1632941741161; Wed, 29 Sep 2021 11:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632941741; cv=none; d=google.com; s=arc-20160816; b=D4KCYBi7DNYJHsPWJQlAmEb6oGRdFXzevazWmTo8f0hxvhKG5ZRcn4QhfpacFHPMai KYA1Xxyu8OK2yj9UpgSqpALOCLN6vEIEqc4UYUqONlN6UWq/dfZkyc3CL5gs9/1SXU/8 VnTCNAUTjo9XA2rccwoRLzWC2YNeYFC9Y0CqX/6V/vhvAvNXMsFZk6T5yp9zPH958i3K lzN74whmsL3pPkq8IXjIkcZfqTt9RzehNo18wRm7CHxOUod9iGycpYAv0OIBMpAkBvAW Ol0Q0PJ91Vf3sNsyAPgLhFN92rYx9mcawQTgNSWyTeZvi9VRgDN5J/IPEoWXfT98oVDE meWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=2omweD4tcsbbyuwPta+qQsignLZA5Lu/JIEhfVLKl4Q=; b=vnLE3IyywWyCVglU5rJ2Ft235tsEbWaPPASrgJXiyomMycXTLdnSlr9t0mRT0Eh9Gp zW8EOQwVg0n8xuwF99/fgC+2F0lOiLOYgbLuhVsHr8ag3frYDfxGssOPsasLG5klUYQ2 TCmXefxjOvPCQxmCZZiRVAYRWvLDOYdPUAqu8pwFTsPn/ALD9YWUMljTFD6LKRO6nDnW fEyghUiXf6LyTIncl4X8Da1jm9cvyoLFYm/ZZkLIK9yRw99X4HxsRHbSze/TTyw24WC+ SwJBPu6tq0Nd5ArxAvQ/V7nXQMwuvBHQkaojhGT++qcv05b5HY1IubY/HO03ZvAFeDkd yvJw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p5si812493plo.204.2021.09.29.11.55.26; Wed, 29 Sep 2021 11:55:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345309AbhI2Poj (ORCPT + 99 others); Wed, 29 Sep 2021 11:44:39 -0400 Received: from mga17.intel.com ([192.55.52.151]:27517 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345157AbhI2Poi (ORCPT ); Wed, 29 Sep 2021 11:44:38 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="205117292" X-IronPort-AV: E=Sophos;i="5.85,332,1624345200"; d="scan'208";a="205117292" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2021 08:42:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,332,1624345200"; d="scan'208";a="617567209" Received: from otc-lr-04.jf.intel.com ([10.54.39.41]) by fmsmga001.fm.intel.com with ESMTP; 29 Sep 2021 08:42:57 -0700 From: kan.liang@linux.intel.com To: acme@kernel.org, jolsa@redhat.com, jmario@redhat.com, linux-kernel@vger.kernel.org Cc: ak@linux.intel.com, Kan Liang Subject: [PATCH 1/2] perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support Date: Wed, 29 Sep 2021 08:38:13 -0700 Message-Id: <1632929894-102778-1-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang -F weight in perf script is broken. # ./perf mem record # ./perf script -F weight Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot print 'weight' field. The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The lower 32 bits are exactly the same for both sample type. The higher 32 bits may be different for different architecture. For a new kernel on x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other ARCHs, the PERF_SAMPLE_WEIGHT is used. With -F weight, current perf script will only check the input string "weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a new kernel on x86, the check fails. Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to replace PERF_SAMPLE_WEIGHT. Reported-by: Joe Mario Fixes: ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") Signed-off-by: Kan Liang --- tools/perf/builtin-script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 6211d0b..9f62ac6 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -459,7 +459,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session) return -EINVAL; if (PRINT_FIELD(WEIGHT) && - evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT)) + evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT)) return -EINVAL; if (PRINT_FIELD(SYM) && -- 2.7.4