From patchwork Mon Jul 10 08:37:52 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: 117730 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4885690vqx; Mon, 10 Jul 2023 02:06:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlEl22sCchG0qyGkHlWJ4gZsA+h80Ov6sPDG/Rs3SXjTRCwb1sGfj0sndtsfI/o8xSenxSnN X-Received: by 2002:a2e:9b47:0:b0:2b6:ffd1:165a with SMTP id o7-20020a2e9b47000000b002b6ffd1165amr9652421ljj.30.1688979973532; Mon, 10 Jul 2023 02:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688979973; cv=none; d=google.com; s=arc-20160816; b=jUnbCgPA90CBc9wSAykuh7+ImXMG8j5aOd3ek6Et6BTluUxL6tm/ZJtQDZJxWGk4vE l8tzGMevDufgbZywwMq5Tz1xbjiTNw1BGFPE02gjAotLPsugauz4kyzL9IsU6YEJqodN fosPW4+pW3ONy6bxGpgDnERYfW5wFvzCv0jFoVaVmYsDJiuwLG+RppRdsqHcEKx0ukhS XfoFbdhBNrOiqXEMSGSttL05C2Y1uu/wn3KicGsx2gYB44o3MEDfGUrpj+iRvkmHFcI8 1ey+nMvQyYJb4HHlTgFvB3vXRa39Ydd9qKm1i9txmy5Icm1B79KItH29+b9qKq1NAgvr 23kQ== 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=inEIYZM4ngXU1qpHljVWGzk0u0iImhhisq+ZMRicFjs=; fh=z8yl1anS5A8VADqjulgqfEsmQ/RLBK3gjgm2hzEqflY=; b=ZQL/c5pH+e/TbekGBc01TH5wSY1vVjoZDJASsNyoJlVjA818RoHzAsXxwO/i21skjq rgxjvVihxis+uTx2DN0qFSukGIU10t2WmI9YSCbaJDZPUSpUXXRg7PWnGSLRHQg+UHIZ V2/Z/FbDdU6yNbaIWn6MLBVWbHrserPiFkrt6B8epG+X5mjpSJkTVHjh+OEm0VyW1rfv 3r3NkHeCXRlW5gJXRaolqcIGf8OXBoqR+wtHNCuaXOmOI2fgqeWxGoL5A9YmMXkXOYTu 676r+Nn2r49U/RQ27Bs2MKbv6G4xE5yZqI9C6m4134QVZYxL9fDl+Ck3ocOCqjKR5yFq 2czQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4ooMdzza; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=J3H11gUW; 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 dx5-20020a170906a84500b00993321873fesi8949506ejb.665.2023.07.10.02.05.50; Mon, 10 Jul 2023 02:06:13 -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=4ooMdzza; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=J3H11gUW; 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 S232243AbjGJIiQ (ORCPT + 99 others); Mon, 10 Jul 2023 04:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231262AbjGJIhz (ORCPT ); Mon, 10 Jul 2023 04:37:55 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE36C3; Mon, 10 Jul 2023 01:37:54 -0700 (PDT) Date: Mon, 10 Jul 2023 08:37:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1688978272; 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=inEIYZM4ngXU1qpHljVWGzk0u0iImhhisq+ZMRicFjs=; b=4ooMdzzaeIPJeWZIW8lHX/3N9bEQ+EWPcxfX8mh2lc2BKQqvFkfNGAAs6yl1E3DfmVzKrL 1PivHvSMQPT1fus1EzBT8evocRvBKXwFZ90Gr8FMBkO/aWX7ZP6bc6AyTeQVhEFPRRI11Z E03sQx/hiiNUtcjAXdQqhJThPzvJjkJIZXmcCSUeUE1Mod8F94dBE4Ke8FqASMTLFmgCmX qu4d5vn7ivBqkA+XDUqpIDBFqJbD4AD/zFplhMlakStIr7guvrjpME0dzyLKTSPammhjdw /AxdBteGRwzcuHzy/6707gka0fjB2bBmQ07ptKYBQi278i1JU4cs77/0eSNU6A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1688978272; 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=inEIYZM4ngXU1qpHljVWGzk0u0iImhhisq+ZMRicFjs=; b=J3H11gUWaFyWJFSX/dOz1Vx4sme/9mnf7DPiS2ObKfxxsI0u9wE4DI4unnvYH6TeoyzVZX uVIMKUiKHeTpWzCw== From: "tip-bot2 for Ravi Bangoria" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/amd: Prevent grouping of IBS events Cc: Sandipan Das , Ravi Bangoria , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230620091603.269-1-ravi.bangoria@amd.com> References: <20230620091603.269-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Message-ID: <168897827224.404.17660481467586350717.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: INBOX X-GMAIL-THRID: 1769215569369542204 X-GMAIL-MSGID: 1771023864325745885 The following commit has been merged into the perf/core branch of tip: Commit-ID: 7c2128235eff99b448af8f4b5b2933495bf1a440 Gitweb: https://git.kernel.org/tip/7c2128235eff99b448af8f4b5b2933495bf1a440 Author: Ravi Bangoria AuthorDate: Tue, 20 Jun 2023 14:46:03 +05:30 Committer: Peter Zijlstra CommitterDate: Mon, 10 Jul 2023 09:52:34 +02:00 perf/amd: Prevent grouping of IBS events IBS PMUs can have only one event active at any point in time. Restrict grouping of multiple IBS events. Reported-by: Sandipan Das Signed-off-by: Ravi Bangoria Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20230620091603.269-1-ravi.bangoria@amd.com --- arch/x86/events/amd/ibs.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 3710148..74e6642 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -247,11 +247,33 @@ int forward_event_to_ibs(struct perf_event *event) return -ENOENT; } +/* + * Grouping of IBS events is not possible since IBS can have only + * one event active at any point in time. + */ +static int validate_group(struct perf_event *event) +{ + struct perf_event *sibling; + + if (event->group_leader == event) + return 0; + + if (event->group_leader->pmu == event->pmu) + return -EINVAL; + + for_each_sibling_event(sibling, event->group_leader) { + if (sibling->pmu == event->pmu) + return -EINVAL; + } + return 0; +} + static int perf_ibs_init(struct perf_event *event) { struct hw_perf_event *hwc = &event->hw; struct perf_ibs *perf_ibs; u64 max_cnt, config; + int ret; perf_ibs = get_ibs_pmu(event->attr.type); if (!perf_ibs) @@ -265,6 +287,10 @@ static int perf_ibs_init(struct perf_event *event) if (config & ~perf_ibs->config_mask) return -EINVAL; + ret = validate_group(event); + if (ret) + return ret; + if (hwc->sample_period) { if (config & perf_ibs->cnt_mask) /* raw max_cnt may not be set */