From patchwork Thu Dec 1 19:57:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 28543 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp460102wrr; Thu, 1 Dec 2022 12:04:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf755HWWdTxxQRi9oVUkrdh6/ODWyW6/j7wQe2HCz8Oq/wtPJiI5EI8Cuq8ywm+9oIU0kv0H X-Received: by 2002:a17:906:3510:b0:781:b7f2:bce9 with SMTP id r16-20020a170906351000b00781b7f2bce9mr58609837eja.269.1669925068985; Thu, 01 Dec 2022 12:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669925068; cv=none; d=google.com; s=arc-20160816; b=ebdwqPx27ZioCCEVGrBrTuCSvnSA4v5ijjJfftSzK+xUMZGnJs+CeHWL8I8Pb7qqB3 w2QdNew7cvc25fo55jPBN4WL0SMi1Zh2ZdT/xobO/CnLKSLbbf71fEWowsjeYhjuKjbA eDWL75YKTLFNBZ5WrZXyw3G4xPmenFWCVbAa65Kbgd0xM1IGRkt4WrGkBff5Xqf+LVKB /Xq16gcEiqruncNL3yeyUrdIMSbR5OuQlHG+njHjpY7dpt2418WIYkuJDHR7ayP/xVP9 V30TyVkPa4kC4ydEF0vBUQMQa5cXJp5T+OKaBJk+mr8+FeRwgYVBSUviCNiyqaWCkQ4v Xsjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CInjWc4Zn/qn1zjefO/qMfJPNe8mAjld2NvB1vVSXdE=; b=CMU7O1CveIKIcQjHohfqmM0/Qxg92PGfwDDIDQp9w6h8rh2wHCBjZx2JBitKYgLACd BDo5e/wfEWfGdj/fopebGTrXQI/4uhGCI6A3+hZZiqZiYuEUPbOwkItjI+Bqa5fq8WcD jq2RTi49HqMyMPLrznSjOMtOCQ3HZNTfzucsmnI666BdZ8BYVeP1Z7Waan1b7a7Ya00f pvzUkwPgJoyVml4mpDtyE/JelA9LOdU4xRm2gjG6rwiPKSlMe5pMU3RISPf7DIcmTcPf CvLYByKmzOXK1ne4KXRKagE9He2pGg/cvTNy4qRG2h6wKRaPogRzw6PfYNSDaoqhhIrC /Atw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BGYQ8AXS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc41-20020a1709071c2900b0073d9c412570si4545308ejc.785.2022.12.01.12.04.02; Thu, 01 Dec 2022 12:04:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BGYQ8AXS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231319AbiLAT5w (ORCPT + 99 others); Thu, 1 Dec 2022 14:57:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbiLAT5U (ORCPT ); Thu, 1 Dec 2022 14:57:20 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3B56BA602 for ; Thu, 1 Dec 2022 11:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669924640; x=1701460640; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=psXZMKbJQ3yGAryg57Kdkp4DtQsybo7dhx1r47nzioo=; b=BGYQ8AXSleZJ/QFFUN2Bu5ZbDXrHd9U6Znf4aPnoHJFp9H2AshJ/j5+G dbUiEkOflH1H32DZne69qM0ZNIQobgnf/AiyQOjo0AsZ2b8qebDKCoQzn swVQwvkYENr0DyxWlqsmq09HZOSIAYnXFKLs4WUeqCM0cL8aHHIOwuXu7 f6o51/wkg5p3tfy15fqTysC6S7HyMSTc5fb7MQy+IOWsd/I5lATrykiwT 6EliA7w/+yfHQ/w1D9Xv96sfoOiydObA7TPP9NrNlr0mqIbUJVvpsMHHH Bv/pZWhinXCA0aKcrEJtR9bbeVG6IF1RnfrLaEnefv7eB5yolq+g4o1MF Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="303391902" X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="303391902" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2022 11:57:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="708205170" X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="708205170" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga008.fm.intel.com with ESMTP; 01 Dec 2022 11:57:19 -0800 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org Cc: ak@linux.intel.com, eranian@google.com, irogers@google.com, Kan Liang Subject: [PATCH 9/9] perf script: Support Retire Latency Date: Thu, 1 Dec 2022 11:57:04 -0800 Message-Id: <20221201195704.2330866-9-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221201195704.2330866-1-kan.liang@linux.intel.com> References: <20221201195704.2330866-1-kan.liang@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751043349030275232?= X-GMAIL-MSGID: =?utf-8?q?1751043349030275232?= From: Kan Liang The Retire Latency field is added in the var3_w of the PERF_SAMPLE_WEIGHT_STRUCT. The Retire Latency reports the number of elapsed core clocks between the retirement of the instruction indicated by the Instruction Pointer field of the PEBS record and the retirement of the prior instruction. That's quite useful to display the information with perf script. Add a new field retire_lat for the Retire Latency information. Reviewed-by: Andi Kleen Signed-off-by: Kan Liang --- tools/perf/builtin-script.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 7ca238277d83..071ffdff1980 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -127,6 +127,7 @@ enum perf_output_field { PERF_OUTPUT_BRSTACKINSNLEN = 1ULL << 36, PERF_OUTPUT_MACHINE_PID = 1ULL << 37, PERF_OUTPUT_VCPU = 1ULL << 38, + PERF_OUTPUT_RETIRE_LAT = 1ULL << 39, }; struct perf_script { @@ -197,6 +198,7 @@ struct output_option { {.str = "brstackinsnlen", .field = PERF_OUTPUT_BRSTACKINSNLEN}, {.str = "machine_pid", .field = PERF_OUTPUT_MACHINE_PID}, {.str = "vcpu", .field = PERF_OUTPUT_VCPU}, + {.str = "retire_lat", .field = PERF_OUTPUT_RETIRE_LAT}, }; enum { @@ -272,7 +274,7 @@ static struct { PERF_OUTPUT_ADDR | PERF_OUTPUT_DATA_SRC | PERF_OUTPUT_WEIGHT | PERF_OUTPUT_PHYS_ADDR | PERF_OUTPUT_DATA_PAGE_SIZE | PERF_OUTPUT_CODE_PAGE_SIZE | - PERF_OUTPUT_INS_LAT, + PERF_OUTPUT_INS_LAT | PERF_OUTPUT_RETIRE_LAT, .invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT, }, @@ -539,6 +541,10 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session) evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_STRUCT, "WEIGHT_STRUCT", PERF_OUTPUT_INS_LAT)) return -EINVAL; + if (PRINT_FIELD(RETIRE_LAT) && + evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_STRUCT, "WEIGHT_STRUCT", PERF_OUTPUT_RETIRE_LAT)) + return -EINVAL; + return 0; } @@ -2175,6 +2181,9 @@ static void process_event(struct perf_script *script, if (PRINT_FIELD(INS_LAT)) fprintf(fp, "%16" PRIu16, sample->ins_lat); + if (PRINT_FIELD(RETIRE_LAT)) + fprintf(fp, "%16" PRIu16, sample->retire_lat); + if (PRINT_FIELD(IP)) { struct callchain_cursor *cursor = NULL; @@ -3849,7 +3858,7 @@ int cmd_script(int argc, const char **argv) "brstacksym,flags,data_src,weight,bpf-output,brstackinsn," "brstackinsnlen,brstackoff,callindent,insn,insnlen,synth," "phys_addr,metric,misc,srccode,ipc,tod,data_page_size," - "code_page_size,ins_lat", + "code_page_size,ins_lat,retire_lat", parse_output_fields), OPT_BOOLEAN('a', "all-cpus", &system_wide, "system-wide collection from all CPUs"),