test-runner: use virtio-fs by default, functional test speedup
v2 cover test-runner: use virtio-fs by default, functional test speedup
v2:
- refactor start_qemu() argv building
- split out rootfs setup to separate functions
- fix bug in check_virtualization() that causes problems here
***
Use virtio-fs instead of 9p, which gives 3x reduction in CPU time for functional tests:
Before:
$ time make check-functional real 1m56,857s user 8m37,727s sys 2m21,655s
After:
$ time make check-functional real 1m4,714s user 2m52,831s sys 0m37,379s
Wall clock improvement becomes more significant under CPU load.
Requires /usr/libexec/virtiofsd installed, and CONFIG_VIRTIO_FS=y in kernel. Enable that option in tester configs.
If virtiofsd is not available, fall back to 9p as before.
Pauli Virtanen (4):
tools/test-runner: replace alloca() based argv setup
doc: enable virtio-fs in tester kernel configs tools/test-runner: use virtiofsd for filesystem passthrough tools/test-runner: Fix CPUID register clobbers
doc/ci.config | 2 + doc/test-runner.rst | 10 +- doc/tester.config | 2 + tools/test-runner.c | 414 +++++++++++++++++++++++++++++++++++--------- 4 files changed, 346 insertions(+), 82 deletions(-)
Signature · 1 line
2.55.0
PATCH v2 1/4 tools/test-runner: replace alloca() based argv setup
Rewrite alloca() based argv array construction that required manual size counting with vasprintf string array. This allows splitting start_qemu() to multiple functions.
--- tools/test-runner.c | 132 +++++++++++++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 43 deletions(-)
tools/test-runner.c +89 -43
@@ -21,6 +21,7 @@#include <stdbool.h> #include <signal.h> #include <string.h> +#include <stdarg.h> #include <getopt.h> #include <poll.h> #include <dirent.h>
@@ -41,6 +42,10 @@#define WAIT_ANY (-1)#endif +#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0])) + +#define _cleanup_ (f) __attribute__((cleanup(f))) +#define CMDLINE_MAX (2048 * 10)#define EXTRA_OPT_MAX 64
@@ -65,6 +70,58 @@ static char *pcie_dev;static char *extra_opts[EXTRA_OPT_MAX ];static int num_extra_opts; +struct strv { +char **strv; +size_t size; +size_t i; +}; + +#define STRV_ERROR (s) ((s).size == 0) + +static void __attribute__((format (printf,2 ,3 ))) +strv_append (struct strv *s,const char *fmt, ...) +{ +va_list ap; +int ret; + +if (s->size ==0 || s->i >= s->size -1 ) + goto fail; + +va_start (ap, fmt); + ret =vasprintf (&s->strv[s->i], fmt, ap); +va_end (ap); + +if (ret <0 ) { +perror ("vasprintf" ); + s->strv[s->i] =NULL ; + goto fail; + } + + s->strv[++s->i] =NULL ; +return ; + +fail: + s->size =0 ; +} + +static void strv_concat (struct strv *s,const char *const *str) +{ +while (*str) { +strv_append (s,"%s" , *str); + str++; + } +} + +static void strv_cleanup (struct strv *s) +{ +size_t i; + +for (i =0 ; i < s->i; ++i) +free (s->strv[i]); + +memset (s,0 ,sizeof (*s)); +} +static const char *qemu_table[] = {"qemu-system-x86_64" ,"qemu-system-i386" ,
@@ -225,8 +282,7 @@ static void prepare_sandbox(void)enable_printk (); } -static char *const qemu_argv[] = { -"" , +static const char *const qemu_argv[] = {"-nodefaults" ,"-no-user-config" ,"-monitor" ,"none" ,
@@ -510,7 +566,9 @@ static int start_qemu(void) {char cwd[PATH_MAX /2 ], initcmd[PATH_MAX ], testargs[PATH_MAX ];char cmdline[CMDLINE_MAX ]; -char **argv; +char *argv_strv[EXTRA_OPT_MAX +64 ]; +struct strv _cleanup_ (strv_cleanup ) argv = { argv_strv, +ARRAY_SIZE (argv_strv) };int i, pos, status =0 ;pid_t pid;
@@ -533,7 +591,7 @@ static int start_qemu(void)if (n <0 || n >= len) {fprintf (stderr,"Buffer overflow detected in " "testargs\n" ); -exit (EXIT_FAILURE ); +return EXIT_FAILURE ; } pos += n;
@@ -558,66 +616,54 @@ static int start_qemu(void) run_auto, audio_server ? audio_server :"" , testargs); - argv =alloca (sizeof (qemu_argv) + - (sizeof (char *) * (8 + (num_devs *4 ))) + - (sizeof (char *) * (usb_dev ?4 :0 )) + - (sizeof (char *) * (pcie_dev ?2 :0 )) + - (sizeof (char *) * num_extra_opts)); -memcpy (argv, qemu_argv,sizeof (qemu_argv)); - - pos = (sizeof (qemu_argv) /sizeof (char *)) -1 ; -/* Make sure qemu_binary is not null */ if (!qemu_binary) {fprintf (stderr,"No QEMU binary is set\n" ); -exit (1 ); +return EXIT_FAILURE ; } - argv[0 ] = (char *) qemu_binary; + +strv_append (&argv,"%s" , qemu_binary); +strv_concat (&argv, qemu_argv);if (qemu_host_cpu) { - argv[pos++] ="-cpu" ; - argv[pos++] ="host" ; +strv_append (&argv,"-cpu" ); +strv_append (&argv,"host" ); } - argv[pos++] ="-kernel" ; - argv[pos++] = (char *) kernel_image; - argv[pos++] ="-append" ; - argv[pos++] = (char *) cmdline; +strv_append (&argv,"-kernel" ); +strv_append (&argv,"%s" , kernel_image); +strv_append (&argv,"-append" ); +strv_append (&argv,"%s" , cmdline);for (i =0 ; i < num_devs; i++) { -char *chrdev, *serdev; - - chrdev =alloca (48 +strlen (device_path)); -sprintf (chrdev,"socket,path=%s,id=bt%d" , device_path, i); - - serdev =alloca (64 ); -sprintf (serdev,"virtconsole,chardev=bt%d,name=bt.%d" , i, i); - - argv[pos++] ="-chardev" ; - argv[pos++] = chrdev; - argv[pos++] ="-device" ; - argv[pos++] = serdev; +strv_append (&argv,"-chardev" ); +strv_append (&argv,"socket,path=%s,id=bt%d" , device_path, i); +strv_append (&argv,"-device" ); +strv_append (&argv,"virtconsole,chardev=bt%d,name=bt.%d" , i, i); }if (usb_dev) { - argv[pos++] ="-device" ; - argv[pos++] ="qemu-xhci" ; - argv[pos++] ="-device" ; - argv[pos++] = usb_dev; +strv_append (&argv,"-device" ); +strv_append (&argv,"qemu-xhci" ); +strv_append (&argv,"-device" ); +strv_append (&argv,"%s" , usb_dev); }if (pcie_dev) { - argv[pos++] ="-device" ; - argv[pos++] = pcie_dev; +strv_append (&argv,"-device" ); +strv_append (&argv,"%s" , pcie_dev); }for (i =0 ; i < num_extra_opts; ++i) - argv[pos++] = extra_opts[i]; +strv_append (&argv,"%s" , extra_opts[i]); - argv[pos] =NULL ; +if (STRV_ERROR (argv)) { +fprintf (stderr,"Failed to build argument list\n" ); +return EXIT_FAILURE ; + }if (!pcie_dev) { -execve (argv[0 ], argv, qemu_envp); +execve (argv.strv[0 ], argv.strv, qemu_envp);return EXIT_FAILURE ; }
@@ -635,7 +681,7 @@ static int start_qemu(void) }if (pid ==0 ) { -execve (argv[0 ], argv, qemu_envp); +execve (argv.strv[0 ], argv.strv, qemu_envp);exit (EXIT_FAILURE ); }
Signature · 1 line
2.55.0
PATCH v2 2/4 doc: enable virtio-fs in tester kernel configs
In reply to Pauli VirtanenAdd support for virtio-fs in tester configs.
--- doc/ci.config | 2 ++ doc/tester.config | 2 ++ 2 files changed, 4 insertions(+)
doc/ci.config +2 -0
@@ -7,6 +7,8 @@ CONFIG_VIRTIO=y CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_CONSOLE=y +CONFIG_VIRTIO_FS=y +CONFIG_FUSE_FS=y CONFIG_HYPERVISOR_GUEST=y CONFIG_PARAVIRT=y
doc/tester.config +2 -0
@@ -2,6 +2,8 @@ CONFIG_PCI=y CONFIG_VIRTIO=y CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_CONSOLE=y +CONFIG_VIRTIO_FS=y +CONFIG_FUSE_FS=y CONFIG_HYPERVISOR_GUEST=y CONFIG_PARAVIRT=y
Signature · 1 line
2.55.0
PATCH v2 3/4 tools/test-runner: use virtiofsd for filesystem passthrough
In reply to Pauli VirtanenThe 9p mount passthrough I/O is fairly CPU hungry and slow. This matters for e.g. running Python in test-runner, since it has to read some amount of files for startup.
Add support for virtio-fs, which is significantly less CPU intensive.
Enable it by default if /usr/libexec/virtiofsd is available, fall back to 9p if virtiofsd not usable.
Before:
$ time make check-functional real 2m9,736s user 1m29,570s sys 0m32,715s
After:
$ time make check-functional real 1m35,703s user 0m28,938s sys 0m7,453s --- doc/test-runner.rst | 10 +- tools/test-runner.c | 233 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 227 insertions(+), 16 deletions(-)
doc/test-runner.rst +8 -2
@@ -8,8 +8,8 @@ DESCRIPTION =========== **test-runner(1)** is used to test Kernel changes to the Bluetooth subsystem, -it launches a virtual machine using qemu(1) and mounts the local filesystem -using virtio (9p). +it launches a virtual machine using qemu(1) with the host filesystem mounted +read-only inside the guest. OPTIONS =======
@@ -26,6 +26,7 @@ OPTIONS :-P/--pcie=<qemu_args>: Provide PCIe device :-q/--qemu=<path>: QEMU binary :-k/--kernel=<image>: Kernel image (bzImage) +:-F/--virtiofs[=<path>]: Path to virtiofsd, or no to disable virtio-fs :-h/--help: Show help options Kernel
@@ -47,6 +48,8 @@ option (like the Bluetooth subsystem) can be enabled on top of this. CONFIG_VIRTIO=y CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_CONSOLE=y + CONFIG_VIRTIO_FS=y + CONFIG_FUSE_FS=y CONFIG_NET=y CONFIG_INET=y
@@ -69,6 +72,9 @@ option (like the Bluetooth subsystem) can be enabled on top of this. CONFIG_DEVTMPFS=y CONFIG_DEBUG_FS=y +Filesystem passthrough uses virtio-fs when ``virtiofsd`` is installed on the +host, otherwise 9p. Use ``-Fno`` for kernels without ``CONFIG_VIRTIO_FS``. + Bluetooth ---------
tools/test-runner.c +219 -14
337 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v2 4/4 tools/test-runner: Fix CPUID register clobbers
In reply to Pauli VirtanenCPUID modifies EAX, EBX, ECX and EDX, but the inline asm clobber list is incomplete. Use the __get_cpuid() intrinsic instead.
Fixes rootfs_setup(r, argv) crashing due to impossible r != &rootfs due to clobbered registers.
--- tools/test-runner.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
tools/test-runner.c +8 -5
@@ -33,6 +33,11 @@#include <sys/param.h> #include <sys/reboot.h> +#if defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) +#include <cpuid.h> +#define HAVE_GET_CPUID +#endif +#include "bluetooth/bluetooth.h" #include "bluetooth/hci.h" #include "bluetooth/hci_lib.h"
@@ -306,12 +311,10 @@ static char *const qemu_envp[] = {static void check_virtualization (void ) { -#if defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) -uint32_t ecx; +#ifdef HAVE_GET_CPUID +unsigned int eax, ebx, ecx, edx; - __asm__ __volatile__("cpuid" :"=c" (ecx) :"a" (1 ) :"memory" ); - -if (!!(ecx & (1 <<5 ))) +if (__get_cpuid (1 , &eax, &ebx, &ecx, &edx) && (ecx & (1 <<5 )))printf ("Found support for Virtual Machine eXtensions\n" );#endif }
Signature · 1 line
2.55.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1163573/
---Test result---
Test Summary:
CheckPatch FAIL 2.15 seconds GitLint FAIL 1.33 seconds BuildEll PASS 19.81 seconds BluezMake PASS 373.66 seconds MakeCheck PASS 14.08 seconds MakeDistcheck PASS 141.19 seconds CheckValgrind PASS 237.21 seconds CheckSmatch PASS 298.62 seconds bluezmakeextell PASS 97.14 seconds IncrementalBuild PASS 417.21 seconds ScanBuild PASS 1131.54 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v2,1/4] tools/test-runner: replace alloca() based argv setup WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __printf(2, 3) over __attribute__((format(printf, 2, 3))) #129: FILE: tools/test-runner.c:81:
+static void __attribute__((format(printf, 2, 3)))
/github/workspace/src/patch/14810752.patch total: 0 errors, 1 warnings, 202 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/patch/14810752.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
[BlueZ,v2,3/4] tools/test-runner: use virtiofsd for filesystem passthrough WARNING:VOLATILE: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #199: FILE: tools/test-runner.c:571:
+static volatile sig_atomic_t terminate;
WARNING:STATIC_CONST_CHAR_ARRAY: char * array declaration might be better as static const #284: FILE: tools/test-runner.c:656:
+ const char *cmd[] = {
/github/workspace/src/patch/14810754.patch total: 0 errors, 2 warnings, 371 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/patch/14810754.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,v2,3/4] tools/test-runner: use virtiofsd for filesystem passthrough
14: B3 Line contains hard tab characters (\t): "real 2m9,736s"
15: B3 Line contains hard tab characters (\t): "user 1m29,570s"
16: B3 Line contains hard tab characters (\t): "sys 0m32,715s"
20: B3 Line contains hard tab characters (\t): "real 1m35,703s"
21: B3 Line contains hard tab characters (\t): "user 0m28,938s"
22: B3 Line contains hard tab characters (\t): "sys 0m7,453s"
https://github.com/bluez/bluez/pull/2522
---
Regards,
Linux Bluetooth
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 8 lines · On Sat, 12 Sep 2026 21:18:19 +0300 you wrote:
v2:
- refactorstart_qemu()argv building
- split out rootfs setup to separate functions
- fix bug incheck_virtualization()that causes problems here***
[...]
Here is the summary with links:
- [BlueZ,v2,1/4] tools/test-runner: replace alloca() based argv setup
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7856c910c27d - [BlueZ,v2,2/4] doc: enable virtio-fs in tester kernel configs https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=67e1394c8054 - [BlueZ,v2,3/4] tools/test-runner: use virtiofsd for filesystem passthrough https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6c1985716322 - [BlueZ,v2,4/4] tools/test-runner: Fix CPUID register clobbers https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c8e2b951b07f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html