|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2] dm_op: Add xendevicemodel_modified_memory_bulk.
On 22/03/17 10:33, Jan Beulich wrote: On 21.03.17 at 14:59, <jennifer.herbert@xxxxxxxxxx> wrote:This version of this patch removes the need for the 'offset' parameter, by instead reducing nr_extents, and working backwards from the end of the array. This patch also removes the need to ever write back the passed array of extents to the guest, but instead putting its partial progress in a 'pfns_processed' parameter, which replaces the old 'offset' parameter. As with the 'offest' parameter, 'pfns_processed' should be set to 0 on calling.So how is the need for 'pfns_processed' better than the prior need for 'offset'? I continue to not see why you'd need any extra field, as you can write back to 'first_pfn' and 'nr' just like the old code did. (But note that I'm not outright objecting to this solution, I'd first like to understand why it was chosen.) With v1 of the patch, on continuation, two buffers get written back to guest, one to update 'offset', and one to update first_pfn (in the array). Although I can't think of an example where this would be a problem, I think that semi-randomly altering items in the passed array may not be expected, and if that data was re-used for something, could cause a bug. There is precedence for changing the op buffer, and using pfns_processed means we never have to change this array, which I think is much cleaner, intuitive, and halving the copy backs. I considered your suggestion of modifying the handle array, but I think this would make the code much harder to follow, and still require data written back to the guest - just in a different place. I thought just reducing the nr_extents a cleaner solution. I can't see the problem with having an argument for continuation - the xen_dm_op will remain the same size, if we use the argument space or not. If its just about how the API looks, I find this highly subjective - its no secret that continuations happen, and data gets stashed in these parameters - and so i see no reason why having a dedicated parameter for this is a problem.
If we want to hide this continuation information, we could define:
struct xen_dm_op_modified_memory {
/* IN - number of extents. */
uint32_t nr_extents;
}
struct xen_dm_op_modified_memory modified_memory_expanded {
struct xen_dm_op_modified_memory modified_memory;
uint32_t pfns_processed
}
and include both structures in the xen_dm_op union.
The caller would use xen_dm_op_modified_memory modified_memory, and due
to the memset(&op, 0, sizeof(op));, the value for pfns_processed would
end up as zero. Xen could use expanded structure, and make use of
pfns_processed.
Or, we could re-purpose the 'pad' member of struct xen_dm_op, call it continuation_data, and have this as a general purpose continuation variable, that the caller wouldn't pay any attention to. What do you think? --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -119,56 +119,89 @@ static int set_isa_irq_level(struct domain *d, uint8_t isa_irq, }static int modified_memory(struct domain *d, aw shucks! I had it as 255, and Paul said "255 or 256?" and I changed it to 256, without thinking, assuming an off by one error, and that he was right. But, with a seconds thought, it should be 255, and Paul was actually referring to a comment later in the code, which was 256.
I'll add a check for (header->pfns_processed > extent.nr), returning -EINVAL.
data->pad is undefined here. But I could add a check for extent.pad in the modified_memory function.
Assuming we keep it, how about calling it "reserved", with a comment in dm.c explaining what its actually for? Let me know what you think, Cheers, -jenny _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |