Received: by 10.223.164.202 with SMTP id h10csp1817826wrb; Fri, 24 Nov 2017 01:48:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMZwid/SwBMzVzTQCS+B6n1ONdJz1pklORMxgZ6qitciDvoE/plcQbCyi/WPZFCKOVbPfl6E X-Received: by 10.98.141.150 with SMTP id p22mr26161553pfk.207.1511516938983; Fri, 24 Nov 2017 01:48:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511516938; cv=none; d=google.com; s=arc-20160816; b=OOKX+MWNu7yl3AXEbG4ztewf1Iy3ASuvu6k43+FH5asawpntXeqYnhpJiaVAYsme6l NvFcNNZn+D5ceCVqtWmiyBnrIcRf3U+8YhHoJ4qUdFAIwzivt0WlvGAP8wmMAYHzaAsY /p/kPylAaRtNrzxMuYz10FRL46k96HD25iWKWLTxKM791jPJQTeHuvF++K8RrjxdYmjP SX7sS4ITh9Fh3ToslShJBftRZEBfIFFljEi0v3Jbbwq97vWYjFGycYFT1utpZezOqG3v zAPPO0rbhPo+nmpxCqoqk+3Ly+Q9mrWYUfhJIsIWRuXmzPczIHNydgwr6VLgteGnJw3f g9tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=QqVc0S/tjfK5dAKgoOt9SoGyX62icSk4tkwuVnPHD3E=; b=vKYRLBxpA6oTJMWIUnCRayBtoaX19/zYBuDnLmjejJL7SSJCOndaYFNDU2sOpLP2aZ PnDCv6eeMuINU5UNs7kfwHnxRa22Tv0as9Ur3er+lcfSGy0HNNUohG/F5TlN3vMle0cT 3K9DmBLdrkjq963Y21ZJct/CFk9M1EMoM1V3azuIoX5KRih3dm44u3LW1xVnnQrjgmcJ XpPAeo9aVq0UU4wAP9D8kJbrDp8zcvCGnVD8bOq3m6c/jAfVnQBjODJQNN3tktDZ4tK7 CVNIQwoOOjD2RKXyVNH4Gew3z6Wa5b3JORR3hnjVNqheYb2ePWIraYABrU1EoBMtcqAU YAIg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si18235125ple.311.2017.11.24.01.48.47; Fri, 24 Nov 2017 01:48:58 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753498AbdKXJqs (ORCPT + 76 others); Fri, 24 Nov 2017 04:46:48 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60022 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753468AbdKXJqp (ORCPT ); Fri, 24 Nov 2017 04:46:45 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAO9kFCv046749 for ; Fri, 24 Nov 2017 04:46:45 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2eeex6p1wr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 24 Nov 2017 04:46:44 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 24 Nov 2017 09:46:42 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 24 Nov 2017 09:46:40 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAO9kevT41877504; Fri, 24 Nov 2017 09:46:40 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F77C52047; Fri, 24 Nov 2017 08:40:08 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id C140652045; Fri, 24 Nov 2017 08:40:07 +0000 (GMT) From: Thomas Richter To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, Thomas Richter Subject: [PATCH] perf annotate: Fix unnecessary memory allocation for s390x Date: Fri, 24 Nov 2017 10:46:37 +0100 X-Mailer: git-send-email 2.13.5 X-TM-AS-GCONF: 00 x-cbid: 17112409-0040-0000-0000-000004122461 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17112409-0041-0000-0000-000020B4F88E Message-Id: <20171124094637.55558-1-tmricht@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-24_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711240132 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- tools/perf/arch/s390/annotate/instructions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c index c9a81673e8aa..89f0b6c00e3f 100644 --- 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_ins_ops(struct arch *arch, const char *na 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; } -- 2.13.4 From 1586057420373603096@xxx Wed Dec 06 17:43:46 +0000 2017 X-GM-THRID: 1586056205743843150 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread