linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Samuel Wu <wusamuel@google.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@kernel.org>, Len Brown <lenb@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Danilo Krummrich <dakr@kernel.org>
Cc: Saravana Kannan <saravanak@google.com>,
	kernel-team@android.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] PM: Support aborting sleep during filesystem sync
Date: Sat, 18 Oct 2025 08:17:12 +0800	[thread overview]
Message-ID: <20251018001715.8621-1-hdanton@sina.com> (raw)
In-Reply-To: <20251017233907.2305303-1-wusamuel@google.com>

On Fri, 17 Oct 2025 23:39:06 +0000 Samuel Wu wrote:
> +/**
> + * pm_sleep_fs_sync - Trigger fs_sync with ability to abort
> + *
> + * Return 0 on successful file system sync, otherwise returns -EBUSY if file
> + * system sync was aborted.
> + */
> +int pm_sleep_fs_sync(void)
> +{
> +	bool need_pm_sleep_fs_sync_requeue;
> +	unsigned long flags;
> +
> +	do {
> +		spin_lock_irqsave(&pm_sleep_fs_sync_lock, flags);
> +		reinit_completion(&pm_sleep_fs_sync_complete);

Given difficulty following up here, can you specify why reinit is needed?
> +		/*
> +		 * Handle the case where a sleep immediately follows a previous
> +		 * sleep that was aborted during fs_sync. In this case, wait for
> +		 * the previous filesystem sync to finish. Then do another
> +		 * filesystem sync so any subsequent filesystem changes are
> +		 * synced before sleeping.
> +		 */
> +		if (pm_sleep_fs_sync_queued) {
> +			need_pm_sleep_fs_sync_requeue = true;
> +		} else {
> +			need_pm_sleep_fs_sync_requeue = false;
> +			pm_sleep_fs_sync_queued = true;
> +			schedule_work(&sync_filesystems);
> +		}
> +		spin_unlock_irqrestore(&pm_sleep_fs_sync_lock, flags);
> +
> +		/*
> +		 * Completion is triggered by fs_sync finishing or an abort sleep
> +		 * signal, whichever comes first
> +		 */
> +		wait_for_completion(&pm_sleep_fs_sync_complete);
> +		if (pm_wakeup_pending())
> +			return -EBUSY;
> +	} while (need_pm_sleep_fs_sync_requeue);
> +
> +	return 0;
> +}
> +

  reply	other threads:[~2025-10-18  0:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 23:39 [PATCH v5] PM: Support aborting sleep during filesystem sync Samuel Wu
2025-10-18  0:17 ` Hillf Danton [this message]
2025-10-21 20:13   ` Samuel Wu
2025-10-22  1:15     ` Hillf Danton
2025-10-22 18:41       ` Samuel Wu
2025-10-22 22:32         ` Hillf Danton
2025-10-29 19:03           ` Samuel Wu
2025-10-18 13:19 ` kernel test robot
2025-10-18 18:31 ` kernel test robot
2025-10-21 20:13   ` Samuel Wu
2025-10-23 19:43 ` Rafael J. Wysocki
2025-10-23 22:46   ` Saravana Kannan
2025-10-24  8:37     ` Rafael J. Wysocki
2025-10-29 13:23       ` Rafael J. Wysocki
2025-10-29 19:13         ` Samuel Wu
2025-10-29 20:35           ` Rafael J. Wysocki

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=20251018001715.8621-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@android.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=saravanak@google.com \
    --cc=wusamuel@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).