Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp593922iog; Mon, 13 Jun 2022 08:47:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tHzw3BRmVraW7B1BWvA3bQTjCzA10q0Eq6dGmK/7RQbmye9fWPcIpPq7Phs5YAZ1Ex1gB/ X-Received: by 2002:a17:902:b908:b0:163:e462:704c with SMTP id bf8-20020a170902b90800b00163e462704cmr248140plb.145.1655135267293; Mon, 13 Jun 2022 08:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655135267; cv=none; d=google.com; s=arc-20160816; b=h85beg+Rl/IZJ+Zg/Z6XRXNIzskCOZMv0VtZi27s119WiaCcHYy7E5nqJFTy49nqWD mKrlSkaR4E6wYRH9MLNvYAd1fPv4uk7UmDJBpHKDabhhhU9sPKiV5fSMMFqUc7+xHuKK t5DR+UulHljEsR4YQqdFTGGmDuDEblT9nxDcLmhfRiZh9qrNnVhfxLtCoFWVaIqDaVHw og5wULHhqDo3JHuDHx5LgNfRioGjMZ1DMEBYhJlJcnry1owLbHTXvlBQTGqBxI+tVREE 2nrH1fQRbsV/LrNfI4Wff3f/s62uySvJV6uEU8O7YVofuyyVqEJrr5Zs2t6pRPzjCm6f 1bBw== 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=+KFg40/sqpVQErsFvkMlsueLpOgNLXk9J/cUm4XDF2A=; b=Ly56V8ea7dmkzCh5jcYYYZh87GQgtBPOh/SUt3Hy8PyEJMFNfmmQomqRKSrjSwYF/c QJs/XqzER+sr2IhODrYmTbpQNOegbJO7x65spWdca2FmRZSA91oDSsURqACdhRFL8BF7 5GT7YNh1z9O9juIQjtwyL/C6C+SGIkyxbA7xtrs2C13Ia0lIkeZKwJCVwM36xNipTMSV BeN8dQfibzzk/tSMp8iio4JZyWiGw44A++0ba90xrzEobO0Qrv/z6J9Vgi4dp5V1Z0pI 1jMboeXCm5D9LnG8FEppHa1MGsr6bnmrzpTYP366SkHaZQHT8LS3Ny0KyWnZ8SZYnQ/m pAHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g19s6bZj; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a170902ec8300b00168a4ef6a67si11980266plg.17.2022.06.13.08.47.33; Mon, 13 Jun 2022 08:47:47 -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=@linuxfoundation.org header.s=korg header.b=g19s6bZj; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343952AbiFMKt5 (ORCPT + 99 others); Mon, 13 Jun 2022 06:49:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344951AbiFMKsK (ORCPT ); Mon, 13 Jun 2022 06:48:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D602C644; Mon, 13 Jun 2022 03:26:02 -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 ams.source.kernel.org (Postfix) with ESMTPS id 118B4B80E90; Mon, 13 Jun 2022 10:26:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66D89C34114; Mon, 13 Jun 2022 10:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115959; bh=Abwf7TIeD+FZEmVoWUjLCWfhzmUzRLUAtMLzDohOC24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g19s6bZjPkVHb6jJcVoEch/blUTrcivRHypc+tKQjlbW6mbR//hWk7RInRtn4Uryd sVD9gLAhaKdYsAVuNOczdOx11V1qWVQdpPuP89OezUp5Tnf89Kwamrwa8B+ZUx7Mbl pfdFUqNLIZjxVTlaqGznNT/F1ObVIgZ/RfuvlZmM= 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 4.14 094/218] powerpc/perf: Fix the threshold compare group constraint for power9 Date: Mon, 13 Jun 2022 12:09:12 +0200 Message-Id: <20220613094923.398624108@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@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=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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 24a78565bca6..279bf3a3afbf 100644 --- a/arch/powerpc/perf/isa207-common.c +++ b/arch/powerpc/perf/isa207-common.c @@ -324,7 +324,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