Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10591334ybi; Thu, 25 Jul 2019 02:03:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCcDoDoDE8QW23gNyl5z8IYI/EeihwuWqeYnj3r2MNG7Znr/0Mzw5z5OpM1ltOljcAt7Wv X-Received: by 2002:a17:902:44e:: with SMTP id 72mr89903018ple.326.1564045427739; Thu, 25 Jul 2019 02:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564045427; cv=none; d=google.com; s=arc-20160816; b=CF4V7lN9Nzm4yLim9pNK7AeDThxvXnqmX19T9Y0yBQEVQGi53R3Zq2rS9pfw8+Uo5T lkvoP/pUb43Ws3WKb9CyAX8KIbVjdilcTiGki8iTPG9xSQJGhipW/CB8og/bQCejj6s0 EM1g4111z7XB13Q8Ob8Q8hsm6hc3aLbuyAU5qkb9mD+W7fKS9Mbst3CtvwA7WXMViD76 x8RWKoD23pYNNoVHCqyiVr06JsmPSgYt+GOVywx3ouvnwpdkJuFTuvkKR8jjPy8qyXG3 gaZahvohQyLojWi1FHznW6GvHoM+zJvGMzln8Kuulg3TJ1/Ai4IVmj+33vUqVJ8KAAkn Z76g== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oYasbZBtlKEsMU832IEJYG1c7H70YR6jblSjS8DP5xY=; b=i87+g97h6GYT5NKyEaIDVqTT1NzkfrDWbQRzhWkN8L6x2YeWJvAh4kf36ctKpJlNT5 SZPKBD2bJKJ0p0s6tkwS/S6r3y5T6r5JikSaqt+v1TWt1okiNs6zIFQfdz29OXky26Va 7lrWmZtZ6D4kxv4aqNju5fs/phb7U0j/LCm87A1F7xmdn/o15mL0E+dhJeIgj5ehOdDS l+U3dCtlXmC+AOCZsn10dPQjwUjV4lUucqyXQBltehiJBnMBOBgIshfD7P1WRzLj4Gj6 9Dwq1mzsw3HFZFNpVilDp9VbV8uS1XE63ukzI1su8+E8TGkwccssLhXZMAXeMWRSu812 g50A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jmmjf5gF; 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 i68si15609198plb.13.2019.07.25.02.03.29; Thu, 25 Jul 2019 02:03:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Jmmjf5gF; 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 S2403846AbfGXUUW (ORCPT + 99 others); Wed, 24 Jul 2019 16:20:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:52930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390805AbfGXTqu (ORCPT ); Wed, 24 Jul 2019 15:46:50 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1AF8D22BF5; Wed, 24 Jul 2019 19:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997609; bh=J+f0qJdgILonNtd7rTG6Zq54fwI/Z1AmPX8qGnU7kes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jmmjf5gF05MyGXJt20K1SA/CZpi1tSqZFX+CTo2tUE3bQw0waIGSJ3YbU/zANnSde LnVRY98mwTLCzSWMYYzxI038o4zOMr2/cdWsN6jfT99g5uxzD+H0QFnoLnHkn49txU d4nfJXpJPbL9GP2Ex9nqcESTvk/oXg3KCNIOto5s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Hendrik Brueckner , Heiko Carstens , Hendrik Brueckner , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.1 075/371] perf report: Fix OOM error in TUI mode on s390 Date: Wed, 24 Jul 2019 21:17:07 +0200 Message-Id: <20190724191730.522246018@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 8a07aa4e9b7b0222129c07afff81634a884b2866 ] Debugging a OOM error using the TUI interface revealed this issue on s390: [tmricht@m83lp54 perf]$ cat /proc/kallsyms |sort .... 00000001119b7158 B radix_tree_node_cachep 00000001119b8000 B __bss_stop 00000001119b8000 B _end 000003ff80002850 t autofs_mount [autofs4] 000003ff80002868 t autofs_show_options [autofs4] 000003ff80002a98 t autofs_evict_inode [autofs4] .... There is a huge gap between the last kernel symbol __bss_stop/_end and the first kernel module symbol autofs_mount (from autofs4 module). After reading the kernel symbol table via functions: dso__load() +--> dso__load_kernel_sym() +--> dso__load_kallsyms() +--> __dso_load_kallsyms() +--> symbols__fixup_end() the symbol __bss_stop has a start address of 1119b8000 and an end address of 3ff80002850, as can be seen by this debug statement: symbols__fixup_end __bss_stop start:0x1119b8000 end:0x3ff80002850 The size of symbol __bss_stop is 0x3fe6e64a850 bytes! It is the last kernel symbol and fills up the space until the first kernel module symbol. This size kills the TUI interface when executing the following code: process_sample_event() hist_entry_iter__add() hist_iter__report_callback() hist_entry__inc_addr_samples() symbol__inc_addr_samples(symbol = __bss_stop) symbol__cycles_hist() annotated_source__alloc_histograms(..., symbol__size(sym), ...) This function allocates memory to save sample histograms. The symbol_size() marco is defined as sym->end - sym->start, which results in above value of 0x3fe6e64a850 bytes and the call to calloc() in annotated_source__alloc_histograms() fails. The histgram memory allocation might fail, make this failure no-fatal and continue processing. Output before: [tmricht@m83lp54 perf]$ ./perf --debug stderr=1 report -vvvvv \ -i ~/slow.data 2>/tmp/2 [tmricht@m83lp54 perf]$ tail -5 /tmp/2 __symbol__inc_addr_samples(875): ENOMEM! sym->name=__bss_stop, start=0x1119b8000, addr=0x2aa0005eb08, end=0x3ff80002850, func: 0 problem adding hist entry, skipping event 0x938b8 [0x8]: failed to process type: 68 [Cannot allocate memory] [tmricht@m83lp54 perf]$ Output after: [tmricht@m83lp54 perf]$ ./perf --debug stderr=1 report -vvvvv \ -i ~/slow.data 2>/tmp/2 [tmricht@m83lp54 perf]$ tail -5 /tmp/2 symbol__inc_addr_samples map:0x1597830 start:0x110730000 end:0x3ff80002850 symbol__hists notes->src:0x2aa2a70 nr_hists:1 symbol__inc_addr_samples sym:unlink_anon_vmas src:0x2aa2a70 __symbol__inc_addr_samples: addr=0x11094c69e 0x11094c670 unlink_anon_vmas: period++ [addr: 0x11094c69e, 0x2e, evidx=0] => nr_samples: 1, period: 526008 [tmricht@m83lp54 perf]$ There is no error about failed memory allocation and the TUI interface shows all entries. Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Cc: Heiko Carstens Cc: Hendrik Brueckner Link: http://lkml.kernel.org/r/90cb5607-3e12-5167-682d-978eba7dafa8@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/annotate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 09762985c713..0c43c5a0d9d9 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -932,9 +932,8 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, if (sym == NULL) return 0; src = symbol__hists(sym, evsel->evlist->nr_entries); - if (src == NULL) - return -ENOMEM; - return __symbol__inc_addr_samples(sym, map, src, evsel->idx, addr, sample); + return (src) ? __symbol__inc_addr_samples(sym, map, src, evsel->idx, + addr, sample) : 0; } static int symbol__account_cycles(u64 addr, u64 start, -- 2.20.1