mirror of
https://github.com/torvalds/linux.git
synced 2026-10-22 23:01:49 +02:00
sched/wait: Avoid modifying entry on failed priority registration
add_wait_queue_priority_exclusive() sets WQ_FLAG_EXCLUSIVE and WQ_FLAG_PRIORITY before checking whether another priority waiter is already present. Thus, when registration fails with -EBUSY, the entry is left unqueued but with modified flags. There is no need to modify the entry before the failure check. Move the flag update after the check so that a rejected registration does not unnecessarily alter the entry. Signed-off-by: Hui Su <sh_def@163.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Sean Christopherson <seanjc@google.com> Link: https://patch.msgid.link/20261011015019.4056529-1-sh_def@163.com
This commit is contained in:
parent
cc459ecd93
commit
159b172906
|
|
@ -54,14 +54,13 @@ int add_wait_queue_priority_exclusive(struct wait_queue_head *wq_head,
|
|||
{
|
||||
struct list_head *head = &wq_head->head;
|
||||
|
||||
wq_entry->flags |= WQ_FLAG_EXCLUSIVE | WQ_FLAG_PRIORITY;
|
||||
|
||||
guard(spinlock_irqsave)(&wq_head->lock);
|
||||
|
||||
if (!list_empty(head) &&
|
||||
(list_first_entry(head, typeof(*wq_entry), entry)->flags & WQ_FLAG_PRIORITY))
|
||||
return -EBUSY;
|
||||
|
||||
wq_entry->flags |= WQ_FLAG_EXCLUSIVE | WQ_FLAG_PRIORITY;
|
||||
list_add(&wq_entry->entry, head);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user