Re: [PATCH-cgroup 2/2] cgroup/cpuset: Include isolated cpuset CPUs in cpu_is_isolated() check
From: Waiman Long
Date: Tue Nov 28 2023 - 13:33:15 EST
On 11/28/23 11:56, Tejun Heo wrote:
Hello,
On Sun, Nov 26, 2023 at 11:19:56PM -0500, Waiman Long wrote:
+bool cpuset_cpu_is_isolated(int cpu)
+{
+ unsigned int seq;
+ bool ret;
+
+ do {
+ seq = read_seqcount_begin(&isolcpus_seq);
+ ret = cpumask_test_cpu(cpu, isolated_cpus);
+ } while (read_seqcount_retry(&isolcpus_seq, seq));
+ return ret;
+}
+EXPORT_SYMBOL_GPL(cpuset_cpu_is_isolated);
We're testing a bit in a bitmask. I don't think we need to worry about value
integrity from RMW updates being broken up. ie. We can just test the bit
without seqlock and drop the first patch?
My concern is that if we have an isolated partition with a set of
isolated CPUs (say 2-4), I don't want any addition, deletion of changes
made to another isolated partition affects the test of the pre-existing
one. Testing result of the partition being change is fair game.
Depending on how the cpumask operators are implemented, we may not have
a guarantee that testing CPU 2, for instance, will always return true.
That is why I am adding some synchronization primitive to prevent
racing. My original plan was to take the callback_lock. However, that
can be somewhat costly if this API is used rather frequently, especially
on systems with large # of CPUs. So I change it to use seqcount for read
protection which has a much lower cost.
Regarding patch 1 on converting callback_lock to raw_spinlock_t, I can
drop it if you have concern about that change. I just need to surround
the write_seqcount_begin()/write_seqcount_end() calls with
preempt_disabled()/preempt_enabled().
Cheers,
Longman