[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250730014708.1516-6-daijunbing@vivo.com>
Date: Wed, 30 Jul 2025 09:47:06 +0800
From: Dai Junbing <daijunbing@...o.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>,
Miklos Szeredi <miklos@...redi.hu>,
"Theodore Ts'o" <tytso@....edu>,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-ext4@...r.kernel.org
Cc: opensource.kernel@...o.com,
Dai Junbing <daijunbing@...o.com>
Subject: [PATCH v1 5/5] jbd2: Add TASK_FREEZABLE to kjournald2 thread
Set the TASK_FREEZABLE flag when the kjournald2 kernel thread sleeps
during journal commit operations. This prevents premature wakeups
during system suspend/resume cycles, avoiding unnecessary CPU wakeups
and power consumption.
in this case, the original code:
prepare_to_wait(&journal->j_wait_commit, &wait,
TASK_INTERRUPTIBLE);
if (journal->j_commit_sequence != journal->j_commit_request)
should_sleep = 0;
transaction = journal->j_running_transaction;
if (transaction && time_after_eq(jiffies, transaction->t_expires))
should_sleep = 0;
......
......
if (should_sleep) {
write_unlock(&journal->j_state_lock);
schedule();
write_lock(&journal->j_state_lock);
}
is functionally equivalent to the more concise:
write_unlock(&journal->j_state_lock);
wait_event_freezable_exclusive(&journal->j_wait_commit,
journal->j_commit_sequence == journal->j_commit_request ||
(journal->j_running_transaction &&
time_after_eq(jiffies, transaction->t_expires)) ||
(journal->j_flags & JBD2_UNMOUNT));
write_lock(&journal->j_state_lock);
Signed-off-by: Dai Junbing <daijunbing@...o.com>
---
fs/jbd2/journal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index d480b94117cd..9a1def9f730b 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -222,7 +222,7 @@ static int kjournald2(void *arg)
DEFINE_WAIT(wait);
prepare_to_wait(&journal->j_wait_commit, &wait,
- TASK_INTERRUPTIBLE);
+ TASK_INTERRUPTIBLE | TASK_FREEZABLE);
transaction = journal->j_running_transaction;
if (transaction == NULL ||
time_before(jiffies, transaction->t_expires)) {
--
2.25.1
Powered by blists - more mailing lists