linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: kernel test robot <lkp@intel.com>,
	kbuild-all@lists.01.org,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Marco Elver <elver@google.com>
Subject: Re: [PATCH next v2 1/2] dump_stack: move cpu lock to printk.c
Date: Fri, 11 Jun 2021 09:00:34 +0200	[thread overview]
Message-ID: <YMMKErwuH7ps8fNe@alley> (raw)
In-Reply-To: <877dj1u9zc.fsf@jogness.linutronix.de>

On Thu 2021-06-10 15:26:15, John Ogness wrote:
> On 2021-06-08, Petr Mladek <pmladek@suse.com> wrote:
> >>    lib/dump_stack.c: In function 'dump_stack_lvl':
> >> >> lib/dump_stack.c:107:2: warning: 'lock_flag' is used uninitialized in this function [-Wuninitialized]
> >>      107 |  printk_cpu_unlock_irqrestore(lock_flag, irq_flags);
> >>          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Interesting. I am curious that it does not complain also about
> > irq_flags. But it is possible the it reports only the first problem.
> 
> Strangely enough, if I set a value for @lock_flag, it is happy and does
> not complain about @irq_flags. Probably a compiler oversight.

Yeah, it is strange.

> > Anyway, we will likely need to do some trickery via #define to tell
> > the compiler that the value is set.
> 
> This is on ARCH=mips and !CONFIG_SMP. So the value is _not_ getting
> set. (The static inline function does nothing.)
> 
> By changing printk_cpu_unlock_irqrestore() to use pointers:
> 
>     static inline void printk_cpu_unlock_irqrestore(bool *lock_flag, unsigned long *irq_flags)
> 
> then the warning disappears. Indeed, by not using pointers on unlock,
> technically data is copied that was never initialized. I thought maybe
> the compiler would optimize all that out, but it seems that it does not.
> 
> I have no problems using pointers for unlock(). It was strange using
> pointers for lock(), but not for unlock() anyway.
> 
> Or would you prefer something else?

I would actually prefer to introduce the macros and pass the flags
without referencing.

I was about to write that I did not mind. But then it came to me that
it might be worth being compatible with the other
irqsafe()/irqrestore() APIs. It seems that people are pretty used
to pass flags directly:

$> git grep irqsave.*flags | wc -l
17084
$> git grep irqsave.*\&flags | wc -l
15

That said, I do not resist on it. It will not block the patchset
if you decided to used the pointers. The lock should not be used
widely...

Best Regards,
Petr

  reply	other threads:[~2021-06-11  7:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 20:02 [PATCH next v2 0/2] introduce printk cpu lock John Ogness
2021-06-07 20:02 ` [PATCH next v2 1/2] dump_stack: move cpu lock to printk.c John Ogness
2021-06-08  2:43   ` kernel test robot
2021-06-08 13:48     ` Petr Mladek
2021-06-10 13:26       ` John Ogness
2021-06-11  7:00         ` Petr Mladek [this message]
2021-06-08 11:40   ` Petr Mladek
2021-06-08 13:55     ` John Ogness
2021-06-08 14:54       ` Petr Mladek
2021-06-07 20:02 ` [PATCH next v2 2/2] printk: fix cpu lock ordering John Ogness
2021-06-08 12:55   ` Petr Mladek
2021-06-08 14:18     ` John Ogness
2021-06-08 14:49       ` Petr Mladek
2021-06-10 14:44         ` John Ogness

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=YMMKErwuH7ps8fNe@alley \
    --to=pmladek@suse.com \
    --cc=0x7f454c46@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=elver@google.com \
    --cc=john.ogness@linutronix.de \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=tglx@linutronix.de \
    /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).