From patchwork Wed Oct 22 16:40:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 39322 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 90983202DB for ; Wed, 22 Oct 2014 16:44:22 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id d1sf883506wiv.6 for ; Wed, 22 Oct 2014 09:44:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=6WctEVJ2qY+fFfN3fZ+tj0NRJBi+3OUiUGSF/45ycq0=; b=R/CSzLeioya0fmn0oeSTaW5xvdwc2xtOiqXN58bOYHpTHe+rXYdFXlzJMWSOmawxMM Oswp4iy7Vyt99cGLiApcygfZ3++Z4IanoEGsA+U1L7EH/V+bQNTlnfLp7GHJor2cH+E+ Hsvr30I163IMh/uyWuBtOl4TjVLUgivcqgbM+CmOcOkE8eE3AUyv9V77kRglEEgtmeF/ 326XoN1Vbis2w5Va358TYo/O1WecmZzGAYMASe3AjQsTels3WL2IKPF80NTDnoNOW/ke zHtlgfWTwTH8lIMFGXoaCcZGlDC+KQz193CCLpUdC8cru3ncXteN2JTPKZeh4u2X69UK Bs1w== X-Gm-Message-State: ALoCoQnIWW9AEBW1zAsZ46+ruTk2DoXddZXzwPvxPlacb+8PXtl2BRI1aClXqPwXOV4l6+5Frl3O X-Received: by 10.112.137.202 with SMTP id qk10mr919430lbb.11.1413996261735; Wed, 22 Oct 2014 09:44:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.169 with SMTP id f9ls213702lam.11.gmail; Wed, 22 Oct 2014 09:44:21 -0700 (PDT) X-Received: by 10.112.85.138 with SMTP id h10mr42709928lbz.33.1413996261584; Wed, 22 Oct 2014 09:44:21 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id jp10si24068397lab.19.2014.10.22.09.44.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 09:44:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id 10so3165083lbg.4 for ; Wed, 22 Oct 2014 09:44:21 -0700 (PDT) X-Received: by 10.152.120.199 with SMTP id le7mr8871291lab.67.1413996261215; Wed, 22 Oct 2014 09:44:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp110698lbz; Wed, 22 Oct 2014 09:44:20 -0700 (PDT) X-Received: by 10.220.71.72 with SMTP id g8mr9761246vcj.33.1413996259659; Wed, 22 Oct 2014 09:44:19 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id t9si10540440vdf.89.2014.10.22.09.44.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 22 Oct 2014 09:44:19 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xgz0R-0004E2-Ex; Wed, 22 Oct 2014 16:43:27 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xgz0P-0004CH-Vn for xen-devel@lists.xensource.com; Wed, 22 Oct 2014 16:43:26 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id 1C/D2-10419-8AED7445; Wed, 22 Oct 2014 16:43:20 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1413996193!12015823!7 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28805 invoked from network); 22 Oct 2014 16:43:19 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-10.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 22 Oct 2014 16:43:19 -0000 X-IronPort-AV: E=Sophos;i="5.04,769,1406592000"; d="scan'208";a="185164557" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Wed, 22 Oct 2014 12:43:10 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xgz05-0001kp-7o; Wed, 22 Oct 2014 17:43:05 +0100 From: Stefano Stabellini To: Date: Wed, 22 Oct 2014 17:40:30 +0100 Message-ID: <1413996037-2747-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, JBeulich@suse.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v11 1/8] xen: introduce gnttab_max_frames and gnttab_max_maptrack_frames command line options X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Introduce gnttab_max_maptrack_frames: a new Xen command line option to specify the max number of maptrack frames per domain. Deprecate the old gnttab_max_nr_frames and introduce gnttab_max_frames instead, that doesn't affect the maptrack. Keep gnttab_max_nr_frames for compatibility. Rename internally max_nr_grant_frames to max_grant_frames to avoid confusions. Introduce DEFAULT_MAX_MAPTRACK_FRAMES, that is completely independent from max_nr_grant_frames. Remove MAX_MAPTRACK_TO_GRANTS_RATIO that is now only used in one place for compatibility. Signed-off-by: Stefano Stabellini Acked-by: Jan Beulich --- Changes in v10: - fix coding style for comments; - move BUILD_BUG_ON closer to where it matters. Changes in v9: - fix coding style for comments; - other style fixes. Changes in v8: - remove unused #include; - set max_nr_grant_frames as __initdata; - set max_grant_frames and max_maptrack_frames as __read_mostly; - fix coding style for comments; - remove MAX_MAPTRACK_TO_GRANTS_RATIO. Changes in v7: - remove 0 initializers; - make max_nr_grant_frames static; - remove preprocessors check on max_nr_grant_frames; - remove double black line; - introduce DEFAULT_MAX_MAPTRACK_FRAMES; - no long lines; - set the new variables independently if the old one is passed as argument. Changes in v6: - change ordering of options in xen-command-line.markdown; - initialize all options to 0, then set the defaults on an initcall depending on what options are used. Changes in v5: - /max_nr_maptrack_frames/max_maptrack_frames/g; - deprecate gnttab_max_nr_frames; - introduce gnttab_max_frames; - rename the max_nr_grant_frames variable to max_grant_frames. --- docs/misc/xen-command-line.markdown | 17 +++++++++- xen/arch/arm/domain.c | 2 +- xen/arch/arm/mm.c | 2 +- xen/arch/x86/mm.c | 2 +- xen/common/compat/grant_table.c | 12 +++---- xen/common/grant_table.c | 62 ++++++++++++++++++++++++----------- xen/include/asm-arm/grant_table.h | 2 +- xen/include/xen/grant_table.h | 4 +-- 8 files changed, 70 insertions(+), 33 deletions(-) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index 28bbaaf..00416af 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -608,11 +608,26 @@ does not provide VM\_ENTRY\_LOAD\_GUEST\_PAT. Specify the serial parameters for the GDB stub. -### gnttab\_max\_nr\_frames +### gnttab\_max\_frames > `= ` Specify the maximum number of frames per grant table operation. +### gnttab\_max\_maptrack\_frames +> `= ` + +Specify the maximum number of maptrack frames domain. +The default value is 8 times gnttab_max_frames. + +### gnttab\_max\_nr\_frames +> `= ` + +*Deprecated* +Use gnttab\_max\_frames and gnttab\_max\_maptrack\_frames instead. + +Specify the maximum number of frames per grant table operation and the +maximum number of maptrack frames domain. + ### guest\_loglvl > `= [/]` where level is `none | error | warning | info | debug | all` diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 2b53931..57f09c3 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -409,7 +409,7 @@ struct domain *alloc_domain_struct(void) return NULL; clear_page(d); - d->arch.grant_table_gpfn = xzalloc_array(xen_pfn_t, max_nr_grant_frames); + d->arch.grant_table_gpfn = xzalloc_array(xen_pfn_t, max_grant_frames); return d; } diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 97e5bc39..dd70d81 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1054,7 +1054,7 @@ int xenmem_add_to_physmap_one( else { if ( (idx >= nr_grant_frames(d->grant_table)) && - (idx < max_nr_grant_frames) ) + (idx < max_grant_frames) ) gnttab_grow_table(d, idx + 1); if ( idx < nr_grant_frames(d->grant_table) ) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 6cd7f45..edd1923 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4564,7 +4564,7 @@ int xenmem_add_to_physmap_one( else { if ( (idx >= nr_grant_frames(d->grant_table)) && - (idx < max_nr_grant_frames) ) + (idx < max_grant_frames) ) gnttab_grow_table(d, idx + 1); if ( idx < nr_grant_frames(d->grant_table) ) diff --git a/xen/common/compat/grant_table.c b/xen/common/compat/grant_table.c index 7ebbbc1..2dc1e44 100644 --- a/xen/common/compat/grant_table.c +++ b/xen/common/compat/grant_table.c @@ -146,11 +146,11 @@ int compat_grant_table_op(unsigned int cmd, unsigned int max_frame_list_size_in_page = (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.setup)) / sizeof(*nat.setup->frame_list.p); - if ( max_frame_list_size_in_page < max_nr_grant_frames ) + if ( max_frame_list_size_in_page < max_grant_frames ) { gdprintk(XENLOG_WARNING, - "max_nr_grant_frames is too large (%u,%u)\n", - max_nr_grant_frames, max_frame_list_size_in_page); + "max_grant_frames is too large (%u,%u)\n", + max_grant_frames, max_frame_list_size_in_page); rc = -EINVAL; } else @@ -284,11 +284,11 @@ int compat_grant_table_op(unsigned int cmd, break; } if ( max_frame_list_size_in_pages < - grant_to_status_frames(max_nr_grant_frames) ) + grant_to_status_frames(max_grant_frames) ) { gdprintk(XENLOG_WARNING, - "grant_to_status_frames(max_nr_grant_frames) is too large (%u,%u)\n", - grant_to_status_frames(max_nr_grant_frames), + "grant_to_status_frames(max_grant_frames) is too large (%u,%u)\n", + grant_to_status_frames(max_grant_frames), max_frame_list_size_in_pages); rc = -EINVAL; break; diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 23266c3..f9a9b44 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -40,16 +40,27 @@ #include #include -#ifndef max_nr_grant_frames -unsigned int max_nr_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES; +/* + * This option is deprecated, use gnttab_max_frames and + * gnttab_max_maptrack_frames instead. + */ +static unsigned int __initdata max_nr_grant_frames; integer_param("gnttab_max_nr_frames", max_nr_grant_frames); -#endif + +unsigned int __read_mostly max_grant_frames; +integer_param("gnttab_max_frames", max_grant_frames); /* The maximum number of grant mappings is defined as a multiplier of the * maximum number of grant table entries. This defines the multiplier used. * Pretty arbitrary. [POLICY] + * As gnttab_max_nr_frames has been deprecated, this multiplier is deprecated too. + * New options allow to set max_maptrack_frames and + * map_grant_table_frames independently. */ -#define MAX_MAPTRACK_TO_GRANTS_RATIO 8 +#define DEFAULT_MAX_MAPTRACK_FRAMES 256 + +static unsigned int __read_mostly max_maptrack_frames; +integer_param("gnttab_max_maptrack_frames", max_maptrack_frames); /* * The first two members of a grant entry are updated as a combined pair. @@ -102,11 +113,6 @@ nr_maptrack_frames(struct grant_table *t) return t->maptrack_limit / MAPTRACK_PER_PAGE; } -static unsigned inline int max_nr_maptrack_frames(void) -{ - return (max_nr_grant_frames * MAX_MAPTRACK_TO_GRANTS_RATIO); -} - #define MAPTRACK_TAIL (~0u) #define SHGNT_PER_PAGE_V1 (PAGE_SIZE / sizeof(grant_entry_v1_t)) @@ -164,7 +170,7 @@ num_act_frames_from_sha_frames(const unsigned int num) } #define max_nr_active_grant_frames \ - num_act_frames_from_sha_frames(max_nr_grant_frames) + num_act_frames_from_sha_frames(max_grant_frames) static inline unsigned int nr_active_grant_frames(struct grant_table *gt) @@ -271,7 +277,7 @@ get_maptrack_handle( while ( unlikely((handle = __get_maptrack_handle(lgt)) == -1) ) { nr_frames = nr_maptrack_frames(lgt); - if ( nr_frames >= max_nr_maptrack_frames() ) + if ( nr_frames >= max_maptrack_frames ) break; new_mt = alloc_xenheap_page(); @@ -1265,7 +1271,7 @@ gnttab_grow_table(struct domain *d, unsigned int req_nr_frames) struct grant_table *gt = d->grant_table; unsigned int i; - ASSERT(req_nr_frames <= max_nr_grant_frames); + ASSERT(req_nr_frames <= max_grant_frames); gdprintk(XENLOG_INFO, "Expanding dom (%d) grant table from (%d) to (%d) frames.\n", @@ -1338,11 +1344,11 @@ gnttab_setup_table( return -EFAULT; } - if ( unlikely(op.nr_frames > max_nr_grant_frames) ) + if ( unlikely(op.nr_frames > max_grant_frames) ) { gdprintk(XENLOG_INFO, "Xen only supports up to %d grant-table frames" " per domain.\n", - max_nr_grant_frames); + max_grant_frames); op.status = GNTST_general_error; goto out1; } @@ -1377,7 +1383,7 @@ gnttab_setup_table( { gdprintk(XENLOG_INFO, "Expand grant table to %u failed. Current: %u Max: %u\n", - op.nr_frames, nr_grant_frames(gt), max_nr_grant_frames); + op.nr_frames, nr_grant_frames(gt), max_grant_frames); op.status = GNTST_general_error; goto out3; } @@ -1438,7 +1444,7 @@ gnttab_query_size( spin_lock(&d->grant_table->lock); op.nr_frames = nr_grant_frames(d->grant_table); - op.max_nr_frames = max_nr_grant_frames; + op.max_nr_frames = max_grant_frames; op.status = GNTST_okay; spin_unlock(&d->grant_table->lock); @@ -2659,7 +2665,7 @@ grant_table_create( /* Tracking of mapped foreign frames table */ if ( (t->maptrack = xzalloc_array(struct grant_mapping *, - max_nr_maptrack_frames())) == NULL ) + max_maptrack_frames)) == NULL ) goto no_mem_2; if ( (t->maptrack[0] = alloc_xenheap_page()) == NULL ) goto no_mem_3; @@ -2670,7 +2676,7 @@ grant_table_create( t->maptrack[0][i - 1].ref = MAPTRACK_TAIL; /* Shared grant table. */ - if ( (t->shared_raw = xzalloc_array(void *, max_nr_grant_frames)) == NULL ) + if ( (t->shared_raw = xzalloc_array(void *, max_grant_frames)) == NULL ) goto no_mem_3; for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ ) { @@ -2681,7 +2687,7 @@ grant_table_create( /* Status pages for grant table - for version 2 */ t->status = xzalloc_array(grant_status_t *, - grant_to_status_frames(max_nr_grant_frames)); + grant_to_status_frames(max_grant_frames)); if ( t->status == NULL ) goto no_mem_4; @@ -2930,6 +2936,24 @@ static struct keyhandler gnttab_usage_print_all_keyhandler = { static int __init gnttab_usage_init(void) { + if ( max_nr_grant_frames ) + { + printk(XENLOG_WARNING + "gnttab_max_nr_frames is deprecated, use gnttab_max_frames instead\n"); + if ( !max_grant_frames ) + max_grant_frames = max_nr_grant_frames; + BUILD_BUG_ON(DEFAULT_MAX_MAPTRACK_FRAMES < DEFAULT_MAX_NR_GRANT_FRAMES); + if ( !max_maptrack_frames ) + max_maptrack_frames = max_nr_grant_frames * + (DEFAULT_MAX_MAPTRACK_FRAMES / DEFAULT_MAX_NR_GRANT_FRAMES); + } + + if ( !max_grant_frames ) + max_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES; + + if ( !max_maptrack_frames ) + max_maptrack_frames = DEFAULT_MAX_MAPTRACK_FRAMES; + register_keyhandler('g', &gnttab_usage_print_all_keyhandler); return 0; } diff --git a/xen/include/asm-arm/grant_table.h b/xen/include/asm-arm/grant_table.h index 47147ce..e798880 100644 --- a/xen/include/asm-arm/grant_table.h +++ b/xen/include/asm-arm/grant_table.h @@ -31,7 +31,7 @@ static inline int replace_grant_supported(void) #define gnttab_shared_gmfn(d, t, i) \ ( ((i >= nr_grant_frames(d->grant_table)) && \ - (i < max_nr_grant_frames)) ? 0 : (d->arch.grant_table_gpfn[i])) + (i < max_grant_frames)) ? 0 : (d->arch.grant_table_gpfn[i])) #define gnttab_need_iommu_mapping(d) (is_domain_direct_mapped(d)) diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h index 5941191..32f5786 100644 --- a/xen/include/xen/grant_table.h +++ b/xen/include/xen/grant_table.h @@ -49,10 +49,8 @@ /* Default maximum size of a grant table. [POLICY] */ #define DEFAULT_MAX_NR_GRANT_FRAMES 32 #endif -#ifndef max_nr_grant_frames /* to allow arch to override */ /* The maximum size of a grant table. */ -extern unsigned int max_nr_grant_frames; -#endif +extern unsigned int max_grant_frames; /* * Tracks a mapping of another domain's grant reference. Each domain has a