All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Jiri Kosina <jikos@kernel.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Pavel Machek <pavel@ucw.cz>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Dave Chinner <david@fromorbit.com>, Jan Kara <jack@suse.cz>,
	Christoph Hellwig <hch@lst.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>, Tejun Heo <tj@kernel.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH 0/3] PM, vfs: use filesystem freezing instead of kthread freezer
Date: Sat, 31 Oct 2015 04:15:25 +0100	[thread overview]
Message-ID: <6015070.Gclh0s3EvS@vostro.rjw.lan> (raw)
In-Reply-To: <alpine.LNX.2.00.1510302204280.17538@pobox.suse.cz>

On Friday, October 30, 2015 10:17:54 PM Jiri Kosina wrote:
> On Fri, 30 Oct 2015, Alan Stern wrote:
> 
> > > > > I would say instead "no I/O is allowed from now on".  Maybe that's an 
> > > > > overstatement, but I think it comes closer to the truth.
> > > 
> > > But that's what PM callbacks are for.

Not really.  In fact, PM callbacks may not be suitable for some use cases even
in theory (that's if you want something to stop running before any PM callbacks
are executed during suspend).

> > Why are PM callbacks any more suitable than the freezer?  
> 
> Once the PM callback triggers, you know that you are really actually 
> undergoing suspend and have to do whatever is necessary.
> 
> OTOH, try_to_freeze() is a kind of "are we there yet?" polling, and the 
> whole state needs to be prepared pro-actively for suspend already when you 
> call it, each and every time, even if you are not going through suspend at 
> all.
> 
> That's sub-optimal, and very easy to get wrong over gradual code changes.
> 
> > The most natural implementation would be for the callback routine to set 
> > a flag; at various strategic points the kthread would check the flag and 
> > if it was set, call a routine that sits around and waits for the suspend 
> > to be over.  
> 
> Could you name at least some existing kthreads that would actually *need* 
> such complex handling, instead of just waiting in schedule() until 
> suspend-resume cycle is over, given that PM callbacks do all the necessary 
> cleanup (putting HW to sleep, cancelling timers, etc) anyway?
> 
> PM callback can always explicitly do kthread_stop() on a particular 
> kthread if really necessary.

Runtime PM uses a freezable workqueue, allocated in pm_start_workqueue().

That's because we don't want async runtime PM to happen during system
suspend/resume and for good reasons, so if you want to remove the freezing
mechanism, you need to stop that workqueue at the beginning of dpm_prepare
and start it again at the end of dpm_complete().

> > Also, you never replied to my question about suspend vs. hibernation.
> 
> The main point of freezer is to reach quiescent state wrt. filesystems 
> (metadata in memory need to be absolutely in sync with what's on disk). 
> That's no different between hibernation and s2ram, is it?
> 
> BTW, a quite some of this has been already "pre-discussed" in 
> Documentation/power/freezing-of-tasks.txt (which has BTW been written 
> before we've had the possibility to freeze filesystems, and this fact is 
> even point there out).

That is somewhat outdated in my view.  At least my list of reasons for using
the freezer is now somewhat different from the one given in that file.

In any case, there may be legitimate reasons for kernel threads to be
freezable, so you need to be careful about the wholesale removal of that
feature.

The above is the only one I can recall ATM, but that doesn't mean there
aren't any other.

Thanks,
Rafael


  reply	other threads:[~2015-10-31  2:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 13:47 [PATCH 0/3] PM, vfs: use filesystem freezing instead of kthread freezer Jiri Kosina
2015-10-30 13:47 ` [PATCH 1/3] power, vfs: move away from PF_KTHREAD freezing in favor of fs freezing Jiri Kosina
2015-10-30 14:04   ` kbuild test robot
2015-10-31  8:55   ` Oliver Neukum
2015-11-02  3:01     ` Neil Brown
2015-11-02  7:54   ` yalin wang
2015-11-02 11:05     ` Jiri Kosina
2015-10-30 13:47 ` [PATCH 2/3] freezer: get rid of the kthread freezer Jiri Kosina
2015-10-30 14:08   ` kbuild test robot
2015-10-30 14:12   ` kbuild test robot
2015-10-30 13:48 ` [PATCH 3/3] freezer: warn if anyone is trying to use freezer on kthreads Jiri Kosina
2015-10-30 15:29 ` [PATCH 0/3] PM, vfs: use filesystem freezing instead of kthread freezer Alan Stern
2015-10-30 15:29   ` Alan Stern
2015-10-30 17:44   ` Pavel Machek
2015-10-30 19:40     ` Jiri Kosina
2015-10-30 20:41       ` Alan Stern
2015-10-30 20:41         ` Alan Stern
2015-10-30 21:17         ` Jiri Kosina
2015-10-31  3:15           ` Rafael J. Wysocki [this message]
2015-10-31  8:19             ` Jiri Kosina
2015-11-02  2:43               ` Rafael J. Wysocki
2015-11-02 10:45                 ` Jiri Kosina
2015-11-02 11:00                   ` Oliver Neukum
2015-11-02 15:18                   ` Alan Stern
2015-11-02 15:18                     ` Alan Stern
2015-11-03  0:10                 ` Dave Chinner
2015-11-03  4:06                   ` Rafael J. Wysocki
2015-11-03  9:31                   ` Jan Kara
2015-11-03 21:33                     ` Rafael J. Wysocki
2015-10-31 16:01             ` Alan Stern
2015-10-31 16:01               ` Alan Stern
2015-10-31 15:56           ` Alan Stern
2015-10-31 15:56             ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6015070.Gclh0s3EvS@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=david@fromorbit.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=jikos@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael.j.wysocki@intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.