Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2288687iof; Wed, 8 Jun 2022 01:31:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZPk2dq+Dagg+ZsuqOuDMNNZm0tN6NZfQ6ral1LvrNpOJZmnrUUgKU0yWnFAdbfVYyo52D X-Received: by 2002:a17:902:d103:b0:166:3e44:cfca with SMTP id w3-20020a170902d10300b001663e44cfcamr32389749plw.141.1654677083213; Wed, 08 Jun 2022 01:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654677083; cv=none; d=google.com; s=arc-20160816; b=OgkilsrsJ5gDBB0hfUTSJPnb4cYLa346Q36HVDSLqp/1mjDV2WFzBFlBJ+QZvgxUM2 S/y/d5w96rFacNooJIgAOoi0RPfvWlMFqm5bRof8VGVjmD+aRKhbVJgfAFdKhwZf/d3d +TY06DdQcEvKJi/FSvJiMWx0U7ViUt4z/9AxAkL+8W1tv694ZNOABs5ZNeYxVNReu8dS XTmc25ZdNBVWv/ZIDPPiWZq+hpUP5Fb3eSOekJuvuZDbw6trqvcuYVJ999YqOKA6D/0S Y1y8wnppuvOXq2+q6BwbDoRri4Klhi5AS+hoXKbdDOekc89O0OC+w7mqXswGWo3Cb0qU SNpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IFV/VthXm01Pgc/sQvIaO2EUAY6LGAGsTm4scu0aWqE=; b=zDYxK+tVnkpo+HtVVciL7XB9mz5sRbXhxb0iS6RnEYM0PL+ihkHuhBawD0vQ2hK6Vf DlQlBo1/6h4TrYIGXH/W2/ddShB1v9vWTS5heVrEnm19z5rZEn4ngo1FHpu/nvOWQN/3 /P8OmFMsP9WaGLGs3mKZpBys5ozKFn/kvEMLxEgxrAVwss72OVq5Ou8V5Ys5X+EeieoG lUgQ3LSkH195EjffKSqXIXW00FtxK9YfYNE7I/3pySID/pdMLPOMghAfItkxV/aL9z6E PVzdZrTl3U+U7+2dmsex8SnG/8Q3pi9FFmVgBy8LZ2kF6+HnXTyl+Os1tQBhNC1kOAhO MlGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UMHhzIE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p22-20020a631e56000000b003fe2bbbb8d9si2074220pgm.460.2022.06.08.01.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:31:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UMHhzIE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0BFB61F21B5; Wed, 8 Jun 2022 00:59:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348956AbiFGRzQ (ORCPT + 99 others); Tue, 7 Jun 2022 13:55:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348657AbiFGRgj (ORCPT ); Tue, 7 Jun 2022 13:36:39 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46F8465AF; Tue, 7 Jun 2022 10:32:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1652ACE23CE; Tue, 7 Jun 2022 17:32:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CA3CC385A5; Tue, 7 Jun 2022 17:32:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623144; bh=kuJGlq+Dp50ebFzN/dD8Ge6yPh9MXymGfk7L2/1qwBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMHhzIE1/a/etFS7y7WQDX7QNK6y5ykTWkPIOwTtJmze2q8zCEXyKKdM1Sbq90pf7 Y+aEunDjRlcxKQ9MsSNGDr6Wv+sLoP77yn4WmGNWJYVdsmfrPNE04zQvY2cJEiD/Dw b5rGzSVsF/VJT+4EjvcpylStqLasjBNHB0jZjD9Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kajol Jain , Athira Rajeev , Michael Ellerman , Sasha Levin Subject: [PATCH 5.10 311/452] powerpc/perf: Fix the threshold compare group constraint for power9 Date: Tue, 7 Jun 2022 19:02:48 +0200 Message-Id: <20220607164917.827166709@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 From: Kajol Jain [ Upstream commit ab0cc6bbf0c812731c703ec757fcc3fc3a457a34 ] Thresh compare bits for a event is used to program thresh compare field in Monitor Mode Control Register A (MMCRA: 9-18 bits for power9). When scheduling events as a group, all events in that group should match value in threshold bits (like thresh compare, thresh control, thresh select). Otherwise event open for the sibling events should fail. But in the current code, incase thresh compare bits are not valid, we are not failing in group_constraint function which can result in invalid group schduling. Fix the issue by returning -1 incase event is threshold and threshold compare value is not valid. Thresh control bits in the event code is used to program thresh_ctl field in Monitor Mode Control Register A (MMCRA: 48-55). In below example, the scheduling of group events PM_MRK_INST_CMPL (873534401e0) and PM_THRESH_MET (8734340101ec) is expected to fail as both event request different thresh control bits and invalid thresh compare value. Result before the patch changes: [command]# perf stat -e "{r8735340401e0,r8734340101ec}" sleep 1 Performance counter stats for 'sleep 1': 11,048 r8735340401e0 1,967 r8734340101ec 1.001354036 seconds time elapsed 0.001421000 seconds user 0.000000000 seconds sys Result after the patch changes: [command]# perf stat -e "{r8735340401e0,r8734340101ec}" sleep 1 Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (r8735340401e0). /bin/dmesg | grep -i perf may provide additional information. Fixes: 78a16d9fc1206 ("powerpc/perf: Avoid FAB_*_MATCH checks for power9") Signed-off-by: Kajol Jain Reviewed-by: Athira Rajeev Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220506061015.43916-2-kjain@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/perf/isa207-common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/perf/isa207-common.c b/arch/powerpc/perf/isa207-common.c index 58448f0e4721..52990becbdfc 100644 --- a/arch/powerpc/perf/isa207-common.c +++ b/arch/powerpc/perf/isa207-common.c @@ -363,7 +363,8 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp) if (event_is_threshold(event) && is_thresh_cmp_valid(event)) { mask |= CNST_THRESH_MASK; value |= CNST_THRESH_VAL(event >> EVENT_THRESH_SHIFT); - } + } else if (event_is_threshold(event)) + return -1; } else { /* * Special case for PM_MRK_FAB_RSP_MATCH and PM_MRK_FAB_RSP_MATCH_CYC, -- 2.35.1