From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH v3] printk: Relocate wake_klogd check close to the end of console_unlock()
Date: Mon, 26 Feb 2018 15:37:35 +0900 [thread overview]
Message-ID: <20180226063735.GC12539@jagdpanzerIV> (raw)
In-Reply-To: <20180219160122.upqkpbbffm3rth6p@pathway.suse.cz>
On (02/19/18 17:01), Petr Mladek wrote:
[..]
> - raw_spin_lock(&logbuf_lock);
> retry = console_seq != log_next_seq;
> + /*
> + * Check whether userland needs notification. Do this only when really
> + * leaving to avoid race with console_trylock_spinning().
> + */
> + if (seen_seq != log_next_seq && !retry) {
> + wake_klogd = true;
> + seen_seq = log_next_seq;
> + }
Let's add the "why" part. This "!retry" might be hard to understand. We
are looking at
- CPUa is about to leave console_unlock()
- printk on CPUb appends a new message
- CPUa detects that `console_seq != log_next_seq', updates `seen_seq'
- printk on CPUb is getting preempted
- CPUa re-takes the console_sem via retry path
- printk CPUb is becoming TASK_RUNNING again - it now spins for console_sem,
since we have an active console_sem owner
- CPUa detects that there is a console_sem waiter, so it offloads the
printing task, without ever waking up klogd
Either we can have that complex "seen_seq != log_next_seq && !retry"
check - or we simply can add
if (console_lock_spinning_disable_and_check()) {
printk_safe_exit_irqrestore(flags);
if (wake_klogd)
wake_up_klogd();
}
to the offloading return path.
The later is *may be* simpler to follow. The rule is: every
!console_suspend and !cant-use-consoles return path from console_unlock()
must wake_up_klogd() [if needed].
-ss
next prev parent reply other threads:[~2018-02-26 6:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-08 13:04 [PATCH v2] printk: Relocate wake_klogd check close to the end of console_unlock() Petr Mladek
2018-02-08 14:53 ` Sergey Senozhatsky
2018-02-08 16:48 ` Petr Mladek
2018-02-09 3:28 ` Sergey Senozhatsky
2018-02-09 10:39 ` Petr Mladek
2018-02-10 7:33 ` Sergey Senozhatsky
2018-02-09 10:47 ` Petr Mladek
2018-02-19 15:58 ` Petr Mladek
2018-02-19 16:01 ` [PATCH v3] " Petr Mladek
2018-02-26 6:37 ` Sergey Senozhatsky [this message]
2018-02-26 15:57 ` Petr Mladek
2018-02-26 16:01 ` Sergey Senozhatsky
2018-02-26 6:27 ` [PATCH v2] " 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=20180226063735.GC12539@jagdpanzerIV \
--to=sergey.senozhatsky.work@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--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).