Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2038850rdf; Mon, 6 Nov 2023 03:01:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbtxOyhr6a0foz7YSIvLAueJkGX6dvkGTV4gYaSJrSNFaxHtvYM06k/E76viaw+kc/Aa+a X-Received: by 2002:a05:6a20:958b:b0:160:97a3:cae9 with SMTP id iu11-20020a056a20958b00b0016097a3cae9mr38961763pzb.54.1699268479707; Mon, 06 Nov 2023 03:01:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699268479; cv=none; d=google.com; s=arc-20160816; b=luzpEv9O5tvj29nEA8sCGCG+fK8cXwUZFBKtgsY7SET4iqIh9QDZndGZAJMio/KsxF WTxbVISa7qdvOeehu1Z9eBso62i3EirrCua9LfOwbMEzzNPGlWZl6u8sMRo+ZUUBdtJh OJDwzUBcNitSHYORZZ+uaDvGG/xPMNIOdYKjKfV28dO/Z3Stjkk25/hShPcuLSmHNGPZ SGLbv7SnsNEqzdmSoJGH1Mv3499cWSp0QcLiq4tHGCPsGIgSSeKIxQtmJsce/VnF21dR SD03R8wvi0d+UfrNXmaSaKR4Iz9rMonAwjkEWNIGqCyRjY7/V68SkP+UD1amoS/YM9iF KZaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=B4jNdFvhfOx19NeKrAcxZskr34X/IhzObwoOPUOU250=; fh=a+SQ3Z81YUvRjFrlJCZVKHhor0WA5Fj/2C9qUfz349g=; b=EWT+J6GNnSslZQ0kwDjcQVrET1XJDzbfyDRWgWEhonimBEFywLkaULXjQGrNnu0qck eIMIxVZnC5M0KR2oxIxBlrngSE2fowkcrZ2ig/L8+HI4KAF61boCf2/fbHrYqvLom4tA eIvBjsibwCt131l3ntprOAWnmmRSi4sTPV6r9QVLd+hHkPRM3870ZTaqS3xhyKR2wBeE rqOZpysnb6BeqYR+VrbbBo69BBBfvAwRIKxeXiE1P22/Y6W86781haJTCsHvlyqV3Js/ 82moSkPaQzNGcp5+fPmnF5kzWybaq3nM/p4bdfFv32/NEuIXoo7ouv+AmCJW2Yc+VMWw /21w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RPFEJhXB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id x2-20020a170902e04200b001c724f997ffsi7404019plx.131.2023.11.06.03.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 03:01:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RPFEJhXB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4BB0F8087DC5; Mon, 6 Nov 2023 03:00:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231243AbjKFLAd (ORCPT + 99 others); Mon, 6 Nov 2023 06:00:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbjKFLAb (ORCPT ); Mon, 6 Nov 2023 06:00:31 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6FCB0; Mon, 6 Nov 2023 03:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699268429; x=1730804429; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=vYGTfzfjTaRu1W/Dx7rwKe4uRJQWKt3qrA6K0mo7Kn0=; b=RPFEJhXBiOzclvz0H92IvltjZk59ygjNJoyB402lo4v17p4/oxGd2LX7 F4ZrLpoqJTypNT64bbBvlF5BZxPz41xCFiXUwyMdhOBG9A+bnkIdZw8I/ zjy5KNqT4KtCPaYAOzk+DEQP3WK99oGMznYqTq8HFlUCejkdNRVVAaA2/ frUKpN2jqjvTfJL9SUpENWYD52b0da87o3xm0XvmDnNGvaEKucI6QkAn9 q1/F9/UIgwQgR3G50hNMz1uU7fXxgX6koPZg3RlRXkBmWIffRM4a3Wsg8 H4nO3mv12cKnBMCJgA50uvwbdyvaUsgwHc9eqtiYsiyaOVaHsqvUKUmZg g==; X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="10788723" X-IronPort-AV: E=Sophos;i="6.03,281,1694761200"; d="scan'208";a="10788723" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 03:00:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="828176819" X-IronPort-AV: E=Sophos;i="6.03,281,1694761200"; d="scan'208";a="828176819" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.251.215.231]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 03:00:17 -0800 Message-ID: <0d232518-4bac-46cc-8635-d834fa232f85@intel.com> Date: Mon, 6 Nov 2023 13:00:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 02/53] perf record: Lazy load kernel symbols Content-Language: en-US To: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Nick Terrell , Kan Liang , Andi Kleen , Kajol Jain , Athira Rajeev , Huacai Chen , Masami Hiramatsu , Vincent Whitchurch , "Steinar H. Gunderson" , Liam Howlett , Miguel Ojeda , Colin Ian King , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , Ming Wang , James Clark , K Prateek Nayak , Sean Christopherson , Leo Yan , Ravi Bangoria , German Gomez , Changbin Du , Paolo Bonzini , Li Dong , Sandipan Das , liuwenyu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20231102175735.2272696-1-irogers@google.com> <20231102175735.2272696-3-irogers@google.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <20231102175735.2272696-3-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 03:00:51 -0800 (PST) On 2/11/23 19:56, Ian Rogers wrote: > Commit 5b7ba82a7591 ("perf symbols: Load kernel maps before using") > changed it so that loading a kernel dso would cause the symbols for > the dso to be eagerly loaded. For perf record this is overhead as the > symbols won't be used. Add a symbol_conf to control the behavior and > disable it for perf record and perf inject. > > Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter > --- > tools/perf/builtin-inject.c | 6 ++++++ > tools/perf/builtin-record.c | 2 ++ > tools/perf/util/event.c | 4 ++-- > tools/perf/util/symbol_conf.h | 3 ++- > 4 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c > index c8cf2fdd9cff..eb3ef5c24b66 100644 > --- a/tools/perf/builtin-inject.c > +++ b/tools/perf/builtin-inject.c > @@ -2265,6 +2265,12 @@ int cmd_inject(int argc, const char **argv) > "perf inject []", > NULL > }; > + > + if (!inject.itrace_synth_opts.set) { > + /* Disable eager loading of kernel symbols that adds overhead to perf inject. */ > + symbol_conf.lazy_load_kernel_maps = true; > + } > + > #ifndef HAVE_JITDUMP > set_option_nobuild(options, 'j', "jit", "NO_LIBELF=1", true); > #endif > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index dcf288a4fb9a..8ec818568662 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -3989,6 +3989,8 @@ int cmd_record(int argc, const char **argv) > # undef set_nobuild > #endif > > + /* Disable eager loading of kernel symbols that adds overhead to perf record. */ > + symbol_conf.lazy_load_kernel_maps = true; > rec->opts.affinity = PERF_AFFINITY_SYS; > > rec->evlist = evlist__new(); > diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c > index 923c0fb15122..68f45e9e63b6 100644 > --- a/tools/perf/util/event.c > +++ b/tools/perf/util/event.c > @@ -617,13 +617,13 @@ struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr, > if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) { > al->level = 'k'; > maps = machine__kernel_maps(machine); > - load_map = true; > + load_map = !symbol_conf.lazy_load_kernel_maps; > } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) { > al->level = '.'; > } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) { > al->level = 'g'; > maps = machine__kernel_maps(machine); > - load_map = true; > + load_map = !symbol_conf.lazy_load_kernel_maps; > } else if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest) { > al->level = 'u'; > } else { > diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h > index 0b589570d1d0..2b2fb9e224b0 100644 > --- a/tools/perf/util/symbol_conf.h > +++ b/tools/perf/util/symbol_conf.h > @@ -42,7 +42,8 @@ struct symbol_conf { > inline_name, > disable_add2line_warn, > buildid_mmap2, > - guest_code; > + guest_code, > + lazy_load_kernel_maps; > const char *vmlinux_name, > *kallsyms_name, > *source_prefix,