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; }