From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "ksummit-discuss@lists.linuxfoundation.org"
<ksummit-discuss@lists.linuxfoundation.org>
Subject: Re: [Ksummit-discuss] [TECH TOPIC] printk redesign
Date: Fri, 23 Jun 2017 14:20:58 +0900 [thread overview]
Message-ID: <20170623052058.GA844@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <CAKMK7uGR_Zn1eW9znd_HNF1VS5ELmrrZwXBwmkpaAzB=F_qG3A@mail.gmail.com>
On (06/22/17 15:42), Daniel Vetter wrote:
[..]
> >> Fixing console_lock is much less likely to happen, I (and better
> >> hackers like Alan Cox) tried, and ran away in tears.
> >
> > well, I don't even pretend to be a kernel hacker, but what were
> > the major obstacles?
>
> The framebuffer notifier gets called from multiple places, with
> multiple different execution contexts and locking contexts, for at
> least 3 different things:
> - Allowing fbdev console support to be built modular, and loaded in
> any order wrt fbdev drivers and still end up with an fbcon console.
> This results in a fbdev driver 2 fbcon call in
> (un)register_framebuffer.
> - Backlight handling. This means fbcon needs to call into the fb
> notifier, giving you a locking inversion.
> - Bunch of other things just for fun.
>
> This means all the locking for all of the above things are entangled
> through the modifiers mutex, with the result that defacto console_lock
> protects everything, and that anything in fbdev that might call into
> one of these notifier use-cases must use console_lock as the
> outermost.
>
> To make matters worse, drm kernel modesetting drivers then get called
> in an fbdev->fbcon->fbdev->drm fbdev emulation->kms driver chain from
> within register_framebuffer to do the initial modeset, and ofc that's
> all under the console_lock.
>
> Tears pretty much guaranteed, and after a few hacks from Alan&me I
> concluded that the only way to fix this is to at least partially
> rewrite fbdev (a dead subsystem, so no one's volunteering), with the
> risk that you get to revert it all because someone is indeed relying
> on that super-flexible module loading order sequence. The simplest fix
> would probably be to make the entire fbdev->fbcon setup depency a
> hard-coded function call, or maybe at most a one-shot symbol_get
> attempt.
many thanks.
I played with the RW console_sem last night... and, yes, I was pretty sad.
just in case, if we ever will return back, I improved "the patch"
a bit, there are still several broken places (console_may_schedule()
on !PREEMPT systems for instance), and so on. uploaded here:
https://github.com/sergey-senozhatsky/linux-next-ss/commits/console_RW_sem
so at least we won't lose the patch, may be.
but, like you said, we've got a much a bigger problems.
> > the thing is,
> > I want to convert console_sem into RW lock. I briefly mentioned it last
> > year in Santa Fe, NM... and in fact I wrote *some sort* of a patch back
> > (well, mostly to see if it can fly at all). the patch has never been
> > finalized, polished, carefully written or properly tested (!).
>
> RW won't help, the problem is the locking inversion design disaster in
> fbdev/fbcon resulting in console_lock being an outermost lock procting
> almost the entire fbdev world.
yes. console_sem is a *Big Konsole Lock* (German spelling, I believe) as
of now. it's way too important and in most of the cases it must be acquired
in exclusive (write) mode. So we are losing the whole point of convertion.
we can, of course, switch printk to rwsem and keep console_lock() as a
wrapper around console_write_lock(), but the benefit of such excerise is
questionable. I was hoping to see more places where we can be in read lock
mode.
-ss
next prev parent reply other threads:[~2017-06-23 5:20 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-19 5:21 Sergey Senozhatsky
2017-06-19 6:22 ` Hannes Reinecke
2017-06-19 14:39 ` Steven Rostedt
2017-06-19 15:20 ` Andrew Lunn
2017-06-19 15:54 ` Hannes Reinecke
2017-06-19 16:17 ` Andrew Lunn
2017-06-19 16:23 ` Mark Brown
2017-06-20 15:58 ` Sergey Senozhatsky
2017-06-20 16:44 ` Luck, Tony
2017-06-20 17:11 ` Sergey Senozhatsky
2017-06-20 17:27 ` Mark Brown
2017-06-20 23:28 ` Steven Rostedt
2017-06-21 7:17 ` Hannes Reinecke
2017-06-21 11:12 ` Sergey Senozhatsky
2017-06-22 14:06 ` Steven Rostedt
2017-06-23 5:43 ` Sergey Senozhatsky
2017-06-23 13:09 ` Steven Rostedt
2017-06-21 12:23 ` Petr Mladek
2017-06-21 14:18 ` Andrew Lunn
2017-06-23 8:46 ` Petr Mladek
2017-06-21 16:09 ` Andrew Lunn
2017-06-23 8:49 ` Petr Mladek
2017-07-19 7:35 ` David Woodhouse
2017-07-20 7:53 ` Sergey Senozhatsky
2017-06-20 16:09 ` Sergey Senozhatsky
2017-06-19 16:26 ` Steven Rostedt
2017-06-19 16:35 ` Andrew Lunn
2017-06-24 11:14 ` Mauro Carvalho Chehab
2017-06-24 14:06 ` Andrew Lunn
2017-06-24 22:42 ` Steven Rostedt
2017-06-24 23:21 ` Andrew Lunn
2017-06-24 23:26 ` Linus Torvalds
2017-06-24 23:40 ` Steven Rostedt
2017-06-26 11:16 ` Sergey Senozhatsky
2017-06-24 23:48 ` Al Viro
2017-06-25 1:29 ` Andrew Lunn
2017-06-25 2:41 ` Linus Torvalds
2017-06-26 8:46 ` Jiri Kosina
2017-07-19 7:59 ` David Woodhouse
2017-06-20 15:56 ` Sergey Senozhatsky
2017-06-20 18:45 ` Daniel Vetter
2017-06-21 9:29 ` Petr Mladek
2017-06-21 10:15 ` Sergey Senozhatsky
2017-06-22 13:42 ` Daniel Vetter
2017-06-22 13:48 ` Daniel Vetter
2017-06-23 9:07 ` Bartlomiej Zolnierkiewicz
2017-06-27 13:06 ` Sergey Senozhatsky
2017-06-23 5:20 ` Sergey Senozhatsky [this message]
2017-06-19 23:46 ` Josh Triplett
2017-06-20 8:24 ` Arnd Bergmann
2017-06-20 14:36 ` Steven Rostedt
2017-06-20 15:26 ` Sergey Senozhatsky
2017-06-22 16:35 ` David Howells
2017-07-19 6:24 ` Sergey Senozhatsky
2017-07-19 6:25 ` Sergey Senozhatsky
2017-07-19 7:26 ` Daniel Vetter
2017-07-20 5:19 ` 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=20170623052058.GA844@jagdpanzerIV.localdomain \
--to=sergey.senozhatsky.work@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=ksummit-discuss@lists.linuxfoundation.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