Message ID | 20231102175735.2272696-3-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp533043vqu; Thu, 2 Nov 2023 10:58:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEf8pImxzXydi+XLJk4e+m4ovuvMFL8TWEepUYBEBc2bkgjRvH7b9dRIUiA/Y04ZUe34zGL X-Received: by 2002:a05:6a21:3290:b0:17b:129b:196f with SMTP id yt16-20020a056a21329000b0017b129b196fmr23706783pzb.11.1698947915515; Thu, 02 Nov 2023 10:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698947915; cv=none; d=google.com; s=arc-20160816; b=YwUsQcOYTiZA7z8f8Y8clIPiG8oQwd6pWZTvpAcnHaIR4ZJIYMFF3GIp2+p/qI8HJS SSDzjkB42rVOFnvWrQePOeEW43+9AFi6QtbqtpD2oPOU8+y3oweXXQRrpWgLgx22AqHd 4HVZ9iy1GTuySaqhCOGgDqyU7Jrbe0r+/oPULMDMIfNFJP7cAK2OK5v8hB0dXygGi3Rk xwVQHY+mfKTMLv7zqDOJtQcmJYK5DmiF/T8aqtUVAsEcQGmOnCMFhwF+llo66lK8a867 HyUsEJnbrbLXZfjCtlXexkpJjW+DFW/OH9ydZ+lNCJ3oUxlp4AQ+yK2YdURzSeibQ1zN At3w== 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.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p47-20020a056a0026ef00b0068a590d8043si57639pfw.375.2023.11.02.10.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 10:58:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; 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.33 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 lipwig.vger.email (Postfix) with ESMTP id B3ACB82096BF; Thu, 2 Nov 2023 10:58:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345168AbjKBR6Q (ORCPT <rfc822;heyuhang3455@gmail.com> + 35 others); Thu, 2 Nov 2023 13:58:16 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Thu, 2 Nov 2023 10:58:01 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da0cb98f66cso1414532276.2 for <linux-kernel@vger.kernel.org>; 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 <irogers@google.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Nick Terrell <terrelln@fb.com>, Kan Liang <kan.liang@linux.intel.com>, Andi Kleen <ak@linux.intel.com>, Kajol Jain <kjain@linux.ibm.com>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, Huacai Chen <chenhuacai@kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>, Vincent Whitchurch <vincent.whitchurch@axis.com>, "Steinar H. Gunderson" <sesse@google.com>, Liam Howlett <liam.howlett@oracle.com>, Miguel Ojeda <ojeda@kernel.org>, Colin Ian King <colin.i.king@gmail.com>, Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong <yangjihong1@huawei.com>, Ming Wang <wangming01@loongson.cn>, James Clark <james.clark@arm.com>, K Prateek Nayak <kprateek.nayak@amd.com>, Sean Christopherson <seanjc@google.com>, Leo Yan <leo.yan@linaro.org>, Ravi Bangoria <ravi.bangoria@amd.com>, German Gomez <german.gomez@arm.com>, Changbin Du <changbin.du@huawei.com>, Paolo Bonzini <pbonzini@redhat.com>, Li Dong <lidong@vivo.com>, Sandipan Das <sandipan.das@amd.com>, liuwenyu <liuwenyu7@huawei.com>, 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 lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 10:58:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781476009335119038 X-GMAIL-MSGID: 1781476009335119038 |
Series |
Improvements to memory use
|
|
Commit Message
Ian Rogers
Nov. 2, 2023, 5:56 p.m. UTC
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 <irogers@google.com>
---
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(-)
Comments
On Thu, Nov 2, 2023 at 10:58 AM Ian Rogers <irogers@google.com> 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 <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Thanks, Namhyung > --- > 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 [<options>]", > 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 >
On 2/11/23 19:56, 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 <irogers@google.com> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> > --- > 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 [<options>]", > 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,
Em Mon, Nov 06, 2023 at 01:00:14PM +0200, Adrian Hunter escreveu: > On 2/11/23 19:56, 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 <irogers@google.com> > Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> Thanks, applied to perf-tools-next. - Arnaldo
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 [<options>]", 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,