Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3358688rdb; Wed, 13 Sep 2023 09:35:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMBki9b5B1JI43CJM3mUN3khr+kHF72U34S7hEdNXoDcGKUU9hE+7qmLggYP3OILg1gGXr X-Received: by 2002:a17:902:f805:b0:1bd:a22a:d40a with SMTP id ix5-20020a170902f80500b001bda22ad40amr2710379plb.2.1694622935445; Wed, 13 Sep 2023 09:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694622935; cv=none; d=google.com; s=arc-20160816; b=xg7lCELhPThioEXjAeRcGwcbt0MNmXVisOGu0MgfHzV/ECs+B7LLSuKJWVzIXcpT07 Mkc3LoR0kYRt6hCsbf9cJwdZY3I/28hsW6magD8idg17xaTI6eCMVLnCTofCtImQTGzD FUnF+oYgnUYCOusdy6ht1E9QCNgvc80kAISf3fOxGkCjSj8mt+KuqNiyCAmKD+xGH8db HoGRzXMa8CB+th0p5LnqVenFU3QzHFyxkYlRtRsPoXsqpb9674pMb73AFr/3gpcsRs5Y r5prlhPep3+YCkJLATemB1cDo/0g98Gr5bgDwBH+4VMadM+GwUk1o4f27s72uh3sMkie Ci+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=x3ECGprZP4G16RGe+qK7GG+eKrejw2q8snMfK2wTP5I=; fh=6SbQdGqnUmnsP0clJa+9fHug/yXLV93Cr0nzffazulA=; b=pP+N8O81yYwJjWPz09AnQxPz0Y2xG3ixwBL5x9F+u9sasnxJ36YIqlT+QqKqideavA 5xX1AubaVWs7emy4ROFQt7d9Tp8ScJAMAPSAl3LdXGdytFyqLuIFoF4ylqWhGMZDoQE+ ZXr/4rYQ0zWa+b/d2S3ifwmtLSDmD8KPrd7PZ+UmnO83PjvnGn1iY3arFmCv2mghd61W 4PHdt9BQg2ECWZ1vVYTxxY/6TTso/Sb23sPVPiJm7OoqaSoz9BT+KJVOykh28CmhdsyR Y+OOStYX3FpXLAsw13C6StX76RrLG4eH4V0sIIinJmFjaNW/Mx4dB1aBukDxMh8lumxs nL3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id jx8-20020a170903138800b001bf5f853a86si10085533plb.647.2023.09.13.09.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:35:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 70C0680EBC86; Wed, 13 Sep 2023 09:24:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229794AbjIMQYR (ORCPT + 99 others); Wed, 13 Sep 2023 12:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjIMQYQ (ORCPT ); Wed, 13 Sep 2023 12:24:16 -0400 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A381CB7; Wed, 13 Sep 2023 09:24:11 -0700 (PDT) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2bcfdadd149so122280831fa.0; Wed, 13 Sep 2023 09:24:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694622250; x=1695227050; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=x3ECGprZP4G16RGe+qK7GG+eKrejw2q8snMfK2wTP5I=; b=QeMMBU+S4obMebTMJcHgvMXpBsmJZ1tucPtQgFbL/NPKIRrpPYCW95ah7EJvG4y4Pt 7PggYk5nH6ZIObBljKsK449/+pD5981WVbVEaXUmvHveK9lpUOB/shHMThC/kttQgtSZ CHZzCUBvHKJ7W4Ytpgt2+GnwrYRcnBzEtwCTuRe5jIH0FwwQnvF2gJ1SROGLDrdhG/Km 3LnBFN9FpGqpU/PWa2cHU+8tP/BN9lfUNYLHDCXp1w2mnS0BocvHCZkUJMewwViFcIiG gkNdeaB9B79rsZ3TZkGaXLNdU7tM8Ai15YgoTqSCPVaHeSrT88hiw+hkZWdJL0CNNdli nbNA== X-Gm-Message-State: AOJu0YzKZuUkHY0r0oam5c55+t1NBsPArGFpvuyf6PgBx0NVrjYkFCdk 3r7/DRAHQRt2sblTqcjBXp0= X-Received: by 2002:a05:651c:451:b0:2bc:b8f5:aaf1 with SMTP id g17-20020a05651c045100b002bcb8f5aaf1mr2578881ljg.35.1694622249757; Wed, 13 Sep 2023 09:24:09 -0700 (PDT) Received: from gmail.com (fwdproxy-cln-112.fbsv.net. [2a03:2880:31ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id kj13-20020a170907764d00b009a1b857e3a5sm8630869ejc.54.2023.09.13.09.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:24:09 -0700 (PDT) Date: Wed, 13 Sep 2023 09:24:07 -0700 From: Breno Leitao To: Peter Zijlstra Cc: 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" , Sandipan Das , leit@fb.com, dcostantino@meta.com, "open list:PERFORMANCE EVENTS SUBSYSTEM" , "open list:PERFORMANCE EVENTS SUBSYSTEM" , Jirka Hladky Subject: Re: [PATCH] perf/x86/amd: Do not WARN on every IRQ Message-ID: References: <20230616115316.3652155-1-leitao@debian.org> <20230616132954.GG4253@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230616132954.GG4253@hirez.programming.kicks-ass.net> 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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:24:16 -0700 (PDT) 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.