[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 17/20] xen/gnttab: Fold grant_table_{create, set_limits}() into grant_table_init()



>>> On 19.03.18 at 20:13, <andrew.cooper3@xxxxxxxxxx> wrote:
> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -1808,22 +1808,28 @@ gnttab_grow_table(struct domain *d, unsigned int 
> req_nr_frames)
>      return -ENOMEM;
>  }
>  
> -static int
> -grant_table_init(struct domain *d, struct grant_table *gt,
> -                 unsigned int grant_frames, unsigned int maptrack_frames)
> +int grant_table_init(struct domain *d, unsigned int max_grant_frames,
> +                     unsigned int max_maptrack_frames)
>  {
> +    struct grant_table *gt;
>      int ret = -ENOMEM;
>  
> -    grant_write_lock(gt);
> +    if ( max_grant_frames < INITIAL_NR_GRANT_FRAMES ||
> +         max_grant_frames > opt_max_grant_frames ||
> +         max_maptrack_frames > opt_max_maptrack_frames )
> +        return -EINVAL;
>  
> -    if ( gt->active )
> -    {
> -        ret = -EBUSY;
> -        goto out_no_cleanup;
> -    }
> +    if ( (gt = xzalloc(struct grant_table)) == NULL )
> +        return -ENOMEM;
> +
> +    /* Simple stuff. */
> +    percpu_rwlock_resource_init(&gt->lock, grant_rwlock);
> +    spin_lock_init(&gt->maptrack_lock);
> +
> +    grant_write_lock(gt);

This was sort of sensible with the old (split) code structure, but
without having stored gt anywhere yet I think you want to
acquire this later. Of course otoh there's not going to be any
contention on the lock here, and it doesn't look like you can
avoid acquiring the lock altogether.

> @@ -1871,7 +1881,6 @@ grant_table_init(struct domain *d, struct grant_table 
> *gt,
>          gt->active = NULL;
>      }
>  
> - out_no_cleanup:

You now want to free gt upwards from here (where the closing
brace is visible in context - the caller won't call grant_table_destroy()
when an error comes back from here. Or wait - that's a bug in patch
16 already. So I'm afraid I have to withdraw my R-b given there.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.