Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2185224rda; Tue, 24 Oct 2023 15:25:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrwB1PZ0IatCX451bGOCZo91WMMwjaMppt0PPyJUO8/QcQbM+/MQE9Z52lRAsD2zHarUs1 X-Received: by 2002:a17:902:c78a:b0:1b8:954c:1f6 with SMTP id w10-20020a170902c78a00b001b8954c01f6mr10505377pla.36.1698186328453; Tue, 24 Oct 2023 15:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698186328; cv=none; d=google.com; s=arc-20160816; b=ZENRaqRzgzCtYC+6VxxM+ylHls0MTsmBtn/W9GS1Jhi29ajAO5+cNxab5Fz8qj1EwB e0alG8dJBvo9eGbbzQB8mfvMCmNGbDUte9sCicInw39XSASWf6ySl3u55JBlYnUjKJbR XH1sSt8sMfI4ISl99VAvjFcgzsqC6V6bGlMGjDUmb0i2C8f3jXqHnF+xu1rPHcTmF9u6 XN78kq5+Hy61+pnHcRZ2JDdyJlh65jb3T0WWn4l24dOL0OndkjLVKrelyCVtdGGPVT0P 7xLyEPq4K0IQ8Wi5rkiEiWvldX9deveTNMslI99vmQQ34Bb08sUvJEkbJjXiyf1Y+epV zjlg== 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=m3RrFaAylSJfbHKcTDzvj4sdZE51LV5H16MsLijA4K8=; fh=NAro5oTsDEB2Or99ABwb774QJkwQSkr6EoLVqn/Yde0=; b=CMpi8xqVa3LCLTu51ImQ8EM8lhxNVuajFkcJrgsMJ4q+uoBuvhsJ4XN5basCUJuWE8 X1g4KApEVHR77k5Ol5msqtn5GN8ECBWIQJw0YRXWLQo5FsKyCYWQmqUF9PGPKs3B6Q+R 9k7TCqqIKO4WoDOayaGduBFxuKuw31/KbXZrga5DcH6mmAjgM7xkRIHM+uPDsexImkez U/DHkxDTx2PZChySnTBkh/Ro1qc5/nmCjGfwxnRakyYeM1PCu0bBrZYj6FOIeQMiwFHP Lp99+M1Mkw/GqXtQ4gcj0izl/ZUqFLiJW86/Ztj6hjnUgneBHE9C1iq+z0jdVhv4LrdC D1gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="UEQxx/EE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n4-20020a170902e54400b001c9d66601ddsi9426257plf.162.2023.10.24.15.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 15:25:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="UEQxx/EE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 8313D8026DCD; Tue, 24 Oct 2023 15:25:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344529AbjJXWZX (ORCPT + 99 others); Tue, 24 Oct 2023 18:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344558AbjJXWZG (ORCPT ); Tue, 24 Oct 2023 18:25:06 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46CB510D1 for ; Tue, 24 Oct 2023 15:24:41 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5a839b31a0dso94314447b3.0 for ; Tue, 24 Oct 2023 15:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698186280; x=1698791080; 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=m3RrFaAylSJfbHKcTDzvj4sdZE51LV5H16MsLijA4K8=; b=UEQxx/EE0WtiG9dMIp4bJpg1YKY88bG+AufaRZWd9HFwxpHH5JY2Fl1U16waQAeGEO uRa+PYvkIDGXPxN6K6ecLrp2PIQem4YVBdIEinc0kRyfAHOMkclMGXkJsCKfq+8wz9no of0a/G3PxbIgUTFZ1Zgy2ERPtV83GcjlyIHcDmnccPogIiVL//y7hufQC85+tfkZyX++ 8yt+S72qyrnHrWRwu23IlpgX2Rtjo4bq4H4vi5gjVvJWTJItoe4xo9T3DGF+vkJ1Qyei lw020vG7K2N3so94j/txWSbAWkF/3fHzhCxH9grblZsqpZiw/bjb0KIsai0xuxHOUs4E MG6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698186280; x=1698791080; 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=m3RrFaAylSJfbHKcTDzvj4sdZE51LV5H16MsLijA4K8=; b=pwmEFzHCY1hvr9iWWDGOeU4MrgWt2ucqv6jwBE/1xHmgyZTwYrTFuW+hznB0k/TYuh Fq9RxEwky2/pGbTUNP5BiHYc7BtOzJ9qAai2aGf6vudP4Tn3gNuryhnTr4RmTFVH7+2q r4SDT9pjE+OtRv5tFkZkxJOEJigrgnPgnmFIYwhuivVIZU2yRjRJQnmBQp1zJu/RKk9T VwN66A3pUQvDbmJBhByJ9H82RBNBH/0QewTwLLhtoQpkW5dhUWUAWmXwyIkSQBaHDW9+ MtyQNOaDh0qr3aomodF9oTSYAMsX2igV5Cnqfx6g2zuBYXL7Mc8elyeZSviYgyRQBDwx vLNw== X-Gm-Message-State: AOJu0YzwIJIU5DmWdu3m6SgrE1gUIOlyw/2KnT1CtouB5jO3HiV/uE1j xBco5SuELiURBF/7tO2c+vVb6hDhuDml X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:93d2:18cc:4d63:45ba]) (user=irogers job=sendgmr) by 2002:a81:5206:0:b0:5a7:b672:4d88 with SMTP id g6-20020a815206000000b005a7b6724d88mr288070ywb.0.1698186279736; Tue, 24 Oct 2023 15:24:39 -0700 (PDT) Date: Tue, 24 Oct 2023 15:23:15 -0700 In-Reply-To: <20231024222353.3024098-1-irogers@google.com> Message-Id: <20231024222353.3024098-13-irogers@google.com> Mime-Version: 1.0 References: <20231024222353.3024098-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-goog Subject: [PATCH v3 12/50] 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 , Leo Yan , Song Liu , Sandipan Das , James Clark , Anshuman Khandual , Miguel Ojeda , Liam Howlett , Yang Jihong , Athira Rajeev , Kajol Jain , K Prateek Nayak , Sean Christopherson , Yanteng Si , Ravi Bangoria , German Gomez , Changbin Du , Paolo Bonzini , Masami Hiramatsu , liuwenyu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 15:25:27 -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.758.gaed0368e0e-goog