From patchwork Wed Mar 22 09:14:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 73296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2242073wrt; Wed, 22 Mar 2023 02:25:48 -0700 (PDT) X-Google-Smtp-Source: AK7set/4tUKVK3GRzgfG+J3AZemkH0lEVSBdUo8/gjJ8QcQI4HPEJDGz33I2QWomZQhzmv2Yrz3d X-Received: by 2002:aa7:8f18:0:b0:627:effd:71ba with SMTP id x24-20020aa78f18000000b00627effd71bamr2432044pfr.6.1679477148362; Wed, 22 Mar 2023 02:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679477148; cv=none; d=google.com; s=arc-20160816; b=s6og0uc3BPmRJDg6re6r5+gS/Vi6C1RPT+cT6kvE2Dh63TEFNzr3uwIUowk/gapW35 68lAOomdqviEGHp4nXWODirOwgAgb+KvaxVo5ZT4+Wqp2K4anDw3qWLJHP3fj+9vbENs 6YphlbeyUNCn6iwfROicHUrTqgEZV0gikclmQlQ1vFjq5KHXYrmsi28UpfXbwykXY1aI P3CgCVDXYHjBPKNSxpnWXZ3k1qk48r6krEOgsmBHz/AskEUo/25rAt8c+kiLTOEUBhLL hbxba8Y2ub9H/3hktXg5fMfblzkGgyKKYsYI3ZHjFkE7m8JxaksA9+KMEIRU8yu9rn68 C+lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=txn/sef3d+aaQF756K6wwuxg+ReBrrWMtqngcq4ZKUE=; b=dQf2ITTEny9kOHtF/rOuM8YcIvv4gVEhBUB+J1XAnxXi3STztGPfxkw0o+TB55+1Yl Xx7vQWBopIP95NRFI/3f5U1phewUuvYg7alV4m73hRXyTwljZJE/PMYn+5HicvxV6cJ6 dZ1HQYWrXzgxgj7hJd2gxQjZ8YsXcZo3Wltq1dBt2tSLqEIoW1gCxnAVqzkbv2JOu1a9 gTS93aiYNCF5x9a+uvslcn+qSZm0FQKPH4GIt1hSB1BrFgWQaigeu5Rd5Ic6wXD0gLsN DXcmf4G1FN3w8f1wPxEJXQIJuxJk0yugvDtDr2xh4oPywI5sBfyfBFke6Q0pQJxUKfIs hoyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SDQq5OIT; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x184-20020a6286c1000000b005a8ec89de5fsi15344467pfd.236.2023.03.22.02.25.35; Wed, 22 Mar 2023 02:25:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SDQq5OIT; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbjCVJOq (ORCPT + 99 others); Wed, 22 Mar 2023 05:14:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230339AbjCVJOk (ORCPT ); Wed, 22 Mar 2023 05:14:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6656539CF0; Wed, 22 Mar 2023 02:14:38 -0700 (PDT) Date: Wed, 22 Mar 2023 09:14:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679476476; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=txn/sef3d+aaQF756K6wwuxg+ReBrrWMtqngcq4ZKUE=; b=SDQq5OIT47TVlv0jwhO16SAmHb7B6GONzm/sp+jALgyx5yqBoq0sU2kCXK+QL0/3u0tU9L ZNnnGwlEyDCOJKKgzAvrhd9DwLtOeUqmUBfGJDvlBDH8tNtWVrCQ/5aXrW5MtGLXhif2so 3uc5KM+BJNro9oZjXAX6ZEtceNRPntJ1L2uaO3pxdgom5YSPOAXB/pNPpKWYdL8msHRLhW XMVW8hsY51Czggg9alV3bBYQbqVgvFpmqM1fAV1P/P/rM1Y4h6brNeJ6JAjbkfaVz8TSWU 2o5CD8AXysZ9f30x36xgKOjtlEIhmSRcnTOQ5OAlL0Scl7fol/ucof08C3W3NQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679476476; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=txn/sef3d+aaQF756K6wwuxg+ReBrrWMtqngcq4ZKUE=; b=3b6J+8YhaUpgabyXgzhC2KogYb46vp40CEemQ2sIw4oRuLrK4vCxxGShpO2+Twg6GULAcI QGan9zfo+Ub+/ECg== From: "tip-bot2 for Breno Leitao" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf/x86/amd/core: Always clear status for idx Cc: Breno Leitao , "Peter Zijlstra (Intel)" , Sandipan Das , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230321113338.1669660-1-leitao@debian.org> References: <20230321113338.1669660-1-leitao@debian.org> MIME-Version: 1.0 Message-ID: <167947647626.5837.12912753854693037433.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761059430332401461?= X-GMAIL-MSGID: =?utf-8?q?1761059430332401461?= The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 263f5ecaf7080513efc248ec739b6d9e00f4129f Gitweb: https://git.kernel.org/tip/263f5ecaf7080513efc248ec739b6d9e00f4129f Author: Breno Leitao AuthorDate: Tue, 21 Mar 2023 04:33:38 -07:00 Committer: Peter Zijlstra CommitterDate: Tue, 21 Mar 2023 14:43:05 +01:00 perf/x86/amd/core: Always clear status for idx The variable 'status' (which contains the unhandled overflow bits) is not being properly masked in some cases, displaying the following warning: WARNING: CPU: 156 PID: 475601 at arch/x86/events/amd/core.c:972 amd_pmu_v2_handle_irq+0x216/0x270 This seems to be happening because the loop is being continued before the status bit being unset, in case x86_perf_event_set_period() returns 0. This is also causing an inconsistency because the "handled" counter is incremented, but the status bit is not cleaned. Move the bit cleaning together above, together when the "handled" counter is incremented. Fixes: 7685665c390d ("perf/x86/amd/core: Add PerfMonV2 overflow handling") Signed-off-by: Breno Leitao Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Sandipan Das Link: https://lore.kernel.org/r/20230321113338.1669660-1-leitao@debian.org --- arch/x86/events/amd/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c index 8c45b19..bccea57 100644 --- a/arch/x86/events/amd/core.c +++ b/arch/x86/events/amd/core.c @@ -923,6 +923,7 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs) /* Event overflow */ handled++; + status &= ~mask; perf_sample_data_init(&data, 0, hwc->last_period); if (!x86_perf_event_set_period(event)) @@ -933,8 +934,6 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs) if (perf_event_overflow(event, &data, regs)) x86_pmu_stop(event, 0); - - status &= ~mask; } /*