From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] printk: Remove superfluous memory barriers from printk_safe
Date: Mon, 16 Oct 2017 20:08:45 +0900 [thread overview]
Message-ID: <20171016110845.GB6316@tigerII.localdomain> (raw)
In-Reply-To: <20171016081252.GG2795@pathway.suse.cz>
On (10/16/17 10:12), Petr Mladek wrote:
[..]
> > > it's not only NMI related, printk() recursion can happen at any stages,
> > > including... um... wait a second. ... including the "before we set up
> > > per-CPU areas" stage? hmm... smells like a bug?
> >
> > I think this was just being overly paranoid.
>
> I was curious because it was not only about reading the per-CPU
> variables. We set and clear the printk_context per-CPU variable
> in every printk() call. I wondered if we accessed some
> non-initialized stuff.
>
> Fortunately, it seems that we are on the safe side.
>
> If I get it correctly, the per-CPU variables are set up in
> setup_per_cpu_areas(). But some per-CPU variables are used even
> before, see
>
> boot_cpu_init()
> smp_processor_id()
> raw_smp_processor_id()
> this_cpu_read(cpu_number)
>
> IMHO, the trick is the following code in setup_per_cpu_areas()
> from arch/x86/kernel/setup_percpu.c:
>
> /*
> * Up to this point, the boot CPU has been using .init.data
> * area. Reload any changed state for the boot CPU.
> */
> if (!cpu)
> switch_to_new_gdt(cpu);
>
> IMHO, this means that per-CPU variable for the first boot-CPU
> can be used at any time. And all the interesting functions:
> boot_cpu_init(), setup_per_cpu_areas(), printk_safe_init() are
> still called in the single-CPU mode.
hm... not so sure, need to check more.
we can access DECLARE_EARLY_PER_CPU() things, which we must copy after
per-cpu pages are set up. `cpu_number' is DECLARE_EARLY_PER_CPU(), btw.
-ss
next prev parent reply other threads:[~2017-10-16 11:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 16:46 Steven Rostedt
2017-10-12 9:34 ` Petr Mladek
2017-10-14 9:21 ` Sergey Senozhatsky
2017-10-16 0:27 ` Steven Rostedt
2017-10-16 8:12 ` Petr Mladek
2017-10-16 11:08 ` Sergey Senozhatsky [this message]
2017-10-16 11:05 ` 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=20171016110845.GB6316@tigerII.localdomain \
--to=sergey.senozhatsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®