Re: [RFC][PATCH v2 00/31] timers: Use del_timer_shutdown() before freeing timers

From: Guenter Roeck
Date: Thu Oct 27 2022 - 20:54:52 EST


On 10/27/22 16:55, Steven Rostedt wrote:
On Thu, 27 Oct 2022 16:24:42 -0700
Guenter Roeck <linux@xxxxxxxxxxxx> wrote:

This is probably just missing a switch to shutdown.
Wild shot, and I don't really know what I am doing,
but I'll try

iff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e71b3b43927c..6c1cb4a219f0 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -767,6 +767,8 @@ static void blk_release_queue(struct kobject *kobj)

might_sleep();

+ del_timer_shutdown(&q->timeout);
+
percpu_ref_exit(&q->q_usage_counter);

if (q->poll_stat)

Or perhaps this:


I think you are correct. Let me give it a try.

-- Steve

diff --git a/block/blk-core.c b/block/blk-core.c
index 17667159482e..69b1daa2e91a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -227,7 +227,7 @@ const char *blk_status_to_str(blk_status_t status)
*/
void blk_sync_queue(struct request_queue *q)
{
- del_timer_sync(&q->timeout);
+ del_timer_shutdown(&q->timeout);
cancel_work_sync(&q->timeout_work);
}
EXPORT_SYMBOL(blk_sync_queue);
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e71b3b43927c..12a1e46536ed 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -769,6 +769,8 @@ static void blk_release_queue(struct kobject *kobj)
percpu_ref_exit(&q->q_usage_counter);
+ blk_sync_queue(q);
+
This might not even be needed. I'll try without it first.

Thanks,
Guenter

if (q->poll_stat)
blk_stat_remove_callback(q, q->poll_cb);
blk_stat_free_callback(q->poll_cb);