Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp553304rdb; Thu, 2 Nov 2023 10:58:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0D6PsMga5AtpJt9w2TFQlv6QTqBl/pn25J40PQtD5CM0AuRRCru320lH0t9Ys68jVoCpV X-Received: by 2002:a17:902:db11:b0:1cc:5899:1133 with SMTP id m17-20020a170902db1100b001cc58991133mr12830674plx.53.1698947936404; Thu, 02 Nov 2023 10:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698947936; cv=none; d=google.com; s=arc-20160816; b=u7UMbWIhgwmbQ4QZtGuwa5yfwHIZcOUFzZ8jRlbwCyqM7/N0YBJ1kZ29xF/jo9vLgT DYGgFPfYpaZMRNn1MVKRL3fIm60lTcnwjSb4LtLuIKrRyp8z/Ucvy+Y6NJvjJ6E+iryx a6JITjZQxEbMavdgL2RYoKz5HvVwmEKio6Q7rVrTPlnZavfUr+YDqnDOQK2QVwMvxESP FTc9g7+dRZYeKd5c9MOg86eKGwBRpqfH2qbbjy6G1AHvDajTOvse3QYmHHPFR3F4GcWh TLk3nC2PsP7qrBdp/dXxUK2tDrvmxP6BRu8Vy34d48E4hkXETn7Q37IREb9xk6JETEMc uQRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=6YkPiUH9uglH2B5aguvlMewabUbKr7KGsfTMSN6Qd6M=; fh=z1KcSqUpYQ9oC4uLSeIkhAYTnJ2bvP0QbNW2xqV5NqA=; b=KEpAjmsfhaCm3tdwWZ6dW9rbxSBsHtH/vNCeREl7dt8xRNd1b6MK9CsDASAExIYkll K0KncE1/VedT/SzBH3VoJSThh9F8ijDTgAAaX4cKVph2N8lR9hcxHO28s/sfshwpOEH0 sUOXRgR6nmw9FTuNOiyGVpnT9J5mpJBVuVo7YaTF/PG0LuOtlIFeqTnRHhKADjQ8BoHf vhQ0XPSsceCXBmnKOpAqAYXfmjgHhWje3yHBJlcnzwuFj49BNVLp97HsVot3H+cTZ3nM 141q/Ib9sSE7J0eCUnS0vDU5sMoIiIN7rfiVNHIeoUrrLLGNkZZWHdvKE08Fq3pUXO3/ PLvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OlWQzUDs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h10-20020a170902f54a00b001b84335fb90si48103plf.286.2023.11.02.10.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 10:58:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OlWQzUDs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1969B801B923; Thu, 2 Nov 2023 10:58:46 -0700 (PDT) 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 S1345632AbjKBR6P (ORCPT + 99 others); Thu, 2 Nov 2023 13:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344655AbjKBR6E (ORCPT ); Thu, 2 Nov 2023 13:58:04 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 545E7186 for ; Thu, 2 Nov 2023 10:58:01 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da0cb98f66cso1414532276.2 for ; Thu, 02 Nov 2023 10:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698947880; x=1699552680; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=6YkPiUH9uglH2B5aguvlMewabUbKr7KGsfTMSN6Qd6M=; b=OlWQzUDstSqpKPyqmQbBQtmdgsv4UDJlzF96FlJD/RyCEC/dOfM595IuSkOYctRti7 i0iQCV98JKydCBjT6a8eWgtgPuqoF7lOu399u142TJUCykP7bScqpNPch7VcP6bB/90x kh8kZfZKjMahhFKTTfXQICbP2z10BkzK/Srq/Z25NI5dAbzSMXzMDy75SSweuugWk5MZ LYwEj6FBujqcutRa/Ny2/Q1IIErRjMFI1fS6DbFPoKyHAhDddStl58SssgXwjxJ5zVH2 PfD/0GAXXuW8I7UQOULH8PssVPF4m6cCQazyqy5pCEUilNr0YMq3q3R22Ys6YLvzl0JT tPIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698947880; x=1699552680; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6YkPiUH9uglH2B5aguvlMewabUbKr7KGsfTMSN6Qd6M=; b=IZnaBZYUO3Prp1wcTpDpoDuE6S6JG/mo11knQFuiQ7G4ToTRWAuSRWpUbjVFctoGO7 7REe3/ECQOoXJHHTQyQNPQCYB4GBDt+J7BwP7FVvi1Cx5pKTu7IqOTnd8AtYdKVxdZnZ Uj4h5VTFEBL9UUSdyiDg/1pXPN5uZu+2fp1Pn16p2wdTwEQ8JaEQ+Du9z7EYl+x18FLT e971dmC3BqnyHQ4HsUIyPCyCtMCUxuaZ+f3PL9x71K5hwJUsRmxMsyYaeOKgd+KwzZd5 Qe86hTinkMm2crU5Y/Vn/8N1Ye6wHtvJ67wDnQGlo4bvSjstfTpWWDqrFdgIcEm4/Tht W0JA== X-Gm-Message-State: AOJu0YxeBnzt4vEyvEHsp9zHVEJfKhj3UEVdj5899HnPMCy8jkyolOjN GHSpP8ZIsY3HXS9997fIj0eqHiO4BsDe X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bb34:df9c:836c:afca]) (user=irogers job=sendgmr) by 2002:a05:6902:168c:b0:da0:3e46:8ba5 with SMTP id bx12-20020a056902168c00b00da03e468ba5mr359878ybb.8.1698947880465; Thu, 02 Nov 2023 10:58:00 -0700 (PDT) Date: Thu, 2 Nov 2023 10:56:44 -0700 In-Reply-To: <20231102175735.2272696-1-irogers@google.com> Message-Id: <20231102175735.2272696-3-irogers@google.com> Mime-Version: 1.0 References: <20231102175735.2272696-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Subject: [PATCH v4 02/53] perf record: Lazy load kernel symbols From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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]); Thu, 02 Nov 2023 10:58:46 -0700 (PDT) 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 | 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, -- 2.42.0.869.gea05f2083d-goog