... | ... | ||
---|---|---|---|
15 | - VFIO device dirty tracking. | 15 | - VFIO device dirty tracking. |
16 | - Legacy VFIO iommu dirty tracking. | 16 | - Legacy VFIO iommu dirty tracking. |
17 | - vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is | 17 | - vIOMMU + Legacy VFIO iommu dirty tracking (migration with vIOMMU is |
18 | currently blocked, so I used a patched QEMU to allow it). | 18 | currently blocked, so I used a patched QEMU to allow it). |
19 | 19 | ||
20 | I also tested calc-dirty-rate as now VFIO dirty pages should be included | ||
21 | in its report, and indeed they are. | ||
22 | |||
20 | I didn't test it with iommu DPT as I don't have access to such HW. | 23 | I didn't test it with iommu DPT as I don't have access to such HW. |
21 | Cedric, I remember you said that you have such HW, it would be very | 24 | It would be great if someone with the proper HW could test it. |
22 | helpful if you could test it. | ||
23 | 25 | ||
24 | Patch structure: | 26 | Patch structure: |
25 | 1-6: Refactor and clean up VFIO dirty page tracking helpers. | 27 | 1-4: Refactor and clean up VFIO dirty page tracking helpers. |
26 | 7: Refactor dirty limit code. | 28 | 5: Refactor dirty limit code. |
27 | 8-9: Drop/unexport migration_is_device() and migration_is_running(). | 29 | 6-7: Drop/unexport migration_is_device() and migration_is_running(). |
30 | |||
31 | Changes from v1 [2]: | ||
32 | * Bail out early in vfio_container_set_dirty_page_tracking() if dirty | ||
33 | tracking has already been started/stopped. (Joao) | ||
34 | * Untied the dirty tracking helpers from migration (i.e., removed | ||
35 | migration_is_running() check) so VFIO dirty pages will be included in | ||
36 | calc-dirty-rate. (Joao) | ||
37 | * Added comment to VFIODevice->dirty_tracking that states it's protected | ||
38 | by BQL. | ||
39 | * Added R-b/A-b tags. | ||
28 | 40 | ||
29 | Thanks. | 41 | Thanks. |
30 | 42 | ||
31 | [1] | 43 | [1] |
32 | https://lore.kernel.org/qemu-devel/20241024213056.1395400-1-peterx@redhat.com/ | 44 | https://lore.kernel.org/qemu-devel/20241024213056.1395400-1-peterx@redhat.com/ |
33 | 45 | ||
34 | Avihai Horon (9): | 46 | [2] |
47 | https://lore.kernel.org/qemu-devel/20241216094638.26406-1-avihaih@nvidia.com/ | ||
48 | |||
49 | Avihai Horon (7): | ||
35 | vfio/container: Add dirty tracking started flag | 50 | vfio/container: Add dirty tracking started flag |
36 | vfio/migration: Refactor vfio_devices_all_dirty_tracking() logic | 51 | vfio/migration: Refactor vfio_devices_all_dirty_tracking() logic |
37 | vfio/migration: Refactor vfio_devices_all_running_and_mig_active() | 52 | vfio/migration: Refactor vfio_devices_all_running_and_mig_active() |
38 | logic | 53 | logic |
39 | vfio/migration: Add vfio_devices_all_dirty_tracking_started() helper | ||
40 | vfio/migration: Drop vfio_dma_unmap_dirty_sync_needed() | ||
41 | vfio/migration: Rename vfio_devices_all_dirty_tracking() | 54 | vfio/migration: Rename vfio_devices_all_dirty_tracking() |
42 | system/dirtylimit: Don't use migration_is_active() | 55 | system/dirtylimit: Don't use migration_is_active() |
43 | migration: Drop migration_is_device() | 56 | migration: Drop migration_is_device() |
44 | migration: Unexport migration_is_active() | 57 | migration: Unexport migration_is_active() |
45 | 58 | ||
46 | include/hw/vfio/vfio-common.h | 4 +- | 59 | include/hw/vfio/vfio-common.h | 6 +-- |
47 | include/hw/vfio/vfio-container-base.h | 1 + | 60 | include/hw/vfio/vfio-container-base.h | 1 + |
48 | include/migration/misc.h | 2 - | 61 | include/migration/misc.h | 2 - |
49 | hw/vfio/common.c | 61 ++++++++++++--------------- | 62 | hw/vfio/common.c | 57 +++++++++++---------------- |
50 | hw/vfio/container-base.c | 8 +++- | 63 | hw/vfio/container-base.c | 12 +++++- |
51 | hw/vfio/container.c | 2 +- | 64 | hw/vfio/container.c | 2 +- |
52 | migration/migration.c | 23 ++++------ | 65 | migration/migration.c | 23 ++++------- |
53 | system/dirtylimit.c | 3 +- | 66 | system/dirtylimit.c | 3 +- |
54 | 8 files changed, 48 insertions(+), 56 deletions(-) | 67 | 8 files changed, 49 insertions(+), 57 deletions(-) |
55 | 68 | ||
56 | -- | 69 | -- |
57 | 2.40.1 | 70 | 2.40.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
3 | 3 | ||
4 | This will be used in the following patches to allow dirty page syncs | 4 | This will be used in the following patches to allow dirty page syncs |
5 | only if dirty tracking has been started. | 5 | only if dirty tracking has been started. |
6 | 6 | ||
7 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | 7 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> |
8 | Reviewed-by: Joao Martins <joao.m.martins@oracle.com> | ||
8 | --- | 9 | --- |
9 | include/hw/vfio/vfio-container-base.h | 1 + | 10 | include/hw/vfio/vfio-container-base.h | 1 + |
10 | hw/vfio/container-base.c | 8 +++++++- | 11 | hw/vfio/container-base.c | 12 +++++++++++- |
11 | 2 files changed, 8 insertions(+), 1 deletion(-) | 12 | 2 files changed, 12 insertions(+), 1 deletion(-) |
12 | 13 | ||
13 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h | 14 | diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/vfio/vfio-container-base.h | 16 | --- a/include/hw/vfio/vfio-container-base.h |
16 | +++ b/include/hw/vfio/vfio-container-base.h | 17 | +++ b/include/hw/vfio/vfio-container-base.h |
... | ... | ||
36 | return 0; | 37 | return 0; |
37 | } | 38 | } |
38 | 39 | ||
39 | g_assert(vioc->set_dirty_page_tracking); | 40 | g_assert(vioc->set_dirty_page_tracking); |
40 | - return vioc->set_dirty_page_tracking(bcontainer, start, errp); | 41 | - return vioc->set_dirty_page_tracking(bcontainer, start, errp); |
42 | + if (bcontainer->dirty_pages_started == start) { | ||
43 | + return 0; | ||
44 | + } | ||
45 | + | ||
41 | + ret = vioc->set_dirty_page_tracking(bcontainer, start, errp); | 46 | + ret = vioc->set_dirty_page_tracking(bcontainer, start, errp); |
42 | + if (!ret) { | 47 | + if (!ret) { |
43 | + bcontainer->dirty_pages_started = start; | 48 | + bcontainer->dirty_pages_started = start; |
44 | + } | 49 | + } |
45 | + | 50 | + |
46 | + return ret; | 51 | + return ret; |
47 | } | 52 | } |
48 | 53 | ||
49 | int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | 54 | int vfio_container_query_dirty_bitmap(const VFIOContainerBase *bcontainer, |
50 | -- | 55 | -- |
51 | 2.40.1 | 56 | 2.40.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
8 | 8 | ||
9 | To accommodate this, refactor vfio_devices_all_dirty_tracking() logic so | 9 | To accommodate this, refactor vfio_devices_all_dirty_tracking() logic so |
10 | it won't use migration_is_active() and migration_is_device(). Instead, | 10 | it won't use migration_is_active() and migration_is_device(). Instead, |
11 | use internal VFIO dirty tracking flags. | 11 | use internal VFIO dirty tracking flags. |
12 | 12 | ||
13 | As a side effect, now that migration status is no longer used to detect | ||
14 | dirty tracking status, VFIO log syncs are untied from migration. This | ||
15 | will make calc-dirty-rate more accurate as now it will also include VFIO | ||
16 | dirty pages. | ||
17 | |||
18 | While at it, as VFIODevice->dirty_tracking is now used to detect dirty | ||
19 | tracking status, add a comment that states how it's protected. | ||
20 | |||
13 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | 21 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> |
14 | --- | 22 | --- |
15 | hw/vfio/common.c | 21 ++++++++++++++++++++- | 23 | include/hw/vfio/vfio-common.h | 2 +- |
16 | 1 file changed, 20 insertions(+), 1 deletion(-) | 24 | hw/vfio/common.c | 17 ++++++++++++++++- |
25 | 2 files changed, 17 insertions(+), 2 deletions(-) | ||
17 | 26 | ||
27 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/include/hw/vfio/vfio-common.h | ||
30 | +++ b/include/hw/vfio/vfio-common.h | ||
31 | @@ -XXX,XX +XXX,XX @@ typedef struct VFIODevice { | ||
32 | OnOffAuto pre_copy_dirty_page_tracking; | ||
33 | OnOffAuto device_dirty_page_tracking; | ||
34 | bool dirty_pages_supported; | ||
35 | - bool dirty_tracking; | ||
36 | + bool dirty_tracking; /* Protected by BQL */ | ||
37 | bool iommu_dirty_tracking; | ||
38 | HostIOMMUDevice *hiod; | ||
39 | int devid; | ||
18 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 40 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
19 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/vfio/common.c | 42 | --- a/hw/vfio/common.c |
21 | +++ b/hw/vfio/common.c | 43 | +++ b/hw/vfio/common.c |
22 | @@ -XXX,XX +XXX,XX @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev) | 44 | @@ -XXX,XX +XXX,XX @@ bool vfio_device_state_is_precopy(VFIODevice *vbasedev) |
... | ... | ||
40 | static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer) | 62 | static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer) |
41 | { | 63 | { |
42 | VFIODevice *vbasedev; | 64 | VFIODevice *vbasedev; |
43 | 65 | ||
44 | - if (!migration_is_active() && !migration_is_device()) { | 66 | - if (!migration_is_active() && !migration_is_device()) { |
45 | + if (!migration_is_running()) { | ||
46 | + return false; | ||
47 | + } | ||
48 | + | ||
49 | + if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) || | 67 | + if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) || |
50 | + bcontainer->dirty_pages_started)) { | 68 | + bcontainer->dirty_pages_started)) { |
51 | return false; | 69 | return false; |
52 | } | 70 | } |
53 | 71 | ||
54 | -- | 72 | -- |
55 | 2.40.1 | 73 | 2.40.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
6 | 6 | ||
7 | However, recently there has been an effort to simplify the migration | 7 | However, recently there has been an effort to simplify the migration |
8 | status API and reduce it to a single migration_is_running() function. | 8 | status API and reduce it to a single migration_is_running() function. |
9 | 9 | ||
10 | To accommodate this, refactor vfio_devices_all_running_and_mig_active() | 10 | To accommodate this, refactor vfio_devices_all_running_and_mig_active() |
11 | logic so it won't use migration_is_active(). | 11 | logic so it won't use migration_is_active(). Do it by simply checking if |
12 | dirty tracking has been started using internal VFIO flags. | ||
12 | 13 | ||
13 | Do it by modifying the logic to check if migration is running and dirty | 14 | This should be equivalent to the previous logic as during migration |
14 | tracking has been started. This should be equivalent to the previous | 15 | dirty tracking is active and when the guest is stopped there shouldn't |
15 | logic because when the guest is stopped there shouldn't be DMA unmaps | 16 | be DMA unmaps coming from it. |
16 | coming from it. Also rename the function properly. | 17 | |
18 | As a side effect, now that migration status is no longer used, DMA unmap | ||
19 | log syncs are untied from migration. This will make calc-dirty-rate more | ||
20 | accurate as now it will also include VFIO dirty pages that were DMA | ||
21 | unmapped. | ||
22 | |||
23 | Also rename the function to properly reflect its new logic and extract | ||
24 | common code from vfio_devices_all_dirty_tracking(). | ||
17 | 25 | ||
18 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | 26 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> |
19 | --- | 27 | --- |
20 | include/hw/vfio/vfio-common.h | 3 +-- | 28 | include/hw/vfio/vfio-common.h | 4 ++-- |
21 | hw/vfio/common.c | 28 ++++------------------------ | 29 | hw/vfio/common.c | 40 +++++++---------------------------- |
22 | hw/vfio/container.c | 2 +- | 30 | hw/vfio/container.c | 2 +- |
23 | 3 files changed, 6 insertions(+), 27 deletions(-) | 31 | 3 files changed, 11 insertions(+), 35 deletions(-) |
24 | 32 | ||
25 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | 33 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h |
26 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/vfio/vfio-common.h | 35 | --- a/include/hw/vfio/vfio-common.h |
28 | +++ b/include/hw/vfio/vfio-common.h | 36 | +++ b/include/hw/vfio/vfio-common.h |
29 | @@ -XXX,XX +XXX,XX @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); | 37 | @@ -XXX,XX +XXX,XX @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); |
30 | void vfio_migration_exit(VFIODevice *vbasedev); | 38 | void vfio_migration_exit(VFIODevice *vbasedev); |
31 | 39 | ||
32 | int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); | 40 | int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); |
33 | -bool | 41 | -bool |
34 | -vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer); | 42 | -vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer); |
35 | +bool vfio_dma_unmap_dirty_sync_needed(const VFIOContainerBase *bcontainer); | 43 | +bool vfio_devices_all_dirty_tracking_started( |
44 | + const VFIOContainerBase *bcontainer); | ||
36 | bool | 45 | bool |
37 | vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | 46 | vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); |
38 | int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | 47 | int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, |
39 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 48 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
40 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/hw/vfio/common.c | 50 | --- a/hw/vfio/common.c |
42 | +++ b/hw/vfio/common.c | 51 | +++ b/hw/vfio/common.c |
52 | @@ -XXX,XX +XXX,XX @@ static bool vfio_devices_all_device_dirty_tracking_started( | ||
53 | return true; | ||
54 | } | ||
55 | |||
56 | +bool vfio_devices_all_dirty_tracking_started( | ||
57 | + const VFIOContainerBase *bcontainer) | ||
58 | +{ | ||
59 | + return vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
60 | + bcontainer->dirty_pages_started; | ||
61 | +} | ||
62 | + | ||
63 | static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer) | ||
64 | { | ||
65 | VFIODevice *vbasedev; | ||
66 | |||
67 | - if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
68 | - bcontainer->dirty_pages_started)) { | ||
69 | + if (!vfio_devices_all_dirty_tracking_started(bcontainer)) { | ||
70 | return false; | ||
71 | } | ||
72 | |||
43 | @@ -XXX,XX +XXX,XX @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) | 73 | @@ -XXX,XX +XXX,XX @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) |
44 | return true; | 74 | return true; |
45 | } | 75 | } |
46 | 76 | ||
47 | -/* | 77 | -/* |
48 | - * Check if all VFIO devices are running and migration is active, which is | 78 | - * Check if all VFIO devices are running and migration is active, which is |
49 | - * essentially equivalent to the migration being in pre-copy phase. | 79 | - * essentially equivalent to the migration being in pre-copy phase. |
50 | - */ | 80 | - */ |
51 | -bool | 81 | -bool |
52 | -vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer) | 82 | -vfio_devices_all_running_and_mig_active(const VFIOContainerBase *bcontainer) |
53 | +bool vfio_dma_unmap_dirty_sync_needed(const VFIOContainerBase *bcontainer) | 83 | -{ |
54 | { | ||
55 | - VFIODevice *vbasedev; | 84 | - VFIODevice *vbasedev; |
56 | - | 85 | - |
57 | - if (!migration_is_active()) { | 86 | - if (!migration_is_active()) { |
58 | + if (!migration_is_running()) { | 87 | - return false; |
59 | return false; | 88 | - } |
60 | } | 89 | - |
61 | |||
62 | - QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { | 90 | - QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) { |
63 | - VFIOMigration *migration = vbasedev->migration; | 91 | - VFIOMigration *migration = vbasedev->migration; |
64 | - | 92 | - |
65 | - if (!migration) { | 93 | - if (!migration) { |
66 | - return false; | 94 | - return false; |
... | ... | ||
72 | - } else { | 100 | - } else { |
73 | - return false; | 101 | - return false; |
74 | - } | 102 | - } |
75 | - } | 103 | - } |
76 | - return true; | 104 | - return true; |
77 | + return vfio_devices_all_device_dirty_tracking_started(bcontainer) || | 105 | -} |
78 | + bcontainer->dirty_pages_started; | 106 | - |
79 | } | ||
80 | |||
81 | static bool vfio_listener_skipped_section(MemoryRegionSection *section) | 107 | static bool vfio_listener_skipped_section(MemoryRegionSection *section) |
108 | { | ||
109 | return (!memory_region_is_ram(section->mr) && | ||
82 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | 110 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c |
83 | index XXXXXXX..XXXXXXX 100644 | 111 | index XXXXXXX..XXXXXXX 100644 |
84 | --- a/hw/vfio/container.c | 112 | --- a/hw/vfio/container.c |
85 | +++ b/hw/vfio/container.c | 113 | +++ b/hw/vfio/container.c |
86 | @@ -XXX,XX +XXX,XX @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer, | 114 | @@ -XXX,XX +XXX,XX @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer, |
87 | int ret; | 115 | int ret; |
88 | Error *local_err = NULL; | 116 | Error *local_err = NULL; |
89 | 117 | ||
90 | - if (iotlb && vfio_devices_all_running_and_mig_active(bcontainer)) { | 118 | - if (iotlb && vfio_devices_all_running_and_mig_active(bcontainer)) { |
91 | + if (iotlb && vfio_dma_unmap_dirty_sync_needed(bcontainer)) { | 119 | + if (iotlb && vfio_devices_all_dirty_tracking_started(bcontainer)) { |
92 | if (!vfio_devices_all_device_dirty_tracking(bcontainer) && | 120 | if (!vfio_devices_all_device_dirty_tracking(bcontainer) && |
93 | bcontainer->dirty_pages_supported) { | 121 | bcontainer->dirty_pages_supported) { |
94 | return vfio_dma_unmap_bitmap(container, iova, size, iotlb); | 122 | return vfio_dma_unmap_bitmap(container, iova, size, iotlb); |
95 | -- | 123 | -- |
96 | 2.40.1 | 124 | 2.40.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | vfio_devices_all_dirty_tracking() and vfio_dma_unmap_dirty_sync_needed() | ||
2 | share the same code that checks if dirty page tracking has been started. | ||
3 | 1 | ||
4 | Extract it to a common helper vfio_devices_all_dirty_tracking_started(). | ||
5 | |||
6 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | ||
7 | --- | ||
8 | hw/vfio/common.c | 25 +++++++++++++------------ | ||
9 | 1 file changed, 13 insertions(+), 12 deletions(-) | ||
10 | |||
11 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/vfio/common.c | ||
14 | +++ b/hw/vfio/common.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static bool vfio_devices_all_device_dirty_tracking_started( | ||
16 | return true; | ||
17 | } | ||
18 | |||
19 | +static bool | ||
20 | +vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer) | ||
21 | +{ | ||
22 | + if (!migration_is_running()) { | ||
23 | + return false; | ||
24 | + } | ||
25 | + | ||
26 | + return vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
27 | + bcontainer->dirty_pages_started; | ||
28 | +} | ||
29 | + | ||
30 | static bool vfio_devices_all_dirty_tracking(VFIOContainerBase *bcontainer) | ||
31 | { | ||
32 | VFIODevice *vbasedev; | ||
33 | |||
34 | - if (!migration_is_running()) { | ||
35 | - return false; | ||
36 | - } | ||
37 | - | ||
38 | - if (!(vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
39 | - bcontainer->dirty_pages_started)) { | ||
40 | + if (!vfio_devices_all_dirty_tracking_started(bcontainer)) { | ||
41 | return false; | ||
42 | } | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) | ||
45 | |||
46 | bool vfio_dma_unmap_dirty_sync_needed(const VFIOContainerBase *bcontainer) | ||
47 | { | ||
48 | - if (!migration_is_running()) { | ||
49 | - return false; | ||
50 | - } | ||
51 | - | ||
52 | - return vfio_devices_all_device_dirty_tracking_started(bcontainer) || | ||
53 | - bcontainer->dirty_pages_started; | ||
54 | + return vfio_devices_all_dirty_tracking_started(bcontainer); | ||
55 | } | ||
56 | |||
57 | static bool vfio_listener_skipped_section(MemoryRegionSection *section) | ||
58 | -- | ||
59 | 2.40.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | There is no need for vfio_dma_unmap_dirty_sync_needed(), as it simply | ||
2 | calls vfio_devices_all_dirty_tracking_started(). | ||
3 | 1 | ||
4 | Drop vfio_dma_unmap_dirty_sync_needed(), export | ||
5 | vfio_devices_all_dirty_tracking_started() and use it instead. | ||
6 | |||
7 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | ||
8 | --- | ||
9 | include/hw/vfio/vfio-common.h | 3 ++- | ||
10 | hw/vfio/common.c | 9 ++------- | ||
11 | hw/vfio/container.c | 2 +- | ||
12 | 3 files changed, 5 insertions(+), 9 deletions(-) | ||
13 | |||
14 | diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/vfio/vfio-common.h | ||
17 | +++ b/include/hw/vfio/vfio-common.h | ||
18 | @@ -XXX,XX +XXX,XX @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp); | ||
19 | void vfio_migration_exit(VFIODevice *vbasedev); | ||
20 | |||
21 | int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); | ||
22 | -bool vfio_dma_unmap_dirty_sync_needed(const VFIOContainerBase *bcontainer); | ||
23 | +bool vfio_devices_all_dirty_tracking_started( | ||
24 | + const VFIOContainerBase *bcontainer); | ||
25 | bool | ||
26 | vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer); | ||
27 | int vfio_devices_query_dirty_bitmap(const VFIOContainerBase *bcontainer, | ||
28 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/vfio/common.c | ||
31 | +++ b/hw/vfio/common.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool vfio_devices_all_device_dirty_tracking_started( | ||
33 | return true; | ||
34 | } | ||
35 | |||
36 | -static bool | ||
37 | -vfio_devices_all_dirty_tracking_started(const VFIOContainerBase *bcontainer) | ||
38 | +bool vfio_devices_all_dirty_tracking_started( | ||
39 | + const VFIOContainerBase *bcontainer) | ||
40 | { | ||
41 | if (!migration_is_running()) { | ||
42 | return false; | ||
43 | @@ -XXX,XX +XXX,XX @@ bool vfio_devices_all_device_dirty_tracking(const VFIOContainerBase *bcontainer) | ||
44 | return true; | ||
45 | } | ||
46 | |||
47 | -bool vfio_dma_unmap_dirty_sync_needed(const VFIOContainerBase *bcontainer) | ||
48 | -{ | ||
49 | - return vfio_devices_all_dirty_tracking_started(bcontainer); | ||
50 | -} | ||
51 | - | ||
52 | static bool vfio_listener_skipped_section(MemoryRegionSection *section) | ||
53 | { | ||
54 | return (!memory_region_is_ram(section->mr) && | ||
55 | diff --git a/hw/vfio/container.c b/hw/vfio/container.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/hw/vfio/container.c | ||
58 | +++ b/hw/vfio/container.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static int vfio_legacy_dma_unmap(const VFIOContainerBase *bcontainer, | ||
60 | int ret; | ||
61 | Error *local_err = NULL; | ||
62 | |||
63 | - if (iotlb && vfio_dma_unmap_dirty_sync_needed(bcontainer)) { | ||
64 | + if (iotlb && vfio_devices_all_dirty_tracking_started(bcontainer)) { | ||
65 | if (!vfio_devices_all_device_dirty_tracking(bcontainer) && | ||
66 | bcontainer->dirty_pages_supported) { | ||
67 | return vfio_dma_unmap_bitmap(container, iova, size, iotlb); | ||
68 | -- | ||
69 | 2.40.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
5 | Rename it to vfio_devices_log_sync_needed() which reflects its purpose | 5 | Rename it to vfio_devices_log_sync_needed() which reflects its purpose |
6 | more accurately and makes the code clearer as there are already several | 6 | more accurately and makes the code clearer as there are already several |
7 | helpers with similar names. | 7 | helpers with similar names. |
8 | 8 | ||
9 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | 9 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> |
10 | Reviewed-by: Joao Martins <joao.m.martins@oracle.com> | ||
10 | --- | 11 | --- |
11 | hw/vfio/common.c | 4 ++-- | 12 | hw/vfio/common.c | 4 ++-- |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
13 | 14 | ||
14 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 15 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c |
... | ... | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
7 | 7 | ||
8 | To accommodate this, and since the same functionality can be achieved | 8 | To accommodate this, and since the same functionality can be achieved |
9 | with migration_is_running(), use it instead of migration_is_active(). | 9 | with migration_is_running(), use it instead of migration_is_active(). |
10 | 10 | ||
11 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | 11 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> |
12 | Reviewed-by: Hyman Huang <yong.huang@smartx.com> | ||
12 | --- | 13 | --- |
13 | system/dirtylimit.c | 3 +-- | 14 | system/dirtylimit.c | 3 +-- |
14 | 1 file changed, 1 insertion(+), 2 deletions(-) | 15 | 1 file changed, 1 insertion(+), 2 deletions(-) |
15 | 16 | ||
16 | diff --git a/system/dirtylimit.c b/system/dirtylimit.c | 17 | diff --git a/system/dirtylimit.c b/system/dirtylimit.c |
... | ... | diff view generated by jsdifflib |
1 | After being removed from VFIO, migration_is_device() no longer has any | 1 | After being removed from VFIO, migration_is_device() no longer has any |
---|---|---|---|
2 | users. Drop it. | 2 | users. Drop it. |
3 | 3 | ||
4 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | 4 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> |
5 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
6 | Acked-by: Peter Xu <peterx@redhat.com> | ||
5 | --- | 7 | --- |
6 | include/migration/misc.h | 1 - | 8 | include/migration/misc.h | 1 - |
7 | migration/migration.c | 7 ------- | 9 | migration/migration.c | 7 ------- |
8 | 2 files changed, 8 deletions(-) | 10 | 2 files changed, 8 deletions(-) |
9 | 11 | ||
... | ... | ||
37 | bool migration_thread_is_self(void) | 39 | bool migration_thread_is_self(void) |
38 | { | 40 | { |
39 | MigrationState *s = current_migration; | 41 | MigrationState *s = current_migration; |
40 | -- | 42 | -- |
41 | 2.40.1 | 43 | 2.40.1 |
44 | |||
45 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
3 | only used in migration.c. | 3 | only used in migration.c. |
4 | 4 | ||
5 | Unexport it and also relocate it so it can be made static. | 5 | Unexport it and also relocate it so it can be made static. |
6 | 6 | ||
7 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> | 7 | Signed-off-by: Avihai Horon <avihaih@nvidia.com> |
8 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
9 | Acked-by: Peter Xu <peterx@redhat.com> | ||
8 | --- | 10 | --- |
9 | include/migration/misc.h | 1 - | 11 | include/migration/misc.h | 1 - |
10 | migration/migration.c | 16 ++++++++-------- | 12 | migration/migration.c | 16 ++++++++-------- |
11 | 2 files changed, 8 insertions(+), 9 deletions(-) | 13 | 2 files changed, 8 insertions(+), 9 deletions(-) |
12 | 14 | ||
... | ... | ||
56 | bool migration_thread_is_self(void) | 58 | bool migration_thread_is_self(void) |
57 | { | 59 | { |
58 | MigrationState *s = current_migration; | 60 | MigrationState *s = current_migration; |
59 | -- | 61 | -- |
60 | 2.40.1 | 62 | 2.40.1 |
63 | |||
64 | diff view generated by jsdifflib |