From patchwork Fri Sep 9 10:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12971463 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F283ECAAD3 for ; Fri, 9 Sep 2022 10:18:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.404124.646467 (Exim 4.92) (envelope-from ) id 1oWb5b-000878-47; Fri, 09 Sep 2022 10:18:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 404124.646467; Fri, 09 Sep 2022 10:18:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWb5b-000871-1K; Fri, 09 Sep 2022 10:18:23 +0000 Received: by outflank-mailman (input) for mailman id 404124; Fri, 09 Sep 2022 10:18:22 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWb5Z-00086v-Re for xen-devel@lists.xenproject.org; Fri, 09 Sep 2022 10:18:21 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60055.outbound.protection.outlook.com [40.107.6.55]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ba3e5fe5-3028-11ed-9760-273f2230c3a0; Fri, 09 Sep 2022 12:18:20 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DU2PR04MB8710.eurprd04.prod.outlook.com (2603:10a6:10:2dd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.20; Fri, 9 Sep 2022 10:18:18 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::59bc:901a:98a7:76d4]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::59bc:901a:98a7:76d4%5]) with mapi id 15.20.5612.019; Fri, 9 Sep 2022 10:18:18 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ba3e5fe5-3028-11ed-9760-273f2230c3a0 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== 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-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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HnVpo75K2ajU9Prf0GLOajBAWXGHI4F8hbqIMVVqlcg=; b=Ud+Kixo4XyeBInAVzu94K67ZobT8AxeuK94s3puOhwGteJGG6fyYl8auzdOw3xpuw7bNquwzl8zVkJCE6ptE5ds9D1M18+B2cBMYXsaQxTtTvl1mlhBT1syRcBwnMa2T3S9ZYp+GbyWKjT7ccvEwPvjzPXFoMoLSKFzoVoX080lsKpA09jz1T0Wcsog/JQyKqbJBN/sbjPCfOqlBMhbDiWTGglf4DhHCqA9o7BmvrgqN7zboxW/d5iNMPPgHR0sLtxt2jfNVzxPxnG6wuyRexb4C7YnZONGqc/CFufSB32jwSsLdcEB+33WVaNZRx9szAMVEv67oxsg900Z8OB67TA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <1c23930f-e809-d623-18ec-599a0e983b7a@suse.com> Date: Fri, 9 Sep 2022 12:18:16 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu From: Jan Beulich Subject: [PATCH] core-parking: fix build with gcc12 and NR_CPUS=1 X-ClientProxiedBy: FRYP281CA0001.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::11) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DU2PR04MB8710:EE_ X-MS-Office365-Filtering-Correlation-Id: 3be7ab50-29e9-487e-26ef-08da924c9da6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Doo2UjbmzJhD6nU+9yNephSbvoti1SyL+gmyC4m2og96FSAANmEjD74Djo9PxtdjBiz+5gPTdvQ1CtSFCRYOPy7HQBrFRovTA3qMTRYUjWK22GjQ9HUHfN1nlMI78zjDumn2wX90xIucHgXbB3iDnKS0D/3PMy5ic6xcSus4wS1V3bL7NZ7+OuAArpDr++2n2m/4aF6N/4OiDIcHq3TKwXamocaX+weuljmWwsgmzgsiKi7WGvyTpBhC9lVYK/n9CtcHAH/9YUUTFkVdJFyYwZXgylePpmBDmTSCTBFdjCksSx478kP2mySsjNAEZ8GK4gvAsb++uaZMf4OKpMEf8xuQkJWR6SfcmWQsDMRlzg4qCA5SJg/NB2C4z0/rRm4FRAkfBGzjVBHZf7x93GsdqiOJHnRc2e9hajzQpaLGHOL6PGVWCKsxa7UpWLP4DIXzLFhaZRBShdAsexfknrY4lyPxUHlZIPeAsrMBniyvShwP6SCGQYtdbzvtnKOn6ZYvuCIYColN9VE/gwPVZvxNvwxyfbNAzZTXoNDtl8vs9x51/LkIMmF1sF0Dk7flHrVgVGZPv7KT/lyHvhptDelEf6M4QO5QiQfhPiOe1m2GeDel6jlaL+3kgME8r04quR7jBTAhGIQR4kRW5wcLtlr9X9pP4OwkJ9gSJX0NszxeoOfYT52l++VXw8Ujd3oDIMeZy3pRnPmEX6a8u2cvZqeiZAE+a5R04HM+x3v0dTOfq7ouqMFTE9VBcRyHG4ZFzKosaLjZMgGCOXPseXa7axJMJcJAaQK2PsgFIk5cQD0DYaw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(346002)(396003)(366004)(39860400002)(376002)(31686004)(31696002)(86362001)(36756003)(8676002)(4326008)(38100700002)(66476007)(66556008)(66946007)(41300700001)(83380400001)(26005)(6512007)(6506007)(478600001)(6486002)(316002)(6916009)(186003)(54906003)(2906002)(2616005)(5660300002)(8936002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?WXuISi8xU/uqeLb3msmkhyJznTGW?= =?utf-8?q?ZA0uBe0HGZtIhV++eDgU25LybNNZea9H/e/65OjLGpUSyVF3oGxvXjgF2cFBjizuK?= =?utf-8?q?s3x7VQwPY2UaFBvUDU6TrgEQRtAvyeDJZeoEPVRnLjhGtFT0+V3FlCx7a6TtKKJzf?= =?utf-8?q?ICFksJs4/Fa7fwi80Vm/3KSTxSxbTbWvy3CFj+dhNP+Sl/5wli3cgOXo8BHfneCRh?= =?utf-8?q?U/mQ8eJoKZwkG8ClWDcS/I/QmI7Z6n/Deo60CdVOAmJcu2PI/JNl+ktG4gjCQp/fK?= =?utf-8?q?6boSL4v/ZtCSn4lHSc3REo/ecn6tJuWfOF2A2Fwsx01FhKtp6Hljf0qGSbk9oeqCP?= =?utf-8?q?cRKi8OHMvzJ+B3MRmsabP6SG7kX6LsmSHnMREIJc0+c86gG1muqT3r/YybWm8trxW?= =?utf-8?q?0C5qsZJCnG8F8QpXxP5m1iTAssIOE4uaXJ0Pqzes3/sxntj75Ef6e3kolfdApdB2k?= =?utf-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1?= =?utf-8?q?sDYN8QbhQGr6FZsLcRhND/pEr/A6WVKYV/S/ekycpuX23snP3UieJq+hUH7HKtjto?= =?utf-8?q?4OJS7kQOA7ywexa7Nm1wr4gIENxx57BqREa1RwwtUgjQeLXxc7+hSlLi/w53tphTa?= =?utf-8?q?jbLQZC44j6lVLqJ5YfDtxej9bnb2K5m3lGtM0H/8x193a/Jk0PcCYtt9ARYCQBXZ8?= =?utf-8?q?+lvAE/FJNV2w?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3be7ab50-29e9-487e-26ef-08da924c9da6 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2022 10:18:18.7834 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YpnThxLGF5A/7EqK57ZbdLAvF/lMhylvuvwT4QhtvBv84meEGgjCGmwoDiqh/eGmvawRqDkjEG/MlXuVlbKigQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8710 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 --- 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);