selftests: ublk: set CPU affinity before thread initialization
authorMing Lei <ming.lei@redhat.com>
Sat, 1 Nov 2025 13:31:19 +0000 (21:31 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 3 Nov 2025 15:34:59 +0000 (08:34 -0700)
commit0123bb91f464487cc1bbdcc515757dc723496a39
treeebaf40998409543cd93719dce2113008093c7379
parentc28ba6b6c51d090103800eb1c7679c32f6501dbc
selftests: ublk: set CPU affinity before thread initialization

Move ublk_thread_set_sched_affinity() call before ublk_thread_init()
to ensure memory allocations during thread initialization occur on
the correct NUMA node. This leverages Linux's first-touch memory
policy for better NUMA locality.

Also convert ublk_thread_set_sched_affinity() to use
pthread_setaffinity_np() instead of sched_setaffinity(), as the
pthread API is the proper interface for setting thread affinity in
multithreaded programs.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
tools/testing/selftests/ublk/kublk.c