From nobody Sat Nov 30 03:47:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1615455675; cv=none; d=zohomail.com; s=zohoarc; b=G9CooWjy+lZto1Mj0yV4W8IzjTM1WhdDNncSlD7TCzmhwzS1c3J+qjd9VtftJJlXwIGS/1rWFdck8MmtKaV+WF2X1LjaeTBUFThLOtLa89+vCimeghe0sSOC4000ouaWSNewkBn18t4LJoMEqWKzh4GESRXoMD7+mG1w3UIItVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615455675; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=1XVkrEfKmBVOU6F+L+VVfC9OHCsEz9IKiz0UT5qoCQE=; b=M1akNAjvOBHuS685nT9cj1k8meBP/fHR1eLkQdSa5Eor410bTtjZbskcBVcG2+MddIVPQcOpb0/vhwYKLE02WsvyY5nhaF2MkxoamnNGYIKk7TIjYyAQyVuexydaLB0g+coh/6aoxUg8dDQ+ZnnpR2Z5Vbzai3hTHstR0q9Z3sY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1615455675837124.6616224016692; Thu, 11 Mar 2021 01:41:15 -0800 (PST) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) When running an hypervisor build with NR_CPUS=3D1 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 =3D=3D 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=3D1, 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 mas= k) #define FREE_CPUMASK_VAR(m) free_cpumask_var(m) #endif =20 -#if NR_CPUS > 1 #define for_each_cpu(cpu, mask) \ for ((cpu) =3D cpumask_first(mask); \ (cpu) < nr_cpu_ids; \ (cpu) =3D cpumask_next(cpu, mask)) -#else /* NR_CPUS =3D=3D 1 */ -#define for_each_cpu(cpu, mask) \ - for ((cpu) =3D 0; (cpu) < 1; (cpu)++, (void)(mask)) -#endif /* NR_CPUS */ =20 /* * The following particular system cpumasks and operations manage