From: "Michal Koutný" <mkoutny@suse.com>
To: Waiman Long <longman@redhat.com>
Cc: Ridong Chen <ridong.chen@linux.dev>, Tejun Heo <tj@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Shuah Khan <shuah@kernel.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH-cgroup/for-7.3] selftests/cgroup: Fix minor defects in test_cpuset
Date: Mon, 20 Jul 2026 17:01:26 +0200 [thread overview]
Message-ID: <al4tyJ2lRMj32Wpn@localhost.localdomain> (raw)
In-Reply-To: <20260717191814.989215-1-longman@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1879 bytes --]
On Fri, Jul 17, 2026 at 03:18:14PM -0400, Waiman Long <longman@redhat.com> wrote:
> With commit 98149f542530 ("selftests/cgroup: Add test for cpuset affinity
> on controller disable"), sashiko [1] had report 3 different issues with
> the new test_cpuset_affinity_on_controller_disable() test.
>
> 1) `cpu_set_equal` iterates over mask bytes instead of bits, ignoring
> CPUs >= 8.
Inline comment
> 2) Thread synchronization logic allows the main thread to read
> uninitialized stack memory, causing test flakiness.
Hm, I cannot see it (alhtough I don't see it through), what was the
stack memory?
(test_phase is static, then re-initalized)
> 3) Test fails instead of skipping gracefully on uniprocessor systems
> or when CPU 1 is unavailable.
Interesting catch.
>
> Fix the reported issues by:
> 1) Iterates over the bit size of the mask.
> 2) Test the new ready flag for each thread to end the wait
> on the condoitional variable and eliminate the now unneeded
> AFFINITY_THREAD_A_READY and AFFINITY_THREADS_READY test phases.
But the symmetric synchronization with counter is easier to reason
about.
> 3) Return KSFT_SKIP on "cpuset.cpus" setting failure.
It'd be better to have same style with test_cpuset_prs.sh, i.e. a guard
at the beginning requesting a minimal number of CPUs. Next time...
> @@ -251,7 +251,7 @@ static int cpu_set_equal(cpu_set_t *dst, unsigned long mask)
> CPU_ZERO(&expected);
> assert(sizeof(mask) < CPU_SETSIZE);
>
> - for (int cpu = 0; cpu < sizeof(mask); ++cpu)
> + for (int cpu = 0; cpu < sizeof(mask) * 8; ++cpu)
> if ((1UL << cpu) & mask)
> CPU_SET(cpu, &expected);
Oh, that was my braino in how masks are stored.
Thanks for correcting me!
It should also extend the assert accordingly:
assert(sizeof(mask) * 8 < CPU_SETSIZE);
Michal
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]
next prev parent reply other threads:[~2026-07-20 15:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 19:18 [PATCH-cgroup/for-7.3] selftests/cgroup: Fix minor defects in test_cpuset Waiman Long
2026-07-17 22:32 ` Tejun Heo
2026-07-17 22:53 ` Waiman Long
2026-07-20 15:01 ` Michal Koutný [this message]
2026-07-20 15:40 ` Waiman Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=al4tyJ2lRMj32Wpn@localhost.localdomain \
--to=mkoutny@suse.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=longman@redhat.com \
--cc=ridong.chen@linux.dev \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.