From patchwork Wed Oct 23 13:00:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206759 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 25A9B1515 for ; Wed, 23 Oct 2019 13:02:15 +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 0169F21906 for ; Wed, 23 Oct 2019 13:02:15 +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="au1rGKfH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0169F21906 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 1iNGFx-0006Ai-Vz; Wed, 23 Oct 2019 13:00:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNGFw-00069a-Vk for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:53 +0000 X-Inumbo-ID: 1471570c-f595-11e9-a531-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1471570c-f595-11e9-a531-bc764e2007e4; Wed, 23 Oct 2019 13:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=CGsCVvA9C5CHOtZ4CTQQ9jiw/fTOwqzG4idefXSC/GY=; b=au1rGKfHQBxGj6116AHfOJ+p0jrDGhR0Q8AI2+kvC8L2FYBXU3trDigv 5z2fkCqJgfVagJF2BC9MlkJybnzuPKj3xhO08lGyXIedIMOKFX8caLe6n I6KqLjKAaCjkbPVVQeXLxXOMgJz7wTLEiwZ9EljYsfL1UWbYmeLBD7l+R k=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: YchAr3PRPOCa9veYsbc4nSzMt4PdAOGMZlx+gjGaeTbJAxRsHgnd7fUH9zHNCfcMfXdl3jV6sX CW+FBckJBBH++RabRS+0Sj/1fPK4m7Ho8uKoDWa/j2+66Gom1uk3CaQmd8mIp7yuJIBq6ygK2o m4ik2RRZ7BqqF6M0tc0JKOqtrzp20MvbUUNu2gmRiKSE07FIEnv58qLSorVVU8IJh3xHqHKSkV gdikwmOODk4jprZXpv5a3V9q0QqcGBZw90JIWI82THghbStn1UuZwbY5AmQPtCBk7Q/SFxvf0N NOo= X-SBRS: 2.7 X-MesageID: 7411227 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,220,1569297600"; d="scan'208";a="7411227" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:08 +0100 Message-ID: <20191023130013.32382-7-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 06/11] 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: Anthony PERARD , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu 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 3b3b6ec381..e4ddfd067f 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -892,6 +892,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) @@ -1015,7 +1030,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);