Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp311697iob; Wed, 18 May 2022 02:45:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyACf7AomjnKFQRBlKbaUln32R1/MRxKRDx0CgNHlhGi2cN+KVUW5YlYe+AVpD+u+/08bQM X-Received: by 2002:a17:90a:94c4:b0:1df:a60b:1e29 with SMTP id j4-20020a17090a94c400b001dfa60b1e29mr4556241pjw.146.1652867132534; Wed, 18 May 2022 02:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652867132; cv=none; d=google.com; s=arc-20160816; b=bdmi1bIIwn3PkOLZjyMMt0a26A/goLxMavEZqNL6Xle+/yrR6uDQyKvoH3iuGpfoJT TtPYC27ExvKD37NJYxpP8PD7ORXstHZtAqjNtoSuIpDju0OR2kuu0Zv2ETWC0kI4+VrD dTcEboIAbYZ/LevbG12Pu+Rj8MBYre0+zh7BIyB3j0p0UAPTjliU1nowvvLbtGj1InQp YaZIdX/VSHlOzjz6dr3p3Vfcjl1I9IIKGBBtztttenscCq1C0OZ/lFgnFaDcX2bcm0Lt lPZNM2f9BrA+O7oyHslvwKgcG/532ni/6Lb+4KOk5dal0IOILRO5rpSYVcWSnpNpw/5v QEhA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6ouknhTsnYgXvyYDad4p4n5Ry9z1YqQ5y5rixLyM520=; b=B2xLaFYZpX75t4FKd8X+bvKumLbOq9P9s0eUdXoaW8UNqDT0llypnO6VT2W/77t4IP M4SZ95W5Xk+vbI46ypju1ZfhDBrd8TJJzuoXg5g2HAZ7w7A165E6OdJ6lu4Glyyz/+2N JsTTU6p7C0nv8ccEnTJRwJtP8+LxOXZwCiNmHVKESd8lycF86yws7lOuV4JxJvBC4g5e CmOXG3ZOXgSqhrj/UcTKtFItkD/tNqeLSjR3pYpKlwQ9zd6dhaHdGO0aWctXsB3IbPes ojSYFfV9IKM8xxKU/glG/6+7X6BXBGhSUSMOILfj+9QFJ3Q7VhF9nb44wATW7aRcVl7o Z6NA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c132-20020a63358a000000b003c2362b7e2dsi2051581pga.256.2022.05.18.02.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 02:45:32 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F050AB0403; Wed, 18 May 2022 02:35:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234318AbiERJe1 (ORCPT + 99 others); Wed, 18 May 2022 05:34:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234364AbiERJeF (ORCPT ); Wed, 18 May 2022 05:34:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D76F8B0400 for ; Wed, 18 May 2022 02:34:02 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 990A51063; Wed, 18 May 2022 02:34:02 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 59D823F66F; Wed, 18 May 2022 02:34:00 -0700 (PDT) From: Sudeep Holla To: Atish Patra , linux-kernel@vger.kernel.org Cc: Sudeep Holla , Atish Patra , Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Qing Wang , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Rob Herring , Andy Shevchenko Subject: [PATCH v2 5/8] arch_topology: Check for non-negative value rather than -1 for IDs validity Date: Wed, 18 May 2022 10:33:22 +0100 Message-Id: <20220518093325.2070336-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220518093325.2070336-1-sudeep.holla@arm.com> References: <20220518093325.2070336-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Instead of just comparing the cpu topology IDs with -1 to check their validity, improve that by checking for a valid non-negative value. Suggested-by: Andy Shevchenko Signed-off-by: Sudeep Holla --- drivers/base/arch_topology.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 77aab5fea46b..be99a78f5b31 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -662,7 +662,7 @@ static int __init parse_dt_topology(void) * only mark cores described in the DT as possible. */ for_each_possible_cpu(cpu) - if (cpu_topology[cpu].package_id == -1) + if (cpu_topology[cpu].package_id < 0) ret = -EINVAL; out_map: @@ -688,7 +688,7 @@ const struct cpumask *cpu_coregroup_mask(int cpu) /* not numa in package, lets use the package siblings */ core_mask = &cpu_topology[cpu].core_sibling; } - if (cpu_topology[cpu].llc_id != -1) { + if (cpu_topology[cpu].llc_id >= 0) { if (cpumask_subset(&cpu_topology[cpu].llc_sibling, core_mask)) core_mask = &cpu_topology[cpu].llc_sibling; } @@ -719,7 +719,8 @@ void update_siblings_masks(unsigned int cpuid) for_each_online_cpu(cpu) { cpu_topo = &cpu_topology[cpu]; - if (cpu_topo->llc_id != -1 && cpuid_topo->llc_id == cpu_topo->llc_id) { + if (cpu_topo->llc_id >= 0 && + cpuid_topo->llc_id == cpu_topo->llc_id) { cpumask_set_cpu(cpu, &cpuid_topo->llc_sibling); cpumask_set_cpu(cpuid, &cpu_topo->llc_sibling); } @@ -733,7 +734,7 @@ void update_siblings_masks(unsigned int cpuid) if (cpuid_topo->cluster_id != cpu_topo->cluster_id) continue; - if (cpuid_topo->cluster_id != -1) { + if (cpuid_topo->cluster_id >= 0) { cpumask_set_cpu(cpu, &cpuid_topo->cluster_sibling); cpumask_set_cpu(cpuid, &cpu_topo->cluster_sibling); } -- 2.36.1