Skip to contentSkip to conversation

Update AVX512 support for xbzrle and CI failure

PATCH In review ling xu 3 participants 8 messages Nov 16, 2022 – Feb 10, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

ling xu

author
#0 lore raw

v7 cover Update AVX512 support for xbzrle and CI failure

This patch updates code of avx512 support for xbzrle_encode_buffer function. We mainly modified code in xbzrle-bench.c for addressing CI failure.

ling xu (2):
Update AVX512 support for xbzrle_encode_buffer
Unit test code and benchmark code

 meson.build                |  16 ++
 meson_options.txt          |   2 +
 migration/ram.c            |  34 ++-
 migration/xbzrle.c         | 124 ++++++++++
 migration/xbzrle.h         |   4 +
 tests/bench/meson.build    |   4 +
 tests/bench/xbzrle-bench.c | 469 +++++++++++++++++++++++++++++++++++++
 tests/unit/test-xbzrle.c   |  39 ++-
 8 files changed, 684 insertions(+), 8 deletions(-)
 create mode 100644 tests/bench/xbzrle-bench.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v7 1/2 AVX512 support for xbzrle_encode_buffer

This commit is the same with [PATCH v6 1/2], and provides avx512 support for xbzrle_encode_buffer function to accelerate xbzrle encoding speed. Runtime check of avx512
support and benchmark for this feature are added. Compared with C
version of xbzrle_encode_buffer function, avx512 version can achieve
50%-70% performance improvement on benchmarking. In addition, if dirty
data is randomly located in 4K page, the avx512 version can achieve
almost 140% performance gain.

---
 meson.build        |  16 ++++++
 meson_options.txt  |   2 +
 migration/ram.c    |  34 +++++++++++--
 migration/xbzrle.c | 124 +++++++++++++++++++++++++++++++++++++++++++++
 migration/xbzrle.h |   4 ++
 5 files changed, 177 insertions(+), 3 deletions(-)
