Linux Power Management development
 help / color / mirror / Atom feed
* Long running ioctl and pm, which should have higher priority?
@ 2025-10-16 21:31 Qu Wenruo
  2025-10-17 10:39 ` Askar Safin
  0 siblings, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2025-10-16 21:31 UTC (permalink / raw)
  To: linux-pm, linux-btrfs, linux-fsdevel@vger.kernel.org

Hi,

Recently I'm dealing with a bug that long running btrfs ioctls (e.g. 
scrub, dev-replace, relocation etc) can block pm suspension/hibernation.

The reason is not that hard to understand, pm requires all user 
processes to be frozen, which requires them to return to the user space, 
thus long running ioctl will break that requirement and leads to timeout.

I have submitted a fix to btrfs so that when it detects the fs or the 
process is being frozen, cancel the ioctl so pm can continue.
(https://lore.kernel.org/linux-btrfs/cover.1760588662.git.wqu@suse.com/T/#t)

But there is a question concerning me, which should have the higher 
priority? The long running ioctl or pm?


A) Long running ioctl has the priority

If the ioctl should have higher priority, the current code is fine, but 
the problem is pm will freeze all other processes (e.g. hang the GUI) 
while waiting for the long running ioctl until time out.

This can be a very frustrating behavior, thus I'm wondering if we go 
this path, is there any interface to show something like, DO NOT 
SUSPEND/HIBERNATE, and immediately let the pm to abort any 
suspension/hibernation attempt without extra timeout?


B) PM has the priority

That's what my patchset did, but the problem is a lot of jobs can not be 
ensured to finish.
If a long running ioctl is interrupted, user may need manual 
intervention to restart the process.

In some cases, the interrupted ioctl is fine to resume, like balance, 
and previously relocated blocks are already written to disk, and re-run 
the operation will start from what's left.

But some operations are not, like scrub which doesn't have any on-disk 
record on the process. It's completely on the ioctl caller to do the 
extra resume.

Furthermore the interruption may be indistinguishable between pm and 
real user signals (SIGINT etc).
If we resume immediately after pm thaw, it may mean intentionally 
interrupted operation will also be resumed.


Any feedback will be appreciated, especially from PM side.

Thanks,
Qu

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-17 20:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 21:31 Long running ioctl and pm, which should have higher priority? Qu Wenruo
2025-10-17 10:39 ` Askar Safin
2025-10-17 10:43   ` Qu Wenruo
2025-10-17 10:46     ` Andrei Borzenkov
2025-10-17 20:51       ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox