From patchwork Thu Mar 11 09:40:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 12130723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 572E4C433E0 for ; Thu, 11 Mar 2021 09:41:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E53C164F4D for ; Thu, 11 Mar 2021 09:41:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E53C164F4D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.96410.182347 (Exim 4.92) (envelope-from ) id 1lKHoG-00073P-Ao; Thu, 11 Mar 2021 09:40:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 96410.182347; Thu, 11 Mar 2021 09:40:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lKHoG-00073I-7q; Thu, 11 Mar 2021 09:40:48 +0000 Received: by outflank-mailman (input) for mailman id 96410; Thu, 11 Mar 2021 09:40:46 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lKHoE-00073D-NY for xen-devel@lists.xenproject.org; Thu, 11 Mar 2021 09:40:46 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f4168d23-4778-427b-ab71-434787f94cf1; Thu, 11 Mar 2021 09:40:45 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3E146AC16; Thu, 11 Mar 2021 09:40:44 +0000 (UTC) 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: f4168d23-4778-427b-ab71-434787f94cf1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1615455644; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1XVkrEfKmBVOU6F+L+VVfC9OHCsEz9IKiz0UT5qoCQE=; b=MZqljq3IQAm31q6uxSEDAaFiKhtAirMgPS3ixjN4ZYyKYth1Q+3U2oqsl5t9tDvtzOUsRv YeDa7TMLqN6ZPUrOSP1foQTd/UL0oUTQ0nZvsc6mlb+tnfhcStOYMyUNa8Png+F3m81zxq itxFjCWpndQy+o41c1uNHzQhu6KPn7s= Subject: [PATCH] xen: fix for_each_cpu when NR_CPUS=1 From: Dario Faggioli To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Date: Thu, 11 Mar 2021 09:40:43 +0000 Message-ID: <161545564302.24868.14477928469038686899.stgit@Wayrath> User-Agent: StGit/0.23 MIME-Version: 1.0 When running an hypervisor build with NR_CPUS=1 for_each_cpu does not take into account whether the bit of the CPU is set or not in the provided mask. This means that whatever we have in the bodies of these loops is always done once, even if the mask was empty and it should never be done. This is clearly a bug and was in fact causing an assert to trigger in credit2 code. Removing the special casing of NR_CPUS == 1 makes things work again. Signed-off-by: Dario Faggioli Reviewed-by: Jan Beulich --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu --- I'm not really sure whether this should be 4.15 material. It's definitely a bug, IMO. The risk is also pretty low, considering that no one should really run Xen in this configuration (NR_CPUS=1, I mean). Which is also the reason why it's probably not really important that we fix it at this point of the release cycle. --- xen/include/xen/cpumask.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h index 256b60b106..e69589fc08 100644 --- a/xen/include/xen/cpumask.h +++ b/xen/include/xen/cpumask.h @@ -368,15 +368,10 @@ static inline void free_cpumask_var(cpumask_var_t mask) #define FREE_CPUMASK_VAR(m) free_cpumask_var(m) #endif -#if NR_CPUS > 1 #define for_each_cpu(cpu, mask) \ for ((cpu) = cpumask_first(mask); \ (cpu) < nr_cpu_ids; \ (cpu) = cpumask_next(cpu, mask)) -#else /* NR_CPUS == 1 */ -#define for_each_cpu(cpu, mask) \ - for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)(mask)) -#endif /* NR_CPUS */ /* * The following particular system cpumasks and operations manage