lkml.org 
[lkml]   [2021]   [Aug]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] semaphore: Add might_sleep() to down_*() family
From
Date
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

\
 
 \ /
  Last update: 2021-08-09 16:35    [W:0.078 / U:0.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site