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

Re: [PATCH for-4.16 v4] gnttab: allow setting max version per-domain


  • To: Julien Grall <julien@xxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 29 Oct 2021 11:41:35 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FFjzSNwd3zDvhkZOMQl7twjqykhZdXQ8hSCSuHYErp8=; b=UUoILe1B8gZ1Vshob73zfq5dpmxpBBu6iG+krJCq9JLrGIVJ/mIBDb6k1rXFFhbQnu6EO4jlMjqCrX/y8lbWo5LLXyhECiu/hgp+3vKQE+7uXqrAYtl62rxKdFr3yF+bWkdbyCJNhR8UnK9xo+EAg3fIJbMRYQYRP2dAf8dABJQq82mHQ+TuRFfV1S0YQG7dz6aj7McKi+6koFLCTz4BwTyU7NMPAfcAUBGqYTM7/s5c7SB5BQILGiM6ohZd/aXTgVZ4dCYsNO8ZE/JM+5HnE4I44Y/wNE4Tbyvyra3tHPThM0C3+Kys48WB5MogDMUyeUWBRsz0KyMXAb9pSgyv3Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e9XFupziMqMsGo5093H4IRzBJdsr2XA/IjIYPJdU+lcsqcbX7fpZG/m6Tu20XdocdVKJW4sD5eq4S1SzGP7YuL10+6cAS0Rr8z8zwd8ShEHvPi3c2Ld+DPLf8ldM5W77hjBoHyN25WMmVw6GRND4o/kzMzEwEFCu0ejcOZav3L2P1NcaLQQno/HAZGqJS1XKqac2Y8uTCZn09dEQztFYVcnu6onpIK/1XImuWQrb0orE5KCJuSFqTjeJ0pusHbU69Z3VFUu2LQM4YmUbB4VoyuflXa1Pg/5cio1EE+cgigWcwC23Lr/k4EroJMdqNNMMKHTnAgeD8bdnlcnCvQSwKA==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "Ian Jackson" <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Fri, 29 Oct 2021 09:42:06 +0000
  • Ironport-data: A9a23:45qp+a10Cq9uRSdvsfbD5Y93kn2cJEfYwER7XKvMYLTBsI5bpzBVz jYbWzuAOPmJM2DwetF/b46ypB4C7JGHy4VkSAJkpC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCan8ZqTNMEn970Es7wb9h2+aEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhu/Apl IQdi4aJTl0wJo7uvu9EWQNnDHQrVUFG0OevzXmXtMWSywvNcmf2wuUoB0YzVWEa0r8pWycUr 6VecW1TKEDY7w616OvTpu1EnMMsIdOtJIoCknph0SvYHbAtRpWrr6DiuIEGhWdg2J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Gs5fU/iPnV7aklT6zEM7ho fTzLT/EEg4ojDS4yyAQCtv+gXKJtN1oy1b+1M9UykSEwifInUR7D1F/n1CGs6dSk4RcUIw77gL PiAcCNSKIU235XCmgWGD0mDo
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Oct 29, 2021 at 09:58:55AM +0100, Julien Grall wrote:
> Hi Roger,
> 
> On 29/10/2021 08:59, Roger Pau Monne wrote:
> > diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
> > index e510395d08..f94f0f272c 100644
> > --- a/xen/common/grant_table.c
> > +++ b/xen/common/grant_table.c
> > @@ -53,6 +53,7 @@ struct grant_table {
> >       percpu_rwlock_t       lock;
> >       /* Lock protecting the maptrack limit */
> >       spinlock_t            maptrack_lock;
> > +    unsigned int          max_version;
> >       /*
> >        * Defaults to v1.  May be changed with GNTTABOP_set_version.  All 
> > other
> >        * values are invalid.
> > @@ -1917,11 +1918,33 @@ active_alloc_failed:
> >   }
> >   int grant_table_init(struct domain *d, int max_grant_frames,
> > -                     int max_maptrack_frames)
> > +                     int max_maptrack_frames, unsigned int options)
> >   {
> >       struct grant_table *gt;
> > +    unsigned int max_grant_version = options & 
> > XEN_DOMCTL_GRANT_version_mask;
> >       int ret = -ENOMEM;
> > +    if ( max_grant_version == XEN_DOMCTL_GRANT_version_default )
> > +        max_grant_version = opt_gnttab_max_version;
> > +    if ( !max_grant_version )
> > +    {
> > +        dprintk(XENLOG_INFO, "%pd: invalid grant table version 0 
> > requested\n",
> > +                d);
> > +        return -EINVAL;
> > +    }
> > +    if ( max_grant_version > opt_gnttab_max_version )
> > +    {
> > +        dprintk(XENLOG_INFO,
> > +                "%pd: requested grant version (%u) greater than supported 
> > (%u)\n",
> > +                d, max_grant_version, opt_gnttab_max_version);
> > +        return -EINVAL;
> > +    }
> > +    if ( unlikely(max_page >= PFN_DOWN(TB(16))) && is_pv_domain(d) &&
> 
> From my understanding, the limit for the grant table v1 is based on the page
> granularity used and the size of the fields.
> 
> So the limit you add is valid for 4KB but not 16KB/64KB. Therefore, I think
> it would be better to use:
> 
> 'max_page >= (1U << 32)'

I'm slightly confused. Isn't Xen always using a 4KB page granularity,
and that also applies to the grant table entries?

I don't think it's possible to use correctly use a 16KB or 64KB page
as an entry for the grant table, as Xen assumes those to always be 4KB
based.

> Furthermore, it would add a comment explaining where this limit comes from.
> 
> Lastly, did you check the compiler wouldn't throw an error on arm32?

I've tested a previous version (v2), but not this one. I assume it
doesn't build?

I've pushed it to gitlab and will adjust as needed.

> > +         max_grant_version < 2 )
> > +        dprintk(XENLOG_INFO,
> > +                "%pd: host memory above 16Tb and grant table v2 
> > disabled\n",
> > +                d);
> 
> I would switch this one to a printk().

That's fine, will adjust unless someone has objections.

Thanks, Roger.



 


Rackspace

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