On Thu 17-12-15 12:00:04, Andrew Morton wrote:
> On Thu, 17 Dec 2015 11:55:11 -0800 Linus Torvalds 
> <torva...@linux-foundation.org> wrote:
> 
> > On Thu, Dec 17, 2015 at 5:02 AM, Michal Hocko <mho...@kernel.org> wrote:
> > > Ups. You are right. I will go with msleep_interruptible(100).
> > 
> > I don't think that's right.
> > 
> > If a signal happens, that loop is now (again) just busy-looping.
> 
> It's called only by a kernel thread so no signal_pending().

Yes that was the thinking.

> This relationship is a bit unobvious and fragile, but we do it in
> quite a few places.

I guess Linus is right and __set_task_state(current, TASK_IDLE) would be
better and easier to read.
---
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 4b0a5d8b92e1..eed99506b891 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -472,8 +472,10 @@ static void oom_reap_vmas(struct mm_struct *mm)
        int attempts = 0;
 
        /* Retry the down_read_trylock(mmap_sem) a few times */
-       while (attempts++ < 10 && !__oom_reap_vmas(mm))
-               msleep_interruptible(100);
+       while (attempts++ < 10 && !__oom_reap_vmas(mm)) {
+               __set_task_state(current, TASK_IDLE);
+               schedule_timeout(HZ/10);
+       }
 
        /* Drop a reference taken by wake_oom_reaper */
        mmdrop(mm);
-- 
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to