qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 2/2] vhost: Only align sections for vhost-user


From: Michael S. Tsirkin
Subject: Re: [PATCH v3 2/2] vhost: Only align sections for vhost-user
Date: Fri, 17 Jan 2020 08:40:54 -0500

On Fri, Jan 17, 2020 at 01:52:44PM +0100, Paolo Bonzini wrote:
> On 16/01/20 21:24, Dr. David Alan Gilbert (git) wrote:
> > +    if (dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER) {   
> > +        /* Round the section to it's page size */
> > +        /* First align the start down to a page boundary */
> > +        size_t mrs_page = qemu_ram_pagesize(mrs_rb);
> > +        uint64_t alignage = mrs_host & (mrs_page - 1);
> > +        if (alignage) {
> > +            mrs_host -= alignage;
> > +            mrs_size += alignage;
> > +            mrs_gpa  -= alignage;
> > +        }
> > +        /* Now align the size up to a page boundary */
> > +        alignage = mrs_size & (mrs_page - 1);
> > +        if (alignage) {
> > +            mrs_size += mrs_page - alignage;
> > +        }
> > +        trace_vhost_region_add_section_aligned(section->mr->name, mrs_gpa, 
> > mrs_size,
> > +                                               mrs_host);
> > +    }
> 
> Ok, now I understand!
> 
> So it seems to me that the vhost-user protocol is deficient, it should
> have had two different fields for the region size and the region
> alignment (so that mmap does not fail).  But I guess that's just yet
> another thing to remember for vhost-user v2.

We don't really need v2 just to add a field. Compatibility is maintained
using feature bits. Adding that is a subject for another patch.
But I'm not sure I understand why does remote need to know about alignment.
This patch seems to handle it locally ...

> I would add a comment to explain why the alignment is needed in the
> first place, but this fix is certainly much more pleasant.  Thanks very
> much.
> 
> Reviewed-by: Paolo Bonzini <address@hidden>
> 
> Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]