[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] core-parking: fix build with gcc12 and NR_CPUS=1


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 9 Sep 2022 12:18:16 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HnVpo75K2ajU9Prf0GLOajBAWXGHI4F8hbqIMVVqlcg=; b=aolgVJsC4QZaiQkLt5dbaZIpcXuhfvfXMGWEg9uLEeJVyf2lz1qPaWeyeshA8RBDMtiJQKylw0LPaBZQGJyD2k+HllKCB3UaaLblH1rewtAZ832I+vdh9ujoF5gOnx8P68hA1peo7isQhMPqf6Z9u6dSAxfaDmf4+EMmA/w/HyGwyVyMUYjHUeJEy+uSVtlfdXedXrNGxzXJU14BniGXNDneRmYc/dzFkXfQjqk68P09rBksDuSbwKwr+K7uYIjXdHA9FSTl7mOFKS2XP+xWltv24qXH3XwWg4rXlVXkN/AwRWUY5uDekwYy32nKciwOt7rFlp31d8YA6VqarTtBqg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IV8R+MtZVnSCi3DfnGDyxrd0AItnLgzQqm+iHqz0Dg0GnZJvL4rrCVGtcZVQJ3Dr9a4367iCSL3DLyEqBKPdRj6JbXcdjnrtb5ADHROuoZ+SQMO+9BXKp8aJau0e58vE/1zv2PcM4HPA2APRNujHMflZ0bLaKwypwAqgG6jfw6bEFUL8X/6djeFoiro8PBDjMy0vrxwPxC1+ggJ3KDrSdATxZYb8OpgA515iF2Momet/QRTR+vn2y6ibweER38WX50G48QqkmiRgqzrwRyBbALeX1L084rNHdYbNYjEFCcCgB2sHsor61wV9V1R2JMHv/Mpcll4+9dNwWeF0RDlkYQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 09 Sep 2022 10:18:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Gcc12 takes issue with core_parking_remove()'s

    for ( ; i < cur_idle_nums; ++i )
        core_parking_cpunum[i] = core_parking_cpunum[i + 1];

complaining that the right hand side array access is past the bounds of
1. Clearly the compiler can't know that cur_idle_nums can only ever be
zero in this case (as the sole CPU cannot be parked).

Beyond addressing the immediate issue also adjust core_parking_init():
There's no point registering any policy when there's no CPU to park.
Since this still doesn't result in the compiler spotting that
core_parking_policy is never written (and hence is continuously NULL),
also amend core_parking_helper() to avoid eventual similar issues there
(minimizing generated code at the same time).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/common/core_parking.c
+++ b/xen/common/core_parking.c
@@ -175,7 +175,7 @@ long cf_check core_parking_helper(void *
     unsigned int cpu;
     int ret = 0;
 
-    if ( !core_parking_policy )
+    if ( !core_parking_policy || CONFIG_NR_CPUS == 1 )
         return -EINVAL;
 
     while ( cur_idle_nums < idle_nums )
@@ -213,8 +213,9 @@ long cf_check core_parking_helper(void *
 
 bool core_parking_remove(unsigned int cpu)
 {
-    unsigned int i;
     bool found = false;
+#if CONFIG_NR_CPUS > 1
+    unsigned int i;
 
     spin_lock(&accounting_lock);
 
@@ -230,6 +231,7 @@ bool core_parking_remove(unsigned int cp
         core_parking_cpunum[i] = core_parking_cpunum[i + 1];
 
     spin_unlock(&accounting_lock);
+#endif /* CONFIG_NR_CPUS > 1 */
 
     return found;
 }
@@ -260,9 +262,11 @@ static int __init register_core_parking_
 
 static int __init cf_check core_parking_init(void)
 {
-    int ret = 0;
+    int ret;
 
-    if ( core_parking_controller == PERFORMANCE_FIRST )
+    if ( CONFIG_NR_CPUS == 1 )
+        ret = 0;
+    else if ( core_parking_controller == PERFORMANCE_FIRST )
         ret = register_core_parking_policy(&performance_first);
     else
         ret = register_core_parking_policy(&power_first);



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.