From: John Ogness <john.ogness@linutronix.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/5] workqueue: use pr_cont_t for cont messages
Date: Thu, 20 Aug 2020 01:32:30 +0206 [thread overview]
Message-ID: <20200819232632.13418-4-john.ogness@linutronix.de> (raw)
In-Reply-To: <20200819232632.13418-1-john.ogness@linutronix.de>
Use the new pr_cont_t mechanism.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/workqueue.c | 71 +++++++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index c41c3c17b86a..472370f02001 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4645,32 +4645,34 @@ void print_worker_info(const char *log_lvl, struct task_struct *task)
copy_from_kernel_nofault(desc, worker->desc, sizeof(desc) - 1);
if (fn || name[0] || desc[0]) {
- printk("%sWorkqueue: %s %ps", log_lvl, name, fn);
+ pr_cont_t c;
+
+ pr_cont_begin(&c, "%sWorkqueue: %s %ps", log_lvl, name, fn);
if (strcmp(name, desc))
- pr_cont(" (%s)", desc);
- pr_cont("\n");
+ pr_cont_append(&c, " (%s)", desc);
+ pr_cont_end(&c);
}
}
-static void pr_cont_pool_info(struct worker_pool *pool)
+static void pr_cont_pool_info(pr_cont_t *c, struct worker_pool *pool)
{
- pr_cont(" cpus=%*pbl", nr_cpumask_bits, pool->attrs->cpumask);
+ pr_cont_append(c, " cpus=%*pbl", nr_cpumask_bits, pool->attrs->cpumask);
if (pool->node != NUMA_NO_NODE)
- pr_cont(" node=%d", pool->node);
- pr_cont(" flags=0x%x nice=%d", pool->flags, pool->attrs->nice);
+ pr_cont_append(c, " node=%d", pool->node);
+ pr_cont_append(c, " flags=0x%x nice=%d", pool->flags, pool->attrs->nice);
}
-static void pr_cont_work(bool comma, struct work_struct *work)
+static void pr_cont_work(pr_cont_t *c, bool comma, struct work_struct *work)
{
if (work->func == wq_barrier_func) {
struct wq_barrier *barr;
barr = container_of(work, struct wq_barrier, work);
- pr_cont("%s BAR(%d)", comma ? "," : "",
+ pr_cont_append(c, "%s BAR(%d)", comma ? "," : "",
task_pid_nr(barr->task));
} else {
- pr_cont("%s %ps", comma ? "," : "", work->func);
+ pr_cont_append(c, "%s %ps", comma ? "," : "", work->func);
}
}
@@ -4680,14 +4682,16 @@ static void show_pwq(struct pool_workqueue *pwq)
struct work_struct *work;
struct worker *worker;
bool has_in_flight = false, has_pending = false;
+ pr_cont_t c;
int bkt;
- pr_info(" pwq %d:", pool->id);
- pr_cont_pool_info(pool);
+ pr_cont_begin(&c, KERN_INFO " pwq %d:", pool->id);
+ pr_cont_pool_info(&c, pool);
- pr_cont(" active=%d/%d refcnt=%d%s\n",
+ pr_cont_append(&c, " active=%d/%d refcnt=%d%s",
pwq->nr_active, pwq->max_active, pwq->refcnt,
!list_empty(&pwq->mayday_node) ? " MAYDAY" : "");
+ pr_cont_end(&c);
hash_for_each(pool->busy_hash, bkt, worker, hentry) {
if (worker->current_pwq == pwq) {
@@ -4698,20 +4702,20 @@ static void show_pwq(struct pool_workqueue *pwq)
if (has_in_flight) {
bool comma = false;
- pr_info(" in-flight:");
+ pr_cont_begin(&c, KERN_INFO " in-flight:");
hash_for_each(pool->busy_hash, bkt, worker, hentry) {
if (worker->current_pwq != pwq)
continue;
- pr_cont("%s %d%s:%ps", comma ? "," : "",
+ pr_cont_append(&c, "%s %d%s:%ps", comma ? "," : "",
task_pid_nr(worker->task),
worker->rescue_wq ? "(RESCUER)" : "",
worker->current_func);
list_for_each_entry(work, &worker->scheduled, entry)
- pr_cont_work(false, work);
+ pr_cont_work(&c, false, work);
comma = true;
}
- pr_cont("\n");
+ pr_cont_end(&c);
}
list_for_each_entry(work, &pool->worklist, entry) {
@@ -4723,26 +4727,26 @@ static void show_pwq(struct pool_workqueue *pwq)
if (has_pending) {
bool comma = false;
- pr_info(" pending:");
+ pr_cont_begin(&c, KERN_INFO " pending:");
list_for_each_entry(work, &pool->worklist, entry) {
if (get_work_pwq(work) != pwq)
continue;
- pr_cont_work(comma, work);
+ pr_cont_work(&c, comma, work);
comma = !(*work_data_bits(work) & WORK_STRUCT_LINKED);
}
- pr_cont("\n");
+ pr_cont_end(&c);
}
if (!list_empty(&pwq->delayed_works)) {
bool comma = false;
- pr_info(" delayed:");
+ pr_cont_begin(&c, KERN_INFO " delayed:");
list_for_each_entry(work, &pwq->delayed_works, entry) {
- pr_cont_work(comma, work);
+ pr_cont_work(&c, comma, work);
comma = !(*work_data_bits(work) & WORK_STRUCT_LINKED);
}
- pr_cont("\n");
+ pr_cont_end(&c);
}
}
@@ -4757,6 +4761,7 @@ void show_workqueue_state(void)
struct workqueue_struct *wq;
struct worker_pool *pool;
unsigned long flags;
+ pr_cont_t c;
int pi;
rcu_read_lock();
@@ -4800,20 +4805,20 @@ void show_workqueue_state(void)
if (pool->nr_workers == pool->nr_idle)
goto next_pool;
- pr_info("pool %d:", pool->id);
- pr_cont_pool_info(pool);
- pr_cont(" hung=%us workers=%d",
+ pr_cont_begin(&c, KERN_INFO "pool %d:", pool->id);
+ pr_cont_pool_info(&c, pool);
+ pr_cont_append(&c, " hung=%us workers=%d",
jiffies_to_msecs(jiffies - pool->watchdog_ts) / 1000,
pool->nr_workers);
if (pool->manager)
- pr_cont(" manager: %d",
+ pr_cont_append(&c, " manager: %d",
task_pid_nr(pool->manager->task));
list_for_each_entry(worker, &pool->idle_list, entry) {
- pr_cont(" %s%d", first ? "idle: " : "",
+ pr_cont_append(&c, " %s%d", first ? "idle: " : "",
task_pid_nr(worker->task));
first = false;
}
- pr_cont("\n");
+ pr_cont_end(&c);
next_pool:
raw_spin_unlock_irqrestore(&pool->lock, flags);
/*
@@ -5752,6 +5757,7 @@ static void wq_watchdog_timer_fn(struct timer_list *unused)
unsigned long thresh = READ_ONCE(wq_watchdog_thresh) * HZ;
bool lockup_detected = false;
struct worker_pool *pool;
+ pr_cont_t c;
int pi;
if (!thresh)
@@ -5785,10 +5791,11 @@ static void wq_watchdog_timer_fn(struct timer_list *unused)
/* did we stall? */
if (time_after(jiffies, ts + thresh)) {
lockup_detected = true;
- pr_emerg("BUG: workqueue lockup - pool");
- pr_cont_pool_info(pool);
- pr_cont(" stuck for %us!\n",
+ pr_cont_begin(&c, KERN_EMERG "BUG: workqueue lockup - pool");
+ pr_cont_pool_info(&c, pool);
+ pr_cont_append(&c, " stuck for %us!",
jiffies_to_msecs(jiffies - pool_ts) / 1000);
+ pr_cont_end(&c);
}
}
--
2.20.1
next prev parent reply other threads:[~2020-08-19 23:26 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 23:26 [RFC PATCH 0/5] printk: new log_cont implementation John Ogness
2020-08-19 23:26 ` [RFC PATCH 1/5] printk: implement pr_cont_t John Ogness
2020-08-20 0:33 ` Joe Perches
2020-08-20 7:44 ` David Laight
2020-08-20 7:59 ` Joe Perches
2020-08-20 8:49 ` David Laight
2020-08-20 9:18 ` John Ogness
2020-08-20 16:03 ` Joe Perches
2020-08-20 10:16 ` Petr Mladek
2020-08-20 12:33 ` David Laight
2020-08-25 13:10 ` Petr Mladek
2020-08-25 13:38 ` David Laight
2020-08-25 15:32 ` Petr Mladek
2020-08-24 2:08 ` Sergey Senozhatsky
2020-08-24 5:37 ` Sergey Senozhatsky
2020-08-19 23:26 ` [RFC PATCH 2/5] sysrq: use pr_cont_t for cont messages John Ogness
2020-08-20 1:03 ` Linus Torvalds
2020-08-20 17:48 ` Joe Perches
2020-08-20 17:53 ` Linus Torvalds
2020-08-20 22:11 ` John Ogness
2020-08-20 22:36 ` Joe Perches
2020-08-19 23:26 ` John Ogness [this message]
2020-08-19 23:26 ` [RFC PATCH 4/5] locking/selftest: " John Ogness
2020-08-19 23:26 ` [RFC PATCH 5/5] lockdep: " John Ogness
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=20200819232632.13418-4-john.ogness@linutronix.de \
--to=john.ogness@linutronix.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).