mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
introduce gnttab_max_frames and gnttab_max_maptrack_frames command line options
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 <stefano.stabellini@eu.citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
204c7a873f
commit
7157012293
8 files changed
+70
-33
No files matched your search
@@ -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
|
||||
> `= <integer>`
|
||||
|
||||
Specify the maximum number of frames per grant table operation.
|
||||
|
||||
### gnttab\_max\_maptrack\_frames
|
||||
> `= <integer>`
|
||||
|
||||
Specify the maximum number of maptrack frames domain.
|
||||
The default value is 8 times gnttab_max_frames.
|
||||
|
||||
### gnttab\_max\_nr\_frames
|
||||
> `= <integer>`
|
||||
|
||||
*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
|
||||
> `= <level>[/<rate-limited level>]` where level is `none | error | warning | info | debug | all`
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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) )
|
||||
|
||||
+1
-1
@@ -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) )
|
||||
|
||||
@@ -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;
|
||||
|
||||
+43
-19
@@ -40,16 +40,27 @@
|
||||
#include <xsm/xsm.h>
|
||||
#include <asm/flushtlb.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||