From: Juergen Gross <jgross@suse.com>
To: Paul Durrant <Paul.Durrant@citrix.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Cc: "sstabellini@kernel.org" <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
Andrew Cooper <Andrew.Cooper3@citrix.com>,
"Tim (Xen.org)" <tim@xen.org>,
George Dunlap <George.Dunlap@citrix.com>,
"jbeulich@suse.com" <jbeulich@suse.com>,
Ian Jackson <Ian.Jackson@citrix.com>
Subject: Re: [PATCH v2 4/8] xen: make grant resource limits per domain
Date: Wed, 6 Sep 2017 11:42:54 +0200 [thread overview]
Message-ID: <f11af3f1-aa23-603a-eafe-c44c2e4fe2b2@suse.com> (raw)
In-Reply-To: <b605e0712f80495f916d276861f00f4f@AMSPEX02CL03.citrite.net>
On 06/09/17 11:10, Paul Durrant wrote:
>> -----Original Message-----
>> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
>> Juergen Gross
>> Sent: 06 September 2017 09:26
>> To: xen-devel@lists.xen.org
>> Cc: Juergen Gross <jgross@suse.com>; sstabellini@kernel.org; Wei Liu
>> <wei.liu2@citrix.com>; George Dunlap <George.Dunlap@citrix.com>;
>> Andrew Cooper <Andrew.Cooper3@citrix.com>; Ian Jackson
>> <Ian.Jackson@citrix.com>; Tim (Xen.org) <tim@xen.org>;
>> jbeulich@suse.com
>> Subject: [Xen-devel] [PATCH v2 4/8] xen: make grant resource limits per
>> domain
>>
>> Instead of using the same global resource limits of grant tables (max.
>> number of grant frames, max. number of maptrack frames) for all domains
>> make these limits per domain. This will allow setting individual limits
>> in the future. For now initialize the per domain limits with the global
>> values.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> xen/common/grant_table.c | 83 +++++++++++++++++++++++++++----------
>> -----------
>> 1 file changed, 46 insertions(+), 37 deletions(-)
>>
>> diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
>> index b50c334f70..ae5f1262e8 100644
>> --- a/xen/common/grant_table.c
>> +++ b/xen/common/grant_table.c
>> @@ -69,6 +69,9 @@ struct grant_table {
>> /* The defined versions are 1 and 2. Set to 0 if we don't know
>> what version to use yet. */
>> unsigned gt_version;
>> + /* Resource limits of the domain. */
>> + unsigned int max_grant_frames;
>> + unsigned int max_maptrack_frames;
>> };
>>
>> #ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */
>> @@ -285,8 +288,8 @@ num_act_frames_from_sha_frames(const unsigned
>> int num)
>> return DIV_ROUND_UP(num * sha_per_page, ACGNT_PER_PAGE);
>> }
>>
>> -#define max_nr_active_grant_frames \
>> - num_act_frames_from_sha_frames(max_grant_frames)
>> +#define max_nr_active_grant_frames(gt) \
>> + num_act_frames_from_sha_frames(gt->max_grant_frames)
>>
>> static inline unsigned int
>> nr_active_grant_frames(struct grant_table *gt)
>> @@ -524,7 +527,7 @@ get_maptrack_handle(
>> * out of memory, try stealing an entry from another VCPU (in case the
>> * guest isn't mapping across its VCPUs evenly).
>> */
>> - if ( nr_maptrack_frames(lgt) < max_maptrack_frames )
>> + if ( nr_maptrack_frames(lgt) < lgt->max_maptrack_frames )
>> new_mt = alloc_xenheap_page();
>>
>> if ( !new_mt )
>> @@ -1663,7 +1666,7 @@ gnttab_grow_table(struct domain *d, unsigned int
>> req_nr_frames)
>> struct grant_table *gt = d->grant_table;
>> unsigned int i, j;
>>
>> - ASSERT(req_nr_frames <= max_grant_frames);
>> + ASSERT(req_nr_frames <= gt->max_grant_frames);
>>
>> gdprintk(XENLOG_INFO,
>> "Expanding dom (%d) grant table from (%d) to (%d) frames.\n",
>> @@ -1728,14 +1731,15 @@ grant_table_init(struct domain *d)
>> if ( gt->nr_grant_frames )
>> return 0;
>>
>> - gt->nr_grant_frames = INITIAL_NR_GRANT_FRAMES;
>> + gt->nr_grant_frames = min_t(unsigned int,
>> INITIAL_NR_GRANT_FRAMES,
>> + gt->max_grant_frames);
>>
>> /* Active grant table. */
>> if ( (gt->active = xzalloc_array(struct active_grant_entry *,
>> - max_nr_active_grant_frames)) == NULL )
>> + max_nr_active_grant_frames(gt))) == NULL )
>> goto no_mem_1;
>> for ( i = 0;
>> - i < num_act_frames_from_sha_frames(INITIAL_NR_GRANT_FRAMES);
>> i++ )
>> + i < num_act_frames_from_sha_frames(gt->nr_grant_frames); i++ )
>> {
>> if ( (gt->active[i] = alloc_xenheap_page()) == NULL )
>> goto no_mem_2;
>> @@ -1745,14 +1749,14 @@ grant_table_init(struct domain *d)
>> }
>>
>> /* Tracking of mapped foreign frames table */
>> - gt->maptrack = vzalloc(max_maptrack_frames * sizeof(*gt->maptrack));
>> + gt->maptrack = vzalloc(gt->max_maptrack_frames * sizeof(*gt-
>>> maptrack));
>> if ( gt->maptrack == NULL )
>> goto no_mem_2;
>>
>> /* Shared grant table. */
>> - if ( (gt->shared_raw = xzalloc_array(void *, max_grant_frames)) == NULL )
>> + if ( (gt->shared_raw = xzalloc_array(void *, gt->max_grant_frames)) ==
>> NULL )
>> goto no_mem_3;
>> - for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ )
>> + for ( i = 0; i < gt->nr_grant_frames; i++ )
>> {
>> if ( (gt->shared_raw[i] = alloc_xenheap_page()) == NULL )
>> goto no_mem_4;
>> @@ -1761,11 +1765,11 @@ grant_table_init(struct domain *d)
>>
>> /* Status pages for grant table - for version 2 */
>> gt->status = xzalloc_array(grant_status_t *,
>> - grant_to_status_frames(max_grant_frames));
>> + grant_to_status_frames(gt->max_grant_frames));
>> if ( gt->status == NULL )
>> goto no_mem_4;
>>
>> - for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ )
>> + for ( i = 0; i < gt->nr_grant_frames; i++ )
>> gnttab_create_shared_page(d, gt, i);
>>
>> gt->nr_status_frames = 0;
>> @@ -1773,7 +1777,7 @@ grant_table_init(struct domain *d)
>> return 0;
>>
>> no_mem_4:
>> - for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ )
>> + for ( i = 0; i < gt->nr_grant_frames; i++ )
>> free_xenheap_page(gt->shared_raw[i]);
>> xfree(gt->shared_raw);
>> gt->shared_raw = NULL;
>> @@ -1782,7 +1786,7 @@ grant_table_init(struct domain *d)
>> gt->maptrack = NULL;
>> no_mem_2:
>> for ( i = 0;
>> - i < num_act_frames_from_sha_frames(INITIAL_NR_GRANT_FRAMES);
>> i++ )
>> + i < num_act_frames_from_sha_frames(gt->nr_grant_frames); i++ )
>> free_xenheap_page(gt->active[i]);
>> xfree(gt->active);
>> gt->active = NULL;
>> @@ -1807,15 +1811,6 @@ gnttab_setup_table(
>> if ( unlikely(copy_from_guest(&op, uop, 1)) )
>> return -EFAULT;
>>
>> - if ( unlikely(op.nr_frames > max_grant_frames) )
>> - {
>> - gdprintk(XENLOG_INFO, "Xen only supports up to %d grant-table
>> frames"
>> - " per domain.\n",
>> - max_grant_frames);
>> - op.status = GNTST_general_error;
>> - goto out;
>> - }
>> -
>> if ( !guest_handle_okay(op.frame_list, op.nr_frames) )
>> return -EFAULT;
>>
>> @@ -1835,6 +1830,15 @@ gnttab_setup_table(
>> gt = d->grant_table;
>> grant_write_lock(gt);
>>
>> + if ( unlikely(op.nr_frames > gt->max_grant_frames) )
>> + {
>> + gdprintk(XENLOG_INFO, "Xen only supports up to %d grant-table
>> frames"
>> + " per domain.\n",
>> + gt->max_grant_frames);
>
> The message should probably now say that the domain has only been provisioned with X grant frames, rather than implying that the limit is still global as it does.
Aah, of course.
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-09-06 9:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-06 8:26 [PATCH v2 0/8] xen: better grant v2 support Juergen Gross
2017-09-06 8:26 ` [PATCH v2 1/8] xen: move XENMAPSPACE_grant_table code into grant_table.c Juergen Gross
2017-09-06 8:34 ` Paul Durrant
2017-09-06 9:31 ` Juergen Gross
2017-09-06 10:04 ` Wei Liu
2017-09-06 8:26 ` [PATCH v2 2/8] xen: clean up grant_table.h Juergen Gross
2017-09-06 8:37 ` Paul Durrant
2017-09-06 10:11 ` Wei Liu
2017-09-06 10:12 ` Juergen Gross
2017-09-06 8:26 ` [PATCH v2 3/8] xen: delay allocation of grant table sub structures Juergen Gross
2017-09-06 8:44 ` Paul Durrant
2017-09-06 9:42 ` Juergen Gross
2017-09-06 9:43 ` Paul Durrant
2017-09-06 8:26 ` [PATCH v2 4/8] xen: make grant resource limits per domain Juergen Gross
2017-09-06 9:10 ` Paul Durrant
2017-09-06 9:42 ` Juergen Gross [this message]
2017-09-06 8:26 ` [PATCH v2 5/8] xen: double default grant frame limit for huge hosts Juergen Gross
2017-09-06 9:12 ` Paul Durrant
2017-09-06 8:26 ` [PATCH v2 6/8] xen: add new domctl hypercall to set grant table resource limits Juergen Gross
2017-09-06 9:17 ` Paul Durrant
2017-09-06 9:43 ` Juergen Gross
2017-09-06 8:26 ` [PATCH v2 7/8] libxc: add libxc support for setting " Juergen Gross
2017-09-06 8:26 ` [PATCH v2 8/8] libxl: add libxl " Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f11af3f1-aa23-603a-eafe-c44c2e4fe2b2@suse.com \
--to=jgross@suse.com \
--cc=Andrew.Cooper3@citrix.com \
--cc=George.Dunlap@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=Paul.Durrant@citrix.com \
--cc=jbeulich@suse.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).