On Mon 2016-01-11 18:17:18, Jacob Pan wrote: > On Fri, 8 Jan 2016 17:49:31 +0100 > Petr Mladek <pmladek@xxxxxxxx> wrote: > > > Is the __preempt_schedule() a problem? It allows to switch the process > > when needed. I thought that it was safe because try_to_freeze() might > > have slept as well. > > > not a problem. i originally thought queue_kthread_work() may add > delay but it doesn't since there is no other work on this kthread. Great. > > > - vulnerable to future changes of queuing work > > > > The question is if it is safe to sleep, freeze, or even migrate > > the system between the works. It looks like because of the > > try_to_freeze() and schedule_interrupt() calls in the original code. > > > > BTW: I wonder if the original code correctly handle freezing after > > the schedule_timeout(). It does not call try_to_freeze() > > there and the forced idle states might block freezing. > > I think that the small overhead of kthread works is worth > > solving such bugs. It makes it easier to maintain these > > sleeping states. > it is in a while loop, so try_to_freeze() gets called. Am I missing > something? But it might take some time until try_to_freeze() is called. If I get it correctly. try_to_freeze_tasks() wakes freezable tasks to get them into the fridge. If clamp_thread() is waken from that schedule_timeout_interruptible(), it still might inject the idle state before calling try_to_freeze(). It means that freezer needs to wait "quite" some time until the kthread ends up in the fridge. Hmm, even my conversion does not solve this entirely. We might need to call freezing(current) in the while (time_before(jiffies, target_jiffies)) { cycle. And break injecting the idle state when freezing is requested. Or do I miss something, please? Best Regards, Petr Best Regards, Petr -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>