Re: [PATCH] libata, freezer: avoid block device removal while systemis frozen

From: Tejun Heo
Date: Wed Dec 18 2013 - 16:39:50 EST


Hello, Rafael.

On Wed, Dec 18, 2013 at 10:48:31PM +0100, Rafael J. Wysocki wrote:
> > I see. In the long term, I think the right thing to do is making the
> > freezer interface more specific so that only the ones which actually
> > need it do so explicitly. Right now, kernel freezables are
> > conceptually at a very high level - it's a global task attribute and a
> > major knob in workqueue. I suppose most of that is historical but by
> > perpetuating the model we're encouraging misuse of freezer in large
> > swaths of the kernel. Even in this specific case, both writeback and
> > jbd workers have no fundamental reason to be freezable and yet
> > they're, eventually developing into totally unnecessary deadlocks.
>
> You're right, but I'm not sure how we can make the interface for workqueues
> more specific, for example. I guess we can simply drop create_freezable_workqueue()
> so that whoever wants to create a freezable workqueue has to use the right
> combination of flags. Can we make it more specific than that?
>
> BTW, pm_start_workqueue(), which is a legitimate user, doesn't even use that macro. :-)

Yeah, we can just rip out the whole freezer support and let the
caller's pm notification hooks implement it by doing

workqueue_set_max_active(wq, 0);
flush_workqueue(wq);

when it needs to "freeze" the workqueue and then reverse it by doing
the following.

workqueue_set_max_active(wq, WQ_DFL_ACTIVE);

It'll be a bit more code in the specific users but given the
specificity of the usage I think that's the appropriate way to do it.
It'll drop quite a bit of complexity from the core freezer and
workqueue code paths too.

Thanks.

--
tejun
--
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/