All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kirti Wankhede <kwankhede@nvidia.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: alex.williamson@redhat.com, cjia@nvidia.com,
	kevin.tian@intel.com, ziye.yang@intel.com,
	changpeng.liu@intel.com, yi.l.liu@intel.com, mlevitsk@redhat.com,
	eskultet@redhat.com, cohuck@redhat.com,
	jonathan.davies@nutanix.com, eauger@redhat.com, aik@ozlabs.ru,
	pasic@linux.ibm.com, felipe@nutanix.com,
	Zhengxiao.zx@alibaba-inc.com, shuangtai.tst@alibaba-inc.com,
	Ken.Xue@amd.com, zhi.a.wang@intel.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/5] VFIO KABI for migration interface
Date: Fri, 23 Nov 2018 02:13:46 +0530	[thread overview]
Message-ID: <b9602280-d465-479c-8f6c-9295089d5460@nvidia.com> (raw)
In-Reply-To: <20181122185417.GE2605@work-vm>



On 11/23/2018 12:24 AM, Dr. David Alan Gilbert wrote:
> * Kirti Wankhede (kwankhede@nvidia.com) wrote:
>> - Defined MIGRATION region type and sub-type.
>> - Defined VFIO device states during migration process.
>> - Defined vfio_device_migration_info structure which will be placed at 0th
>>   offset of migration region to get/set VFIO device related information.
>>   Defined actions and members of structure usage for each action:
>>     * To convey VFIO device state to be transitioned to.
>>     * To get pending bytes yet to be migrated for VFIO device
>>     * To ask driver to write data to migration region and return number of bytes
>>       written in the region
>>     * In migration resume path, user space app writes to migration region and
>>       communicates it to vendor driver.
>>     * Get bitmap of dirty pages from vendor driver from given start address
>>
>> Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com>
>> Reviewed-by: Neo Jia <cjia@nvidia.com>
> 
> <snip>
> 
>> + * Action Get buffer:
>> + *      On this action, vendor driver should write data to migration region and
>> + *      return number of bytes written in the region.
>> + *      data.offset [output] : offset in the region from where data is written.
>> + *      data.size [output] : number of bytes written in migration buffer by
>> + *          vendor driver.
> 
> <snip>
> 
>> + */
>> +
>> +struct vfio_device_migration_info {
>> +        __u32 device_state;         /* VFIO device state */
>> +        struct {
>> +            __u64 precopy_only;
>> +            __u64 compatible;
>> +            __u64 postcopy_only;
>> +            __u64 threshold_size;
>> +        } pending;
>> +        struct {
>> +            __u64 offset;           /* offset */
>> +            __u64 size;             /* size */
>> +        } data;
> 
> I'm curious how the offsets/size work; how does the 
> kernel driver know the maximum size of state it's allowed to write?


Migration region looks like:
 ----------------------------------------------------------------------
|vfio_device_migration_info|    data section			      |	
|                          |     ///////////////////////////////////  |
 ----------------------------------------------------------------------
 ^			         ^                                 ^
 offset 0-trapped part         data.offset                     data.size


Kernel driver defines the size of migration region and tells VFIO user
space application (QEMU here) through VFIO_DEVICE_GET_REGION_INFO ioctl.
So kernel driver can calculate the size of data section. Then kernel
driver can have (data.size >= data section size) or (data.size < data
section size), hence VFIO user space application need to know data.size
to copy only relevant data.

> Why would it pick a none-0 offset into the output region?

Data section is always followed by vfio_device_migration_info structure
in the region, so data.offset will always be none-0.
Offset from where data is copied is decided by kernel driver, data
section can be trapped or mapped depending on how kernel driver defines
data section. If mmapped, then data.offset should be page aligned, where
as initial section which contain vfio_device_migration_info structure
might not end at offset which is page aligned.

Thanks,
Kirti

> Without having dug further these feel like i/o rather than just output;
> i.e. the calling process says 'put it at that offset and you've got size
> bytes' and the kernel replies with 'I did put it at offset and I wrote
> only this size bytes'
> 
> Dave
> 
>> +        struct {
>> +            __u64 start_addr;
>> +            __u64 total;
>> +            __u64 copied;
>> +        } dirty_pfns;
>> +} __attribute__((packed));
>> +
>>  /* -------- API for Type1 VFIO IOMMU -------- */
>>  
>>  /**
>> -- 
>> 2.7.0
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> 

  reply	other threads:[~2018-11-22 20:44 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20 20:39 [Qemu-devel] [PATCH 0/5] Add migration support for VFIO device Kirti Wankhede
2018-11-20 20:39 ` [Qemu-devel] [PATCH 1/5] VFIO KABI for migration interface Kirti Wankhede
2018-11-21  0:26   ` Tian, Kevin
2018-11-21  4:24     ` Kirti Wankhede
2018-11-21  6:13       ` Tian, Kevin
2018-11-22 20:01         ` Kirti Wankhede
2018-11-26  7:14           ` Tian, Kevin
2018-11-21 17:26   ` Pierre Morel
2018-11-22 18:54   ` Dr. David Alan Gilbert
2018-11-22 20:43     ` Kirti Wankhede [this message]
2018-11-23 11:44       ` Dr. David Alan Gilbert
2018-11-23  5:47   ` Zhao Yan
2018-11-27 19:52   ` Alex Williamson
2018-12-04 10:53     ` Cornelia Huck
2018-12-04 17:14       ` Alex Williamson
2018-11-20 20:39 ` [Qemu-devel] [PATCH 2/5] Add save and load functions for VFIO PCI devices Kirti Wankhede
2018-11-21  5:32   ` Peter Xu
2018-11-20 20:39 ` [Qemu-devel] [PATCH 3/5] Add migration functions for VFIO devices Kirti Wankhede
2018-11-21  7:39   ` Zhao, Yan Y
2018-11-22 21:21     ` Kirti Wankhede
2018-11-23  5:29       ` Zhao Yan
2018-11-22  8:22   ` Zhao, Yan Y
2018-11-22 19:57   ` Dr. David Alan Gilbert
2018-11-29  8:04   ` Zhao Yan
2018-12-17 11:19   ` Gonglei (Arei)
2018-12-19  2:12     ` Zhao Yan
2018-12-21  7:36       ` Zhi Wang
2018-11-20 20:39 ` [Qemu-devel] [PATCH 4/5] Add vfio_listerner_log_sync to mark dirty pages Kirti Wankhede
2018-11-22 20:00   ` Dr. David Alan Gilbert
2018-11-20 20:39 ` [Qemu-devel] [PATCH 5/5] Make vfio-pci device migration capable Kirti Wankhede
2018-11-21  5:47 ` [Qemu-devel] [PATCH 0/5] Add migration support for VFIO device Peter Xu
2018-11-22 21:01   ` Kirti Wankhede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9602280-d465-479c-8f6c-9295089d5460@nvidia.com \
    --to=kwankhede@nvidia.com \
    --cc=Ken.Xue@amd.com \
    --cc=Zhengxiao.zx@alibaba-inc.com \
    --cc=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=changpeng.liu@intel.com \
    --cc=cjia@nvidia.com \
    --cc=cohuck@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eauger@redhat.com \
    --cc=eskultet@redhat.com \
    --cc=felipe@nutanix.com \
    --cc=jonathan.davies@nutanix.com \
    --cc=kevin.tian@intel.com \
    --cc=mlevitsk@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shuangtai.tst@alibaba-inc.com \
    --cc=yi.l.liu@intel.com \
    --cc=zhi.a.wang@intel.com \
    --cc=ziye.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.