Linux block layer
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Christoph Hellwig <hch@infradead.org>, Daeho Jeong <daeho43@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com,
	Daeho Jeong <daehojeong@google.com>,
	linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@kernel.org>, Len Brown <lenb@kernel.org>,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH v2] f2fs: quiesce background threads during system suspend using PM notifier
Date: Mon, 10 Aug 2026 09:34:33 -0700	[thread overview]
Message-ID: <ff74edb1-43c7-485f-ab78-ec13b500a0bb@acm.org> (raw)
In-Reply-To: <ann0OPPglToV_hjs@infradead.org>

On 8/10/26 8:54 AM, Christoph Hellwig wrote:
> On Thu, Aug 06, 2026 at 10:01:08AM -0700, Daeho Jeong wrote:
>> From: Daeho Jeong <daehojeong@google.com>
>>
>> During system suspend, a race condition can cause f2fs_gc and f2fs_discard
>> threads to call submit_bio() while the underlying block device (e.g., UFS)
>> is in Runtime PM suspend. Because Runtime PM worker threads are already
>> frozen during task freezing, the threads become trapped in
>> __bio_queue_enter() waiting on mq_freeze_wq, leading to a PM freezer
>> timeout.
> 
> That does sound like a general issue with our block device / threading
> handling.

Daeho's description above mixes up unrelated topics. A runtime suspended 
UFS device is resumed automatically by the block layer if necessary. The
issue Daeho is trying to solve is unrelated to runtime suspend according
to my understanding.

>> To prevent this deadlock, register a PM notifier to set SBI_IS_SUSPENDING
>> during PM_SUSPEND_PREPARE. Background GC and discard threads check this
>> flag and immediately stop issuing new bios, allowing them to enter a
>> freezable sleep state cleanly before process freezing begins.
>>
>> In addition, check freezing() as a fast path to stop issuing new I/O
>> when non-PM freezing (e.g. dm-snapshot or cgroup freezer) is requested.
> 
> .. which means that we really sould have all the relevant parties
> invited into figuring out whast is happening here, rather than
> band-aiding something that looks like a horrible hack inside a
> file system.
> 
> Unfortunately I see this a lot with f2fs.  Please reach out to all
> relevant maintainers for something that does not look strictly local
> to f2fs.

This information was shared earlier with Daeho 
(https://b.corp.google.com/issues/515470309#comment45): [ ... ]
Register a Freezable Kernel Thread (Recommended) [ ... ]
Why this works: During suspend, freezer stops freezable kernel threads 
before devices and block queues enter their PM suspend phases. When the 
queue freezes later, your thread is already safely sleeping in 
try_to_freeze() and will not attempt submit_bio(). [ ... ]

PS: I'm no longer subscribed to the f2fs-devel mailing list.

Bart.

  reply	other threads:[~2026-08-10 16:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260806170108.2100312-1-daeho43@gmail.com>
2026-08-10 15:54 ` [PATCH v2] f2fs: quiesce background threads during system suspend using PM notifier Christoph Hellwig
2026-08-10 16:34   ` Bart Van Assche [this message]
2026-08-10 16:53     ` Daeho Jeong

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=ff74edb1-43c7-485f-ab78-ec13b500a0bb@acm.org \
    --to=bvanassche@acm.org \
    --cc=daeho43@gmail.com \
    --cc=daehojeong@google.com \
    --cc=hch@infradead.org \
    --cc=kernel-team@android.com \
    --cc=lenb@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox