Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2724865pxj; Mon, 31 May 2021 09:09:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAP4cGsBZ3+ugjQ7c4/Utlj3sZ7GruFw/sljLHhC4SrdjIKTbKwKV5AVRvxG+551pbhZM6 X-Received: by 2002:a05:6402:44:: with SMTP id f4mr26449626edu.364.1622477388662; Mon, 31 May 2021 09:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622477388; cv=none; d=google.com; s=arc-20160816; b=DVmUelIqH5DX0YigrkLIBg9xNJNW5/CHMPvJUd6qtOpLpwvrtfvnSYxWEfv7nxWrJ8 X+A5rVOJY8rIl3u7yJLnfALnfDBNJGkfk5JWr2UXZmhHeDP1epVn+CmUPG9drTaMKRGp y+loX4CYLJrLAtefOsjtIq5LvhJex8EEDvfx+PVNrx/8/MmiLGO1Y7Opz2o8XD/fLOHV ZCDffMpiiB5/ELZf72TtAvRVLCbxJ3yIz4IkvAHoqWvqEs9j6mAKddnVKgKGkICOt+2P kECKNXVPhYI9YiOcV8/5ivj4BnIYpoq7OKv32MFfX61Ef/JIEjjnSEEyTY2tRZ7n4W4i 52Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=P9U++W55JwXVOhjEYSxjEhsFUHG06UgaIi/mJ/g4YX4=; b=ZHj+i3REYOnbaUHyn5PK+suVewD8mwK0ezGAknC9iybYUFwBr1jqi8eQ+9bpW2m3EK rZiFJoA855ePVY9sR4ILe4cFRk4mm6bOHPSWXV0FnOjZY6TDY9KpEkZ67+1R7ZUAs3XO FURVyCnTBN4vqy545PHE/CjkmzQB9wV7FO98aGSQHIB3U0svPKfAoiqxuOxGO1/+tYRD xl4rjG4wIKYOD79o/WhMenG36kiJ6RvfDWCY7Jcg5pfJc37Hy/53fxOYqc2fXyVBVptb 92YFKIQIl1GwJApCZNmq+IMoV1xE7oIhna/GdEQfokkTs8GggxgHOEJQi9e3FRAJV+Uj +ZmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KzuRsZzQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z25si6957895edq.402.2021.05.31.09.09.25; Mon, 31 May 2021 09:09:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KzuRsZzQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233478AbhEaQJG (ORCPT + 99 others); Mon, 31 May 2021 12:09:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:60154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233604AbhEaOgJ (ORCPT ); Mon, 31 May 2021 10:36:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 179966162F; Mon, 31 May 2021 13:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469078; bh=u4xqj8Zvvajo2QYdfEv5ehNR/i44+Ki388AIdQJcLXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KzuRsZzQ/166v+yu87yW/18KLzr7Lb6AhtTQ8iAld93BdLqC5dBh5GWcFtibmruUG 5un3SDZup7DwEJobUuROnVTvoG9m0GrcWTVHkWz4linSJBghhwFZEXgLgCP9b2xNW+ k7xkCbRm46Uy5CvkT9bW/BEc4nVVFMs4AR8qAGqs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Andi Kleen , Jiri Olsa , Arnaldo Carvalho de Melo Subject: [PATCH 5.12 026/296] perf intel-pt: Fix transaction abort handling Date: Mon, 31 May 2021 15:11:21 +0200 Message-Id: <20210531130704.656640384@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adrian Hunter commit cb7987837c31b217b28089bbc78922d5c9187869 upstream. When adding support for power events, some handling of FUP packets was unified. That resulted in breaking reporting of TSX aborts, by not considering the associated TIP packet. Fix that. Example: A machine that supports TSX is required. It will have flag "rtm". Kernel parameter tsx=on may be required. # for w in `cat /proc/cpuinfo | grep -m1 flags `;do echo $w | grep rtm ; done rtm Test program: #include #include int main() { int x = 0; if (_xbegin() == _XBEGIN_STARTED) { x = 1; _xabort(1); } else { printf("x = %d\n", x); } return 0; } Compile with -mrtm i.e. gcc -Wall -Wextra -mrtm xabort.c -o xabort Record: perf record -e intel_pt/cyc/u --filter 'filter main @ ./xabort' ./xabort Before: # perf script --itrace=be -F+flags,+addr,-period,-event --ns xabort 1478 [007] 92161.431348552: tr strt 0 [unknown] ([unknown]) => 400b6d main+0x0 (/root/xabort) xabort 1478 [007] 92161.431348624: jmp 400b96 main+0x29 (/root/xabort) => 400bae main+0x41 (/root/xabort) xabort 1478 [007] 92161.431348624: return 400bb4 main+0x47 (/root/xabort) => 400b87 main+0x1a (/root/xabort) xabort 1478 [007] 92161.431348637: jcc 400b8a main+0x1d (/root/xabort) => 400b98 main+0x2b (/root/xabort) xabort 1478 [007] 92161.431348644: tr end call 400ba9 main+0x3c (/root/xabort) => 40f690 printf+0x0 (/root/xabort) xabort 1478 [007] 92161.431360859: tr strt 0 [unknown] ([unknown]) => 400bae main+0x41 (/root/xabort) xabort 1478 [007] 92161.431360882: tr end return 400bb4 main+0x47 (/root/xabort) => 401139 __libc_start_main+0x309 (/root/xabort) After: # perf script --itrace=be -F+flags,+addr,-period,-event --ns xabort 1478 [007] 92161.431348552: tr strt 0 [unknown] ([unknown]) => 400b6d main+0x0 (/root/xabort) xabort 1478 [007] 92161.431348624: tx abrt 400b93 main+0x26 (/root/xabort) => 400b87 main+0x1a (/root/xabort) xabort 1478 [007] 92161.431348637: jcc 400b8a main+0x1d (/root/xabort) => 400b98 main+0x2b (/root/xabort) xabort 1478 [007] 92161.431348644: tr end call 400ba9 main+0x3c (/root/xabort) => 40f690 printf+0x0 (/root/xabort) xabort 1478 [007] 92161.431360859: tr strt 0 [unknown] ([unknown]) => 400bae main+0x41 (/root/xabort) xabort 1478 [007] 92161.431360882: tr end return 400bb4 main+0x47 (/root/xabort) => 401139 __libc_start_main+0x309 (/root/xabort) Fixes: a472e65fc490a ("perf intel-pt: Add decoder support for ptwrite and power event packets") Signed-off-by: Adrian Hunter Cc: Andi Kleen Cc: Jiri Olsa Cc: stable@vger.kernel.org Link: http://lore.kernel.org/lkml/20210519074515.9262-2-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c @@ -1146,6 +1146,8 @@ static bool intel_pt_fup_event(struct in decoder->set_fup_tx_flags = false; decoder->tx_flags = decoder->fup_tx_flags; decoder->state.type = INTEL_PT_TRANSACTION; + if (decoder->fup_tx_flags & INTEL_PT_ABORT_TX) + decoder->state.type |= INTEL_PT_BRANCH; decoder->state.from_ip = decoder->ip; decoder->state.to_ip = 0; decoder->state.flags = decoder->fup_tx_flags; @@ -1220,8 +1222,10 @@ static int intel_pt_walk_fup(struct inte return 0; if (err == -EAGAIN || intel_pt_fup_with_nlip(decoder, &intel_pt_insn, ip, err)) { + bool no_tip = decoder->pkt_state != INTEL_PT_STATE_FUP; + decoder->pkt_state = INTEL_PT_STATE_IN_SYNC; - if (intel_pt_fup_event(decoder)) + if (intel_pt_fup_event(decoder) && no_tip) return 0; return -EAGAIN; }