Received: by 10.213.65.68 with SMTP id h4csp497110imn; Fri, 16 Mar 2018 09:31:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELsqWKgJjeVGzpr8J5hDZnFUTc9UEdGA7zlxslwp9jYod/pNueNFPdb+0ba7s1A2px4IvFak X-Received: by 10.99.140.87 with SMTP id q23mr1944865pgn.258.1521217896847; Fri, 16 Mar 2018 09:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521217896; cv=none; d=google.com; s=arc-20160816; b=OyVHZv/wFEi4vkJ8FmJdCFefF+QfU+e7ik1A8SoqWPEy9NRWwetNfpiXw0EFMfu4qW pXQ7orLplJlzn4JNhimXVUUmhszJSIlJIL1b0owadhy7PQ8N+HvuYIGwrJWjpdLgozzN 1FyHI4iL3eavm6ahWve4rIvPbW79e2+00URvJCKra133eWseoZ3s3Cj3ua2RzLzd0xw1 WOPCD+Z7cW/yqfAOSKIjEGcYJ3puM02x9ClIuDCFAC1z38uu0hPiFUrzSW08ZHqfPeXf AFcfz2YRNnRzqzXHvWliLfdlGXm4VmJiAoMq5Ilve5TDRlu2gQFKQCN95k3yeGsz5f7a CsBQ== 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=7SEA738idDuSi478Lbw2bOUH3TBCDM7MyDWmIy0mofU=; b=WE3SnLmpZcX8Jlh7s/vIgXid9Y1A2QG97tvW4yZsGzMVb+iO2RzmNe0rfOTyHOlQ6v 5WYhJr/3x16oo3uyeiB4ii7Q1U2ICzeDw0yb8aUMzo37rZrKH8MXP2uIFmutaEklIHn0 CbNXy1cDtAtJroUw5+o2QwOMt5CfV1MrawGgeYiUVty2Og3tTB+SZwJ75+MAIIE2C+6i aV5+hGPEk7V6bwyp2Am7Zotps8W1UpBbMziYhTenJDQDGsgqyvclhi5VH/A4fkv7ioTb z+VtWY0Y/ftLaGi5FPv9YxVYA44RtJ4yDxDt30sWbM6r4xXq+IcTaViJRe510d4VUCI4 cS0Q== 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 a100-v6si6497171pli.483.2018.03.16.09.31.22; Fri, 16 Mar 2018 09:31:36 -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 S1752764AbeCPQ3i (ORCPT + 99 others); Fri, 16 Mar 2018 12:29:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43060 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934305AbeCPPit (ORCPT ); Fri, 16 Mar 2018 11:38:49 -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 AE12149F; Fri, 16 Mar 2018 15:38:48 +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.14 072/109] perf annotate: Fix unnecessary memory allocation for s390x Date: Fri, 16 Mar 2018 16:23:41 +0100 Message-Id: <20180316152333.904246358@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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 @@ -16,7 +16,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; }