From patchwork Mon Apr 3 15:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 78601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2411458vqo; Mon, 3 Apr 2023 09:04:43 -0700 (PDT) X-Google-Smtp-Source: AKy350baGEFs7m1HzTj8Q86ZT8NOY4YysifUlroBmB81PSeGSo5/xmZn/Zt5FA7o99gxHmFw0l6V X-Received: by 2002:a05:6402:6c1:b0:4fb:4354:ab2e with SMTP id n1-20020a05640206c100b004fb4354ab2emr34259741edy.28.1680537883520; Mon, 03 Apr 2023 09:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680537883; cv=none; d=google.com; s=arc-20160816; b=Dz6LRRvf8BMb8ZzS70uyA/hOnqjTbXKw5Wqhpu0HaQmyNUTOsaCs33d4kKmHbOYf0n VWl4uqVq5Un8T8DggTP1dP7uWHxiq1WQL0FZ+a6JLacc74vefkx621r116px0XHCtdcD W4xu2IEfAS4IxmPbGST4ARhhbn6t4uq3AyTmeIMa9OZekjbd+VdDp7UDJKY/pCuqCXsN KWLFZozYnGWBWajdeW9Q85IfvBfh3ry0+OLWtUmkbB0iN1HbPJsd+B9aeUePLoqGX72m 4pligKpyBRQOjs1/WGnjC6XXONHzMpdL+SiOziqmYH+bIvFkjkwZK56VQ+nCckYGU+j9 UwIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jAGLThnIbYuu8rTTXaNg4QDdhbkeeP5jzt1Yzaac2RE=; b=QhjRkoBsEc7vLuq9REYoQ6zhQXw26JTto2eGOaBJaP3pJ2Yw7gmJe+V2XW+6bw7hV8 6FSxBrQNKG/Z0ynyQ/JdejrGWFmvCvRMqYsHJVk2JuhzD1R749L7xLKKUmSaef76GGr+ UrxEUWAVa5NfYn8/7h7dHToZigpzqPNro4x+TEbob7tOkaV3G/XQ+QliWLl69v2P54Em VJjD2lh2CSd0XOyBG3Q5LU5XHV3dJTjYI/F+5tTA97ZJxoj/WIJQD+hYBRhQjaX8V1pr JQQbyamAPIcVNNJJRWbhhuBXaeojd3lmtb/P6pqvnzNYl3NVTmz1pUV6kXYUW2VJ+h61 PPcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lGxHlYJz; 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 f17-20020a05640214d100b004fd2b59e8c2si3749632edx.549.2023.04.03.09.03.54; Mon, 03 Apr 2023 09:04:43 -0700 (PDT) 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=lGxHlYJz; 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 S232854AbjDCPuX (ORCPT + 99 others); Mon, 3 Apr 2023 11:50:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232500AbjDCPuK (ORCPT ); Mon, 3 Apr 2023 11:50:10 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EEE535B8; Mon, 3 Apr 2023 08:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680536991; x=1712072991; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o+pwottLJkhoBGrr5tQbs6DpDn3ZA4WcvxwmOO9XIis=; b=lGxHlYJzKwrSf6ZLiAkFPjIRCfklDSk37oyUVuNBlqOoOZmRL6uH0pua BOPbZBrhOlSsm1uS4RmFga17EvH4sfi8GV30FUi5eCfT0uPiacaUc4wZ6 YWRHODs2lFLYi3YiU8JUUWip6aVXzQqzk3c/PGu+UVUIHZxtM55aGwlgQ F2ghQlX3HIbC7PNH5mvYERvHN2I8xrBjMm28gX0JdqpLt0Tp6TRFH6V1p QHIhzy5rwnSYy2KM4L2Z8RHkzbMF2xZwcODiSTobNoUoZhXHJiHCeIFcZ +d6F3Upvpu0Dcq8LbC1WieEsEhMpa7iOgu0TnDq6YTZrNB6txuLPbyiCb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10669"; a="339430305" X-IronPort-AV: E=Sophos;i="5.98,315,1673942400"; d="scan'208";a="339430305" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2023 08:48:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10669"; a="663243329" X-IronPort-AV: E=Sophos;i="5.98,315,1673942400"; d="scan'208";a="663243329" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.40.243]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2023 08:48:45 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 1/2] perf auxtrace: Fix address filter entire kernel size Date: Mon, 3 Apr 2023 18:48:30 +0300 Message-Id: <20230403154831.8651-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403154831.8651-1-adrian.hunter@intel.com> References: <20230403154831.8651-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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?1762171691493568867?= X-GMAIL-MSGID: =?utf-8?q?1762171691493568867?= kallsyms is not completely in address order. In find_entire_kern_cb(), calculate the kernel end from the maximum address not the last symbol. Example: Before: $ sudo cat /proc/kallsyms | grep ' [twTw] ' | tail -1 ffffffffc00b8bd0 t bpf_prog_6deef7357e7b4530 [bpf] $ sudo cat /proc/kallsyms | grep ' [twTw] ' | sort | tail -1 ffffffffc15e0cc0 t iwl_mvm_exit [iwlmvm] $ perf.d093603a05aa record -v --kcore -e intel_pt// --filter 'filter *' -- uname |& grep filter Address filter: filter 0xffffffff93200000/0x2ceba000 After: $ perf.8fb0f7a01f8e record -v --kcore -e intel_pt// --filter 'filter *' -- uname |& grep filter Address filter: filter 0xffffffff93200000/0x2e3e2000 Fixes: 1b36c03e3569 ("perf record: Add support for using symbols in address filters") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter --- tools/perf/util/auxtrace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 498ff7f24463..b2a5e5397bad 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -2449,6 +2449,7 @@ static int find_entire_kern_cb(void *arg, const char *name __maybe_unused, char type, u64 start) { struct sym_args *args = arg; + u64 size; if (!kallsyms__is_function(type)) return 0; @@ -2458,7 +2459,9 @@ static int find_entire_kern_cb(void *arg, const char *name __maybe_unused, args->start = start; } /* Don't know exactly where the kernel ends, so we add a page */ - args->size = round_up(start, page_size) + page_size - args->start; + size = round_up(start, page_size) + page_size - args->start; + if (size > args->size) + args->size = size; return 0; } From patchwork Mon Apr 3 15:48:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 78610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2415719vqo; Mon, 3 Apr 2023 09:09:50 -0700 (PDT) X-Google-Smtp-Source: AKy350YIiAjU5Wv5eqLN4ZQWYiqTnk9+ZCo9uQCL1x0jKpNSg0FuARVaxrZRKcQ8hLn8EWOiupEV X-Received: by 2002:aa7:9423:0:b0:627:f0b9:d5c1 with SMTP id y3-20020aa79423000000b00627f0b9d5c1mr35024134pfo.17.1680538190130; Mon, 03 Apr 2023 09:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680538190; cv=none; d=google.com; s=arc-20160816; b=hHWNgTloHH/6NU3lhjpi0168mIRfaNMk8/alnwFwDiA3rGsv2MQZMyen3ZFzWcZwXZ Y6kvdGP/c0/H8Tmn9kfqduFw9asSr/JrPrNjQQjUD5qAIUgdnGjE8xf2FaH1Ngy463pd 8CUpXKPooUJh4rXXobAiPshIKExTixlwWJ9LoqPVOIVJfZ/ZsxZyPuGcyP7h9L6yOlSi DaR9A3fyNTasKrQZz9Ws1eVu1gubOQ2EN4eddY0G+2vokRhgEmmFoCuJZdoqDV2KQico DChqgbm4jQjP8gI1hO/qok3Y9jIgVYrDFahrIdCHOJTG0yUu9L2ZX3IN2afi5OvrO4Iv Jt1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BvAL3pNvfbDGjKpjCk0JEai2sTUiDrRpYr5hjxELeyU=; b=GD7oVgyXl/lIIY4d5HmRi5iYgZwj6DHof3/47YFLleSl2+sTE7HRd3gg8A4aRIEes/ rOTU69PQtBVjIvB3GCLL3DYOA2z2neIbA8hB95s2iWD/D+SJJDfKnw0XFPDYYmwrvQY8 z9ug9ZpD+KzaKmpcnW9Gu+fqdajoFymDNpIUWUYPfaA/p4aR9BGKqhGOG5rXjNlWNHAF Lrh76b+rHoEk22ALTEB+smSjTc/HApbIi5npYlvMYLIA0FWJz1lzIsjp6IAdphPlEawt oGn0BaZJQIQXd8jt8epzsI4ZqMdPM5oRMig63IW7lpHv+c9VIgWiyI5wKa8g/gimACKp mUvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Q8y6LB/B"; 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 a27-20020aa795bb000000b00627ed0fa77csi8323705pfk.188.2023.04.03.09.09.37; Mon, 03 Apr 2023 09:09:50 -0700 (PDT) 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="Q8y6LB/B"; 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 S232731AbjDCPua (ORCPT + 99 others); Mon, 3 Apr 2023 11:50:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232617AbjDCPuL (ORCPT ); Mon, 3 Apr 2023 11:50:11 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39C0030EB; Mon, 3 Apr 2023 08:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680536992; x=1712072992; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RVH6nOCjK5mMwmhujxNK93yJbU7YNiX2duZPr3uivlw=; b=Q8y6LB/BTitfG1C0Yjbv5LG7SL+RWxRj2lQWUwhdz1fJ3KcIt9Pl5Xb5 MD/FHRlGaU6KoVKmjFxXP8L9rHIOZA+JPqKgtWasLr1ZXtBgakVf3huJZ gsKmC2eeJVerMoLruUe9Zdi8ABhlHinyaozPfKHCvh/WAryD2a8Qq8CYi fnAhv751cX8ZGYyryGPXWs1AB2UFoFxMH54feJ+zbs5RUFHhcu0KtHi67 W7/X3wu3hJ+aPMv3/GKP1DELA1ECpvn+cNvQlq0lJLVH0a/Jy1uLenS8F 7dZr+igpOI7ULOylEUMxY4ISYD1Bav2K5dwWMQpAmbpkWO31jAguHYuJj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10669"; a="339430321" X-IronPort-AV: E=Sophos;i="5.98,315,1673942400"; d="scan'208";a="339430321" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2023 08:48:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10669"; a="663243337" X-IronPort-AV: E=Sophos;i="5.98,315,1673942400"; d="scan'208";a="663243337" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.40.243]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2023 08:48:47 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 2/2] perf intel-pt: Fix CYC timestamps after standalone CBR Date: Mon, 3 Apr 2023 18:48:31 +0300 Message-Id: <20230403154831.8651-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403154831.8651-1-adrian.hunter@intel.com> References: <20230403154831.8651-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable 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?1762172013115834118?= X-GMAIL-MSGID: =?utf-8?q?1762172013115834118?= After a standalone CBR (not associated with TSC), update the cycles reference timestamp and reset the cycle count, so that CYC timestamps are calculated relative to that point with the new frequency. Fixes: cc33618619ce ("perf tools: Add Intel PT support for decoding CYC packets") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter --- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c index 0ac860c8dd2b..7145c5890de0 100644 --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c @@ -1998,6 +1998,8 @@ static void intel_pt_calc_cbr(struct intel_pt_decoder *decoder) decoder->cbr = cbr; decoder->cbr_cyc_to_tsc = decoder->max_non_turbo_ratio_fp / cbr; + decoder->cyc_ref_timestamp = decoder->timestamp; + decoder->cycle_cnt = 0; intel_pt_mtc_cyc_cnt_cbr(decoder); }