Received: by 10.213.65.68 with SMTP id h4csp480172imn; Fri, 16 Mar 2018 09:02:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELvf++46PyXXSapjHmcteL0VqJI3zts648rWAW/XR/yBUj2xWjlymCNUbKENB+NMZtc5ZSPz X-Received: by 2002:a17:902:a9c7:: with SMTP id b7-v6mr2652318plr.190.1521216142429; Fri, 16 Mar 2018 09:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521216142; cv=none; d=google.com; s=arc-20160816; b=pKY17BePknuxk8GRtCDREBe0mOni02GhW9q7aIN2CkKcGsY0Mh9qW5hE0wuCDw6h2q biZXJsnhPV9xuGD5e0Uimb0Ec/wwxm+WyHCE3AdXeyrywkbj64vlveyoj5nOzmGXRBqd /k4CbDzzTedKDRN5C2TiG60qti//p0pk7UfuGNZNugN8zToXmjwZuAMJiZn0omzSXkhR UfG5SH0ubmVRt27MJLToSJG99s/moUPiGXHOKgLkOPMejUVquTwCb8oiYeouUrWPw0jX etCR2sVi56EvPIqcdykCKkTZCPu9QX9rD+SUEG4GHe3ElFYsHc3uxxq+IoyJkyGgQbPC qKJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=eJozvPFDu77guxFPsifjAFrIvPH8MWFbIsFfKiS9TxA=; b=UzDm1jvqhrAqSrm4MHzJBV+Iq6Z2B96wnuupghvKc2KIWZ5Y9UmHz/02q6LEuy9uIv uEPKc+irwlxZjt4XoVDaSgQNxuG00TEMbFGtgo9yaJs+y2qPUXiPk/+kubvN44mf/rAh kMAXMLaqqLNFAYSUMtvTwPbpytDFh/KcSXcyRFDwolEhBJY2PjedaJOkLNYr0QiHSbXC 7G0dr3pKYlXL8UFnYFztOV7zcMVNtT4U0S1HOJCyfiN6U7fOq7HKBgCse8wGKLMkzVPT SQCgh+TFolLQWaY5bArratQM62vtWoprGuNqBpf2qZsY/Dlm8X9A8Kb+RJH6H3KDT/0w FOFw== 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 x32-v6si6566357pld.591.2018.03.16.09.01.58; Fri, 16 Mar 2018 09:02:22 -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 S965203AbeCPPnG (ORCPT + 99 others); Fri, 16 Mar 2018 11:43:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44712 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965190AbeCPPnC (ORCPT ); Fri, 16 Mar 2018 11:43:02 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C7DA5E1F; Fri, 16 Mar 2018 15:43:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Hendrik Brueckner , Ravi Bangoria , Heiko Carstens , Martin Schwidefsky , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.15 087/128] perf annotate: Fix unnecessary memory allocation for s390x Date: Fri, 16 Mar 2018 16:23:48 +0100 Message-Id: <20180316152340.917059783@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Richter [ Upstream commit 36c263607d36c6a3788c09301d9f5fe35404048a ] This patch fixes a bug introduced with commit d9f8dfa9baf9 ("perf annotate s390: Implement jump types for perf annotate"). 'perf annotate' displays annotated assembler output by reading output of command objdump and parsing the disassembled lines. For each shown mnemonic this function sequence is executed: disasm_line__new() | +--> disasm_line__init_ins() | +--> ins__find() | +--> arch->associate_instruction_ops() The s390x specific function assigned to function pointer associate_instruction_ops refers to function s390__associate_ins_ops(). This function checks for supported mnemonics and assigns a NULL pointer to unsupported mnemonics. However even the NULL pointer is added to the architecture dependend instruction array. This leads to an extremely large architecture instruction array (due to array resize logic in function arch__grow_instructions()). Depending on the objdump output being parsed the array can end up with several ten-thousand elements. This patch checks if a mnemonic is supported and only adds supported ones into the architecture instruction array. The array does not contain elements with NULL pointers anymore. Before the patch (With some debug printf output): [root@s35lp76 perf]# time ./perf annotate --stdio > /tmp/xxxbb real 8m49.679s user 7m13.008s sys 0m1.649s [root@s35lp76 perf]# fgrep '__ins__find sorted:1 nr_instructions:' /tmp/xxxbb | tail -1 __ins__find sorted:1 nr_instructions:87433 ins:0x341583c0 [root@s35lp76 perf]# The number of different s390x branch/jump/call/return instructions entered into the array is 87433. After the patch (With some printf debug output:) [root@s35lp76 perf]# time ./perf annotate --stdio > /tmp/xxxaa real 1m24.553s user 0m0.587s sys 0m1.530s [root@s35lp76 perf]# fgrep '__ins__find sorted:1 nr_instructions:' /tmp/xxxaa | tail -1 __ins__find sorted:1 nr_instructions:56 ins:0x3f406570 [root@s35lp76 perf]# The number of different s390x branch/jump/call/return instructions entered into the array is 56 which is sensible. Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Acked-by: Ravi Bangoria Cc: Heiko Carstens Cc: Martin Schwidefsky Link: http://lkml.kernel.org/r/20171124094637.55558-1-tmricht@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/arch/s390/annotate/instructions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c @@ -18,7 +18,8 @@ static struct ins_ops *s390__associate_i if (!strcmp(name, "br")) ops = &ret_ops; - arch__associate_ins_ops(arch, name, ops); + if (ops) + arch__associate_ins_ops(arch, name, ops); return ops; }