Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp106829rdg; Wed, 11 Oct 2023 23:25:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeCFwvZfUHAhyymC98FxtWJQpDZUc/x8l10V5w3Bs1+h/QtFd84cd2is83wpTN9brXdeTm X-Received: by 2002:a05:6870:a110:b0:1d6:fba1:ef75 with SMTP id m16-20020a056870a11000b001d6fba1ef75mr26577660oae.15.1697091947286; Wed, 11 Oct 2023 23:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697091947; cv=none; d=google.com; s=arc-20160816; b=g3Y3zc3HnJa3Z3kEd93Lbu3N/gc4MO1L/afwy73KFlAjIzSfiNXKFrV+oKkQqoMyxl AlBWfoJc+sr5Fa2ZNT92WDKpAv404aBuaw8LNjMgg6YBCQsO5LA1QYZyWx8URAcqWQSM 1/Ae9fVeXBwOaocu0e99SIMEEiqKNnwILz1nHUFnShKzWkIExnBJ1heGgvz/PaF1J9Z5 0piKtb5h+O/XYqfqbh1ZQd3jUogtzbLo3dThZilQnGbHLuwuneelsoXC0EGtDhPvLLjD UWgB+l8y1zA/pU5fijXD1aiXwgMZc3xj/Fur+tRgTm+2mgX3070JCDhjRkZE51odxJHB xFLQ== 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=Fc/6/O/gRte1zMhmeMtD4ohISB3aWdPXWc8V2/IjDG4=; fh=d2c3GDvCFnEMjeV5/UdzkMgvIdbP06sIBDmJP5CjgvI=; b=0gaQSXpGBf0M5JkANgJKCG3CK9JKdwQHQd3/wz8JCGGOHL7O3dQmV9FBn6aFK7q58P a4DRITQ9SZi+AlLYWe+lBXguYgD1hE4zpFm7Dw8pM9vfDKCgCSDs2MgWxjfa2X6BgtN6 cuIKyg1s4ASzNZeNiDyrNM8XJxoyeY10aUeoho1UEmCrHK+k5fui/nIXn4qoogcDKQFb EubKQn4ZhzqpGKoXM+h5wrTvUDJBM7yJ/PRyd1zcUmHVbUvAwr3fi7CIflFILEFE3UtT ZH/aPabUhse6Ha5O2/Kgp7V2y7SfjieagTzEz673F83DyOiDzvDtbSJJP1GOBTB61TAh t+Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MfjQ5C7J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id y9-20020a631809000000b00578b4082453si1487812pgl.712.2023.10.11.23.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 23:25:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MfjQ5C7J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 9F2388215AEE; Wed, 11 Oct 2023 23:25:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377742AbjJLGZF (ORCPT + 99 others); Thu, 12 Oct 2023 02:25:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377453AbjJLGYs (ORCPT ); Thu, 12 Oct 2023 02:24:48 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF781A3 for ; Wed, 11 Oct 2023 23:24:31 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a7a6fd18abso9897927b3.1 for ; Wed, 11 Oct 2023 23:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697091870; x=1697696670; 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=Fc/6/O/gRte1zMhmeMtD4ohISB3aWdPXWc8V2/IjDG4=; b=MfjQ5C7JEOErhS+sVyt+9BIu5x/F+EcfbqxY16YvfH+Baa1uydnkaaaYfeNb++GAhe w1jyj9CRpk9NtQvcuVy0u8EgsYvvICa06QNJGL60h6i1fNgf6a6eec6bbWSHgn9MylgN ctHoEn3sNsfj17CE9duwG0Bt25OAZbgB5aOLWOMaeZIxRP1wm1cyCvbm4lnSbrqK6J7T FjjHz3WCelmLYsstXYwiICf40c9lSzvWP+JzzaATTDQuiHLMs8ZhSdTHGTz5Fk3VVVEV labXbkeucDueh9576aAAymNQDILXk4SL3yfSOXvYg7Wk8wqWmtjhHPUjLgpuc1NODLkv KcfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697091870; x=1697696670; 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=Fc/6/O/gRte1zMhmeMtD4ohISB3aWdPXWc8V2/IjDG4=; b=JeQ8y4sZW8FhFE2q/ErWDBeUHvDF6MnMviuK7oLWPxqo6e5aYq7wjPI2DeuZhldHrS 0UBlk/ziFCByar0zZ6lSXJQk8hG84qpAbhHLpCZtqIsjRNWS2lJB1e3rK05CkqD15XAm nRNVc+2E2ijV+mMOUzaV9w8i33QWBco4F0SROJpNhcZdv07/NWRb/b01c51bqF/YIiBj dviotIwI/9WBDfLFENNewQH6HM8bU3C+MCkJu5zbRU7tZ18ReI2bIK/y5PBc3PbhXmp2 JSwDeuu3atZ9JmRsdT4Myz3TfSwpG7busHsat96iwmqngpQ+chwyqX8BzvotCf81RHG4 UT9Q== X-Gm-Message-State: AOJu0YwBALAdaDRGAzeps3Wzy0iwVjucWAk15wiVVWBNfxl/zW2rai20 rBHzX4ioN3eOygg/JNwQQvw6w/KLiBvx X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:7be5:14d2:880b:c5c9]) (user=irogers job=sendgmr) by 2002:a81:4005:0:b0:5a7:be34:345 with SMTP id l5-20020a814005000000b005a7be340345mr175704ywn.6.1697091870082; Wed, 11 Oct 2023 23:24:30 -0700 (PDT) Date: Wed, 11 Oct 2023 23:23:56 -0700 In-Reply-To: <20231012062359.1616786-1-irogers@google.com> Message-Id: <20231012062359.1616786-11-irogers@google.com> Mime-Version: 1.0 References: <20231012062359.1616786-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v2 10/13] 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 , 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 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,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 howler.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 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 23:25:35 -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 | 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; + #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.609.gbb76f46606-goog