From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: sergey.senozhatsky@gmail.com, pmladek@suse.com, jack@suse.com,
tj@kernel.org, kyle@kernel.org, davej@codemonkey.org.uk,
calvinowens@fb.com, gregkh@linuxfoundation.org, jslaby@suse.cz,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
sergey.senozhatsky.work@gmail.com
Subject: Re: printk: reset may_schedule if console_trylock() from console_unlock()
Date: Thu, 05 Jan 2017 10:56:18 +0000 [thread overview]
Message-ID: <20170105105618.GE480@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <201701051927.IJF65159.OFFtSLQOOFHJMV@I-love.SAKURA.ne.jp>
On (01/05/17 19:27), Tetsuo Handa wrote:
[..]
> > the other thing is... do we really need to console_conditional_schedule()
> > from fbcon_*()? console_unlock() does cond_resched() after every line it
> > prints. wouldn't that be enough?
>
> Every record, isn't it?
yes. after every call to console drivers.
> How many bytes can a record write to consoles?
1024 - PREFIX_MAX bytes at most.
> > so may be we can drop some of console_conditional_schedule()
> > call sites in fbcon. or update console_conditional_schedule()
> > function to always return the current preemption value, not the
> > one we saw in console_trylock().
>
> Replacing console_may_schedule with get_console_may_schedule() will avoid
> this bug. I noticed that we forgot to reset console_may_schedule to 0
> because the "again:" label is located after the assignment line.
well...
we call cond_resched() from under the spin_lock(), which modifies the
preempt count and cond_resched() which we call from
console_conditional_schedule() checks that current->preempt count is
0 before it calls tif_need_resched().
there are configs/setups where spinlock does not modify preempt count,
but I suspect that on those setups cond_resched() does nothing.
so it looks to me that we just WARN from ___might_sleep() but, at least
in this particular case, I don't think we can actually schedule().
but I just had a very quick look, so I may be completely wrong. need
to double check.
what I tried to say:
-- I will send out a patch for printk() once we settle down the current
work in progress.
why do I want to address this in printk? because who knows, may be there
is (or there will be) something out there that takes rcu_read_lock() and
then does the console_conditional_schedule(). rcu does not modify current
preempt count, it has its own preempt counter, and get_console_may_schedule()
takes that into account.
> What happened here was:
>
> [...]
I need more time to walk through your analysis/proposal.
-ss
prev parent reply other threads:[~2017-01-05 10:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-05 10:27 printk: reset may_schedule if console_trylock() from console_unlock() Tetsuo Handa
2017-01-05 10:56 ` Sergey Senozhatsky [this message]
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=20170105105618.GE480@jagdpanzerIV.localdomain \
--to=sergey.senozhatsky.work@gmail.com \
--cc=calvinowens@fb.com \
--cc=davej@codemonkey.org.uk \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.com \
--cc=jslaby@suse.cz \
--cc=kyle@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=pmladek@suse.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).