Messages in this thread | | | Subject | Re: [PATCH] semaphore: Add might_sleep() to down_*() family | From | Xiaoming Ni <> | Date | Mon, 9 Aug 2021 22:33:18 +0800 |
| |
On 2021/8/9 20:52, Waiman Long wrote: > On 8/8/21 11:51 PM, Xiaoming Ni wrote: >> 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. > If the code enters down_common(), it is not "might" sleep but "will" sleep, and an alarm is printed in __schedule_bug() later.
"might_sleep()" is used to check potential problems, and "_schedule_bug()" is used to check actual faults.
So, I still think we should add "might_sleep()" to each down_*() function to alert code owner to potential problems early.
Thanks Xiaoming Ni
| |