From: Jan Kara <jack@suse.cz>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jan Kara <jack@suse.com>, Petr Mladek <pmladek@suse.com>,
Tejun Heo <tj@kernel.org>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
linux-kernel@vger.kernel.org,
Byungchul Park <byungchul.park@lge.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Jan Kara <jack@suse.cz>
Subject: Re: [RFC][PATCH v4 1/2] printk: Make printk() completely async
Date: Tue, 15 Mar 2016 11:03:23 +0100 [thread overview]
Message-ID: <20160315100323.GF17942@quack.suse.cz> (raw)
In-Reply-To: <1457964820-4642-2-git-send-email-sergey.senozhatsky@gmail.com>
> + if (!sync_print) {
> + if (printk_thread && !in_panic) {
> + /*
> + * This will wakeup the printing kthread and offload
> + * printing to a schedulable context.
> + */
> + __this_cpu_or(printk_pending,
> + PRINTK_PENDING_KTHREAD_OUTPUT);
> + irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
> + } else if (in_sched) {
> + /*
> + * @in_sched messages may come too early, when we don't
> + * yet have @printk_thread. We can't print deferred
> + * messages directly, because this may deadlock, route
> + * them via IRQ context.
> + */
> + __this_cpu_or(printk_pending,
> + PRINTK_PENDING_IRQ_OUTPUT);
> + irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
> + } else {
> + sync_print = true;
> + }
> + }
I'm a bit undecided whether we want to go through irq work even for the
common case of !in_sched messages or whether we want to directly call
wake_up() in that case. Maybe I'd do it like:
if (!sync_print) {
if (in_sched) {
__this_cpu_or(printk_pending,
PRINTK_PENDING_IRQ_OUTPUT);
irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
} else if (printk_thread && !in_panic) {
wake_up(&printing_wait);
} else {
sync_print = true;
}
}
and the wake_up_klogd_work_func() would look like:
static void wake_up_klogd_work_func(struct irq_work *irq_work)
{
int pending = __this_cpu_xchg(printk_pending, 0);
if (pending & PRINTK_PENDING_OUTPUT) {
if (printk_thread) {
wake_up(&printing_wait);
} else {
/*
* If trylock fails, someone else is doing the printing
*/
if (console_trylock())
console_unlock();
}
}
...
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2016-03-15 10:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-14 14:13 [RFC][PATCH v4 0/2] printk: Make printk() completely async Sergey Senozhatsky
2016-03-14 14:13 ` [RFC][PATCH v4 1/2] " Sergey Senozhatsky
2016-03-15 10:03 ` Jan Kara [this message]
2016-03-15 14:07 ` Sergey Senozhatsky
2016-03-16 5:39 ` Byungchul Park
2016-03-16 6:58 ` Sergey Senozhatsky
2016-03-16 7:30 ` Byungchul Park
2016-03-16 7:56 ` Sergey Senozhatsky
2016-03-16 10:34 ` Byungchul Park
2016-03-17 0:34 ` Sergey Senozhatsky
2016-03-18 5:49 ` Byungchul Park
2016-03-18 7:11 ` Sergey Senozhatsky
2016-03-18 8:23 ` byungchul.park
2016-03-16 7:00 ` Byungchul Park
2016-03-16 7:07 ` Sergey Senozhatsky
2016-03-15 15:58 ` Petr Mladek
2016-03-16 2:01 ` Sergey Senozhatsky
2016-03-16 2:10 ` Byungchul Park
2016-03-16 2:31 ` Sergey Senozhatsky
2016-03-14 14:13 ` [RFC][PATCH v4 2/2] printk: Skip messages on oops Sergey Senozhatsky
2016-03-17 10:56 ` Sergey Senozhatsky
2016-04-23 19:36 ` [RFC][PATCH v4 0/2] printk: Make printk() completely async Pavel Machek
2016-04-24 5:03 ` Sergey Senozhatsky
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=20160315100323.GF17942@quack.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=byungchul.park@lge.com \
--cc=jack@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=pmladek@suse.com \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=tj@kernel.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).