meson.build +16 -0
index cf3e517e56..d0d28f5c9e 100644
@@ -2344,6 +2344,22 @@ config_host_data.set('CONFIG_AVX512F_OPT', get_option('avx512f') \
     int main(int argc, char *argv[]) { return bar(argv[argc - 1]); }
   '''), error_message: 'AVX512F not available').allowed())
 
+config_host_data.set('CONFIG_AVX512BW_OPT', get_option('avx512bw') \
+  .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512BW') \
+  .require(cc.links('''
+    #pragma GCC push_options
+    #pragma GCC target("avx512bw")
+    #include <cpuid.h>
+    #include <immintrin.h>
+    static int bar(void *a) {
+
+      __m512i *x = a;
+      __m512i res= _mm512_abs_epi8(*x);
+      return res[1];
+    }
+    int main(int argc, char *argv[]) { return bar(argv[0]); }
+  '''), error_message: 'AVX512BW not available').allowed())
+
 have_pvrdma = get_option('pvrdma') \
   .require(rdma.found(), error_message: 'PVRDMA requires OpenFabrics libraries') \
   .require(cc.compiles(gnu_source_prefix + '''
meson_options.txt +2 -0
index 66128178bf..96814dd211 100644
@@ -104,6 +104,8 @@ option('avx2', type: 'feature', value: 'auto',
        description: 'AVX2 optimizations')
 option('avx512f', type: 'feature', value: 'disabled',
        description: 'AVX512F optimizations')
+option('avx512bw', type: 'feature', value: 'auto',
+       description: 'AVX512BW optimizations')
 option('keyring', type: 'feature', value: 'auto',
        description: 'Linux keyring support')
 
migration/ram.c +31 -3
index dc1de9ddbc..ff4c15c9c3 100644
@@ -83,6 +83,34 @@
 /* 0x80 is reserved in migration.h start with 0x100 next */
 #define RAM_SAVE_FLAG_COMPRESS_PAGE    0x100
 
+int (*xbzrle_encode_buffer_func)(uint8_t *, uint8_t *, int,
+     uint8_t *, int) = xbzrle_encode_buffer;
+#if defined(CONFIG_AVX512BW_OPT)
+#include "qemu/cpuid.h"
+static void __attribute__((constructor)) init_cpu_flag(void)
+{
+    unsigned max = __get_cpuid_max(0, NULL);
+    int a, b, c, d;
+    if (max >= 1) {
+        __cpuid(1, a, b, c, d);
+         /* We must check that AVX is not just available, but usable.  */
+        if ((c & bit_OSXSAVE) && (c & bit_AVX) && max >= 7) {
+            int bv;
+            __asm("xgetbv" : "=a"(bv), "=d"(d) : "c"(0));
+            __cpuid_count(7, 0, a, b, c, d);
+           /* 0xe6:
+            *  XCR0[7:5] = 111b (OPMASK state, upper 256-bit of ZMM0-ZMM15
+            *                    and ZMM16-ZMM31 state are enabled by OS)
+            *  XCR0[2:1] = 11b (XMM state and YMM state are enabled by OS)
+            */
+            if ((bv & 0xe6) == 0xe6 && (b & bit_AVX512BW)) {
+                xbzrle_encode_buffer_func = xbzrle_encode_buffer_avx512;
+            }
+        }
+    }
+}
+#endif
+
 XBZRLECacheStats xbzrle_counters;
 
 /* struct contains XBZRLE cache and a static page
@@ -802,9 +830,9 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
     memcpy(XBZRLE.current_buf, *current_data, TARGET_PAGE_SIZE);
 
     /* XBZRLE encoding (if there is no overflow) */
-    encoded_len = xbzrle_encode_buffer(prev_cached_page, XBZRLE.current_buf,
-                                       TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
-                                       TARGET_PAGE_SIZE);
+    encoded_len = xbzrle_encode_buffer_func(prev_cached_page, XBZRLE.current_buf,
+                                            TARGET_PAGE_SIZE, XBZRLE.encoded_buf,
+                                            TARGET_PAGE_SIZE);
 
     /*
      * Update the cache contents, so that it corresponds to the data
migration/xbzrle.c +124 -0

127 lines not on this page · raw message

migration/xbzrle.h +4 -0
index a0db507b9c..6feb49160a 100644
@@ -18,4 +18,8 @@ int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
                          uint8_t *dst, int dlen);
 
 int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
+#if defined(CONFIG_AVX512BW_OPT)
+int xbzrle_encode_buffer_avx512(uint8_t *old_buf, uint8_t *new_buf, int slen,
+                                uint8_t *dst, int dlen);
+#endif
 #endif
Signature · 1 line
2.25.1
Reviewed-by on v7 1/2
#2 lore raw

Re: [PATCH v7 1/2] AVX512 support for xbzrle_encode_buffer

Quoted 11 lines · ling xu

This commit is the same with [PATCH v6 1/2], and provides avx512 support for xbzrle_encode_buffer function to accelerate xbzrle encoding speed. Runtime check of avx512
support and benchmark for this feature are added. Compared with C
version of xbzrle_encode_buffer function, avx512 version can achieve
50%-70% performance improvement on benchmarking. In addition, if dirty
data is randomly located in 4K page, the avx512 version can achieve
almost 140% performance gain.

But there were a lot of "but's":

Quoted 17 lines
meson.build +9 -0
index cf3e517e56..d0d28f5c9e 100644
@@ -2344,6 +2344,22 @@ config_host_data.set('CONFIG_AVX512F_OPT', get_option('avx512f') \
     int main(int argc, char *argv[]) { return bar(argv[argc - 1]); }
   '''), error_message: 'AVX512F not available').allowed())
 
+config_host_data.set('CONFIG_AVX512BW_OPT', get_option('avx512bw') \
+  .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512BW') \
+  .require(cc.links('''
+    #pragma GCC push_options
+    #pragma GCC target("avx512bw")
+    #include <cpuid.h>
+    #include <immintrin.h>
+    static int bar(void *a) {
+

meson.build config_host_data.set('CONFIG_AVX512F_OPT', get_option('avx512f') \ · line 2365

Quoted 10 lines
meson.build +7 -0
+      __m512i *x = a;
+      __m512i res= _mm512_abs_epi8(*x);
+      return res[1];
+    }
+    int main(int argc, char *argv[]) { return bar(argv[0]); }
+  '''), error_message: 'AVX512BW not available').allowed())
+
 have_pvrdma = get_option('pvrdma') \
   .require(rdma.found(), error_message: 'PVRDMA requires OpenFabrics libraries') \
   .require(cc.compiles(gnu_source_prefix + '''

This file misses:

@@ -3783,6 +3799,7 @@ summary_info += {'debug stack usage': get_option('debug_stack_usage')}
summary_info += {'mutex debugging': get_option('debug_mutex')}
summary_info += {'memory allocator': get_option('malloc')}
summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')}
+summary_info += {'avx512bw optimization': config_host_data.get('CONFIG_AVX512BW_OPT')}
summary_info += {'avx512f optimization': config_host_data.get('CONFIG_AVX512F_OPT')}
summary_info += {'gprof enabled': get_option('gprof')}
summary_info += {'gcov': get_option('b_coverage')}

meson_options.txt +2 -0
index 559a571b6b..e5f199119e 100644
@@ -104,6 +104,8 @@ option('avx2', type: 'feature', value: 'auto',
        description: 'AVX2 optimizations')
 option('avx512f', type: 'feature', value: 'disabled',
        description: 'AVX512F optimizations')
+option('avx512bw', type: 'feature', value: 'auto',
+       description: 'AVX512BW optimizations')
 option('keyring', type: 'feature', value: 'auto',
        description: 'Linux keyring support')
 

And you are missing:

scripts/meson-buildoptions.sh +3 -0
index 0f71e92dcb..c2982ea087 100644
@@ -70,6 +70,7 @@ meson_options_help() {
   printf "%s\n" '  attr            attr/xattr support'
   printf "%s\n" '  auth-pam        PAM access control'
   printf "%s\n" '  avx2            AVX2 optimizations'
+  printf "%s\n" '  avx512bw        AVX512BW optimizations'
   printf "%s\n" '  avx512f         AVX512F optimizations'
   printf "%s\n" '  blkio           libblkio block device driver'
   printf "%s\n" '  bochs           bochs image format support'
@@ -198,6 +199,8 @@ _meson_option_parse() {
     --disable-auth-pam) printf "%s" -Dauth_pam=disabled ;;
     --enable-avx2) printf "%s" -Davx2=enabled ;;
     --disable-avx2) printf "%s" -Davx2=disabled ;;
+    --enable-avx512bw) printf "%s" -Davx512bw=enabled ;;
+    --disable-avx512bw) printf "%s" -Davx512bw=disabled ;;
     --enable-avx512f) printf "%s" -Davx512f=enabled ;;
     --disable-avx512f) printf "%s" -Davx512f=disabled ;;
     --enable-gcov) printf "%s" -Db_coverage=true ;;
author
#3 lore raw

PATCH v7 2/2 Update bench-code for addressing CI problem

In reply to ling xu

Unit test code is in test-xbzrle.c, and benchmark code is in xbzrle-bench.c for performance benchmarking. we have modified xbzrle-bench.c to address CI problem.

---
 tests/bench/meson.build    |   4 +
 tests/bench/xbzrle-bench.c | 469 +++++++++++++++++++++++++++++++++++++
 tests/unit/test-xbzrle.c   |  39 ++-
 3 files changed, 507 insertions(+), 5 deletions(-)
 create mode 100644 tests/bench/xbzrle-bench.c
tests/bench/meson.build +4 -0
index 279a8fcc33..daefead58d 100644
@@ -3,6 +3,10 @@ qht_bench = executable('qht-bench',
                        sources: 'qht-bench.c',
                        dependencies: [qemuutil])
 
+xbzrle_bench = executable('xbzrle-bench',
+                       sources: 'xbzrle-bench.c',
+                       dependencies: [qemuutil,migration])
+
 executable('atomic_add-bench',
            sources: files('atomic_add-bench.c'),
            dependencies: [qemuutil],
tests/bench/xbzrle-bench.c new file +469 -0

469 lines not on this page · raw message

tests/unit/test-xbzrle.c +34 -5
index ef951b6e54..547046d093 100644
@@ -16,6 +16,35 @@
 
 #define XBZRLE_PAGE_SIZE 4096
 
+int (*xbzrle_encode_buffer_func)(uint8_t *, uint8_t *, int,
+     uint8_t *, int) = xbzrle_encode_buffer;
+#if defined(CONFIG_AVX512BW_OPT)
+#include "qemu/cpuid.h"
+static void __attribute__((constructor)) init_cpu_flag(void)
+{
+    unsigned max = __get_cpuid_max(0, NULL);
+    int a, b, c, d;
+    if (max >= 1) {
+        __cpuid(1, a, b, c, d);
+         /* We must check that AVX is not just available, but usable.  */
+        if ((c & bit_OSXSAVE) && (c & bit_AVX) && max >= 7) {
+            int bv;
+            __asm("xgetbv" : "=a"(bv), "=d"(d) : "c"(0));
+            __cpuid_count(7, 0, a, b, c, d);
+           /* 0xe6:
+            *  XCR0[7:5] = 111b (OPMASK state, upper 256-bit of ZMM0-ZMM15
+            *                    and ZMM16-ZMM31 state are enabled by OS)
+            *  XCR0[2:1] = 11b (XMM state and YMM state are enabled by OS)
+            */
+            if ((bv & 0xe6) == 0xe6 && (b & bit_AVX512BW)) {
+                xbzrle_encode_buffer_func = xbzrle_encode_buffer_avx512;
+            }
+        }
+    }
+    return ;
+}
+#endif
+
 static void test_uleb(void)
 {
     uint32_t i, val;
@@ -54,7 +83,7 @@ static void test_encode_decode_zero(void)
     buffer[1000 + diff_len + 5] = 105;
 
     /* encode zero page */
-    dlen = xbzrle_encode_buffer(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
+    dlen = xbzrle_encode_buffer_func(buffer, buffer, XBZRLE_PAGE_SIZE, compressed,
                        XBZRLE_PAGE_SIZE);
     g_assert(dlen == 0);
 
@@ -78,7 +107,7 @@ static void test_encode_decode_unchanged(void)
     test[1000 + diff_len + 5] = 109;
 
     /* test unchanged buffer */
-    dlen = xbzrle_encode_buffer(test, test, XBZRLE_PAGE_SIZE, compressed,
+    dlen = xbzrle_encode_buffer_func(test, test, XBZRLE_PAGE_SIZE, compressed,
                                 XBZRLE_PAGE_SIZE);
     g_assert(dlen == 0);
 
@@ -96,7 +125,7 @@ static void test_encode_decode_1_byte(void)
 
     test[XBZRLE_PAGE_SIZE - 1] = 1;
 
-    dlen = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed,
+    dlen = xbzrle_encode_buffer_func(buffer, test, XBZRLE_PAGE_SIZE, compressed,
                        XBZRLE_PAGE_SIZE);
     g_assert(dlen == (uleb128_encode_small(&buf[0], 4095) + 2));
 
@@ -121,7 +150,7 @@ static void test_encode_decode_overflow(void)
     }
 
     /* encode overflow */
-    rc = xbzrle_encode_buffer(buffer, test, XBZRLE_PAGE_SIZE, compressed,
+    rc = xbzrle_encode_buffer_func(buffer, test, XBZRLE_PAGE_SIZE, compressed,
                               XBZRLE_PAGE_SIZE);
     g_assert(rc == -1);
 
@@ -152,7 +181,7 @@ static void encode_decode_range(void)
     test[1000 + diff_len + 5] = 109;
 
     /* test encode/decode */
-    dlen = xbzrle_encode_buffer(test, buffer, XBZRLE_PAGE_SIZE, compressed,
+    dlen = xbzrle_encode_buffer_func(test, buffer, XBZRLE_PAGE_SIZE, compressed,
                                 XBZRLE_PAGE_SIZE);
 
     rc = xbzrle_decode_buffer(compressed, dlen, test, XBZRLE_PAGE_SIZE);
Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH v7 2/2] Update bench-code for addressing CI problem

In reply to ling xu
Quoted 21 lines · ling xu

Unit test code is in test-xbzrle.c, and benchmark code is in xbzrle-bench.c for performance benchmarking. we have modified xbzrle-bench.c to address CI problem.

---
  tests/bench/meson.build    |   4 +
  tests/bench/xbzrle-bench.c | 469 +++++++++++++++++++++++++++++++++++++
  tests/unit/test-xbzrle.c   |  39 ++-
  3 files changed, 507 insertions(+), 5 deletions(-)

create mode 100644 tests/bench/xbzrle-bench.c

tests/bench/xbzrle-bench.c new file +0 -0
new file mode 100644
index 0000000000..8848a3a32d

tests/bench/xbzrle-bench.c line 7

Quoted 7 lines
tests/bench/xbzrle-bench.c new file +7 -0
@@ -0,0 +1,469 @@
+/*
+ * Xor Based Zero Run Length Encoding unit tests.
+ *
+ * Copyright 2013 Red Hat, Inc. and/or its affiliates
+ *
+ * Authors:
+ *  Orit Wasserman  <[email protected]>

Is Orit the real author? Or is it based on migration/xbzrle.c?

tests/bench/xbzrle-bench.c line 15

Quoted 7 lines
tests/bench/xbzrle-bench.c new file +7 -0
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "../migration/xbzrle.h"

Interesting migration include path. Similarly:

$ git grep -F '#include "../' tests | egrep -v '(../libqtest.h|tests/tcg/mips|../multiarch)'
tests/qtest/netdev-socket.c:12:#include "../unit/socket-helpers.h"
tests/unit/test-qgraph.c:20:#include "../qtest/libqos/qgraph.h"
tests/unit/test-qgraph.c:21:#include "../qtest/libqos/qgraph_internal.h"

tests/migration/aarch64/a-b-kernel.S:14:#include "../migration-test.h" tests/unit/test-vmstate.c:27:#include "../migration/migration.h" tests/unit/test-vmstate.c:30:#include "../migration/qemu-file.h" tests/unit/test-vmstate.c:31:#include "../migration/savevm.h" tests/unit/test-xbzrle.c:15:#include "../migration/xbzrle.h"

$ ls -1 migration/*.h
migration/block.h
migration/channel-block.h
migration/channel.h
migration/dirtyrate.h
migration/exec.h
migration/fd.h
migration/migration.h      [*]
migration/multifd.h
migration/page_cache.h
migration/postcopy-ram.h
migration/qemu-file.h      [*]
migration/ram.h
migration/rdma.h
migration/savevm.h         [*]
migration/socket.h
migration/threadinfo.h
migration/tls.h
migration/trace.h
migration/xbzrle.h         [*]
migration/yank_functions.h
$ ls -1 include/migration/*.h
include/migration/blocker.h
include/migration/colo.h
include/migration/cpu.h
include/migration/failover.h
include/migration/global_state.h
include/migration/misc.h
include/migration/qemu-file-types.h
include/migration/register.h
include/migration/snapshot.h
include/migration/vmstate.h

Do the 4 files marked [*] belong to include/migration/?

#6 lore raw

Re: [PATCH v7 2/2] Update bench-code for addressing CI problem

Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 12 lines · ling xu

Unit test code is in test-xbzrle.c, and benchmark code is in xbzrle-bench.c for performance benchmarking. we have modified xbzrle-bench.c to address CI problem.

---
  tests/bench/meson.build    |   4 +
  tests/bench/xbzrle-bench.c | 469 +++++++++++++++++++++++++++++++++++++
  tests/unit/test-xbzrle.c   |  39 ++-
  3 files changed, 507 insertions(+), 5 deletions(-)

create mode 100644 tests/bench/xbzrle-bench.c

Quoted 15 lines

tests/bench/xbzrle-bench.c line 7

Quoted 13 lines
tests/bench/xbzrle-bench.c new file +7 -0
new file mode 100644
index 0000000000..8848a3a32d
@@ -0,0 +1,469 @@
+/*
+ * Xor Based Zero Run Length Encoding unit tests.
+ *
+ * Copyright 2013 Red Hat, Inc. and/or its affiliates
+ *
+ * Authors:
+ *  Orit Wasserman  <[email protected]>

Is Orit the real author? Or is it based on migration/xbzrle.c?

Based on as far as I can se.

Quoted 9 lines

tests/bench/xbzrle-bench.c line 15

Quoted 7 lines
tests/bench/xbzrle-bench.c new file +7 -0
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "../migration/xbzrle.h"

Interesting migration include path. Similarly:

xbzrle.h is only exported for migration. Nothing else can use them. So we can't put that on include/migration/*

Quoted 46 lines
$ git grep -F '#include "../' tests | egrep -v
'(../libqtest.h|tests/tcg/mips|../multiarch)'
tests/qtest/netdev-socket.c:12:#include "../unit/socket-helpers.h"
tests/unit/test-qgraph.c:20:#include "../qtest/libqos/qgraph.h"
tests/unit/test-qgraph.c:21:#include "../qtest/libqos/qgraph_internal.h"

tests/migration/aarch64/a-b-kernel.S:14:#include "../migration-test.h" tests/unit/test-vmstate.c:27:#include "../migration/migration.h" tests/unit/test-vmstate.c:30:#include "../migration/qemu-file.h" tests/unit/test-vmstate.c:31:#include "../migration/savevm.h" tests/unit/test-xbzrle.c:15:#include "../migration/xbzrle.h"

$ ls -1 migration/*.h
migration/block.h
migration/channel-block.h
migration/channel.h
migration/dirtyrate.h
migration/exec.h
migration/fd.h
migration/migration.h      [*]
migration/multifd.h
migration/page_cache.h
migration/postcopy-ram.h
migration/qemu-file.h      [*]
migration/ram.h
migration/rdma.h
migration/savevm.h         [*]
migration/socket.h
migration/threadinfo.h
migration/tls.h
migration/trace.h
migration/xbzrle.h         [*]
migration/yank_functions.h
$ ls -1 include/migration/*.h
include/migration/blocker.h
include/migration/colo.h
include/migration/cpu.h
include/migration/failover.h
include/migration/global_state.h
include/migration/misc.h
include/migration/qemu-file-types.h
include/migration/register.h
include/migration/snapshot.h
include/migration/vmstate.h
Quoted 1 line

Do the 4 files marked [*] belong to include/migration/?

The split is:
include/migration/* <- exported for everybody to use
migration/*.h <- Only for migration

Now, doing tests for migration makes this difference complicated, because some tests really need things that are not exported.

This is the way that it is normally used in the tree, no?

Later, Juan.

#7 lore raw

Re: [PATCH v7 2/2] Update bench-code for addressing CI problem

Quoted 95 lines · Juan Quintela
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 12 lines · ling xu

Unit test code is in test-xbzrle.c, and benchmark code is in xbzrle-bench.c for performance benchmarking. we have modified xbzrle-bench.c to address CI problem.

---
   tests/bench/meson.build    |   4 +
   tests/bench/xbzrle-bench.c | 469 +++++++++++++++++++++++++++++++++++++
   tests/unit/test-xbzrle.c   |  39 ++-
   3 files changed, 507 insertions(+), 5 deletions(-)

create mode 100644 tests/bench/xbzrle-bench.c

Quoted 15 lines

tests/bench/xbzrle-bench.c line 7

Quoted 13 lines
tests/bench/xbzrle-bench.c new file +7 -0
new file mode 100644
index 0000000000..8848a3a32d
@@ -0,0 +1,469 @@
+/*
+ * Xor Based Zero Run Length Encoding unit tests.
+ *
+ * Copyright 2013 Red Hat, Inc. and/or its affiliates
+ *
+ * Authors:
+ *  Orit Wasserman  <[email protected]>

Is Orit the real author? Or is it based on migration/xbzrle.c?

Based on as far as I can se.

Quoted 9 lines

tests/bench/xbzrle-bench.c line 15

Quoted 7 lines
tests/bench/xbzrle-bench.c new file +7 -0
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "../migration/xbzrle.h"

Interesting migration include path. Similarly:

xbzrle.h is only exported for migration. Nothing else can use them. So we can't put that on include/migration/*

Quoted 46 lines
$ git grep -F '#include "../' tests | egrep -v
'(../libqtest.h|tests/tcg/mips|../multiarch)'
tests/qtest/netdev-socket.c:12:#include "../unit/socket-helpers.h"
tests/unit/test-qgraph.c:20:#include "../qtest/libqos/qgraph.h"
tests/unit/test-qgraph.c:21:#include "../qtest/libqos/qgraph_internal.h"

tests/migration/aarch64/a-b-kernel.S:14:#include "../migration-test.h" tests/unit/test-vmstate.c:27:#include "../migration/migration.h" tests/unit/test-vmstate.c:30:#include "../migration/qemu-file.h" tests/unit/test-vmstate.c:31:#include "../migration/savevm.h" tests/unit/test-xbzrle.c:15:#include "../migration/xbzrle.h"

$ ls -1 migration/*.h
migration/block.h
migration/channel-block.h
migration/channel.h
migration/dirtyrate.h
migration/exec.h
migration/fd.h
migration/migration.h      [*]
migration/multifd.h
migration/page_cache.h
migration/postcopy-ram.h
migration/qemu-file.h      [*]
migration/ram.h
migration/rdma.h
migration/savevm.h         [*]
migration/socket.h
migration/threadinfo.h
migration/tls.h
migration/trace.h
migration/xbzrle.h         [*]
migration/yank_functions.h
$ ls -1 include/migration/*.h
include/migration/blocker.h
include/migration/colo.h
include/migration/cpu.h
include/migration/failover.h
include/migration/global_state.h
include/migration/misc.h
include/migration/qemu-file-types.h
include/migration/register.h
include/migration/snapshot.h
include/migration/vmstate.h
Quoted 1 line

Do the 4 files marked [*] belong to include/migration/?

Quoted 8 lines

The split is:
include/migration/* <- exported for everybody to use
migration/*.h <- Only for migration

Now, doing tests for migration makes this difference complicated, because some tests really need things that are not exported.

This is the way that it is normally used in the tree, no?

Yes you are correct. Thanks for clarifying!

Phil.