Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 215AE208CB for ; Thu, 2 Nov 2023 17:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OlWQzUDs" 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 5564919A for ; Thu, 2 Nov 2023 10:58:01 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da0c7d27fb0so1423011276.1 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=fhp5Vb+C41psWmehHW4ZOmtntpk5aLAJR4HJZ+6nHnCziaNGabMKW7Z8CsIEiIRWim 4+Ku87nYBkC0i7L9qZ9tDfZ3GvAoGLh7WJW7F+/ZhR7hZXhivN8J6D/y5GtISPZY/Svi G7TtHi5/F/36zi+ekhtx/0H7I76ZNEDaMYVQ6qZWqENb8zCFnNFAdNFgIhWNn2htxyBa npt1wfKT4+og7bLnkaTf9l3vfZ7dPcbmbp0sMKwUASSLP9f3gyy5GQePb0Ws0paCZMGy PhwlIn4lqKOuoAPLZE+ccuoFJjQoN3fgFdZ7omfnNNGm2np4r3NMmaEMr6SpdHtE9a2r SW1Q== X-Gm-Message-State: AOJu0Yy1QiNpbENpwLiAZ1W10Zw17BH+mcqiSFiikeOlZfemWJERPoCZ eTt0ldFZWLHubWMKDyFx2uvAcCHUvwOh X-Google-Smtp-Source: AGHT+IFAYbM1/j+8aRo54ZHb+eR4podUcUkBtWOjip+Fy4WIlGGxkvrc8Lq8EkTVS9PnfCE/4VDkVHWOQD1B 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> Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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" 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