Re: [Patch v4 1/2] freezer: check OOM kill while being frozen

From: Rafael J. Wysocki
Date: Thu Sep 11 2014 - 09:58:33 EST


On Thursday, September 11, 2014 03:08:40 PM Michal Hocko wrote:
> On Wed 10-09-14 15:24:17, Michal Hocko wrote:
> > On Tue 09-09-14 22:53:32, Rafael J. Wysocki wrote:
> > > On Wednesday, September 10, 2014 01:46:58 AM Tejun Heo wrote:
> > > > Hello,
> > > >
> > > > On Tue, Sep 09, 2014 at 06:06:25PM +0200, Michal Hocko wrote:
> > > > > > Even for userland tasks, try_to_freeze() can currently be anywhere in
> > > > > > the kernel. The frequently used ones are few but there are some odd
> > > > >
> > > > > I always thought that user space tasks can be in the fridge only on the
> > > > > way out from the kernel (get_signal_to_deliver). I have quickly greped
> > > >
> > > > It *can* be anywhere. We used to have some deep in nfs. They got
> > > > removed later due to deadlocks but in theory they still can be
> > > > anywhere.
> > >
> > > Well, it would be good to determine the difference between theory and practice
> > > in this particular respect, because if in practice it can't be anywhere,
> > > we can just set an "every new instance of try_to_freeze() has to be documented"
> > > rule (which may not be a bad idea anyway) and disallow people to break things.
> >
> > What do you think about this way to help distinguish kernel threads and
> > user processes and keep the future maintenance of freezer saner?
>
> This is not enough. I have completely missed freezer_count... Will have
> to think about this. There is quite large base of callers of this... It
> won't be trivial to check whether all of them are safe. Especially after
> 467de1fc67d1b which made the functionality usable for !user tasks as
> well. Btw. is this even desirable? The follow up patch (33e638b9070b)
> have (ab)used freezer_{do_not_}count just to be reverted later by
> 72081624d5ad3. I haven't checked other kernel thread users which might be
> added later. Don't rather put try_to_freeze_user_task into freezer_count
> to reflect the original intention (assuming that a separate API for user
> and kthread is desirable of course).

Well, to me the only difference is that user space is frozen "automatically"
while kernel threads need to flag themselves as "freezable" and then call
try_to_freeze() directly somewhere. Whether or not that difference is big
enough for a separate API is a good question and I'm not sure if they can be
entirely separate anyway.

And I'm still wondering if the OOM killer may be made avoid killing frozen
tasks.

Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/