From patchwork Mon Oct 13 14:58:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38675 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A91F72039B for ; Mon, 13 Oct 2014 15:03:55 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf4269508lab.7 for ; Mon, 13 Oct 2014 08:03:54 -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=9EClI37AQKVica2A00LWua6rr9mfcv1diccW5NAgWP8=; b=mJ9J39gxOFaplhwKM1Iydz5MIdj7/Oj7ClBTWEMp4mFcFhzx/P+BrV8TgbN3J7LRoL XgVwBx2Etcl77B0CY4Bujdoj4dxanspjl1LjeIP1EusuFmVxcEzk1jDXx5IQmaWjz6PP NkrsXjIX4pW4O8nYd3ewj47azsbp2Llib69SYCPQxYST12wxMO2QXV7nifkyraa7F9pA Oyclr9UmbfhUdICEWji9f1ELsMMd+WIieZ8CyKYJVRuhLDNaT7OtwWCLmttDaX7B/Msv 5xU9cVxdzQEgACHW4lt8CwDcP1YpjcsbfnYFoIBWE6RyR/RtDGzJ+A4CpCu8/6JEH94M iebA== X-Gm-Message-State: ALoCoQnnSc8osZuqaxMCcCvKdi8mjwrndYOZtp8UUO62TCGWiFBBLPbcEApXuBZgfjZehC7DYMrh X-Received: by 10.152.29.167 with SMTP id l7mr717042lah.3.1413212634556; Mon, 13 Oct 2014 08:03:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.229 with SMTP id h5ls507850lam.4.gmail; Mon, 13 Oct 2014 08:03:54 -0700 (PDT) X-Received: by 10.152.87.146 with SMTP id ay18mr24901587lab.72.1413212634383; Mon, 13 Oct 2014 08:03:54 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by mx.google.com with ESMTPS id r1si22613959lar.58.2014.10.13.08.03.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Oct 2014 08:03:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id q1so6876394lam.36 for ; Mon, 13 Oct 2014 08:03:54 -0700 (PDT) X-Received: by 10.152.7.145 with SMTP id j17mr24310456laa.67.1413212634192; Mon, 13 Oct 2014 08:03:54 -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 c5csp230993lbz; Mon, 13 Oct 2014 08:03:53 -0700 (PDT) X-Received: by 10.140.83.208 with SMTP id j74mr39457715qgd.91.1413212632613; Mon, 13 Oct 2014 08:03:52 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id k4si25046115qae.95.2014.10.13.08.03.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 13 Oct 2014 08:03:52 -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 1Xdh7n-0004Hl-5l; Mon, 13 Oct 2014 15:01:27 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xdh7l-0004Fc-6q for xen-devel@lists.xensource.com; Mon, 13 Oct 2014 15:01:25 +0000 Received: from [85.158.143.35:16836] by server-1.bemta-4.messagelabs.com id 84/91-05872-449EB345; Mon, 13 Oct 2014 15:01:24 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1413212480!12585469!3 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29130 invoked from network); 13 Oct 2014 15:01:23 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 13 Oct 2014 15:01:23 -0000 X-IronPort-AV: E=Sophos;i="5.04,711,1406592000"; d="scan'208";a="180809048" 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; Mon, 13 Oct 2014 11:01:09 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xdh7P-0008Ho-MN; Mon, 13 Oct 2014 16:01:03 +0100 From: Stefano Stabellini To: Date: Mon, 13 Oct 2014 15:58:37 +0100 Message-ID: <1413212324-664-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: MIA2 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v5 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.215.49 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. Signed-off-by: Stefano Stabellini --- 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 | 15 ++++++++++++ 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 | 46 ++++++++++++++++++++++------------- xen/include/asm-arm/grant_table.h | 2 +- xen/include/xen/grant_table.h | 2 +- 8 files changed, 55 insertions(+), 28 deletions(-) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index 389701a..9960ea1 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -611,8 +611,23 @@ Specify the serial parameters for the GDB stub. ### 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. + +### 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_nr_frames. + ### 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 c5b48ef..675a51b 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1040,7 +1040,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 5b3f06f..fe6a6e3 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4539,7 +4539,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..49efe10 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -24,6 +24,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include @@ -41,8 +42,8 @@ #include #ifndef max_nr_grant_frames -unsigned int max_nr_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES; -integer_param("gnttab_max_nr_frames", max_nr_grant_frames); +unsigned int max_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES; +integer_param("gnttab_max_frames", max_grant_frames); #endif /* The maximum number of grant mappings is defined as a multiplier of the @@ -51,6 +52,22 @@ integer_param("gnttab_max_nr_frames", max_nr_grant_frames); */ #define MAX_MAPTRACK_TO_GRANTS_RATIO 8 +static unsigned int max_maptrack_frames = DEFAULT_MAX_NR_GRANT_FRAMES * + MAX_MAPTRACK_TO_GRANTS_RATIO; +integer_param("gnttab_max_maptrack_frames", max_maptrack_frames); + +/* this option is deprecated, use gnttab_max_frames and + * gnttab_max_maptrack_frames instead */ +static void __init parse_gnttab_max_nr_frames(const char *s) +{ + if ( isdigit(*s) ) + { + max_grant_frames = simple_strtoul(s, &s, 0); + max_maptrack_frames = max_grant_frames * MAX_MAPTRACK_TO_GRANTS_RATIO; + } +} +custom_param("gnttab_max_nr_frames", parse_gnttab_max_nr_frames); + /* * The first two members of a grant entry are updated as a combined pair. * The following union allows that to happen in an endian-neutral fashion. @@ -102,11 +119,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 +176,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 +283,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 +1277,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 +1350,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 +1389,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 +1450,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 +2671,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 +2682,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 +2693,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; 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..9f3a1f3 100644 --- a/xen/include/xen/grant_table.h +++ b/xen/include/xen/grant_table.h @@ -51,7 +51,7 @@ #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; +extern unsigned int max_grant_frames; #endif /*