From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Peter Zijlstra <peterz@infradead.org>
Cc: 王贇 <yun.wang@linux.alibaba.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Paul Mackerras" <paulus@samba.org>,
"Jisheng Zhang" <jszhang@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
live-patching@vger.kernel.org, linux-riscv@lists.infradead.org,
"Miroslav Benes" <mbenes@suse.cz>,
"Joe Lawrence" <joe.lawrence@redhat.com>,
"Helge Deller" <deller@gmx.de>,
x86@kernel.org, linux-csky@vger.kernel.org,
"Ingo Molnar" <mingo@redhat.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Petr Mladek" <pmladek@suse.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Jiri Kosina" <jikos@kernel.org>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Borislav Petkov" <bp@alien8.de>,
"Josh Poimboeuf" <jpoimboe@redhat.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
linux-parisc@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Guo Ren" <guoren@kernel.org>,
"Colin Ian King" <colin.king@canonical.com>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] tracing: Have all levels of checks prevent recursion
Date: Fri, 21 Jul 2023 17:34:41 +0200 [thread overview]
Message-ID: <1b402c0c-1beb-d93f-ff6d-955350995ca3@intel.com> (raw)
In-Reply-To: <20211015142541.4badd8a9@gandalf.local.home>
From: Steven Rostedt <rostedt@goodmis.org>
Date: Fri, 15 Oct 2021 14:25:41 -0400
Sorry for such a necroposting :z
Just wanted to know if this is a bug, so that I could send a fix, or
intended behaviour.
> On Fri, 15 Oct 2021 14:20:33 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
>>> I think having one copy of that in a header is better than having 3
>>> copies. But yes, something along them lines.
>>
>> I was just about to ask you about this patch ;-)
>
> Except it doesn't build :-p (need to move the inlined function down a bit)
>
> diff --git a/include/linux/preempt.h b/include/linux/preempt.h
> index 4d244e295e85..b32e3dabe28b 100644
> --- a/include/linux/preempt.h
> +++ b/include/linux/preempt.h
> @@ -77,6 +77,27 @@
> /* preempt_count() and related functions, depends on PREEMPT_NEED_RESCHED */
> #include <asm/preempt.h>
>
> +/**
> + * interrupt_context_level - return interrupt context level
> + *
> + * Returns the current interrupt context level.
> + * 0 - normal context
> + * 1 - softirq context
> + * 2 - hardirq context
> + * 3 - NMI context
> + */
> +static __always_inline unsigned char interrupt_context_level(void)
> +{
> + unsigned long pc = preempt_count();
> + unsigned char level = 0;
> +
> + level += !!(pc & (NMI_MASK));
> + level += !!(pc & (NMI_MASK | HARDIRQ_MASK));
> + level += !!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET));
This doesn't take into account that we can switch the context manually
via local_bh_disable() / local_irq_save() etc. During the testing of the
separate issue[0], I've found that the function returns 1 in both just
softirq and softirq under local_irq_save().
Is this intended? Shouldn't that be
level += !!(pc & (NMI_MASK));
level += !!(pc * (NMI_MASK | HARDIRQ_MASK)) || irqs_disabled();
level += !!(pc * (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)) ||
in_atomic();
?
Otherwise, the result it returns is not really "context level".
> +
> + return level;
> +}
> +
[0]
https://lore.kernel.org/netdev/b3884ff9-d903-948d-797a-1830a39b1e71@intel.com
Thanks,
Olek
next prev parent reply other threads:[~2023-07-21 22:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 15:00 [PATCH] tracing: Have all levels of checks prevent recursion Steven Rostedt
2021-10-15 16:17 ` Peter Zijlstra
2021-10-15 17:35 ` Steven Rostedt
2021-10-15 17:58 ` Steven Rostedt
2021-10-15 18:04 ` Peter Zijlstra
2021-10-15 18:20 ` Steven Rostedt
2021-10-15 18:24 ` Peter Zijlstra
2021-10-15 19:00 ` Steven Rostedt
2021-10-15 18:25 ` Steven Rostedt
2023-07-21 15:34 ` Alexander Lobakin [this message]
2023-07-21 16:00 ` Steven Rostedt
2023-07-21 16:06 ` Alexander Lobakin
2023-07-21 16:26 ` Steven Rostedt
2023-07-22 1:22 ` Jakub Kicinski
2021-10-18 10:19 ` Petr Mladek
2021-10-18 13:50 ` Steven Rostedt
2021-10-18 15:09 ` Petr Mladek
2021-10-19 2:02 ` Steven Rostedt
2021-10-19 6:41 ` Petr Mladek
2021-10-19 13:00 ` Steven Rostedt
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=1b402c0c-1beb-d93f-ff6d-955350995ca3@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=aou@eecs.berkeley.edu \
--cc=bp@alien8.de \
--cc=colin.king@canonical.com \
--cc=deller@gmx.de \
--cc=guoren@kernel.org \
--cc=hpa@zytor.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@redhat.com \
--cc=jszhang@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yun.wang@linux.alibaba.com \
/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).