Skip to content

Name threads

Dr. David Alan Gilbert (git) qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 12 repliesIn review
  2. v13 patches 11 repliesSuperseded

Changes in v2 from the cover letter

Change the name to debug-threads and add more scary warnings to stop
anyone even thinking they should use the thread names as an API.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Rework --name to use QemuOptsvl.c+39 -135 replies
2/3Add 'debug-threads' suboption to --nameinclude/qemu/thread.h qemu-options.hx util/qemu-thread-posix.c +2 more+30 -23 replies
3/3Add a 'name' parameter to qemu_thread_createcpus.c hw/block/dataplane/virtio-blk.c hw/usb/ccid-card-emulated.c +8 more+41 -192 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchAlex BennéeLaszlo Ersek
1/3R-b R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/3] Name threads

From: "Dr. David Alan Gilbert" <[email protected]>

This series uses pthread_setname_np (when available) to set the names on threads that QEMU creates to make life easier when debugging.

It's turned off by default (because there were worries that it might break tools that relied on process names) but is enabled by adding

debug-threads=on

to the --name option.

Note that the initial thread still has the default name (or the value passed as the process= parameter to --name).

The naming of the individual threads is not meant to form an API; tools shall not rely on the names.

The first patch converts --name to use QemuOpts, a side effect of this is that
--name process=foo,bar
no longer allows a process name of 'foo,bar', since ',' is a separator.

With this enabled in gdb we see:

(gdb) info threads

  Id   Target Id         Frame 
  5    Thread 0x7fb6670f9700 (LWP 18243) "worker" 0x00007fb66b8fcec0 in sem_timedwait () from /lib64/libpthread.so.0
  4    Thread 0x7fb666515700 (LWP 18244) "CPU 0/KVM" 0x00007fb669ab0117 in ioctl () from /lib64/libc.so.6
  3    Thread 0x7fb665d14700 (LWP 18245) "CPU 1/KVM" 0x00007fb669ab0117 in ioctl () from /lib64/libc.so.6
  2    Thread 0x7fb5d7fff700 (LWP 18247) "vnc_worker" 0x00007fb66b8fad20 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
* 1    Thread 0x7fb66d451a00 (LWP 18242) "qemuprocess" 0x00007fb669aaeb4f in ppoll () from /lib64/libc.so.6

and it also shows up well in 'top' using the H and V options.

V1->V2 changes
Change the name to debug-threads and add more scary warnings to stop
anyone even thinking they should use the thread names as an API.

Number CPU threads

Dr. David Alan Gilbert (3):
Rework --name to use QemuOpts
Add 'debug-threads' suboption to --name
Add a 'name' parameter to qemu_thread_create

 cpus.c                          | 25 +++++++++++++----
 hw/block/dataplane/virtio-blk.c |  2 +-
 hw/usb/ccid-card-emulated.c     |  8 +++---
 include/qemu/thread.h           |  3 +-
 libcacard/vscclient.c           |  2 +-
 migration.c                     |  2 +-
 qemu-options.hx                 |  7 +++--
 thread-pool.c                   |  2 +-
 ui/vnc-jobs.c                   |  3 +-
 util/compatfd.c                 |  3 +-
 util/qemu-thread-posix.c        | 16 +++++++++--
 util/qemu-thread-win32.c        | 10 ++++++-
 vl.c                            | 61 ++++++++++++++++++++++++++++++++---------
 13 files changed, 110 insertions(+), 34 deletions(-)
Signature · 1 line
1.8.5.3