Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2674853pxa; Mon, 17 Aug 2020 16:16:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4OX0Tv9FTvAdWQd8ZS+jsSsTu+OcA9k86Oj0CyoMbFiEs3CENDy5LHhvmIfETMHqG+dET X-Received: by 2002:a17:906:1396:: with SMTP id f22mr17019089ejc.227.1597706166941; Mon, 17 Aug 2020 16:16:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1597706166; cv=pass; d=google.com; s=arc-20160816; b=YeY6EyGTcPOElqMCsKAZJZGZGogThq7KgmSdm0puIPcbXk88TymUY1rKAeMgpLkF2Q WHBhBed/ov5oWDeu+j9jAKcBzS+e/833OywWbouf5hSLzO+3GB8DXykjOpdyRzOwiW4w libjWNOOdN+j+BQD5SqRXiPqkLbB2/B48VuF+3YKPGDKciHqpF+jHJ6zdYW7tBwcaHT+ gGTMoUMUj0CqXyLy8JGZxMrAviQFeD+LpeZiZtC0bRmaTFxdrGvOgALG8muuezbp4ie4 U5E48mSxZ6nRbOfSU+lCWLu5QGVKV9U+rAH9xOhYdOguDgk9mYlN+ol7p6Q8qZF0iZ0h g0BA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hnEj/O8CSdwM2zZoXD++68K0jVVhG2Uo4qgTREfzwAg=; b=ykne5mWeXzPHRnnnYtw2zL482DM2r9My1rsnRr+R/+A0wQGq08R7yNMaaZG74Aucv8 06swZAteVYCtTXD7ynM1Pyfals7Q6i2L+MCU8oK7xRuD86b6tq0RhLK5I9GAC0r1hiLh a7BKH9uunzkheG7VCIcgIRiO0HghK0EBBPt8V6lG04Trrod9/6Oo8s0IHOzUNgNLHru6 pRd7z0VU7jEZtJFUSPbFutEBxzY8cDy8Iy10n6YbU0L1rU2kWah5Nz0KGRvjj9A9ylZ8 0+mxqlILlE6VkzASDDXaYIBbTc03V5FzvLpIPDzb9S0nrPzhNXS+gDh3fG1W38DSpn8Y N3bw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=dWd51KCl; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk14si12093271edb.61.2020.08.17.16.15.43; Mon, 17 Aug 2020 16:16:06 -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=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=dWd51KCl; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729907AbgHQWHm (ORCPT + 99 others); Mon, 17 Aug 2020 18:07:42 -0400 Received: from mail-eopbgr690087.outbound.protection.outlook.com ([40.107.69.87]:27081 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729822AbgHQWHj (ORCPT ); Mon, 17 Aug 2020 18:07:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FuQNlg3plPVIBP1oPdQuJc4pk6V52vw7MY289C/LJCwclqO5RUeOK8kpSptzCXYjvBEx6BEY8Wp9XtsQtI/tYhiEiIpr7LP3FlFbRPs7lbxTb6uztkyTD9whQwx1RPqgh1lO2YY3Lc+4M/rDOW/Dg8a5cLSJ4s2ob2zaV579rrBzoPspYd1qRt16fGYjTY2mI4WpFc4nKWkLsnZ7qxQxsdl7+Izk9W8DxZ6jsSAiJ5CWl6Gk9SaP7MTphI1pjVBOuZKAXVdIzl9bfpFqwcWD4ZVELN3RUQDfuetaSYC48qtRJhLAlxmCs4UzG3NVGTtYzPRcvB7TRVm4q+Ie+XdPFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hnEj/O8CSdwM2zZoXD++68K0jVVhG2Uo4qgTREfzwAg=; b=UIsnrAW0I+1GgZQ7VESTofZRNb5k6xz5a5/tS+UwZhkXNP+zbjcSdPtqmDpI0ykzT924ieCpz5XU/sr3GKM/0ZHNzkPIy9VXiGJASJRqPf5bVOftynISs1F/DdVV4jGOUCQQmJq4n0gV64nG5dhB3ajTxl1Xv7RPMxuytncqo9Nqa29lZxlxZcVzpSYfEptGugjurg8uZ3AuYWf0hVOrnOkbv0k6E8BLb2CI426pDLFIUSCVG8vz0C5+hQ/oQaxJzASkBvzKhu+zyL1Tk5NlSUFKdE7H/36bmMi7XtWE/llj8uHuH+EtgZGJYFO+KjQeiN1UM5fcPsc67rIWmxj46w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hnEj/O8CSdwM2zZoXD++68K0jVVhG2Uo4qgTREfzwAg=; b=dWd51KClfexS1bOiaxAq63QfHHDgeoV0sWtu/uaPld9ofpWZjqu4H7mYa8Kw560O8UdkY9CtZ0fn9ajCmK4E4GpqzeyMMyINVEHQXq/cNyv76zzX8EBFZUrAtD9JcMBqxrmu8RdhZg3r9SQxKwMx0JFfgoVhMST67dO3QPi1mGI= Authentication-Results: infradead.org; dkim=none (message not signed) header.d=none;infradead.org; dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB2946.namprd12.prod.outlook.com (2603:10b6:408:9d::13) by BN6PR12MB1652.namprd12.prod.outlook.com (2603:10b6:405:6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.22; Mon, 17 Aug 2020 22:07:30 +0000 Received: from BN8PR12MB2946.namprd12.prod.outlook.com ([fe80::ac22:9457:4d25:5ff0]) by BN8PR12MB2946.namprd12.prod.outlook.com ([fe80::ac22:9457:4d25:5ff0%5]) with mapi id 15.20.3283.024; Mon, 17 Aug 2020 22:07:30 +0000 From: Kim Phillips To: Peter Zijlstra , Ingo Molnar , Ingo Molnar , Thomas Gleixner , Borislav Petkov , Kim Phillips Cc: Stephane Eranian , Stephane Eranian , Alexander Shishkin , Arnaldo Carvalho de Melo , "H. Peter Anvin" , Jiri Olsa , Mark Rutland , Michael Petlan , Namhyung Kim , LKML , x86 , stable@vger.kernel.org Subject: [PATCH 5/7] perf/x86/amd/ibs: Fix raw sample data accumulation Date: Mon, 17 Aug 2020 17:06:26 -0500 Message-Id: <20200817220628.7604-5-kim.phillips@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200817220628.7604-1-kim.phillips@amd.com> References: <20200817220628.7604-1-kim.phillips@amd.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SA0PR11CA0014.namprd11.prod.outlook.com (2603:10b6:806:d3::19) To BN8PR12MB2946.namprd12.prod.outlook.com (2603:10b6:408:9d::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (70.114.200.6) by SA0PR11CA0014.namprd11.prod.outlook.com (2603:10b6:806:d3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.20 via Frontend Transport; Mon, 17 Aug 2020 22:07:28 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [70.114.200.6] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9ccdde95-f71d-467c-da5a-08d842f9ef0e X-MS-TrafficTypeDiagnostic: BN6PR12MB1652: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LKQ1grIbGP3/BkfRnW9e+Zsc2Tz6zTironKY1wxO432BZ96F8+UYCJHuxbGg3/SNXTOLxQC1mrXjB9SntZ9lVhgC0lTK+1+1k2kUmQRwKJXSEpemw9M1pNVX9Kw1cXVdLIkeshx2oiFeRTNw/Jtsazn96DpkLnXE4KTQFqeMKCUaCc4oFlz3xmIDj2Hs75O6bbreF8vUBRijzFjHHkuNo7pkdnNku8s9UUbe14czBRT9/AN0+MzvMoY1/C+aHEoBhSW2cF1W9+SR3drF0HB1zDavPLmtBCivCJ0Vp67xBr8Yay8LRAeev+qmUQB35xluVEG1jOsmfAJ1UVodsv8PFbdg1W/MWUdtjeG0/Rcgmcd688V9224AvSIJlw256xUw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB2946.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(346002)(376002)(396003)(366004)(136003)(110136005)(86362001)(6506007)(4326008)(956004)(16526019)(36756003)(44832011)(2616005)(5660300002)(186003)(83380400001)(7049001)(66946007)(7416002)(2906002)(6486002)(6512007)(8936002)(52116002)(69590400007)(66556008)(54906003)(66476007)(316002)(1076003)(478600001)(26005)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: BX2xXOMkUvDvn0XTytPFdvgrP/GXwstfgCIe5pcqpvfYiqLMLled75w0hVzn+YoVW7oyUUcluz7rhOkIOE2l2rUfbKlblp0bBrM1wYDcJbxUtAP/UXa3Jp7NKotrrT4mAXc9u5/hD4c6K8qGlZr3aoUR91a6ZMTj1ZnJVZITOgfuu6lrkV5F5SGYLl6wGmGB17Z5s5BSHTwpdqLxu7stygzxuJbs7qv8WqCo4m7uIkR9r/jtrxCCYNQtXhBN9Vs+JV5iZ8R0LEtYs8uqsGJZpfvKqmqL3HxOgA4YSG0gPcvXyUqOJYf3Xe5WWRA8sicM/BSdzIT6Rcom3RRW5T4XMYWTsD1a9pKfIYixBJG5snrvWcLHFBI9tbueWik0lEP8sMEeW8HwM42hAWvZEq8PYFiFZ3n5RKconNbhZuEIvzW9zzv/JnKo7YznDavfNvdUl0nmByHq8EpeYa6DjpByNblvmUPYYtH6MpZPAHwjelQboQFtksUzq0fgM9a4hlPaf5NxrMtb8rVhVxnU7clr8u3c2JOE6QLk36OkwD3am3oUnJWpPvEz2czKKUTN3HE+OBuaugMl0eCQva8OHd8B+aU4DhOFB9Alhm5ff6JHWHVPebmqHgZ2snfZimds0cHf/Q8b6AcR7x3bID4qfoNdMA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ccdde95-f71d-467c-da5a-08d842f9ef0e X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB2946.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2020 22:07:29.9612 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BSjQAD9SpPemP6Jzzfy3gBoVnB2JsHIyRn/PKehojUf8mc9idrVRHtikDhRu7Pq0+fNdUbbgmHbLF+1sSYOc5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1652 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Neither IbsBrTarget nor OPDATA4 are populated in IBS Fetch mode. Don't accumulate them into raw sample user data in that case. Also, in Fetch mode, add saving the IBS Fetch Control Extended MSR. Technically, there is an ABI change here with respect to the IBS raw sample data format. I don't see any perf driver version information being included in perf.data file headers, but, existing users can detect whether the size of the sample record has reduced by 8 bytes to determine whether the IBS driver has this fix. Reported-by: Stephane Eranian Signed-off-by: Kim Phillips Fixes: 904cb3677f3a ("perf/x86/amd/ibs: Update IBS MSRs and feature definitions") Cc: Stephane Eranian Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Borislav Petkov Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: "H. Peter Anvin" Cc: Jiri Olsa Cc: Mark Rutland Cc: Michael Petlan Cc: Namhyung Kim Cc: LKML Cc: x86 Cc: stable@vger.kernel.org --- arch/x86/events/amd/ibs.c | 26 ++++++++++++++++---------- arch/x86/include/asm/msr-index.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index ffeb24d31c3d..609ae7d165c1 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -637,18 +637,24 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs) perf_ibs->offset_max, offset + 1); } while (offset < offset_max); + /* + * Read IbsBrTarget, IbsOpData4, and IbsExtdCtl separately + * depending on their availability. + * Can't add to offset_max as they are staggered + */ if (event->attr.sample_type & PERF_SAMPLE_RAW) { - /* - * Read IbsBrTarget and IbsOpData4 separately - * depending on their availability. - * Can't add to offset_max as they are staggered - */ - if (ibs_caps & IBS_CAPS_BRNTRGT) { - rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++); - size++; + if (perf_ibs == &perf_ibs_op) { + if (ibs_caps & IBS_CAPS_BRNTRGT) { + rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++); + size++; + } + if (ibs_caps & IBS_CAPS_OPDATA4) { + rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++); + size++; + } } - if (ibs_caps & IBS_CAPS_OPDATA4) { - rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++); + if (perf_ibs == &perf_ibs_fetch && (ibs_caps & IBS_CAPS_FETCHCTLEXTD)) { + rdmsrl(MSR_AMD64_ICIBSEXTDCTL, *buf++); size++; } } diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 2859ee4f39a8..b08c8a2afc0e 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -464,6 +464,7 @@ #define MSR_AMD64_IBSOP_REG_MASK ((1UL<