From patchwork Mon Feb 22 21:02:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 8383361 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 82B509F1D4 for ; Mon, 22 Feb 2016 21:05:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9027A205CD for ; Mon, 22 Feb 2016 21:05:43 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FC24205B5 for ; Mon, 22 Feb 2016 21:05:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXxdI-000198-TJ; Mon, 22 Feb 2016 21:03:04 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXxdH-00017F-3b for xen-devel@lists.xen.org; Mon, 22 Feb 2016 21:03:03 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 7F/89-03883-6877BC65; Mon, 22 Feb 2016 21:03:02 +0000 X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1456174980!24170877!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40765 invoked from network); 22 Feb 2016 21:03:01 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-3.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Feb 2016 21:03:01 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1ML2tIC004515 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Feb 2016 21:02:55 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u1ML2s5Q015513 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 22 Feb 2016 21:02:55 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u1ML2sT7008272; Mon, 22 Feb 2016 21:02:54 GMT Received: from localhost.localdomain (/89.181.88.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 22 Feb 2016 13:02:54 -0800 From: Joao Martins To: xen-devel@lists.xen.org Date: Mon, 22 Feb 2016 21:02:13 +0000 Message-Id: <1456174934-22973-8-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456174934-22973-1-git-send-email-joao.m.martins@oracle.com> References: <1456174934-22973-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Wei Liu , Joao Martins , Ian Jackson , Ian Campbell , Stefano Stabellini Subject: [Xen-devel] [PATCH RFC 7/8] libxl: introduce topology fields X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently there is "smt" option that changes from a flat core topology to a core+thread topology. This patch adds more expressive options for describing the topology as seen by the guest i.e. sockets, cores and threads to adjust cpu topology as seen by the guest. Signed-off-by: Joao Martins --- CC: Ian Jackson CC: Stefano Stabellini CC: Ian Campbell CC: Wei Liu --- tools/libxl/libxl_dom.c | 18 ++++++++++++------ tools/libxl/libxl_types.idl | 4 ++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index ff9356d..1e6d9ab 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -507,14 +507,20 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid, } libxl_cpuid_apply_policy(ctx, domid); - if (info->type == LIBXL_DOMAIN_TYPE_HVM - && libxl_defbool_val(info->smt)) { + if (info->type == LIBXL_DOMAIN_TYPE_HVM) { - uint32_t threads = 0; + uint32_t threads = 0, cores = 0; + + if (libxl_defbool_val(info->smt) + && !libxl__count_threads_per_core(gc, &threads)) + cores = info->max_vcpus / threads; + else if (info->topology.cores) { + cores = info->topology.cores; + threads = info->topology.threads; + } - if (!libxl__count_threads_per_core(gc, &threads)) - libxl__cpuid_set_topology(ctx, domid, - info->max_vcpus / threads, threads); + if (cores && threads) + libxl__cpuid_set_topology(ctx, domid, cores, threads); } if (info->cpuid != NULL) diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index fa4725a..caba626 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -422,6 +422,10 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("vcpu_hard_affinity", Array(libxl_bitmap, "num_vcpu_hard_affinity")), ("vcpu_soft_affinity", Array(libxl_bitmap, "num_vcpu_soft_affinity")), ("smt", libxl_defbool), + ("topology", Struct(None, [("sockets", integer), + ("cores", integer), + ("threads", integer), + ])), ("numa_placement", libxl_defbool), ("tsc_mode", libxl_tsc_mode), ("max_memkb", MemKB),