Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1341190ybb; Sat, 4 Apr 2020 01:44:00 -0700 (PDT) X-Google-Smtp-Source: APiQypJLZ7fDYw92M8bSVkRZWpWsabYvkhTDBLpV9aWCcsjSwAUvznNUw9SGrUDI/+nt0f6vElTc X-Received: by 2002:a54:4e13:: with SMTP id a19mr6186947oiy.108.1585989840783; Sat, 04 Apr 2020 01:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585989840; cv=none; d=google.com; s=arc-20160816; b=Kbdgb/fOTTsyMHu9PEgo7Ni3NoNKhgrjbrF60n3ycB8yrvoeF9I3mFM5lu+tpiwzXH PvDtqK2Z2ORENFxlfIj2LZUYwtcWi77JoT0HzXfeiet5zWC8F7t1VUF+56KtLnDOaGNQ uaYtiRi65uYYc92kj4Zv6euNCMWYFbk0mTuOelsdGK/qrorAtxwaw5eiql8uDTSLm8bG BbZ4nIlBFgyBy5dGC7m4EHWc3NJGBfoN/g42xXiph+rtEJT9+zNOte7OtlVcAxMyo/Nf P+6iNiVRjaKaoWlzmw3Jt2eC29bmb5sNWIWPQZodcnXi8f3gh/DNke/5yv95kIyd2OCD DAbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=3dIhENZlKBfTEAWhSOdsiG2tXFGrCDP4PE7kW38+4p0=; b=aBdhBXoo67QXXKfET9nrPQKqTJzRtf+YblbKEWWByuxGpSDygGWwDQgtN5kywzYdnN IFeDfXvwEBuaq/pw73lmVhe7P4f4h2/b2E7tCTzoO4Jp2VQmUx3XNzw/LujUD+4QGopi T7uhTsUkYEXm9mtjPe+qibYahzqMUcRxLNTnXnBZMZTFN6g8+1+MQoDfWDipZC61YERz Joykm1vQeSp4JXvSq2Pa3kMkhYbDIlM4Z4TJhAYelIVQrGPSUk9P4S9zEY+T3/wU5JcS 0pShPo2Vvwb+UAHwYVWT9ezSg/iKTXTlytfi2AswN7+AJbvQhVK4HXbYWuj6xwDesdox pLUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w8si5184579otp.266.2020.04.04.01.43.48; Sat, 04 Apr 2020 01:44:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726637AbgDDImS (ORCPT + 99 others); Sat, 4 Apr 2020 04:42:18 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:41657 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726490AbgDDImK (ORCPT ); Sat, 4 Apr 2020 04:42:10 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jKeNB-0000yS-BG; Sat, 04 Apr 2020 10:41:49 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 051371C0483; Sat, 4 Apr 2020 10:41:44 +0200 (CEST) Date: Sat, 04 Apr 2020 08:41:43 -0000 From: "tip-bot2 for Kemeng Shi" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf symbols: Fix arm64 gap between kernel start and module end Cc: Kemeng Shi , Alexander Shishkin , Hewenliang , Hu Shiyuan , Ian Rogers , Jiri Olsa , Mark Rutland , Namhyung Kim , Nick Desaulniers , Peter Zijlstra , Thomas Richter , Arnaldo Carvalho de Melo , x86 , LKML In-Reply-To: <33fd24c4-0d5a-9d93-9b62-dffa97c992ca@huawei.com> References: <33fd24c4-0d5a-9d93-9b62-dffa97c992ca@huawei.com> MIME-Version: 1.0 Message-ID: <158598970362.28353.14113544312342122835.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 78886f3ed37e89a06c76b95be873573e27900979 Gitweb: https://git.kernel.org/tip/78886f3ed37e89a06c76b95be873573e27900979 Author: Kemeng Shi AuthorDate: Mon, 30 Mar 2020 15:41:11 +08:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Fri, 03 Apr 2020 09:37:55 -03:00 perf symbols: Fix arm64 gap between kernel start and module end During execution of command 'perf report' in my arm64 virtual machine, this error message is showed: failed to process sample __symbol__inc_addr_samples(860): ENOMEM! sym->name=__this_module, start=0x1477100, addr=0x147dbd8, end=0x80002000, func: 0 The error is caused with path: cmd_report __cmd_report perf_session__process_events __perf_session__process_events ordered_events__flush __ordered_events__flush oe->deliver (ordered_events__deliver_event) perf_session__deliver_event machines__deliver_event perf_evlist__deliver_sample tool->sample (process_sample_event) hist_entry_iter__add iter->add_entry_cb(hist_iter__report_callback) hist_entry__inc_addr_samples symbol__inc_addr_samples __symbol__inc_addr_samples h = annotated_source__histogram(src, evidx) (NULL) annotated_source__histogram failed is caused with path: ... hist_entry__inc_addr_samples symbol__inc_addr_samples symbol__hists annotated_source__alloc_histograms src->histograms = calloc(nr_hists, sizeof_sym_hist) (failed) Calloc failed as the symbol__size(sym) is too huge. As show in error message: start=0x1477100, end=0x80002000, size of symbol is about 2G. This is the same problem as 'perf annotate: Fix s390 gap between kernel end and module start (b9c0a64901d5bd)'. Perf gets symbol information from /proc/kallsyms in __dso__load_kallsyms. A part of symbol in /proc/kallsyms from my virtual machine is as follows: #cat /proc/kallsyms | sort ... ffff000001475080 d rpfilter_mt_reg [ip6t_rpfilter] ffff000001475100 d $d [ip6t_rpfilter] ffff000001475100 d __this_module [ip6t_rpfilter] ffff000080080000 t _head ffff000080080000 T _text ffff000080080040 t pe_header ... Take line 'ffff000001475100 d __this_module [ip6t_rpfilter]' as example. The start and end of symbol are both set to ffff000001475100 in dso__load_all_kallsyms. Then symbols__fixup_end will set the end of symbol to next big address to ffff000001475100 in /proc/kallsyms, ffff000080080000 in this example. Then sizeof of symbol will be about 2G and cause the problem. The start of module in my machine is ffff000000a62000 t $x [dm_mod] The start of kernel in my machine is ffff000080080000 t _head There is a big gap between end of module and begin of kernel if a samll amount of memory is used by module. And the last symbol in module will have a large address range as caotaining the big gap. Give that the module and kernel text segment sequence may change in the future, fix this by limiting range of last symbol in module and kernel to 4K in arch arm64. Signed-off-by: Kemeng Shi Cc: Alexander Shishkin Cc: Hewenliang Cc: Hu Shiyuan Cc: Ian Rogers Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Nick Desaulniers Cc: Peter Zijlstra Cc: Thomas Richter Link: http://lore.kernel.org/lkml/33fd24c4-0d5a-9d93-9b62-dffa97c992ca@huawei.com [ refreshed the patch on current codebase, added string.h include as strchr() is used ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm64/util/Build | 1 +- tools/perf/arch/arm64/util/machine.c | 27 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+) create mode 100644 tools/perf/arch/arm64/util/machine.c diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build index 789956f..5c13438 100644 --- a/tools/perf/arch/arm64/util/Build +++ b/tools/perf/arch/arm64/util/Build @@ -1,4 +1,5 @@ perf-y += header.o +perf-y += machine.o perf-y += perf_regs.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o diff --git a/tools/perf/arch/arm64/util/machine.c b/tools/perf/arch/arm64/util/machine.c new file mode 100644 index 0000000..d41b27e --- /dev/null +++ b/tools/perf/arch/arm64/util/machine.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include "debug.h" +#include "symbol.h" + +/* On arm64, kernel text segment start at high memory address, + * for example 0xffff 0000 8xxx xxxx. Modules start at a low memory + * address, like 0xffff 0000 00ax xxxx. When only samll amount of + * memory is used by modules, gap between end of module's text segment + * and start of kernel text segment may be reach 2G. + * Therefore do not fill this gap and do not assign it to the kernel dso map. + */ + +#define SYMBOL_LIMIT (1 << 12) /* 4K */ + +void arch__symbols__fixup_end(struct symbol *p, struct symbol *c) +{ + if ((strchr(p->name, '[') && strchr(c->name, '[') == NULL) || + (strchr(p->name, '[') == NULL && strchr(c->name, '['))) + /* Limit range of last symbol in module and kernel */ + p->end += SYMBOL_LIMIT; + else + p->end = c->start; + pr_debug4("%s sym:%s end:%#lx\n", __func__, p->name, p->end); +}