timers: Fix usleep_range() in the context of wake_up_process
Reference:
("timers: Fix usleep_range() in the context of wake_up_process()")
in https://lore.kernel.org/patchwork/patch/729295/
Author: Douglas Anderson <dianders@chromium.org>
Users of usleep_range() expect that it will _never_ return in less time
than the minimum passed parameter. However, nothing in the code ensures
this, when the sleeping task is woken by wake_up_process() or any other
mechanism which can wake a task from uninterruptible state.
Neither usleep_range() nor schedule_hrtimeout_range*() have any
protection against wakeups. schedule_hrtimeout_range*() is designed this
way despite the fact that the API documentation does not mention it.
msleep() already has code to handle this case since it will loop as long
as there was still time left. usleep_range() has no such loop, add it.
Presumably this problem was not detected before because usleep_range()
is only used in a few places and the function is mostly used in contexts
which are not exposed to wakeups of any form.
An effort was made to look for users relying on the old behavior by
looking for usleep_range() in the same file as wake_up_process().
No problems were found by this search, though it is conceivable that
someone could have put the sleep and wakeup in two different files.
An effort was made to ask several upstream maintainers if they were
aware of people relying on wake_up_process() to wake up usleep_range().
No maintainers were aware of that but they were aware of many people
relying on usleep_range() never returning before the minimum.
MTK-Commit-Id: 0aba3a81b9df0ade76d8e409af30fc936132055d
Change-Id: Icee6dcbbebf6ca032d7b56f8937edf3e6babd73e
Signed-off-by:
Freddy Hsin <freddy.hsin@mediatek.com>
CR-Id: ALPS05259796
Feature: [Module]Timer
Loading
Please register or sign in to comment