From nobody Sun Feb 8 15:28:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 971DCC0015E for ; Thu, 29 Jun 2023 14:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231508AbjF2OiD (ORCPT ); Thu, 29 Jun 2023 10:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231766AbjF2Ohw (ORCPT ); Thu, 29 Jun 2023 10:37:52 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A254430DD; Thu, 29 Jun 2023 07:37:51 -0700 (PDT) Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TEWahJ021970; Thu, 29 Jun 2023 14:37:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Z3BXx87NONENKyRCVCG4NKF1gcn0Sn0umYhm4oYj4BE=; b=fIuKUCz0Pmj4SSR9tQoOhTzWoXAWk3QunXQ06mBeerhqzJkGg0OwuHDwpsI0yxdPkg+D 0O3X4fFsf97LdXVfN/NSWbLHAKHUs5Q7NGo7M2OwKO9/FXqP8S7DRhfmdzEjiRFXw3B5 RZHZWBxAgljYterwiYttgo/yVlTWNKAUxJJZnSsMfhUcmVbZUCG53TBCn+RPmMjJiEj5 ATqJPJ4pmgne5avWJRG/e7aow3pBFsUNxPZ2lhpId0PSOBuF03qqAaRD+s0Bof3OTvJL D+OiyaM5aDu2lWZ/YLu+a/VGY72snlJMe5zfJgi2xKjsX7OWEZ9YzY3dNpESzJdADmK9 gQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rhbtfr7cs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 14:37:34 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35TEYFf5029524; Thu, 29 Jun 2023 14:37:13 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rhbtfr6d3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 14:37:13 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35T9UewQ018753; Thu, 29 Jun 2023 14:31:55 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3rdr453d0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jun 2023 14:31:54 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35TEVqtx21955106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 14:31:52 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 88E4620040; Thu, 29 Jun 2023 14:31:52 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AF0720043; Thu, 29 Jun 2023 14:31:52 +0000 (GMT) Received: from pomme.tlslab.ibm.com (unknown [9.101.4.33]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Jun 2023 14:31:52 +0000 (GMT) From: Laurent Dufour To: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, tglx@linutronix.de, dave.hansen@linux.intel.com, mingo@redhat.com, bp@alien8.de Subject: [PATCH v3 2/9] cpu/SMT: Move smt/control simple exit cases earlier Date: Thu, 29 Jun 2023 16:31:42 +0200 Message-ID: <20230629143149.79073-3-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230629143149.79073-1-ldufour@linux.ibm.com> References: <20230629143149.79073-1-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: znAJTOAkjGFcbZbbUhM-H8vWPDtgTGry X-Proofpoint-ORIG-GUID: MdiUQEipbuLwmI_5kVk5Rp4UXK0jmVLn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-29_03,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 impostorscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306290132 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Michael Ellerman Move the simple exit cases, ie. which don't depend on the value written, earlier in the function. That makes it clearer that regardless of the input those states can not be transitioned out of. That does have a user-visible effect, in that the error returned will now always be EPERM/ENODEV for those states, regardless of the value written. Previously writing an invalid value would return EINVAL even when in those states. Signed-off-by: Michael Ellerman --- kernel/cpu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 237394e0574a..c67049bb3fc8 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2482,6 +2482,12 @@ __store_smt_control(struct device *dev, struct devic= e_attribute *attr, { int ctrlval, ret; =20 + if (cpu_smt_control =3D=3D CPU_SMT_FORCE_DISABLED) + return -EPERM; + + if (cpu_smt_control =3D=3D CPU_SMT_NOT_SUPPORTED) + return -ENODEV; + if (sysfs_streq(buf, "on")) ctrlval =3D CPU_SMT_ENABLED; else if (sysfs_streq(buf, "off")) @@ -2491,12 +2497,6 @@ __store_smt_control(struct device *dev, struct devic= e_attribute *attr, else return -EINVAL; =20 - if (cpu_smt_control =3D=3D CPU_SMT_FORCE_DISABLED) - return -EPERM; - - if (cpu_smt_control =3D=3D CPU_SMT_NOT_SUPPORTED) - return -ENODEV; - ret =3D lock_device_hotplug_sysfs(); if (ret) return ret; --=20 2.41.0