workqueue: Fix hung time report of worker pools
[platform/kernel/linux-starfive.git] / kernel / workqueue.c
index 8e21c35..4dd494f 100644 (file)
@@ -4850,10 +4850,16 @@ static void show_one_worker_pool(struct worker_pool *pool)
        struct worker *worker;
        bool first = true;
        unsigned long flags;
+       unsigned long hung = 0;
 
        raw_spin_lock_irqsave(&pool->lock, flags);
        if (pool->nr_workers == pool->nr_idle)
                goto next_pool;
+
+       /* How long the first pending work is waiting for a worker. */
+       if (!list_empty(&pool->worklist))
+               hung = jiffies_to_msecs(jiffies - pool->watchdog_ts) / 1000;
+
        /*
         * Defer printing to avoid deadlocks in console drivers that
         * queue work while holding locks also taken in their write
@@ -4862,9 +4868,7 @@ static void show_one_worker_pool(struct worker_pool *pool)
        printk_deferred_enter();
        pr_info("pool %d:", pool->id);
        pr_cont_pool_info(pool);
-       pr_cont(" hung=%us workers=%d",
-               jiffies_to_msecs(jiffies - pool->watchdog_ts) / 1000,
-               pool->nr_workers);
+       pr_cont(" hung=%lus workers=%d", hung, pool->nr_workers);
        if (pool->manager)
                pr_cont(" manager: %d",
                        task_pid_nr(pool->manager->task));