From nobody Wed Nov 27 04:50:27 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 header.i=@intel.com; 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=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1701355221; cv=none; d=zohomail.com; s=zohoarc; b=XarCjfLFJ34SHp4DlYJ4FlbrYPp9FcDGulHE+hG/+p7/qkVy9bsi3fWXt8eMTQEeCEcHKSmZDNH1burjqlFzFZp+t5x5RFWTRxnrs2o1M+PRe/3+vSC0pqke8NKnfsX75wbqesKiwjJLH/o5qQgGb53H1qIhEVrPe97TQOaMXco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701355221; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p12BeQhcmKSgnkJJJQ3ZDkbTcZ5sKuxF+tV1dPV93lU=; b=iTSSBqnVZPzqLnUYs82DK15o0oeaGp105ohjH2LIQpN4Plclsg2wFOUnHtufzmXjJbKWcihuRCQnvBL4NkIIitLvPEQBWI1NP+rBJiG8XcULf+nnDMzHrfkSQCNx7wKa+wgQDO/1IG++BTtz9V9a3mwUoycegXSKK+kcRt1D124= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701355221036153.00211656150566; Thu, 30 Nov 2023 06:40:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.644820.1006494 (Exim 4.92) (envelope-from ) id 1r8iCh-0003WV-KY; Thu, 30 Nov 2023 14:39:47 +0000 Received: by outflank-mailman (output) from mailman id 644820.1006494; Thu, 30 Nov 2023 14:39:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8iCg-0003P8-N4; Thu, 30 Nov 2023 14:39:46 +0000 Received: by outflank-mailman (input) for mailman id 644820; Thu, 30 Nov 2023 14:36:44 +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 1r8i9k-0000pO-AZ for xen-devel@lists.xenproject.org; Thu, 30 Nov 2023 14:36:44 +0000 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dfa734af-8f8d-11ee-9b0f-b553b5be7939; Thu, 30 Nov 2023 15:36:42 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2023 06:36:24 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orsmga005.jf.intel.com with ESMTP; 30 Nov 2023 06:36:14 -0800 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: dfa734af-8f8d-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701355002; x=1732891002; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lndGadsp6lchipVix45sBuugJYcXf54DoIQPmPepLjo=; b=A6azXLPohjn3O2rubFp/PwjM2P0N7a1vzt+L4NzbeQoNeofkrrtPBG/V cVz5L2SGMPrFA1l5NUmqhJ253NbxyUg/ZIFrmkgprX0Y8f2Fr9fdnAlqk jhRJTq8FKmnPjdFXWtbJdgoBhKs59YptmVLm6FE87Eov8rGRgGDqmY60A 47/SdNx8iMnGlK22IMQXNESB57X0UU2jq6G6H4Re4/olwPJnBnKGMi/LK RRRiQhDOzjiVF2XoVMinXQ9RiQOjHw3dDbVdN6DkX0uE8+UVlbynjGWRI 0K2ezNsW1+f4+CqnyuJlZN36itjZChq9OgKlmqESyCCgk6nU+9FAdkEhp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="479532685" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="479532685" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="942730506" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="942730506" From: Zhao Liu To: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Richard Henderson , "Michael S . Tsirkin" , Jason Wang , Nicholas Piggin , Daniel Henrique Barboza , Igor Mammedov , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , David Gibson , Harsh Prateek Bora , Stefano Stabellini , Anthony Perard , Paul Durrant , Gerd Hoffmann , Peter Maydell , Alistair Francis , "Edgar E . Iglesias" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Bin Meng , Palmer Dabbelt , Weiwei Li , Liu Zhiwei , qemu-devel@nongnu.org, kvm@vger.kernel.org, qemu-ppc@nongnu.org, xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org Cc: Nina Schoetterl-Glausch , Thomas Huth , Zhiyuan Lv , Zhenyu Wang , Yongwei Ma , Zhao Liu Subject: [RFC 37/41] hw/i386: Allow i386 to create new CPUs from QOM topology Date: Thu, 30 Nov 2023 22:41:59 +0800 Message-Id: <20231130144203.2307629-38-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130144203.2307629-1-zhao1.liu@linux.intel.com> References: <20231130144203.2307629-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1701355224000000001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu For QOM topology, maximum number of CPUs and the number of plugged CPUs are configured in core level. Iterate through all the cpu-cores to determine how many CPUs should be created in each cpu-core. Signed-off-by: Zhao Liu --- hw/i386/x86.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 3c99f4c3ab51..febffed92a83 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -152,9 +152,35 @@ void x86_cpus_init(X86MachineState *x86ms, int default= _cpu_version) } =20 possible_cpus =3D mc->possible_cpu_arch_ids(ms); - for (i =3D 0; i < ms->smp.cpus; i++) { - x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, - NULL, i, &error_fatal); + + /* + * possible_cpus_qom_granu means the QOM topology support. + * + * TODO: Drop the "!mc->smp_props.possible_cpus_qom_granu" case when + * i386 completes QOM topology support. + */ + if (mc->smp_props.possible_cpus_qom_granu) { + CPUCore *core; + int cpu_index =3D 0; + int core_idx =3D 0; + + MACHINE_CORE_FOREACH(ms, core) { + for (i =3D 0; i < core->plugged_threads; i++) { + x86_cpu_new(x86ms, possible_cpus->cpus[cpu_index].arch_id, + OBJECT(core), cpu_index, &error_fatal); + cpu_index++; + } + + if (core->plugged_threads < core->nr_threads) { + cpu_index +=3D core->nr_threads - core->plugged_threads; + } + core_idx++; + } + } else { + for (i =3D 0; i < ms->smp.cpus; i++) { + x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, + NULL, i, &error_fatal); + } } } =20 --=20 2.34.1