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

Re: [Xen-devel] [v5][PATCH 03/10] xen:x86: define a new hypercall to get RMRR mappings

>>> On 03.09.14 at 03:45, <tiejun.chen@xxxxxxxxx> wrote:
> On 2014/9/2 21:15, Jan Beulich wrote:
>>>>> On 02.09.14 at 13:10, <tiejun.chen@xxxxxxxxx> wrote:
>>> On 2014/9/2 18:15, Jan Beulich wrote:
>>>>>>> On 02.09.14 at 11:59, <tiejun.chen@xxxxxxxxx> wrote:
>>>>> +    case XENMEM_reserved_device_memory_map:
>>>>> +    {
>>>>> +        struct xen_mem_reserved_device_memory *xmrdm = NULL;
>>>>> +        struct xen_mem_reserved_device_memory_map xmrdmm;
>>>>> +        XEN_GUEST_HANDLE(xen_mem_reserved_device_memory_t) buffer;
>>>>> +        XEN_GUEST_HANDLE_PARAM(xen_mem_reserved_device_memory_t) 
> buffer_param;
>>>>> +        const struct iommu_ops *ops = iommu_get_ops();
>>>>> +        unsigned int nr_entries = 0;
>>>>> +        unsigned int i = 0;
>>>>> +
>>>>> +        xmrdm = ops->get_device_reserved_memory(&nr_entries);
>>> Do we still need this iommu_ops somewhere else?
>> Not this one, but another one (as I had described further down).
>>>>> +        if ( !nr_entries )
>>> Do we still need this 'nr_entries' here?
>> Doesn't look like so. But it's you coding this up - you ought to clearly
>> see what is needed and what not.
> I mean we need to get 'nr_entries' before any real operations since if 
> that is zero, any following operations are pointless. And even that is 
> nonzero, but actually the user don't know how many buffer should be 
> passed, so often we may need to notify user again at the first time then 
> the user call this again with a appropriate buffer. Right?
> So how do we get this 'nr_entries'? Seems we have to to go VT-D stuff to 
> walk that list or other similar approaches. If so, why we still get 
> those real mapping entries later by accessing VT-D stuff again?
> Shouldn't we figure out a approach we just call one time?

Just go look for other examples of similar operations: There's
absolutely no need to know the number of entries up front. Just
have a way for the callback function to signal its caller that it
can abort the loop and return right away if you really need this.
But I doubt you do, since even when the caller has provided too
little buffer space you still want to tell it how much is needed. And
the necessary counting would still be done in the callback function.


Xen-devel mailing list



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