From patchwork Fri Oct 11 16:55:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11185969 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 D90B213BD for ; Fri, 11 Oct 2019 16:57:38 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 B3F5B21835 for ; Fri, 11 Oct 2019 16:57:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="JZ777Cop" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3F5B21835 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eu.citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iIyDM-0006Ow-4U; Fri, 11 Oct 2019 16:56:28 +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.89) (envelope-from ) id 1iIyDK-0006Nv-6m for xen-devel@lists.xenproject.org; Fri, 11 Oct 2019 16:56:26 +0000 X-Inumbo-ID: 001a7259-ec48-11e9-933c-12813bfff9fa Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 001a7259-ec48-11e9-933c-12813bfff9fa; Fri, 11 Oct 2019 16:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1570812961; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JNRfdopukaOlhMpCjX7qlV0PExRAUddJQPV/qbm4lpc=; b=JZ777CopNDC/K1+r+2NpjuvcIpyhem2Egve3UdY0OJ2uI2Shp3XIKyrI awkA/GdKP4cLH7Y9fAD3LHonO1yCUVdAcX0iFRKcGa7b5zgLGiozJUEeh CJwOaZCtM+HcUgxYFeCfqEA9/2MWw9P539d3g6Y8QjxAEkxA0ohvBi2Rp g=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@eu.citrix.com; spf=Pass smtp.mailfrom=Ian.Jackson@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of ian.jackson@eu.citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of Ian.Jackson@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="Ian.Jackson@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: MqK8haB2v9gCI5UCp1G1RqxVy5EKXVZ4HZnGmNAiDbDnCcJzygDVKSerrUYUGmEbAbCAMybm5V XfjttP+jTzwSQPhMlFOjBe4rpRvugDI2YJ9pBo2Ksc9/NAqbksRm+V3nfH60CmqtK0v/wHrpfx tKW+3qfcd+8IrupjxLa/0S2Gkkol5RAxD1Ag/Ts3QQ+r9ZrQRr9fx8RkcIIehUs0YFJSvAgnxz t+NAzbiG63mXirhlRdzjTgkyuBi7rROCr3lkVTdKu9RCmhnMcezG4RQ/vbikEzitc8fykfJKOi zJ4= X-SBRS: 2.7 X-MesageID: 6777203 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.67,284,1566878400"; d="scan'208";a="6777203" From: Ian Jackson To: Date: Fri, 11 Oct 2019 17:55:45 +0100 Message-ID: <20191011165549.21639-3-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191011165549.21639-1-ian.jackson@eu.citrix.com> References: <20191011165549.21639-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v3 06/10] libxl: Remove/deprecate libxl_get_required_*_memory from the API X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Paul Durrant , Ian Jackson , Jan Beulich , Andrew Cooper Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" These are now redundant because shadow_memkb and iommu_memkb are now defaulted automatically by libxl_domain_need_memory and libxl_domain_create etc. Callers should not now call these; instead, they should just let libxl take care of it. libxl_get_required_shadow_memory was introduced in f89f555827a6 "remove late (on-demand) construction of IOMMU page tables" We can freely remove it because it was never in any release. libxl_get_required_shadow_memory has been in libxl approximately forever. It should probably not have survived the creation of libxl_domain_create, but it seems the API awkwardnesses we see in recent commits prevented this. So we have to keep it. It remains functional but we can deprecate it. Hopefully we can get rid of it completely before we find the need to change the calculation to use additional information which its arguments do not currently supply. Signed-off-by: Ian Jackson Acked-by: Anthony PERARD --- tools/libxl/libxl_create.c | 17 ++++++++++++++++- tools/libxl/libxl_utils.c | 15 --------------- tools/libxl/libxl_utils.h | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index a1b00a8aef..b394312d98 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -888,6 +888,21 @@ static bool ok_to_default_memkb_in_create(libxl__gc *gc) */ } +static unsigned long libxl__get_required_iommu_memory(unsigned long maxmem_kb) +{ + unsigned long iommu_pages = 0, mem_pages = maxmem_kb / 4; + unsigned int level; + + /* Assume a 4 level page table with 512 entries per level */ + for (level = 0; level < 4; level++) + { + mem_pages = DIV_ROUNDUP(mem_pages, 512); + iommu_pages += mem_pages; + } + + return iommu_pages * 4; +} + int libxl__domain_config_setdefault(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid) @@ -1011,7 +1026,7 @@ int libxl__domain_config_setdefault(libxl__gc *gc, && ok_to_default_memkb_in_create(gc)) d_config->b_info.iommu_memkb = (d_config->c_info.passthrough == LIBXL_PASSTHROUGH_SYNC_PT) - ? libxl_get_required_iommu_memory(d_config->b_info.max_memkb) + ? libxl__get_required_iommu_memory(d_config->b_info.max_memkb) : 0; ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info); diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 405733b7e1..f360f5e228 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -48,21 +48,6 @@ unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, unsigned return 4 * (256 * smp_cpus + 2 * (maxmem_kb / 1024)); } -unsigned long libxl_get_required_iommu_memory(unsigned long maxmem_kb) -{ - unsigned long iommu_pages = 0, mem_pages = maxmem_kb / 4; - unsigned int level; - - /* Assume a 4 level page table with 512 entries per level */ - for (level = 0; level < 4; level++) - { - mem_pages = DIV_ROUNDUP(mem_pages, 512); - iommu_pages += mem_pages; - } - - return iommu_pages * 4; -} - char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid) { unsigned int len; diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h index 630ccbe28a..46918aea84 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -24,7 +24,7 @@ const char *libxl_basename(const char *name); /* returns string from strdup */ unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, unsigned int smp_cpus); -unsigned long libxl_get_required_iommu_memory(unsigned long maxmem_kb); + /* deprecated; see LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG in libxl.h */ int libxl_name_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid); int libxl_domain_qualifier_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid); char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid);