[PATCH] dm log-writes: Add missing set_freezable() for freezable kthread

Haotian Zhang posted 1 patch 2 months, 1 week ago
drivers/md/dm-log-writes.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] dm log-writes: Add missing set_freezable() for freezable kthread
Posted by Haotian Zhang 2 months, 1 week ago
The log_writes_kthread() calls try_to_freeze() but lacks set_freezable(),
rendering the freeze attempt ineffective since kernel threads are
non-freezable by default. This prevents proper thread suspension during
system suspend/hibernate.

Add set_freezable() to explicitly mark the thread as freezable.

Fixes: 0e9cebe72459 ("dm: add log writes target")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/md/dm-log-writes.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
index 679b07dee229..1f8fbc27a12f 100644
--- a/drivers/md/dm-log-writes.c
+++ b/drivers/md/dm-log-writes.c
@@ -432,6 +432,7 @@ static int log_writes_kthread(void *arg)
 	struct log_writes_c *lc = arg;
 	sector_t sector = 0;
 
+	set_freezable();
 	while (!kthread_should_stop()) {
 		bool super = false;
 		bool logging_enabled;
-- 
2.50.1.windows.1
Re: [PATCH] dm log-writes: Add missing set_freezable() for freezable kthread
Posted by Benjamin Marzinski 2 months, 1 week ago
On Mon, Dec 01, 2025 at 03:41:03PM +0800, Haotian Zhang wrote:
> The log_writes_kthread() calls try_to_freeze() but lacks set_freezable(),
> rendering the freeze attempt ineffective since kernel threads are
> non-freezable by default. This prevents proper thread suspension during
> system suspend/hibernate.
> 
> Add set_freezable() to explicitly mark the thread as freezable.
> 

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>

> Fixes: 0e9cebe72459 ("dm: add log writes target")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
>  drivers/md/dm-log-writes.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
> index 679b07dee229..1f8fbc27a12f 100644
> --- a/drivers/md/dm-log-writes.c
> +++ b/drivers/md/dm-log-writes.c
> @@ -432,6 +432,7 @@ static int log_writes_kthread(void *arg)
>  	struct log_writes_c *lc = arg;
>  	sector_t sector = 0;
>  
> +	set_freezable();
>  	while (!kthread_should_stop()) {
>  		bool super = false;
>  		bool logging_enabled;
> -- 
> 2.50.1.windows.1
>