Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3776056rdb; Thu, 14 Sep 2023 02:08:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4WcIDgpCGBoLao1M27Zr2n4UJn4vRlYnJPO5nXC1pcYxzWpd0j3bSHfcAsVd59KAzNz50 X-Received: by 2002:a05:6a00:168a:b0:68f:b3ed:7d4d with SMTP id k10-20020a056a00168a00b0068fb3ed7d4dmr5914549pfc.15.1694682520151; Thu, 14 Sep 2023 02:08:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694682520; cv=pass; d=google.com; s=arc-20160816; b=s6zJy8IN6utS62Sxo69JG8UsisbEjb4lUrENLRu43zEd60UGZOYBhzYZ6Byd1BGCGA WN8405zlGBCZOmiDptC8o2tZ3esPuweJ9SYW0HuDobDe9DOVYVBOCdcqF0V+K0NnhHX/ 2L8Zs2sGb4slAB8769Th2m7dWt4tB3Zk/SUv9N98AeOzXG9NrIuGFG2nis8Ukoh/fWDh ZCCQsT/EEXv7Ib7E53zZvecQ6GZR5TNixEUB4W88WoR02f05/PVjArTWVaGlEw1/8PW2 w/o19LcZJNLGHt0CzhBFpg6vlcOqIDhj9pSCZx+iEITPteLiTf2jqkhnl1T+A6SvwvMm T0Hw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=gZ12PAz8npyD5wFTFC9pFjfNn7tQSQRaCybCWgYa9R0=; fh=QVBlywePTT8Di6oaVRXgTbRKtuU5/TxZ+fU08IcXJn4=; b=vUiAp7V7vaw9Rehj6i6uhpA+J1fcgUh0idtzf8M1O4mfaVLzPVzaiVYwa4uNNp9bFp cq+/YkuRQcgcVKoo21Pn4ZAXEwT+lIeI5sIcLzhzEoRZ5PrlvRryYGW97KOVh2k0sSuJ V/NlOLCp0dfcj/bSbWbXbAx6nK9VWqPA7Q1wXx5SQee5UIx6Ncm7Vbg1gkEaT50f87KC 0gZDUZjme3nofgS2sH5yX0FRk0pvar6NawEydyyNyb9HXW+nUBqjgyGQhvvGVx75pSaz 7fY5XAyAynWesQuYFVgDUXQFrJYgpBjIGi+bykVdT8HFMwsOSuwO1ulYMt3O3KYicw7k eWvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=AdAZmBNT; 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 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ay26-20020a056a00301a00b0068a55cc9a10si1213714pfb.381.2023.09.14.02.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 02:08:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=AdAZmBNT; 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 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E4E2C81DDE58; Thu, 14 Sep 2023 01:56:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236116AbjINI4b (ORCPT + 99 others); Thu, 14 Sep 2023 04:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236717AbjINI4L (ORCPT ); Thu, 14 Sep 2023 04:56:11 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2045.outbound.protection.outlook.com [40.107.244.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B298A1FF1; Thu, 14 Sep 2023 01:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lhvQ+qTcXEXkGcOkVDmi2fb5FRVWTrqAkZCkVh6YETkdBVvbbLobbDZKm69IDBh+QRYI5kvO+oDozq7o11RsLCHW3Oe7g8VR5sbEXGPzXb8d0eujv0CIWbEUpO/hliMRKewiQqQC5Pzqtuc+DRjN/VAwVzzSy9Jgdvv6tqJ+z/KAcA/oaXgiiI76NyHXZdsJfJ5asU7x5+e5ocnJicJOcsU7wXyyaFStDYhgIk1JEPSsTIOid6bRYweChqkCawva/2ujskFroWTYPpdneALCphfvsRKpVCeVshYqTm27HfK4Gf2nNPmv0y/MKcqn0jfrYjVa9wkyL6AU9PQxtifeVw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gZ12PAz8npyD5wFTFC9pFjfNn7tQSQRaCybCWgYa9R0=; b=FRkAlLgSwb/gnrxfe7Fc2//vP3rXQOr++gkqRysUDRaMzy5jIYiJyad9/8M70S7i3Asg0UcJaySFBW0Vv6YOiTmlKd7WpNpbB0sgzy387/hObyaRs1OsVPBldGHkYj+ad06Dyl6kiTXX7rrlFKotkdaPuVYJRMTGnCKQjs8ts5/evXuads9ftE7GWJJyQZzU8OvdH8s4SYtBlR/ZtG5DcdCaZiHv/oI3XHwhE3UM6F3Ug1CArsH6SLTMN/1dwRUJHh/BGgawBNfBBvuIKmRv0+kgxAL1nQpwF1sBrsiHjSfS7yMeAYWS0T2/JhJdUrmdIBlc8W9RComoW/aeU85IqQ== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gZ12PAz8npyD5wFTFC9pFjfNn7tQSQRaCybCWgYa9R0=; b=AdAZmBNTDMetxlcIU8rHqZHr5593g6gARAWAqaNv40D2R6d70bgdNa2MkaPjGQ9AnQ1OWNIO0enucyiR7SZtjWQ2rQQwALwyRaQbD6AKqP/No7Lo/OrtJgtY/NQzU1VblprGhI0lHb1qdfZFb8m/G+o11Ivx2ym513O8fxp1hRw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) by SA1PR12MB6945.namprd12.prod.outlook.com (2603:10b6:806:24c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Thu, 14 Sep 2023 08:55:50 +0000 Received: from PH7PR12MB5712.namprd12.prod.outlook.com ([fe80::a285:eb6e:8fc:7cd7]) by PH7PR12MB5712.namprd12.prod.outlook.com ([fe80::a285:eb6e:8fc:7cd7%4]) with mapi id 15.20.6745.035; Thu, 14 Sep 2023 08:55:50 +0000 Message-ID: Date: Thu, 14 Sep 2023 14:25:40 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] perf/x86/amd: Do not WARN on every IRQ Content-Language: en-US To: Jirka Hladky , Breno Leitao Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , leit@fb.com, dcostantino@meta.com, "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:PERFORMANCE EVENTS SUBSYSTEM" References: <20230616115316.3652155-1-leitao@debian.org> <20230616132954.GG4253@hirez.programming.kicks-ass.net> From: Sandipan Das In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PN2PR01CA0105.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:27::20) To PH7PR12MB5712.namprd12.prod.outlook.com (2603:10b6:510:1e3::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB5712:EE_|SA1PR12MB6945:EE_ X-MS-Office365-Filtering-Correlation-Id: 26147481-9f41-4425-032c-08dbb50064bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JQr8MVu2udN2qEMCZAXB1+7tAJDQx7T2Kq1J8rvYs471ZvW9PCSt4GDp4mzPKgtp/hLx28HlTEzeg9+0Q95SPgSvMil/opK4F3NswdXV9BJ1bPJjHh0F4jME/mLuOtCnoV0qZ/QkxVwa+VsRiQ2Za8g0337VX2b7O+nQsn+35CxCj0wEOWmqhycqWW8qItW4M20mzEXXXNjy7zZ/Rtb5Vr59hyzGLVPDcx4VMQQijFHb0uTw1xXrgvwNhrceQyZoZ/w/E58Vx9KCFO69mD2Z6czyiCkKnuBfwzhbEQY8YkkSzYJn5eVoPUxmhx+1Q0QA3+FBUIe7EtEHf6wDkI9ujX9gbtgYtU/RzHNv0Dp73LSlTF1dD0jFUOyBzeBvB7AgIy8eDTG0VejYSSYKIYSioN6E5uDu9uOpURk8DkJ5HPA9Oq2nh7DkY5XYI7wmhsEYbDqC+aX8uU0ucRWcHfnluvv2VIpTAAi/MC/zgpB4jqPbleygZHmXoPT17bIfy07cBTwYuXwLmL4yAR3Uus3ZrnFPN/whOOyC4IBZOScQ/vKCNMeIqnoZlupJZPTzS0Ej21Wygq0JdJfOhVwmhn+vWpY7ynvIfBoR3/y9HMyxqhUIg3WPZCOIIpp29JXeNP9gVQVfFvoc9ZJJN2CCXXuaeg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB5712.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(366004)(39860400002)(376002)(396003)(186009)(1800799009)(451199024)(6666004)(6512007)(53546011)(6506007)(2616005)(6486002)(26005)(8676002)(44832011)(7416002)(8936002)(5660300002)(4326008)(31696002)(2906002)(41300700001)(86362001)(110136005)(36756003)(66476007)(54906003)(316002)(66946007)(66556008)(38100700002)(478600001)(83380400001)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aFJrQU9ZT001VFhtQk5iVWtBc00wUjQzdTBJdFI0TXI2ZEV2MXBqNzBicDNX?= =?utf-8?B?OGlFYmpvNTRtcmYrUmlRc2lmNzNYLytRaHBzcnZ1aFZzUXhFdHFmUnhKY2Q1?= =?utf-8?B?M0drZnlENzRTTGNEODFlQmJ1a1hUVmVaUmJ6ZFJ1aXJuRWJWV2ZwRGwvZ0VD?= =?utf-8?B?NUIyT1RiaTQ0TFpqOHcycFBhMlNJNjlqT0k5cDFZTXk1MGVieFd2NnlhRVZk?= =?utf-8?B?VThhaVZ6bzY1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?= =?utf-8?B?RUdvRS82TytpMVVyYk84VVdpck1hZ1RaL2NkbkhVNzZEMjhkSi9kQ3FRcVNS?= =?utf-8?Q?GeyuOfm9kenSAtO1w0cTqmHXh?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26147481-9f41-4425-032c-08dbb50064bb X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB5712.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2023 08:55:50.0898 (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: g3HhdvEUADNXQesNPQR5AkSwV4ZeZNf3Se6gelZ+8l2TZ3Je1WivjxQMmAUvNKsZCTANKyakTCvH2W3AYrWIxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6945 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 01:56:35 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Hi Breno, Jirka, On 9/14/2023 2:15 PM, Jirka Hladky wrote: > Hi Breno, > > I'm definitively voting for using WARN_ON_ONCE - in the current > implementation, we are getting thousands of the same warnings and Call > Traces, causing the system to become unusable. > >> Anyway, please let me know whatever is your preferred way and I will submit a v2. > @Peter Zijlstra and @Sandipan - could you please comment on the > preferred implementation of the patch? > I agree with using WARN_ON_ONCE() to make this less intrusive. > > On Wed, Sep 13, 2023 at 6:24 PM Breno Leitao wrote: >> >> Hi Peter, >> >> On Fri, Jun 16, 2023 at 03:29:54PM +0200, Peter Zijlstra wrote: >>> On Fri, Jun 16, 2023 at 04:53:15AM -0700, Breno Leitao wrote: >>>> On some systems, the Performance Counter Global Status Register is >>>> coming with reserved bits set, which causes the system to be unusable >>>> if a simple `perf top` runs. The system hits the WARN() thousands times >>>> while perf runs. >>>> >>>> WARNING: CPU: 18 PID: 20608 at arch/x86/events/amd/core.c:944 amd_pmu_v2_handle_irq+0x1be/0x2b0 >>>> >>>> This happens because the "Performance Counter Global Status Register" >>>> (PerfCntGlobalStatus) MSR has bit 7 set. Bit 7 should be reserved according >>>> to the documentation (Figure 13-12 from "AMD64 Architecture Programmer’s >>>> Manual, Volume 2: System Programming, 24593"[1] >>> >>> Would it then not make more sense to mask out bit7 before: >>> >>> + status &= ~AMD_PMU_V2_GLOBAL_STATUS_RESERVED; >>> if (!status) >>> goto done; >> >> Instead of masking `status` against AMD_PMU_V2_GLOBAL_STATUS_RESERVED >> (AMD64_NUM_COUNTERS?), I opted for using the `amd_pmu_global_cntr_mask` >> global variable because it seems to represent what the loop below is >> iterating over: >> >> /* PMC Enable and Overflow bits for PerfCntrGlobal* registers */ >> static u64 amd_pmu_global_cntr_mask __read_mostly; >> >> Also, I think we want to WARN_ON_ONCE() if we see this problem. Right >> now, it warns at every time we call this function, which makes the >> machine unusable, but, warning it once could be helpful to figure out >> there is something wrong with the machine/firmware. >> >> Anyway, please let me know whatever is your preferred way and I will >> submit a v2. >> > >