diff options
author | Frederic Weisbecker <frederic@kernel.org> | 2024-09-27 00:49:00 +0200 |
---|---|---|
committer | Frederic Weisbecker <frederic@kernel.org> | 2025-01-08 18:15:03 +0100 |
commit | 5eacb68a358503cb350eaf68599a0d6caef569ab (patch) | |
tree | 271c433062459a3f92454ce6407fe70e9d535c33 /scripts/generate_rust_analyzer.py | |
parent | 3a5446612a3f2579c751ddb77c5e16b9a0d47001 (diff) |
kthread: Make sure kthread hasn't started while binding it
Make sure the kthread is sleeping in the schedule_preempt_disabled()
call before calling its handler when kthread_bind[_mask]() is called
on it. This provides a sanity check verifying that the task is not
randomly blocked later at some point within its function handler, in
which case it could be just concurrently awaken, leaving the call to
do_set_cpus_allowed() without any effect until the next voluntary sleep.
Rely on the wake-up ordering to ensure that the newly introduced "started"
field returns the expected value:
TASK A TASK B
------ ------
READ kthread->started
wake_up_process(B)
rq_lock()
...
rq_unlock() // RELEASE
schedule()
rq_lock() // ACQUIRE
// schedule task B
rq_unlock()
WRITE kthread->started
Similarly, writing kthread->started before subsequent voluntary sleeps
will be visible after calling wait_task_inactive() in
__kthread_bind_mask(), reporting potential misuse of the API.
Upcoming patches will make further use of this facility.
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Diffstat (limited to 'scripts/generate_rust_analyzer.py')
0 files changed, 0 insertions, 0 deletions