Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2082819rda; Tue, 24 Oct 2023 11:43:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmdplTOP/0E9FpjXWMg6P720MOkTWgaHCP9KMEyYkQINaAAsfd961V97gqw3wO2tC2uxi9 X-Received: by 2002:a05:6359:6099:b0:168:e7b7:1e40 with SMTP id ry25-20020a056359609900b00168e7b71e40mr4665757rwb.7.1698172996065; Tue, 24 Oct 2023 11:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698172996; cv=none; d=google.com; s=arc-20160816; b=RzHh9FR+u/EH/uFv7P3BrQPi6U72VaFFtLZu4FMKl7o3m1XyRuaDPSP5NNUSv1/L7R MuEu59s5ZcuFpWBDrZPbtacJcmlXbDxOOMS7TBVmBa9yTevmi/u8yGt6P+qo0QczklGA Qj/UzZ2ZP+oWxUYOy2SFn/zsD5Oxv7mnvdMHoCfuNSlRscAblMWMHQ8qkWQXydn5DALW 7IZkuhvxbH2K3COq5OyQjXiv1+0C/g06PFvEs71vdRwHhZI4Fu2/R0qGI8or6x42rhm5 TUKPiHTmz5wYDaqjo6BlVyjSwESjh/pg+AhcRzMPjWy4Du4tbA0czNvqNkqkEv0S9VcO /bwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=09epGMxkhhjkdYiw8KiYrXokGkqZWFd0a0WWXHQ6/zM=; fh=qwxshGX4DO2MQ/BdLoxSiJpZ2FFdRTo+qUDwdZsIGnM=; b=D2gxTR7xw1pvAtLawkqnYrzTbR2FqVHMX5bFk8ln7BuTib+6QWLwwJIz1A73mwIg7Q lpH2cSpmISxY9xrJ4I+XAr/tJHWooxjCn8XHcZ2ikP86V5Ey/GTmBIFMIFIolDGNLGjH D2AetCBAjq0qqVCCc5dPiNYwvtXSBOvbP0Ws4l/sjUCi+My4FDDpdrPliPAIDU1q3BEO a7u+xLF0as57VdyE6cyCvu77JFem/m3leJGfJuuK6aIAevRb9U94HAv/SilcYXzgFuHG vLjrQEDlmQ7tO0uOKKs2pP97+tLLHfy4snCsdryxZKh8VIbrlAEHqlIND4hcHV3OpKrQ cXow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Kqj8MJYk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b69-20020a633448000000b00573fc6de956si1363517pga.223.2023.10.24.11.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 11:43:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Kqj8MJYk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 52DAC803D8E0; Tue, 24 Oct 2023 11:43:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344169AbjJXSm4 (ORCPT + 99 others); Tue, 24 Oct 2023 14:42:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344042AbjJXSmx (ORCPT ); Tue, 24 Oct 2023 14:42:53 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F20EB10C9 for ; Tue, 24 Oct 2023 11:42:49 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-53f647c84d4so2393a12.0 for ; Tue, 24 Oct 2023 11:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698172968; x=1698777768; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=09epGMxkhhjkdYiw8KiYrXokGkqZWFd0a0WWXHQ6/zM=; b=Kqj8MJYkyul1ZOwP802BG3+Y4g+ksBOBskIt2PCkuuMJ0aBkI+mNNLyvhwukZHtiXM VkseY0e4JT3qAAvdMZ1KNT4RoAPIHanq1/lRmyPtmNBM0d9JHmQQLX6wU9SCyehfdS73 eUXT55LTUccCYf32OBfv8/QUqLo42fJfX98r1OM4/1MDeCvhacT8vs0r0WxcC7Dj4UsD rTvYnKrx4hz0ZbehcXiSe4A32Res0OT6QPB7QreN7J6zFOJ775X6bGbT5PcRQL3gdkqm R3+UYIiOR5UB/Ux3ugwubMKPVTw6PEoYKujILK3mxDwuX4jF4apxevKArViMSmVRqAvh FBww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698172968; x=1698777768; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=09epGMxkhhjkdYiw8KiYrXokGkqZWFd0a0WWXHQ6/zM=; b=KoxlJht9dZE1zx3G21VJhWuoapD2FHKskUUPSb8u4VxJbkIN7ilVvR+sSpL+mtVtqe K98Vj2tLRRUexurovkBEoz5apc0Qjyt3gWPtHGNvXRuQ33BJKPuG4FPzcZkOipnW/DXs 4l8fypbp03RsllrlW1d1obH0cn8hTeKPEhk8MnSc4FOs+cUlNJ4aNDBt48xKlYNmUJBE c02DyiqtVphopjuChpimlAfUjGiudzI1KpP2uqqQiehUEynpw08ARBDlGq6pHRZcRFrE 1qa9Gvw9h0wtkqahCLk+UK7EsbP41jysW6hU7ejCngJw6LiO3m7bMtEBXYSnihQUeUyO BMcQ== X-Gm-Message-State: AOJu0YwlbIU7sNiEPaA4Krp+MQ9qspCUtDibsqQJN1Eay4YXOcQsOslk bQoUw2hSJVr7RipSXmlJchNGLeNw7Zgsa8o7I/G7zQ== X-Received: by 2002:a05:6402:288e:b0:540:9e44:483f with SMTP id eg14-20020a056402288e00b005409e44483fmr115978edb.4.1698172967814; Tue, 24 Oct 2023 11:42:47 -0700 (PDT) MIME-Version: 1.0 References: <20231012062359.1616786-1-irogers@google.com> <20231012062359.1616786-11-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Tue, 24 Oct 2023 11:42:33 -0700 Message-ID: Subject: Re: [PATCH v2 10/13] perf record: Lazy load kernel symbols To: Adrian Hunter Cc: 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 24 Oct 2023 11:43:13 -0700 (PDT) On Thu, Oct 19, 2023 at 4:02=E2=80=AFAM Adrian Hunter wrote: > > 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 =3D true; > > Possibly not for itrace kernel decoding, so: > > if (!inject->itrace_synth_opts.set) > symbol_conf.lazy_load_kernel_maps =3D true; Thanks, added to v3. Ian > > + > > #ifndef HAVE_JITDUMP > > set_option_nobuild(options, 'j', "jit", "NO_LIBELF=3D1", 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 =3D true; > > rec->opts.affinity =3D PERF_AFFINITY_SYS; > > > > rec->evlist =3D 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 *threa= d, u8 cpumode, u64 addr, > > if (cpumode =3D=3D PERF_RECORD_MISC_KERNEL && perf_host) { > > al->level =3D 'k'; > > maps =3D machine__kernel_maps(machine); > > - load_map =3D true; > > + load_map =3D !symbol_conf.lazy_load_kernel_maps; > > } else if (cpumode =3D=3D PERF_RECORD_MISC_USER && perf_host) { > > al->level =3D '.'; > > } else if (cpumode =3D=3D PERF_RECORD_MISC_GUEST_KERNEL && perf_g= uest) { > > al->level =3D 'g'; > > maps =3D machine__kernel_maps(machine); > > - load_map =3D true; > > + load_map =3D !symbol_conf.lazy_load_kernel_maps; > > } else if (cpumode =3D=3D PERF_RECORD_MISC_GUEST_USER && perf_gue= st) { > > al->level =3D 'u'; > > } else { > > diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_con= f.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, >