lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180116022349.GD6607@jagdpanzerIV>
Date:   Tue, 16 Jan 2018 11:23:49 +0900
From:   Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:     Petr Mladek <pmladek@...e.com>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        Tejun Heo <tj@...nel.org>, akpm@...ux-foundation.org,
        linux-mm@...ck.org, Cong Wang <xiyou.wangcong@...il.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Johannes Weiner <hannes@...xchg.org>,
        Mel Gorman <mgorman@...e.de>, Michal Hocko <mhocko@...nel.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        Peter Zijlstra <peterz@...radead.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Jan Kara <jack@...e.cz>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
        rostedt@...e.goodmis.org, Byungchul Park <byungchul.park@....com>,
        Pavel Machek <pavel@....cz>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 0/2] printk: Console owner and waiter logic cleanup

On (01/15/18 15:45), Petr Mladek wrote:
[..]
> > With the preempt_disable() there really isn't a delay. I agree, we
> > shouldn't let printk preempt (unless we have CONFIG_PREEMPT_RT enabled,
> > but that's another story).
> > 
> > > 
> > > so very schematically, for hand-off it's something like
> > > 
> > > 	if (... console_trylock_spinning()) // grabbed the ownership
> > > 
> > > 		<< ... preempted ... >>
> > > 
> > > 		console_unlock();
> > 
> > Which I think we should stop, with the preempt_disable().
> 
> Adding the preempt_disable() basically means to revert the already
> mentioned commit 6b97a20d3a7909daa06625 ("printk: set may_schedule
> for some of console_trylock() callers").
> 
> I originally wanted to solve this separately to make it easier. But
> the change looks fine to me. Therefore we reached a mutual agreement.
> Sergey, do you want to send a patch or should I just put it at
> the end of this patchset?

you can add the patch.

[..]
> > I think adding the preempt_disable() would fix printk() but let non
> > printk console_unlock() still preempt.
> 
> I would personally remove cond_resched() from console_unlock()
> completely.

hmm, not so sure. I think it's there for !PREEMPT systems which have
to print a lot of messages. the case I'm speaking about in particular
is when we register a CON_PRINTBUFFER console and need to console_unlock()
(flush) all of the messages we currently have in the logbuf. we better
have that cond_resched() there, I think.

> Sleeping in console_unlock() increases the chance that more messages
> would need to be handled. And more importantly it reduces the chance
> of a successful handover.
> 
> As a result, the caller might spend there very long time, it might
> be getting increasingly far behind. There is higher risk of lost
> messages. Also the eventual taker might have too much to proceed
> in preemption disabled context.

yes.

> Removing cond_resched() is in sync with printk() priorities.

hmm, not sure. we have sleeping console_lock()->console_unlock() path
for PREEMPT kernels, that cond_resched() makes the !PREEMPT kernels to
have the same sleeping console_lock()->console_unlock().

printk()->console_unlock() seems to be a pretty independent thing,
unfortunately (!), yet sleeping console_lock()->console_unlock()
messes up with it a lot.

> The highest one is to get the messages out.
> 
> Finally, removing cond_resched() should make the behavior more
> predictable (never preempted)

but we are always preempted in PREEMPT kernels when the current
console_sem owner acquired the lock via console_lock(), not via
console_trylock(). cond_resched() does the same, but for !PREEMPT.

	-ss

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