On 8/8/21 11:51 PM, Xiaoming Ni wrote:If the code enters down_common(), it is not "might" sleep but "will" sleep, and an alarm is printed in __schedule_bug() later.
On 2021/8/9 11:01, Waiman Long wrote:
I think it is simpler to just put a "might_sleep()" in __down_common() which is the function where sleep can actually happen.
If the actual atomic context hibernation occurs, the corresponding alarm log is generated in __schedule_bug().
__schedule()
--> schedule_debug()
--> __schedule_bug()
However, "might_sleep()" indicates the possibility of sleep, so that code writers can identify and fix the problem as soon as possible, but does not trigger atomic context sleep.
Is it better to put "might_sleep()" in each down API entry than __down_common() to help identify potential code problems?
Putting "might_sleep()" in each down_*() functions mean that whenever we add a new API function, we have to remember to add "might_sleep()". If
we put it in down_common(), it will work for any newly added API function in the future even though I doubt we will add any.