From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Jan Kara <jack@suse.cz>
Subject: Re: [RFC][PATCH 1/4] printk: introduce printing kernel thread
Date: Thu, 23 Mar 2017 14:12:42 +0900 [thread overview]
Message-ID: <20170323051242.GE2519@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <20170322164058.GE4008@pathway.suse.cz>
On (03/22/17 17:40), Petr Mladek wrote:
[..]
> > +void console_printing_thread_off(void)
> > +{
> > + printk_kthread_disable++;
> > + barrier();
> > +}
> > +
> > +/* This re-enables printk_kthread offloading. */
> > +void console_printing_thread_on(void)
> > +{
> > + barrier();
> > + printk_kthread_disable--;
> > +}
>
> I really like that these functions are re-entrant. It will make
> our life much easier.
>
> Just a small nitpicking. I would prefer to use the name
> console_printk_kthread_off()/on(). I was several times confused
> by "printing_thread" when searching the sources. The common
> sub-string "printk_kthread" for all the related stuff would
> make my life easier ;-)
well, I guess I can rename it.
one observation here is that those functions neither turn off nor
disable printk_kthread. we mark the point after which we will not
wake_up printk_kthread, but that does not mean that printk_kthread
is already or soon will be inactive. it actually can be in running
state. so the name
console_do_not_offload_printing_to_printk_kthread_unless_its_already_running()
will describe it better. :)
---
overall the whole need of off()/on() sections is slightly worrisome.
there are probably not so many cases when we need to forcibly avoid
wake_up(printk_kthread) calls, but we don't have any checks/mechanisms
to verify it (like, for example, might_sleep()). so it's case by case.
> Just an idea. printk() and printk_deferred() behave the same way
> when the kthread is enabled. I wonder if we should make it more
> explicit by using names like:
>
> printk_deferred_mode_disabled++;
> printk_deferred_mode_off();
> printk_deferred_mode_on();
hm, I certainly see what you meant here, but I suspect this naming may
be a bit misleading - "so printk_deferred_mode_off() disables printk_deferred()?"
> Also it is an already know term and a more generic name. This API
> is used globally while the kthread is an implementation detail.
> The offloading might be done another way in the future.
yes, this is why I avoided mentioning "printk_kthread" (directly)
in API naming. console_printing_thread is sort of neutral (well,
sort of). not insisting that the naming is perfect, of course.
> Finally, I think about using this variable instead of the ugly
> LOGLEVEL_SCHED. The catch is that LOGLEVEL_SCHED forces
> the deferred mode while these functions force the opposite.
hm, sorry. not sure I see how we can do this.
LOGLEVEL_SCHED hack is... hacky. yes.
when we examine `printk_kthread_disable' we decide wether we must
a) wake_up() printk_kthread
or
b) do console_trylock()
the LOGLEVEL_SCHED thing is completely different tho. it tells us that
neither of the above is safe -- both wake_up() and console_trylock()
can potentially call into the scheduler. so I'm not sure we can easily
replace LOGLEVEL_SCHED with `printk_kthread_disable'.
-ss
next prev parent reply other threads:[~2017-03-23 8:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-06 12:45 [RFC][PATCH 0/4] " Sergey Senozhatsky
2017-03-06 12:45 ` [RFC][PATCH 1/4] " Sergey Senozhatsky
2017-03-22 16:40 ` Petr Mladek
2017-03-23 5:12 ` Sergey Senozhatsky [this message]
2017-03-23 10:40 ` Petr Mladek
2017-03-24 5:20 ` Sergey Senozhatsky
2017-03-06 12:45 ` [RFC][PATCH 2/4] printk: offload printing from wake_up_klogd_work_func() Sergey Senozhatsky
2017-03-17 12:19 ` Petr Mladek
2017-03-18 9:57 ` Sergey Senozhatsky
2017-03-20 16:09 ` Petr Mladek
2017-03-21 4:01 ` Sergey Senozhatsky
2017-03-23 9:00 ` Sergey Senozhatsky
2017-03-23 12:11 ` Petr Mladek
2017-03-06 12:45 ` [RFC][PATCH 3/4] kernel, power: disable printk_kthread in unsafe places Sergey Senozhatsky
2017-03-22 15:38 ` Petr Mladek
2017-03-06 12:45 ` [RFC][PATCH 4/4] printk: enable printk offloading Sergey Senozhatsky
2017-03-22 15:43 ` Petr Mladek
2017-03-22 16:40 ` Sergey Senozhatsky
2017-03-22 17:59 ` [RFC][PATCH 0/4] printk: introduce printing kernel thread Peter Zijlstra
2017-03-23 4:09 ` Sergey Senozhatsky
2017-03-23 8:51 ` Peter Zijlstra
2017-03-24 1:59 ` Sergey Senozhatsky
2017-03-24 4:43 ` Sergey Senozhatsky
2017-03-24 14:43 ` Petr Mladek
2017-03-25 0:18 ` Sergey Senozhatsky
2017-03-23 12:01 ` Petr Mladek
2017-04-03 11:53 ` Sergey Senozhatsky
2017-04-04 12:59 ` 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=20170323051242.GE2519@jagdpanzerIV.localdomain \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rjw@rjwysocki.net \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--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
all inboxes | Powered by JetHome®