Re: [PATCH 4/9] KVM: selftests: Drop unreachable, dead code from hardware disable test

[email protected]
Newsgroups dev.linux.lists.kvmarm,org.kernel.vger.kvm
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Replacing a blocking `pthread_join` with an infinite busy-wait loop (`while (1);`) in the child process unnecessarily burns CPU and causes scheduler contention with the parent process.
--

--- Patch [4]: [PATCH 4/9] KVM: selftests: Drop unreachable, dead code from hardware disable test ---
commit 80b1aa13e14f4a3f65225bf79adc03a7a8eda318
Author: Sean Christopherson <[email protected]>

KVM: selftests: Drop unreachable, dead code from hardware disable test

This commit removes unreachable code from the hardware disable test to reduce
noise and simplify the test logic. It refactors thread creation and replaces
a blocking wait with a busy loop in the child process.

> diff --git a/tools/testing/selftests/kvm/hardware_disable_test.c b/tools/testing/selftests/kvm/hardware_disable_test.c
> index 1bcbd13e99947..e08aef94382f3 100644
> --- a/tools/testing/selftests/kvm/hardware_disable_test.c
> +++ b/tools/testing/selftests/kvm/hardware_disable_test.c

[ ... ]

> @@ -96,21 +84,19 @@ static void run_test(u32 run)
[ ... ]
>  	pr_debug("%s: [%d] all threads launched\n", __func__, run);
>  	sem_post(sem);
> -	for (i = 0; i < VCPU_NUM; ++i)
> -		check_join(threads[i], &b);
> -	/* Should not be reached */
> -	TEST_ASSERT(false, "%s: [%d] child escaped the ninja", __func__, run);
> +
> +	/* Wait for the parent to SIGKILL this child. */
> +	while (1);

[Severity: Medium]
Since the child and parent share the same CPU affinity, will this busy spin
loop cause unnecessary scheduler contention with the parent process when the
parent's timer fires?

Because the processes are pinned to a single CPU core, spinning in this loop
burns CPU cycles and forces the parent to contend with the spinning child for
CPU time.

Would it be better to use a blocking wait like pause() or sleep() here to
reduce scheduler latency and avoid 100% CPU utilization?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.