From patchwork Mon May 6 08:33:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Like Xu X-Patchwork-Id: 10930729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47A751395 for ; Mon, 6 May 2019 08:36:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3815528474 for ; Mon, 6 May 2019 08:36:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B901285DB; Mon, 6 May 2019 08:36:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BB1D828474 for ; Mon, 6 May 2019 08:36:21 +0000 (UTC) Received: from localhost ([127.0.0.1]:52452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNZ6i-0004LS-GV for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 May 2019 04:36:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNZ5M-0002pU-Hb for qemu-devel@nongnu.org; Mon, 06 May 2019 04:34:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNZ5L-0007IQ-2D for qemu-devel@nongnu.org; Mon, 06 May 2019 04:34:56 -0400 Received: from mga14.intel.com ([192.55.52.115]:60065) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hNZ5K-0007DN-PX for qemu-devel@nongnu.org; Mon, 06 May 2019 04:34:55 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 May 2019 01:34:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,437,1549958400"; d="scan'208";a="155407038" Received: from xulike-server.sh.intel.com ([10.239.48.134]) by FMSMGA003.fm.intel.com with ESMTP; 06 May 2019 01:34:41 -0700 From: Like Xu To: qemu-devel@nongnu.org Date: Mon, 6 May 2019 16:33:07 +0800 Message-Id: <1557131596-25403-2-git-send-email-like.xu@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1557131596-25403-1-git-send-email-like.xu@linux.intel.com> References: <1557131596-25403-1-git-send-email-like.xu@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH v2 01/10] hw/boards: add struct CpuTopology to MachineState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr. David Alan Gilbert" , Paolo Bonzini , Alistair Francis , Igor Mammedov , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP To remove usages of global smp variables arch by arch, a bisect friendly way is introduced to initialize struct CpuTopology with duplicate ones; no semantic changes. Suggested-by: Igor Mammedov Suggested-by: Eduardo Habkost Signed-off-by: Like Xu Reviewed-by: Alistair Francis --- include/hw/boards.h | 15 +++++++++++++++ vl.c | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index 6f7916f..dc89c6d 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -231,6 +231,20 @@ typedef struct DeviceMemoryState { } DeviceMemoryState; /** + * CpuTopology: + * @cpus: the number of logical processors on the machine + * @cores: the number of cores in one package + * @threads: the number of threads in one core + * @max_cpus: the maximum number of logical processors on the machine + */ +typedef struct CpuTopology { + unsigned int cpus; + unsigned int cores; + unsigned int threads; + unsigned int max_cpus; +} CpuTopology; + +/** * MachineState: */ struct MachineState { @@ -272,6 +286,7 @@ struct MachineState { const char *cpu_type; AccelState *accelerator; CPUArchIdList *possible_cpus; + CpuTopology smp; struct NVDIMMState *nvdimms_state; }; diff --git a/vl.c b/vl.c index d9fea0a..43fd247 100644 --- a/vl.c +++ b/vl.c @@ -4099,6 +4099,11 @@ int main(int argc, char **argv, char **envp) smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); + current_machine->smp.cpus = smp_cpus; + current_machine->smp.max_cpus = max_cpus; + current_machine->smp.cores = smp_cores; + current_machine->smp.threads = smp_threads; + /* sanity-check smp_cpus and max_cpus against machine_class */ if (smp_cpus < machine_class->min_cpus) { error_report("Invalid SMP CPUs %d. The min CPUs "