Message ID | 20240229105208.456704-1-liaochang1@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-86592-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp310323dyb; Thu, 29 Feb 2024 02:57:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUt2gmTnkDJF+slNwPoPHSPK0zMK4e+eeG99URXBwvYHHJWA9e1h7LOKaK4I8zwOYZXgzyIrQkFkUDaKbiEIIAVbEJxUg== X-Google-Smtp-Source: AGHT+IFeifq1G2XhtJ39nPSlIQmT+h3L1Y8hM5aHBkWBK5DsJl7dfZgeE6w8ZMmvYZvihwn7HIby X-Received: by 2002:a05:6102:358b:b0:472:8d0d:16f5 with SMTP id h11-20020a056102358b00b004728d0d16f5mr245522vsu.33.1709204262297; Thu, 29 Feb 2024 02:57:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709204262; cv=pass; d=google.com; s=arc-20160816; b=E2VHc580cAv5Ia4lGzXKi3BZ/iiEdIi8ofgPLcUDxnF/ynAB3xJIjKmiTYmFwgtv07 eQ9ncYo/DtQFxYJE5GtVCe8/ER5ufBkbzzaEk0iVWEr8CUbFVZToyhfUsNoe05H9vOqW KTP2F1Qttv3xdmopyxT8r4EOqBSkAiiZvVcOEmMDH36JUwfQ8STKf9G6eTVDRAa72kJ9 nN5OXO4NOCh6LOUbJZmhyN+UOEHIx7gjixnUEkulymwDEhlgKHCIplqKRip+FYiRxG3m pycgRS90jEyjAcyenQga8KYREextgXyMHGcYLu28j6CGEMA0jrmMCyxBdAH0gp141wdG WqYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=EjmhbjWuzGsgjjm3fTdFbj85GE2u6BwQsPltwIgNwV4=; fh=YLgIcMi+Vak/ZwJ7tX0I648rDDbrU/Mia2/6gqp6vts=; b=ZAqDNzuTpt0j3UNTGP6rNs0QdaGflYQKPkzFwWAiRD3gUjw6oiX8A5BUrfsJEg3ZNn AOxgkZbxDbsvx254/qtOtsUfHln1J4trG1LAq6YJYD4cmmM0BwnjwWd5DEakA2quqR2J pPD+FNs5CR/rl+/U2+xsWgQ6ZHkS16VLl/wA66RWdHpv6me2p2ghyYmzWZJvdhQ+1jX1 UJHOT3zF2Ga3Ph8hHqqxl+YNakplFtsqG4Dcg7BZ+EEtR7w8n4eZQA/bfDx6GjmsQ7VM VBWElqqdBhULJsuxqcLa3qGyhXlPPmbsvN60qaai7eo3ky5qRa7XxtnZQ5D1fKjqyaT8 gu9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-86592-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86592-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z11-20020ac8710b000000b0042e813efbb1si1119937qto.440.2024.02.29.02.57.42 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 02:57:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86592-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-86592-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86592-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 196791C231EE for <ouuuleilei@gmail.com>; Thu, 29 Feb 2024 10:57:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3712A7AE43; Thu, 29 Feb 2024 10:57:30 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2E4A6351C for <linux-kernel@vger.kernel.org>; Thu, 29 Feb 2024 10:57:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709204248; cv=none; b=LLnW+wteSHYkJm3Z+SDlsk4vOsDe36U2ZcNptn12G1ouH+IXLSXIhrfjO0TeawhEFtplTzCNJV8Yo5gMLgRGMQs5m4ugGazXUIVKUFSPDez+D1aV94elh5DPUmpJ5IZeZC7aZys3ApMFjwZ1N1bBm7ksKdDDYxnlM4cN4A2+IwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709204248; c=relaxed/simple; bh=mlQriLFckdSfeNQ7AaJtv9Q/udzqXN7eCK5x+5iiUfg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=GZKZUWiwbnZmVK/IRqG9Alek6nLQtBI/3Z6zmPkVBJy9/wZEXF1tP7gqoIzamMZy69kg0kLB5P0VFZom3IEputl3eqmu3tXpUJXI/oZ0SH6EtquwxXUHmTd6wQRYjy1/2w9fm3SL+H4b4rkXSKEr0hJYcuc/vdq5DUmBuDWsDpE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tlp5l1mq0z2BdZj; Thu, 29 Feb 2024 18:55:07 +0800 (CST) Received: from kwepemd100005.china.huawei.com (unknown [7.221.188.91]) by mail.maildlp.com (Postfix) with ESMTPS id 1FAC5140390; Thu, 29 Feb 2024 18:57:23 +0800 (CST) Received: from kwepemd200013.china.huawei.com (7.221.188.133) by kwepemd100005.china.huawei.com (7.221.188.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Thu, 29 Feb 2024 18:57:22 +0800 Received: from huawei.com (10.67.174.28) by kwepemd200013.china.huawei.com (7.221.188.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Thu, 29 Feb 2024 18:57:22 +0800 From: Liao Chang <liaochang1@huawei.com> To: <catalin.marinas@arm.com>, <will@kernel.org>, <broonie@kernel.org>, <mark.rutland@arm.com>, <maz@kernel.org>, <joey.gouly@arm.com>, <kristina.martsenko@arm.com>, <liaochang1@huawei.com>, <ryan.roberts@arm.com>, <jeremy.linton@arm.com> CC: <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] arm64: cpufeatures: Clean up temporary variable to simplify code Date: Thu, 29 Feb 2024 10:52:08 +0000 Message-ID: <20240229105208.456704-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemd200013.china.huawei.com (7.221.188.133) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792230568588241490 X-GMAIL-MSGID: 1792230568588241490 |
Series |
arm64: cpufeatures: Clean up temporary variable to simplify code
|
|
Commit Message
Liao Chang
Feb. 29, 2024, 10:52 a.m. UTC
Clean up one temporary variable to simplifiy code in capability
detection.
Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
arch/arm64/kernel/cpufeature.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
Comments
On Thu, Feb 29, 2024 at 10:52:08AM +0000, Liao Chang wrote: > Clean up one temporary variable to simplifiy code in capability > detection. > > Signed-off-by: Liao Chang <liaochang1@huawei.com> This looks line a nice cleanup, so: Acked-by: Mark Rutland <mark.rutland@arm.com> For context, we removed the last other user of 'num' in commit: 21fb26bfb01ffe0d ("arm64: alternatives: add alternative_has_feature_*()") Mark. > --- > arch/arm64/kernel/cpufeature.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 8d1a634a403e..0e900b23f7ab 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -3052,13 +3052,9 @@ static void __init enable_cpu_capabilities(u16 scope_mask) > boot_scope = !!(scope_mask & SCOPE_BOOT_CPU); > > for (i = 0; i < ARM64_NCAPS; i++) { > - unsigned int num; > - > caps = cpucap_ptrs[i]; > - if (!caps || !(caps->type & scope_mask)) > - continue; > - num = caps->capability; > - if (!cpus_have_cap(num)) > + if (!caps || !(caps->type & scope_mask) || > + !cpus_have_cap(caps->capability)) > continue; > > if (boot_scope && caps->cpu_enable) > -- > 2.34.1 >
On Thu, 29 Feb 2024 10:52:08 +0000, Liao Chang wrote: > Clean up one temporary variable to simplifiy code in capability > detection. > > Applied to arm64 (for-next/misc), thanks! [1/1] arm64: cpufeatures: Clean up temporary variable to simplify code https://git.kernel.org/arm64/c/622442666dcc
Hi, On 2/29/24 04:52, Liao Chang wrote: > Clean up one temporary variable to simplifiy code in capability > detection. > > Signed-off-by: Liao Chang <liaochang1@huawei.com> > --- > arch/arm64/kernel/cpufeature.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 8d1a634a403e..0e900b23f7ab 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -3052,13 +3052,9 @@ static void __init enable_cpu_capabilities(u16 scope_mask) > boot_scope = !!(scope_mask & SCOPE_BOOT_CPU); > > for (i = 0; i < ARM64_NCAPS; i++) { > - unsigned int num; > - > caps = cpucap_ptrs[i]; > - if (!caps || !(caps->type & scope_mask)) > - continue; > - num = caps->capability; > - if (!cpus_have_cap(num)) > + if (!caps || !(caps->type & scope_mask) || > + !cpus_have_cap(caps->capability)) > continue; > > if (boot_scope && caps->cpu_enable) Looks functionality equivalent to me, and just to see if it makes a binary difference I compiled both variations (gcc 14.0.1) and they do result in the same instruction sequence. Meaning gcc is smart enough to drop the tmp, its also smart enough equate/apply de Morgan's law. The latter might make it more readable too, but I guess its all a matter of taste. Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 8d1a634a403e..0e900b23f7ab 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -3052,13 +3052,9 @@ static void __init enable_cpu_capabilities(u16 scope_mask) boot_scope = !!(scope_mask & SCOPE_BOOT_CPU); for (i = 0; i < ARM64_NCAPS; i++) { - unsigned int num; - caps = cpucap_ptrs[i]; - if (!caps || !(caps->type & scope_mask)) - continue; - num = caps->capability; - if (!cpus_have_cap(num)) + if (!caps || !(caps->type & scope_mask) || + !cpus_have_cap(caps->capability)) continue; if (boot_scope && caps->cpu_enable)