Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp262830rdb; Thu, 19 Oct 2023 04:02:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHPcz+UMvvLJzCW/L+mh3/wKiJHr20GBCDaTfSox6dR1NnXs7jReexZ5xmxPTGueqvag2T X-Received: by 2002:a05:6a00:22d3:b0:6bc:eb60:b26c with SMTP id f19-20020a056a0022d300b006bceb60b26cmr1636060pfj.25.1697713348583; Thu, 19 Oct 2023 04:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697713348; cv=none; d=google.com; s=arc-20160816; b=yx2tpnyiPK0H1TIPvsoG4b4JWpumewn14bVGLmMKFPSScGRVXj9KUElaKxEhtgcaKg DTkrhYkNfd+A8vTpnJtrqxt5iafDrnsPvvVqU95Ak12xdNWvoW4sqr5OUmbOL5sFUKoN wpsJX+WuyQUmXb3kNoV0LgKE+xH1RnXfNydWE2LsJyG9Sq8JLka8qbQ9TzLiIuallq3c SG4R0sEwnwsgwA1jionQZCgGzScrig0Igjv1EjzaTAi0BpDg6BqO+2PyCEYucmWaVQvX uR4Yq+Ckq7r4xHE+49z3C7tf180l+JOxrUwMA1Ax7teFq3bEieRD00flxZLHV4GXK18X bNYw== 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=WLmh8BkuTQUjdTx+weMsW8rtQBl3D1gi7DLP6PKZ3v8=; fh=zHyBSMprUdftUoJIoVV35htvJs6/zXGdCUtx9Woy/Z4=; b=A3cw0A/e668cez4pRF53xeY6APxs05hMyRlEgtq4ToisHp5gGxIuewzfqPPj6ClCVq nl+RRwH6oZTWQ/A2nQFUgrB5+y9CaObRAH9a22/NNtn3f7B6UdD6RQz5Hgk2MpQuIlvF POjMc/pad1PIXXxGsGJRJpPrGq2fYtO1IysWFIcOevMpIqYOaYBE+Wr/ldw58FAjVnI8 CbXBkgloIo/3j7AfqUJR+QDV5stRKlnTcTXqs6PQmeSlDsfB7tysQJztBmWjyOLxXFKQ DGhM0z3REZmtbHxSwLrf3Gk9O797nM+2ASZq3Ii8Hd6f5j41B6MjLJ7csLlVl5G0fTjl 4EiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=glxnQJzH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id g8-20020aa79f08000000b006bd360e70edsi5765561pfr.103.2023.10.19.04.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 04:02:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=glxnQJzH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id C2B3F8168225; Thu, 19 Oct 2023 04:02:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345224AbjJSLCS (ORCPT + 99 others); Thu, 19 Oct 2023 07:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233090AbjJSLCR (ORCPT ); Thu, 19 Oct 2023 07:02:17 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A586A112; Thu, 19 Oct 2023 04:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697713335; x=1729249335; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=dS7MBxgFMsSLS+p8OyIgAOLuaoqyA0fOLFfs16p9U9o=; b=glxnQJzHnwK2nGIZx0u9JSK8g1exn4Kp+xckDxFnk2uuCNqnyZu0r+XX Y8h2FWMs/hpZRD07WmNyzGoQYi4EJVmeKuuWzpj6XA+BNyxcgI9PlMJd4 hO8kG5OmW2uh3SBK+kWmC0OUMz/lrTMMilS9GGo2cROmT2UjeKlFp/SbQ 76qNU4EXMPfnrgVuz/MG9PIteX8KGRfz4u/JZ3+V4g4MzhV4KoR4zi6Rz MDqVxSnpBsG4TW9zQmsxK27jkQa0t3v8OpwcEubZKYZAg1SahrWyxUgju PCVElCGkuqQfuDa9fm6w4psd/5rfgHb53eCYfh/ZvLFYKgWeUxwNqaPOx w==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="366464129" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="366464129" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 04:02:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="760603065" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="760603065" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.249.39.14]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 04:02:09 -0700 Message-ID: Date: Thu, 19 Oct 2023 14:02:06 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 10/13] 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 , Song Liu , Sandipan Das , Anshuman Khandual , James Clark , Liam Howlett , Miguel Ojeda , Leo Yan , German Gomez , Ravi Bangoria , Artem Savkov , Athira Rajeev , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org References: <20231012062359.1616786-1-irogers@google.com> <20231012062359.1616786-11-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: <20231012062359.1616786-11-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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 04:02:25 -0700 (PDT) On 12/10/23 09:23, 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 > --- > tools/perf/builtin-inject.c | 4 ++++ > tools/perf/builtin-record.c | 2 ++ > tools/perf/util/event.c | 4 ++-- > tools/perf/util/symbol_conf.h | 3 ++- > 4 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c > index c8cf2fdd9cff..1539fb18c749 100644 > --- a/tools/perf/builtin-inject.c > +++ b/tools/perf/builtin-inject.c > @@ -2265,6 +2265,10 @@ int cmd_inject(int argc, const char **argv) > "perf inject []", > NULL > }; > + > + /* Disable eager loading of kernel symbols that adds overhead to perf inject. */ > + symbol_conf.lazy_load_kernel_maps = true; Possibly not for itrace kernel decoding, so: if (!inject->itrace_synth_opts.set) 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,