wqueue: workaound g_notifier_pending list unsafe

Situation:

thread1                             thread2
work_notifier_signal
enter_critical_section
dq_peek(&g_notifier_pending)
    dq_rem(&g_notifier_pending)
    work_queue()
      // switch -->                 work_notifier_teardown
                                    enter_critical_section
                                    dq_rem(&g_notifier_pending)
                                    leave_critical_section
                                    <--- switch back
    error occured
leave_critical_section

Workaound:
used sched_lock() to prevent the switch

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2024-09-02 23:49:29 +08:00 committed by Xiang Xiao
parent 1d5f43664d
commit f3ada4b666

View File

@ -344,6 +344,7 @@ void work_notifier_signal(enum work_evtype_e evtype,
*/
flags = enter_critical_section();
sched_lock();
/* Process the notification at the head of the pending list until the
* pending list is empty
@ -386,6 +387,7 @@ void work_notifier_signal(enum work_evtype_e evtype,
}
}
sched_unlock();
leave_critical_section(flags);
}