xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: 'Juergen Gross' <jgross@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.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>,
	"julien.grall@arm.com" <julien.grall@arm.com>,
	"jbeulich@suse.com" <jbeulich@suse.com>,
	Ian Jackson <Ian.Jackson@citrix.com>,
	"dgdegra@tycho.nsa.gov" <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v7 12/16] xen: delay allocation of grant table	sub structures
Date: Tue, 19 Sep 2017 10:28:16 +0000	[thread overview]
Message-ID: <b26bd6fdb6d74036bd943e19c6f614bc@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <20170919095852.15785-13-jgross@suse.com>

> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
> Juergen Gross
> Sent: 19 September 2017 10:59
> To: xen-devel@lists.xenproject.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>;
> julien.grall@arm.com; jbeulich@suse.com; dgdegra@tycho.nsa.gov
> Subject: [Xen-devel] [PATCH v7 12/16] xen: delay allocation of grant table
> sub structures
> 
> Delay the allocation of the grant table sub structures in order to
> allow modifying parameters needed for sizing of these structures at a
> per domain basis. Allocate the structures from gnttab_setup_table()
> and the table frames only from gnttab_grow_table().

Is this last sentence still correct?

  Paul

> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> V6:
> - move call of grant_table_init() for dom0 to grant_table_create()
>   (Jan Beulich)
> - move frame allocations to gnttab_grow_table() (Jan Beulich)
> - several other changes due to new patch order
> 
> V4:
> - make ret more local (Wei Liu)
> 
> V3:
> - move call of grant_table_init() from gnttab_setup_table() to
>   gnttab_grow_table() (Paul Durrant)
> ---
>  xen/common/grant_table.c | 113 ++++++++++++++++++++++----------------
> ---------
>  1 file changed, 52 insertions(+), 61 deletions(-)
> 
> diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
> index f48eeff7ad..f66940551e 100644
> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -1655,6 +1655,46 @@ gnttab_unpopulate_status_frames(struct domain
> *d, struct grant_table *gt)
>      gt->nr_status_frames = 0;
>  }
> 
> +static int
> +grant_table_init(struct grant_table *gt)
> +{
> +    if ( gt->active )
> +        return -EBUSY;
> +
> +    /* Active grant table. */
> +    gt->active = xzalloc_array(struct active_grant_entry *,
> +                               max_nr_active_grant_frames);
> +    if ( gt->active == NULL )
> +        goto no_mem;
> +
> +    /* Tracking of mapped foreign frames table */
> +    gt->maptrack = vzalloc(max_maptrack_frames * sizeof(*gt->maptrack));
> +    if ( gt->maptrack == NULL )
> +        goto no_mem;
> +
> +    /* Shared grant table. */
> +    gt->shared_raw = xzalloc_array(void *, max_grant_frames);
> +    if ( gt->shared_raw == NULL )
> +        goto no_mem;
> +
> +    /* Status pages for grant table - for version 2 */
> +    gt->status = xzalloc_array(grant_status_t *,
> +                               grant_to_status_frames(max_grant_frames));
> +    if ( gt->status == NULL )
> +        goto no_mem;
> +
> +    return 0;
> +
> + no_mem:
> +    xfree(gt->shared_raw);
> +    gt->shared_raw = NULL;
> +    vfree(gt->maptrack);
> +    gt->maptrack = NULL;
> +    xfree(gt->active);
> +    gt->active = NULL;
> +    return -ENOMEM;
> +}
> +
>  /*
>   * Grow the grant table. The caller must hold the grant table's
>   * write lock before calling this function.
> @@ -1665,6 +1705,10 @@ gnttab_grow_table(struct domain *d, unsigned int
> req_nr_frames)
>      struct grant_table *gt = d->grant_table;
>      unsigned int i, j;
> 
> +    ASSERT(gt->active);
> +
> +    if ( req_nr_frames < INITIAL_NR_GRANT_FRAMES )
> +        req_nr_frames = INITIAL_NR_GRANT_FRAMES;
>      ASSERT(req_nr_frames <= max_grant_frames);
> 
>      gdprintk(XENLOG_INFO,
> @@ -3381,75 +3425,21 @@ grant_table_create(
>      struct domain *d)
>  {
>      struct grant_table *t;
> -    unsigned int i, j;
> 
>      if ( (t = xzalloc(struct grant_table)) == NULL )
> -        goto no_mem_0;
> +        return -ENOMEM;
> 
>      /* Simple stuff. */
>      percpu_rwlock_resource_init(&t->lock, grant_rwlock);
>      spin_lock_init(&t->maptrack_lock);
> -    t->nr_grant_frames = INITIAL_NR_GRANT_FRAMES;
> -
> -    /* Active grant table. */
> -    if ( (t->active = xzalloc_array(struct active_grant_entry *,
> -                                    max_nr_active_grant_frames)) == NULL )
> -        goto no_mem_1;
> -    for ( i = 0;
> -          i < num_act_frames_from_sha_frames(INITIAL_NR_GRANT_FRAMES);
> i++ )
> -    {
> -        if ( (t->active[i] = alloc_xenheap_page()) == NULL )
> -            goto no_mem_2;
> -        clear_page(t->active[i]);
> -        for ( j = 0; j < ACGNT_PER_PAGE; j++ )
> -            spin_lock_init(&t->active[i][j].lock);
> -    }
> -
> -    /* Tracking of mapped foreign frames table */
> -    t->maptrack = vzalloc(max_maptrack_frames * sizeof(*t->maptrack));
> -    if ( t->maptrack == NULL )
> -        goto no_mem_2;
> -
> -    /* Shared grant table. */
> -    if ( (t->shared_raw = xzalloc_array(void *, max_grant_frames)) == NULL )
> -        goto no_mem_3;
> -    for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ )
> -    {
> -        if ( (t->shared_raw[i] = alloc_xenheap_page()) == NULL )
> -            goto no_mem_4;
> -        clear_page(t->shared_raw[i]);
> -    }
> -
> -    /* Status pages for grant table - for version 2 */
> -    t->status = xzalloc_array(grant_status_t *,
> -                              grant_to_status_frames(max_grant_frames));
> -    if ( t->status == NULL )
> -        goto no_mem_4;
> -
> -    for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ )
> -        gnttab_create_shared_page(d, t, i);
> -
> -    t->nr_status_frames = 0;
> 
>      /* Okay, install the structure. */
>      d->grant_table = t;
> -    return 0;
> 
> - no_mem_4:
> -    for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ )
> -        free_xenheap_page(t->shared_raw[i]);
> -    xfree(t->shared_raw);
> - no_mem_3:
> -    vfree(t->maptrack);
> - no_mem_2:
> -    for ( i = 0;
> -          i < num_act_frames_from_sha_frames(INITIAL_NR_GRANT_FRAMES);
> i++ )
> -        free_xenheap_page(t->active[i]);
> -    xfree(t->active);
> - no_mem_1:
> -    xfree(t);
> - no_mem_0:
> -    return -ENOMEM;
> +    if ( d->domain_id == 0 )
> +        return grant_table_init(t);
> +
> +    return 0;
>  }
> 
>  void
> @@ -3651,8 +3641,9 @@ int grant_table_set_limits(struct domain *d,
> unsigned int grant_frames,
> 
>      grant_write_lock(gt);
> 
> -    ret = 0;
> -    /* Set limits, alloc needed arrays. */
> +    /* Set limits. */
> +    if ( !gt->active )
> +        ret = grant_table_init(gt);
> 
>      grant_write_unlock(gt);
> 
> --
> 2.12.3
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-09-19 10:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19  9:58 [PATCH v7 00/16] xen: better grant v2 support Juergen Gross
2017-09-19  9:58 ` [PATCH v7 01/16] xen: correct gnttab_get_status_frames() Juergen Gross
2017-09-19  9:58 ` [PATCH v7 02/16] xen: move XENMAPSPACE_grant_table code into grant_table.c Juergen Gross
2017-09-19 10:08   ` Paul Durrant
2017-09-19 15:41     ` Jan Beulich
2017-09-19  9:58 ` [PATCH v7 03/16] xen: clean up grant_table.h Juergen Gross
2017-09-19 15:55   ` Jan Beulich
     [not found]   ` <59C15A04020000780017D047@suse.com>
2017-09-19 16:04     ` Juergen Gross
2017-09-19  9:58 ` [PATCH v7 04/16] xen: add new domctl hypercall to set grant table resource limits Juergen Gross
2017-09-19 10:14   ` Paul Durrant
2017-09-19 10:20     ` Juergen Gross
2017-09-19  9:58 ` [PATCH v7 05/16] xen: add function for obtaining highest possible memory address Juergen Gross
2017-09-19  9:58 ` [PATCH v7 06/16] xen: add max possible mfn to struct xen_sysctl_physinfo Juergen Gross
2017-09-19  9:58 ` [PATCH v7 07/16] libxc: add libxc support for setting grant table resource limits Juergen Gross
2017-09-19 10:59   ` Ian Jackson
2017-09-19  9:58 ` [PATCH v7 08/16] tools: set grant limits for xenstore stubdom Juergen Gross
2017-09-19  9:58 ` [PATCH v7 09/16] libxl: add max possible mfn to libxl_physinfo Juergen Gross
2017-09-19 11:00   ` Ian Jackson
2017-09-19  9:58 ` [PATCH v7 10/16] xl: add global grant limit config items Juergen Gross
2017-09-19 10:59   ` Ian Jackson
2017-09-19  9:58 ` [PATCH v7 11/16] libxl: add libxl support for setting grant table resource limits Juergen Gross
2017-09-19 10:59   ` Ian Jackson
2017-09-19  9:58 ` [PATCH v7 12/16] xen: delay allocation of grant table sub structures Juergen Gross
2017-09-19 10:28   ` Paul Durrant [this message]
2017-09-19 10:35     ` Juergen Gross
2017-09-19 10:39       ` Paul Durrant
2017-09-19  9:58 ` [PATCH v7 13/16] xen/arm: move arch specific grant table bits into grant_table.c Juergen Gross
2017-09-19 10:30   ` Paul Durrant
2017-09-19  9:58 ` [PATCH v7 14/16] xen: make grant resource limits per domain Juergen Gross
2017-09-19 10:34   ` Paul Durrant
2017-09-19  9:58 ` [PATCH v7 15/16] xen: make grant table limits boot parameters dom0 only Juergen Gross
2017-09-19  9:58 ` [PATCH v7 16/16] xen: add new Xen cpuid node for max address width info 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=b26bd6fdb6d74036bd943e19c6f614bc@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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).