From patchwork Tue Nov 26 17:17:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 11262907 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 69BD314DB for ; Tue, 26 Nov 2019 17:18:52 +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 32ADD20659 for ; Tue, 26 Nov 2019 17:18:52 +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="IO4IiNyz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32ADD20659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=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 1iZeTL-00022l-Dw; Tue, 26 Nov 2019 17:17:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZeTK-00022g-AD for xen-devel@lists.xenproject.org; Tue, 26 Nov 2019 17:17:54 +0000 X-Inumbo-ID: add85828-1070-11ea-83b8-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id add85828-1070-11ea-83b8-bc764e2007e4; Tue, 26 Nov 2019 17:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1574788672; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ASpLrY08k0vg3iG3H6eN2C2LQ2l7vVfEfltmDsQSMVA=; b=IO4IiNyzsEYXJ6Q7FksHBeyRlGE34oW6bI1yTxX4Go0lS4RUQzfMxZb+ VreOy72ny6WiPiE8aHLY7HaZmvcWbTCc+aa2H/pjZSOw5uyH00l9ZCeHU iJFDJWXvG3oBjU+GNyfXxPdn2ZnquMxMNTZVZzokWDAtpIVrwJdKZBh8O s=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 8VkAuDj7OiyC31pbVuPLk8RC6lB3lpQzNHPyylq8EkDnvFZmD//lvZ0DJqJB+/5lSq8c9wIZo2 9xOvOIpZXPdQQLoSEoz8FJaRGEg2/UPUOWSSCiZRg6nVAufzOgFzHmD6FEmO1KZSDQjwVHdePg 7xMCXdkTvxPjxQ3aqCkYcxGWQU9Pf7yu92jweaUfjAREHF/Tq/M6puuH1jXU0bY7WYYcU41Elu 95wQtPukO19rO5lW4Y3pkewoLDS884vQPFq3bso+J1JCVMcknakEdLe0urkYqMIUg/v7BEjpjs UCs= X-SBRS: 2.7 X-MesageID: 9410834 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,246,1571716800"; d="scan'208";a="9410834" From: George Dunlap To: Date: Tue, 26 Nov 2019 17:17:47 +0000 Message-ID: <20191126171747.3185988-2-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191126171747.3185988-1-george.dunlap@citrix.com> References: <20191126171747.3185988-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-4.13 2/2] Rationalize max_grant_frames and max_maptrack_frames handling 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: Juergen Gross , Stefano Stabellini , Julien Grall , Wei Liu , Paul Durrant , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , =?utf-8?q?Marek_Marczykowski-G?= =?utf-8?q?=C3=B3recki?= , Jan Beulich , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Xen used to have single, system-wide limits for the number of grant frames and maptrack frames a guest was allowed to create. Increasing or decreasing this single limit on the Xen command-line would change the limit for all guests on the system. Later, per-domain limits for these values was created. The system-wide limits became strict limits: domains could not be created with higher limits, but could be created with lower limits. However, the change also introduced a range of different "default" values into various places in the toolstack: - The python libxc bindings hard-coded these values to 32 and 1024, respectively - The libxl default values are 32 and 1024 respectively. - xl will use the libxl default for maptrack, but does its own default calculation for grant frames: either 32 or 64, based on the max possible mfn. These defaults interact poorly with the hypervisor command-line limit: - The hypervisor command-line limit cannot be used to raise the limit for all guests anymore, as the default in the toolstack will effectively override this. - If you use the hypervisor command-line limit to *reduce* the limit, then the "default" values generated by the toolstack are too high, and all guest creations will fail. In other words, the toolstack defaults require any change to be effected by having the admin explicitly specify a new value in every guest. In order to address this, have grant_table_init treat '0' values for max_grant_frames and max_maptrack_frames as instructions to use the system-wide default. Have all the above toolstacks default to passing 0 unless a different value is explicitly given. This restores the old behavior, that changing the hypervisor command-line option can change the behavior for all guests, while retaining the ability to set per-guest values. It also removes the bug that *reducing* the system-wide max will cause all domains without explicit limits to fail. (The ocaml bindings require the caller to always specify a value, and the code to start a xenstored stubdomain hard-codes these to 4 and 128 respectively; these will not be addressed here.) Signed-off-by: George Dunlap --- Release justification: This is an observed regression (albeit one that has spanned several releases now). Compile-tested only. NB this patch could be applied without the whitespace fixes (perhaps with some fix-ups); it's just easier since my editor strips trailing whitespace out automatically. CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper CC: Jan Beulich CC: Paul Durrant CC: Julien Grall CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Juergen Gross CC: Marek Marczykowski-Górecki --- tools/libxl/libxl.h | 4 ++-- tools/python/xen/lowlevel/xc/xc.c | 2 -- tools/xl/xl.c | 12 ++---------- xen/common/grant_table.c | 7 +++++++ xen/include/public/domctl.h | 6 ++++-- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 49b56fa1a3..1648d337e7 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -364,8 +364,8 @@ */ #define LIBXL_HAVE_BUILDINFO_GRANT_LIMITS 1 -#define LIBXL_MAX_GRANT_FRAMES_DEFAULT 32 -#define LIBXL_MAX_MAPTRACK_FRAMES_DEFAULT 1024 +#define LIBXL_MAX_GRANT_FRAMES_DEFAULT 0 +#define LIBXL_MAX_MAPTRACK_FRAMES_DEFAULT 0 /* * LIBXL_HAVE_BUILDINFO_* indicates that libxl_domain_build_info has diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 6d2afd5695..0f861872ce 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -127,8 +127,6 @@ static PyObject *pyxc_domain_create(XcObject *self, }, .max_vcpus = 1, .max_evtchn_port = -1, /* No limit. */ - .max_grant_frames = 32, - .max_maptrack_frames = 1024, }; static char *kwd_list[] = { "domid", "ssidref", "handle", "flags", diff --git a/tools/xl/xl.c b/tools/xl/xl.c index ddd29b3f1b..b6e220184d 100644 --- a/tools/xl/xl.c +++ b/tools/xl/xl.c @@ -51,8 +51,8 @@ libxl_bitmap global_pv_affinity_mask; enum output_format default_output_format = OUTPUT_FORMAT_JSON; int claim_mode = 1; bool progress_use_cr = 0; -int max_grant_frames = -1; -int max_maptrack_frames = -1; +int max_grant_frames = 0; +int max_maptrack_frames = 0; xentoollog_level minmsglevel = minmsglevel_default; @@ -96,7 +96,6 @@ static void parse_global_config(const char *configfile, XLU_Config *config; int e; const char *buf; - libxl_physinfo physinfo; config = xlu_cfg_init(stderr, configfile); if (!config) { @@ -199,13 +198,6 @@ static void parse_global_config(const char *configfile, if (!xlu_cfg_get_long (config, "max_grant_frames", &l, 0)) max_grant_frames = l; - else { - libxl_physinfo_init(&physinfo); - max_grant_frames = (libxl_get_physinfo(ctx, &physinfo) != 0 || - !(physinfo.max_possible_mfn >> 32)) - ? 32 : 64; - libxl_physinfo_dispose(&physinfo); - } if (!xlu_cfg_get_long (config, "max_maptrack_frames", &l, 0)) max_maptrack_frames = l; diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index b34d520f6d..cd24029e33 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1843,6 +1843,13 @@ int grant_table_init(struct domain *d, unsigned int max_grant_frames, struct grant_table *gt; int ret = -ENOMEM; + /* Default to maximum values if no lower ones are specified */ + if ( !max_grant_frames ) + max_grant_frames = opt_max_grant_frames; + + if ( !max_maptrack_frames ) + max_maptrack_frames = opt_max_maptrack_frames; + if ( max_grant_frames < INITIAL_NR_GRANT_FRAMES || max_grant_frames > opt_max_grant_frames || max_maptrack_frames > opt_max_maptrack_frames ) diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 9f2cfd602c..27d04f67aa 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -82,8 +82,10 @@ struct xen_domctl_createdomain { uint32_t iommu_opts; /* - * Various domain limits, which impact the quantity of resources (global - * mapping space, xenheap, etc) a guest may consume. + * Various domain limits, which impact the quantity of resources + * (global mapping space, xenheap, etc) a guest may consume. For + * max_grant_frames and max_maptrack_frames, "0" means "use the + * default maximum value". */ uint32_t max_vcpus; uint32_t max_evtchn_port;