Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1083706ybl; Wed, 14 Aug 2019 10:25:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHkkjq3Gjct9d//EgKdO1MROGXA0fOSRiVkQCLkaItKRWb2YZ3fYwrWD3UqyVhHutM77Im X-Received: by 2002:a17:90a:9f4a:: with SMTP id q10mr759359pjv.95.1565803550384; Wed, 14 Aug 2019 10:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803550; cv=none; d=google.com; s=arc-20160816; b=ftHMNY9+XEh+AAz0g3xlI6JsL8YIYNuoWQoS7cLzFv6AlVECzR02yaK1wbUx4B85CU 4Zxt2Np2nKoEzk3fW2Dq25o4RQ+LjI8Ys8R4sXYWQTn/78Xro3+wzvl2PDS72QDRl416 80tJsJLLdLdC82toCNekrvceI+cFjyUyaKqCzGMl9hgsbhb7daLDu4tb4//cKWtXY5U+ H9WU+7FVFY7rw2/ilvD3ohGgOlzhKOkMvUv9VOEFHfKn83eODMcxydJsjbNQvfpX+kIP NCnOlfIoKjf1ww/LXHUl0+15QcAQcAzFPXW4nG+NXm4vlGhsYkL+z7ddU5gP3SCTczo4 E/JQ== 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=PcZ+kbDHUuddIj5GSyHvDEqEpSH6ObXwSz3pScl36ZI=; b=hb6+8nTwt6pOr0kPvlfq9NykqTZ021QQWfpFGBNnjwzeooCe2L00QSoBBMBB1BYN/K NwpNWL07y82PvVqdZmWSLkJJ7aaX+8crIBNS+iRxjyQF+Z2h9eCYAbaIRiigxSPGeWrQ 2FDuFRG23ik2c5psqtsUW2JfgJtz4zNn+AVlJ3GNO052fVl+sOjZkZYXaVDxQWbnTIVv W+li5vAEgJ1s7MCevsfy3nxhUydQ6Cdv+Qndylh7qznZAaMhITG3m/nuHgapSa41g2Fy FX8ZVbmNnvhqt5FubrhLkvDwTrSOnba4NGvvuauhAfE1XcTqT1LQNsXHBt4fJOuonSk2 XIhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fb6yirfC; 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 l70si196632pge.446.2019.08.14.10.25.26; Wed, 14 Aug 2019 10:25:50 -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=fb6yirfC; 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 S1728713AbfHNRGH (ORCPT + 99 others); Wed, 14 Aug 2019 13:06:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:55052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729570AbfHNRGB (ORCPT ); Wed, 14 Aug 2019 13:06:01 -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 788C72084D; Wed, 14 Aug 2019 17:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802361; bh=oIeCDuvDRbqdjwaCtctjHfWzO8SZ0NiKDhUZU+tEvrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fb6yirfCrZsZxnTdd3DITKM8hWUporenkR6h4CWXfRN5z0PWbdHfTVgJDw0O0MR0g 5K6UYabM/9prQRUDFEgUFyhR8Yt2Yjupsyg4sX4GlRxt/q7ahhzVQH9MQtD/LJuY/h b/KxZ+bgZ1K5Iw9vQcgy4eW9rNS9FBmz4S5R8s3w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Denis Bakhvalov , Andi Kleen , Jiri Olsa , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.2 096/144] perf script: Fix off by one in brstackinsn IPC computation Date: Wed, 14 Aug 2019 19:00:52 +0200 Message-Id: <20190814165803.898702921@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 dde4e732a5b02fa5599c2c0e6c48a0c11789afc4 ] When we hit the end of a program block, need to count the last instruction too for the IPC computation. This caused large errors for small blocks. % perf script -b ls / > /dev/null Before: % perf script -F +brstackinsn --xed ... 00007f94c9ac70d8 jz 0x7f94c9ac70e3 # PRED 3 cycles [36] 4.33 IPC 00007f94c9ac70e3 testb $0x20, 0x31d(%rbx) 00007f94c9ac70ea jnz 0x7f94c9ac70b0 00007f94c9ac70ec testb $0x8, 0x205ad(%rip) 00007f94c9ac70f3 jz 0x7f94c9ac6ff0 # PRED 1 cycles [37] 3.00 IPC After: % perf script -F +brstackinsn --xed ... 00007f94c9ac70d8 jz 0x7f94c9ac70e3 # PRED 3 cycles [15] 4.67 IPC 00007f94c9ac70e3 testb $0x20, 0x31d(%rbx) 00007f94c9ac70ea jnz 0x7f94c9ac70b0 00007f94c9ac70ec testb $0x8, 0x205ad(%rip) 00007f94c9ac70f3 jz 0x7f94c9ac6ff0 # PRED 1 cycles [16] 4.00 IPC Suggested-by: Denis Bakhvalov Signed-off-by: Andi Kleen Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190711181922.18765-2-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/builtin-script.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index d089eb706d188..4380474c8c35a 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1057,7 +1057,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample, printed += ip__fprintf_sym(ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp); if (ip == end) { - printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, insn, fp, + printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, ++insn, fp, &total_cycles); if (PRINT_FIELD(SRCCODE)) printed += print_srccode(thread, x.cpumode, ip); -- 2.20.1