From: Kevin Hao <haokexin@gmail.com>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: gfs2@lists.linux.dev, "Rafael J. Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@ucw.cz>
Subject: [PATCH 2/2] gfs2: Use wait_event_freezable_timeout() for freezable kthread
Date: Mon, 18 Dec 2023 13:35:58 +0800 [thread overview]
Message-ID: <20231218053558.1200822-2-haokexin@gmail.com> (raw)
In-Reply-To: <20231218053558.1200822-1-haokexin@gmail.com>
A freezable kernel thread can enter frozen state during freezing by
either calling try_to_freeze() or using wait_event_freezable() and its
variants. So for the following snippet of code in a kernel thread loop:
try_to_freeze();
wait_event_interruptible_timeout();
We can change it to a simple wait_event_freezable_timeout() and then
eliminate a function call.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
fs/gfs2/log.c | 4 +---
fs/gfs2/quota.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index a268b69bb636..20059fc913e7 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -1331,9 +1331,7 @@ int gfs2_logd(void *data)
t = gfs2_tune_get(sdp, gt_logd_secs) * HZ;
- try_to_freeze();
-
- t = wait_event_interruptible_timeout(sdp->sd_logd_waitq,
+ t = wait_event_freezable_timeout(sdp->sd_logd_waitq,
test_bit(SDF_FORCE_AIL_FLUSH, &sdp->sd_flags) ||
gfs2_ail_flush_reqd(sdp) ||
gfs2_jrnl_flush_reqd(sdp) ||
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 173581736a6e..05ef8409b614 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -1603,11 +1603,9 @@ int gfs2_quotad(void *data)
quotad_check_timeo(sdp, "sync", gfs2_quota_sync, t,
"ad_timeo, &tune->gt_quota_quantum);
- try_to_freeze();
-
t = min(quotad_timeo, statfs_timeo);
- t = wait_event_interruptible_timeout(sdp->sd_quota_wait,
+ t = wait_event_freezable_timeout(sdp->sd_quota_wait,
sdp->sd_statfs_force_sync ||
gfs2_withdrawn(sdp) ||
kthread_should_stop(),
--
2.39.2
next prev parent reply other threads:[~2023-12-18 5:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-18 5:35 [PATCH 1/2] gfs2: Add missing set_freezable() for freezable kthread Kevin Hao
2023-12-18 5:35 ` Kevin Hao [this message]
2023-12-21 14:11 ` [PATCH 2/2] gfs2: Use wait_event_freezable_timeout() " Andreas Gruenbacher
2023-12-21 14:10 ` [PATCH 1/2] gfs2: Add missing set_freezable() " Andreas Gruenbacher
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=20231218053558.1200822-2-haokexin@gmail.com \
--to=haokexin@gmail.com \
--cc=agruenba@redhat.com \
--cc=gfs2@lists.linux.dev \
--cc=pavel@ucw.cz \
--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