From patchwork Thu Nov 24 12:03:02 2022 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: 25482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3355764wrr; Thu, 24 Nov 2022 04:07:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ldbcib+ZV1bchBdw3H5Nz9K2TFjGK3svPBqKrovSBoYEgawIQHjFNXecsv3Jm1aE02LkG X-Received: by 2002:a05:6402:4008:b0:458:dd63:e339 with SMTP id d8-20020a056402400800b00458dd63e339mr11983761eda.81.1669291665853; Thu, 24 Nov 2022 04:07:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669291665; cv=none; d=google.com; s=arc-20160816; b=pasAS0jmid0EX+W4auUijntuz2xdRt9qwx4/hXITmMuta5tqMkSUf6HSiQW3wwPf5b sKJHTDlFNE7RcUAmQXaw5yKxW7eoIY/vBZtWqPmiXG0tl0GRckoie4diK6VtMEE+zNvM +EY2R5Oe3ncfSm8sFq1wzPJ2+n7TcLU2+G65HH1tv8Cc3U7JJb95fURU5JtDZzWAMQYZ l88K4RrbjC+dlfiAzUgDhPn2x0+Q0qPQKAcPSEEeDqE1P7p/DkF7hI8E4AJYX1L4nJWC 9YQxewXA/bHs/ZkfZjjtwpGZ/u/GsBS2serXl9/qEWIKTcnEsxZ1QGlSP5SkNmSNAGGB Flsw== 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=10A2Ap9seqEIVSGltb1NkNdPUOpWyyLq4f6tk2n+K6w=; b=0+LapDyswRmqxU/lg8+9x8U5p9iSjlCBe+bma7i395aFVNkMffDz6ANynoTihBFH+y cWMqba33KqrXd81j50tcYv4XpiPZvNivNAW5lcK2mBKLjNuIFSIvIGXA3upwC9J5A7bg CKtubR3tjgFw7jCPi5DlyvbPPe4Qew8mTRqtCff5B6S/Ade9R3BmkjI+GsY7RltvTrPn L04tG2rD1HzJwZSYnvQX4gog96arPluDI0+dlzP8Pz2nIeAlhov1Fho1eiBubxvwEbT1 YsXDy+azpFHKt/ktYrKQQEYl2MWM2XCspwsbeTjQXAIf3XFTjh+Y/fNcfVRO8dT9pBxr ZSGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WQdc3Xr9; 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 i5-20020a05640242c500b0046822f4ca71si960147edc.366.2022.11.24.04.07.21; Thu, 24 Nov 2022 04:07:45 -0800 (PST) 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=WQdc3Xr9; 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 S230271AbiKXMEC (ORCPT + 99 others); Thu, 24 Nov 2022 07:04:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbiKXMDb (ORCPT ); Thu, 24 Nov 2022 07:03:31 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFCCC60685; Thu, 24 Nov 2022 04:03:04 -0800 (PST) Date: Thu, 24 Nov 2022 12:03:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669291383; 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=10A2Ap9seqEIVSGltb1NkNdPUOpWyyLq4f6tk2n+K6w=; b=WQdc3Xr9lC331UbiUsUnYAsc+yKSIX9To/F/K3713N3/Ho9lkKQqJ3QRII+4GgICTuYG5c YTrwETf5jDvLVM2dqBRPWlvsWd+5F9vdLP3TcXJv+qxSUXdIR42D8AQVHpoykpB7bU8tyL UB6uK84eXsrRt5sPlInVBxWSA8CFAYE8qSxbW2oUpORXOcTR7Z4O7zq9UvzUKxugWHtjHb htmh+jZAGuyAJLhxBLKsaFsgIh6LZAF67pLDeXVUorqBwIikQREp50ZEEICmOd6gchMSzY 0eeBwpUKPTQjRLa8QfEhX+N6WPTAxmAZbkTvVzNTWQ8M9KXMRDQ6uwCED0g6Lw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669291383; 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=10A2Ap9seqEIVSGltb1NkNdPUOpWyyLq4f6tk2n+K6w=; b=AvVHk75+BIjqEiI/45TYnbrtjlWtnhJDZJ1Am3T9kUuz4Ocg8WCRhI1Ky5zX5zym3H1/FH DesckpDE4vlHM9CQ== 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/core: Don't allow grouping events from different hw pmus Cc: Ravi Bangoria , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221122080326.228-1-ravi.bangoria@amd.com> References: <20221122080326.228-1-ravi.bangoria@amd.com> MIME-Version: 1.0 Message-ID: <166929138240.4906.17980748237008458473.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750182968999855057?= X-GMAIL-MSGID: =?utf-8?q?1750379177643304111?= The following commit has been merged into the perf/core branch of tip: Commit-ID: bf480f9385667309a8866e65833f261d4773df9a Gitweb: https://git.kernel.org/tip/bf480f9385667309a8866e65833f261d4773df9a Author: Ravi Bangoria AuthorDate: Tue, 22 Nov 2022 13:33:26 +05:30 Committer: Peter Zijlstra CommitterDate: Thu, 24 Nov 2022 11:09:19 +01:00 perf/core: Don't allow grouping events from different hw pmus Event group from different hw pmus does not make sense and thus perf has never allowed it. However, with recent rewrite that restriction has been inadvertently removed. Fix it. Fixes: bd2756811766 ("perf: Rewrite core context handling") Signed-off-by: Ravi Bangoria Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20221122080326.228-1-ravi.bangoria@amd.com --- kernel/events/core.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index f2b865c..65e20c5 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -12503,15 +12503,21 @@ SYSCALL_DEFINE5(perf_event_open, * perf_event_pmu_context. */ pmu = group_leader->pmu_ctx->pmu; - } else if (!is_software_event(event) && - is_software_event(group_leader) && - (group_leader->group_caps & PERF_EV_CAP_SOFTWARE)) { - /* - * In case the group is a pure software group, and we - * try to add a hardware event, move the whole group to - * the hardware context. - */ - move_group = 1; + } else if (!is_software_event(event)) { + if (is_software_event(group_leader) && + (group_leader->group_caps & PERF_EV_CAP_SOFTWARE)) { + /* + * In case the group is a pure software group, and we + * try to add a hardware event, move the whole group to + * the hardware context. + */ + move_group = 1; + } + + /* Don't allow group of multiple hw events from different pmus */ + if (!in_software_context(group_leader) && + group_leader->pmu_ctx->pmu != pmu) + goto err_locked; } }