[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251018001715.8621-1-hdanton@sina.com>
Date: Sat, 18 Oct 2025 08:17:12 +0800
From: Hillf Danton <hdanton@...a.com>
To: Samuel Wu <wusamuel@...gle.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Pavel Machek <pavel@...nel.org>,
Len Brown <lenb@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Danilo Krummrich <dakr@...nel.org>
Cc: Saravana Kannan <saravanak@...gle.com>,
kernel-team@...roid.com,
linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5] PM: Support aborting sleep during filesystem sync
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;
> +}
> +
Powered by blists - more mailing lists