From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
Petr Mladek <pmladek@suse.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Michal Hocko <mhocko@kernel.org>, Pavel Machek <pavel@ucw.cz>,
Steven Rostedt <rostedt@goodmis.org>,
Andreas Mohr <andi@lisas.de>, Jan Kara <jack@suse.cz>,
dri-devel <dri-devel@lists.freedesktop.org>,
Linux MM <linux-mm@kvack.org>
Subject: Re: printk: Should console related code avoid __GFP_DIRECT_RECLAIM memory allocations?
Date: Tue, 11 Jul 2017 13:57:10 +0900 [thread overview]
Message-ID: <20170711045710.GC4586@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <20170711023150.GB4586@jagdpanzerIV.localdomain>
On (07/11/17 11:31), Sergey Senozhatsky wrote:
[..]
> (replying to both Petr and Daniel)
>
> interesting direction, gents.
>
> and this is what I thought about over the weekend; it's very sketchy and
> I didn't spend too much time on it. (I'm on a sick leave now, sorry).
>
> it's quite close to what you guys have mentioned above.
>
> a) keep console_sem only to protect console drivers list modification
> b) add a semaphore/mutex to struct console
> c) move global console_seq/etc to struct console
> e) use a single kthread for printing, but do console_unlock() multi passes,
> printing unseen logbuf messages on per-console basis
>
>
> so console_lock()/console_unlock() will simply protect console drivers
> list from concurrent manipulation; it will not prevent us from printing.
> now, there are places where console_lock() serves a special purpose - it
> makes sure that no new lines are printed to the console while we scroll
> it/flip it/etc. IOW while we do "some things" to a particular console.
> the problem here, is that this also blocks printing to all of the registered
> console drivers, not just the one we are touching now. therefore, what I was
> thinking about is to disable/enable that particular console in all of the
> places where we really want to stop printing to this console for a bit.
>
> IOW, something like
>
>
>
> console_lock()
> : down(console_sem);
>
> console_disable(con)
> : lock(con->lock);
> : con->flags &= ~CON_ENABLED;
> : unlock(con->lock)
>
> console_unlock()
> : for_each_console(con)
> : while (con->console_seq != log_next_seq) {
> : msg_print_text();
> : con->console_seq++;
> :
> : call_console_drivers()
> : : if (con->flags & CON_ENABLED)
> : : con->write()
> : }
> : up(console_sem);
>
>
> // do "some things" to this console. it's disabled, so no
> // ->write() callback would be called in the meantime
>
> console_lock()
> : down(console_sem);
>
> console_enable(con)
> : lock(con->lock);
> : con->flags |= CON_ENABLED;
> : unlock(con->lock)
>
>
> // so now we enabled that console again. it's ->console_seq is
> // probably behind the rest of consoles, so console_unlock()
> // will ->write() all the unseen message to this console.
>
> console_unlock()
> : for_each_console(con)
> : while (con->console_seq != log_next_seq) {
> : msg_print_text();
> : con->console_seq++;
> :
> : call_console_drivers()
> : : if (con->flags & CON_ENABLED)
> : : con->write()
> : }
> : up(console_sem);
>
ok, obviously stupid.
I meant to hold con->lock between console_disable() and console_enable().
so no other CPU can unregister it, etc. printk->console_unlock(), thus,
can either have a racy con->flags check (no con->lock taken) or try
something like down_trylock(&con->lock): if it fails, continue.
but need to look more.
-ss
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-07-11 4:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 10:28 printk: Should console related code avoid __GFP_DIRECT_RECLAIM memory allocations? Tetsuo Handa
2017-07-07 2:39 ` Sergey Senozhatsky
2017-07-07 8:41 ` Daniel Vetter
2017-07-08 13:30 ` Tetsuo Handa
2017-07-10 5:07 ` Sergey Senozhatsky
2017-07-10 12:59 ` Petr Mladek
2017-07-10 18:07 ` Daniel Vetter
2017-07-11 2:31 ` Sergey Senozhatsky
2017-07-11 4:57 ` Sergey Senozhatsky [this message]
2017-07-11 7:50 ` Daniel Vetter
2017-07-11 9:48 ` Sergey Senozhatsky
2017-07-11 11:36 ` Daniel Vetter
2017-07-10 13:33 ` Michal Hocko
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=20170711045710.GC4586@jagdpanzerIV.localdomain \
--to=sergey.senozhatsky.work@gmail.com \
--cc=andi@lisas.de \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jack@suse.cz \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=pavel@ucw.cz \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.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;
as well as URLs for NNTP newsgroup(s).