From patchwork Fri Sep 6 19:12:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11135869 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA27815E6 for ; Fri, 6 Sep 2019 19:20:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 90AB32070C for ; Fri, 6 Sep 2019 19:20:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="W1He1hfu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90AB32070C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6JmA-0002F2-HP for patchwork-qemu-devel@patchwork.kernel.org; Fri, 06 Sep 2019 15:20:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42439) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Jf5-000323-28 for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Jf3-0004IZ-OB for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:12:46 -0400 Received: from mail-eopbgr820047.outbound.protection.outlook.com ([40.107.82.47]:35392 helo=NAM01-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6Jf3-0004Hx-Hn for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:12:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UNa8gzatfrDZC0LGQHQ++qfs0f6g/Z1cXdsTseTuJHzoi0Cal/d7Mh/jJ0elQrMh9U9GHZ8QPyafK1+PZ/hIxRmclR4koQSJO5SMg1r4Qa91KTqKE2JdQs55aGvGbAqremGaKZRAS/SgfrCotMYeMFOm0yforsOfXbyql00XAfK6+zUKJah93z42rcXUkAYK/o7u0jRYtkfmBkkHaBrOZMtbZTdQRvFm6fPN4lsT6zOsbbZYuw7Le3mUKd2pANTYsqu15HhMG7Zjb5kKxu57yoE+8vA85MpvAfIICz9QZoq4miJpSNEJxGw8vjuyAyMFgAy9lLPwxPCBk4HhjhfVrA== 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-SenderADCheck; bh=JuqYy9UvvBS5/L+WPADOg993uQRllW65PkBUEj1tMS8=; b=XmCaW8cE2pUncufiYOrXKbH4guzbRbsaGVoq0Dws7PJkvvZNAu/9vqSUn9i9etjf1gC6frcb8SMiDMnx8AFzcTi/JLasFA5Gi5L0ABBN3e305MYvaziMsENoEv3/RgEKLkrDkrbsIQ83qF7IzRHk1hGSWrbixKBauQqPlDyUTibGIdqGXOsG8G+UFdQ6Z5n02o0J6ddEyTnKjh48bV0RZDHEkJ3TAThBAlY+BOCMWf9l7l+SDDzHFoSeNzsCk5w23hEvdVpMM92suUn/QR2ZMT5OvXQCmx9+VO2LpdvbplSqhMGvuHryUAU3mRdknBBDK7qz5h1p/2PkoOyyCn2fPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JuqYy9UvvBS5/L+WPADOg993uQRllW65PkBUEj1tMS8=; b=W1He1hfu7h9QPE0x16b4Vw5ndTzo1KGcjM20tIAIj4vg0dl1Tb67/45zVfSF9+oRV7cT+j28KKhtdZGmXHewQFQEDPlGc1EZ28nmVHPsE93QHiOtctl7O7dfd4ejw+8+j00LxI7cY28pr/Hpmfsz2gmlcOVkIc9gdLrRZ8S0eSg= Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB1179.namprd12.prod.outlook.com (10.168.234.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2241.14; Fri, 6 Sep 2019 19:12:41 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8%3]) with mapi id 15.20.2220.022; Fri, 6 Sep 2019 19:12:40 +0000 From: "Moger, Babu" To: ssg.sos.staff , "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "eblake@redhat.com" , "armbru@redhat.com" , "imammedo@redhat.com" Thread-Topic: [RFC 2 PATCH 09/16] hw/i386: Introduce initialize_topo_info function Thread-Index: AQHVZOcNbGFqs/bz/0O7j4JtAjT1Xg== Date: Fri, 6 Sep 2019 19:12:40 +0000 Message-ID: <156779715852.21957.5495116804345322435.stgit@localhost.localdomain> References: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> In-Reply-To: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0601CA0007.namprd06.prod.outlook.com (2603:10b6:803:2f::17) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e05cdf22-8d6d-4824-e73a-08d732fe2fac x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB1179; x-ms-traffictypediagnostic: DM5PR12MB1179: x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 0152EBA40F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(189003)(199004)(6116002)(103116003)(76176011)(305945005)(86362001)(256004)(2201001)(71190400001)(71200400001)(81156014)(81166006)(2906002)(476003)(3846002)(446003)(8676002)(11346002)(486006)(102836004)(7736002)(6506007)(386003)(6486002)(26005)(8936002)(5660300002)(186003)(4326008)(66066001)(6436002)(14454004)(25786009)(52116002)(9686003)(6512007)(53936002)(99286004)(2501003)(110136005)(478600001)(316002)(66476007)(64756008)(66446008)(66556008)(66946007); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1179; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: r2UF9rZ/mnctBgsekybFePc7ZTs5MpUP8xg5FwdBRDFNHRXjr0zLuVOh8KkO1vWbwIsK/qbu1EQOI3o3BY6KZHk2WbyfV/f3SaklRI4EB4AHtWxNkUxEMq3MNs9ijjL/Mpd+LEjmBdZTxPTClOh8lxME/+gVAR8HLo7IgeesYojfIHMKrz5RGHkTWvfn+QrCHhx1tzdPm6cB9GdUl2tzfo3DaVWcGH6IhUtfrPVoWNDqkENgfuvHk3rRMsBLUYOejaHwZAr+sZegCHbwRbNILxYamWH8kF/2JoT0M7yiyjkVvdw2s8cerT53FRPZUcFr3oo6pksyTYSz6G1JO1z1khuRFZYXbtB6AHl16DnMBuHO/3SYOqtofpn7dvH+f/l7GGj/xnXEhCZZlOmKqv5IzPErJ6K8D6g/ERYV1abUhEk= Content-ID: <80927C8386A37F468857F4476325BEA8@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e05cdf22-8d6d-4824-e73a-08d732fe2fac X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2019 19:12:40.3554 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 8D8b7KHEiSqvhjb4DwKTPvHh+g/3zNZUU3JuqCp1WUQ9Yk/2Sco1IcNYG5sOecpj X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1179 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.82.47 Subject: [Qemu-devel] [RFC 2 PATCH 09/16] hw/i386: Introduce initialize_topo_info function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Introduce initialize_topo_info to initialize X86CPUTopoInfo data structure to build the topology. No functional change. Signed-off-by: Babu Moger Reviewed-by: Eduardo Habkost --- hw/i386/pc.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f71389ad9f..504e1ab083 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -918,6 +918,17 @@ bool e820_get_entry(int idx, uint32_t type, uint64_t *address, uint64_t *length) return false; } +static inline void initialize_topo_info(X86CPUTopoInfo *topo_info, + PCMachineState *pcms, + const MachineState *ms) +{ + topo_info->nr_dies = pcms->smp_dies; + topo_info->nr_cores = ms->smp.cores; + topo_info->nr_threads = ms->smp.threads; + topo_info->nr_sockets = ms->smp.sockets; + topo_info->numa_nodes = nb_numa_nodes; +} + /* Calculates initial APIC ID for a specific CPU index * * Currently we need to be able to calculate the APIC ID from the CPU index @@ -934,9 +945,7 @@ static uint32_t x86_cpu_apic_id_from_index(PCMachineState *pcms, uint32_t correct_id; static bool warned; - topo_info.nr_dies = pcms->smp_dies; - topo_info.nr_cores = ms->smp.cores; - topo_info.nr_threads = ms->smp.threads; + initialize_topo_info(&topo_info, pcms, ms); correct_id = x86_apicid_from_cpu_idx(&topo_info, cpu_index); if (pcmc->compat_apic_id_mode) { @@ -2399,9 +2408,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, return; } - topo_info.nr_dies = pcms->smp_dies; - topo_info.nr_cores = smp_cores; - topo_info.nr_threads = smp_threads; + initialize_topo_info(&topo_info, pcms, ms); env->nr_dies = pcms->smp_dies; @@ -2859,9 +2866,7 @@ static int64_t pc_get_default_cpu_node_id(const MachineState *ms, int idx) PCMachineState *pcms = PC_MACHINE(ms); X86CPUTopoInfo topo_info; - topo_info.nr_dies = pcms->smp_dies; - topo_info.nr_cores = ms->smp.cores; - topo_info.nr_threads = ms->smp.threads; + initialize_topo_info(&topo_info, pcms, ms); assert(idx < ms->possible_cpus->len); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, @@ -2876,9 +2881,6 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms) X86CPUTopoInfo topo_info; int i; - topo_info.nr_dies = pcms->smp_dies; - topo_info.nr_cores = ms->smp.cores; - topo_info.nr_threads = ms->smp.threads; if (ms->possible_cpus) { /* @@ -2891,6 +2893,9 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms) ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) + sizeof(CPUArchId) * max_cpus); + + initialize_topo_info(&topo_info, pcms, ms); + ms->possible_cpus->len = max_cpus; for (i = 0; i < ms->possible_cpus->len; i++) { X86CPUTopoIDs topo_ids;