From: Tejun Heo <tj@kernel.org>
To: Petr Mladek <pmladek@suse.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
Michal Koutny <mkoutny@suse.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC 5/5] workqueue: Print backtraces from CPUs with hung CPU bound workqueues
Date: Thu, 2 Feb 2023 13:45:05 -1000 [thread overview]
Message-ID: <Y9xLAdc9ODyEO+RQ@slm.duckdns.org> (raw)
In-Reply-To: <20230201134543.13687-6-pmladek@suse.com>
Hello,
I generally really like it.
> +static bool show_pool_suspicious_workers(struct worker_pool *pool, bool shown_title)
Maybe the name can be a bit more specific? show_cpu_pool_hog()?
> +{
> + bool shown_any = false;
> + struct worker *worker;
> + unsigned long flags;
> + int bkt;
> +
> + raw_spin_lock_irqsave(&pool->lock, flags);
> +
> + if (pool->cpu < 0)
> + goto out;
This can be tested before grabbling the lock.
> + if (!per_cpu(wq_watchdog_hung_cpu, pool->cpu))
> + goto out;
Given that the state is per-pool, would it make sense to mark this on the
pool instead?
> + if (list_empty(&pool->worklist))
> + goto out;
This condition isn't really necessary, right?
> + hash_for_each(pool->busy_hash, bkt, worker, hentry) {
> + if (!task_is_running(worker->task))
> + continue;
> +
> + if (!shown_title) {
> + pr_info("Showing backtraces of running workers in stuck CPU-bound worker pools:\n");
> + shown_title = true;
> + }
> +
> + shown_any = true;
> + pr_info("pool %d:\n", pool->id);
> + sched_show_task(worker->task);
> + }
> +out:
> + raw_spin_unlock_irqrestore(&pool->lock, flags);
> + return shown_any;
> +}
> +
> +static void show_suspicious_workers(void)
> +{
> + struct worker_pool *pool;
> + bool shown_title = false;
> + int pi;
> +
> + rcu_read_lock();
> +
> + for_each_pool(pool, pi) {
> + bool shown;
> +
> + shown = show_pool_suspicious_workers(pool, shown_title);
> + if (shown)
> + shown_title = shown;
Maybe, move shown to the outer scope and:
shown |= show_pool_suspicious_workers(pool, show);
> + }
> +
> + rcu_read_unlock();
> +}
>
> static void wq_watchdog_reset_touched(void)
> {
Thanks.
--
tejun
next prev parent reply other threads:[~2023-02-02 23:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 13:45 [RFC 0/5] workqueue: Debugging improvements Petr Mladek
2023-02-01 13:45 ` [RFC 1/5] workqueue: Fix hung time report of worker pools Petr Mladek
2023-02-01 13:45 ` [RFC 2/5] workqueue: Warn when a new worker could not be created Petr Mladek
2023-02-02 23:30 ` Tejun Heo
2023-02-03 14:10 ` Petr Mladek
2023-02-03 19:29 ` Tejun Heo
2023-02-15 18:02 ` Michal Koutný
2023-02-16 9:43 ` Petr Mladek
2023-02-01 13:45 ` [RFC 3/5] workqueue: Interrupted create_worker() is not a repeated event Petr Mladek
2023-02-01 13:45 ` [RFC 4/5] workqueue: Warn when a rescuer could not be created Petr Mladek
2023-02-01 13:45 ` [RFC 5/5] workqueue: Print backtraces from CPUs with hung CPU bound workqueues Petr Mladek
2023-02-02 23:45 ` Tejun Heo [this message]
2023-02-03 14:26 ` Petr Mladek
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=Y9xLAdc9ODyEO+RQ@slm.duckdns.org \
--to=tj@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=pmladek@suse.com \
/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
all inboxes | Powered by JetHome®