linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH 2/3] tracing: Use in_serving_softirq() to deduct softirq status.
Date: Wed, 13 Jan 2021 00:00:56 +0100	[thread overview]
Message-ID: <20210112230057.2374308-3-bigeasy@linutronix.de> (raw)
In-Reply-To: <20210112230057.2374308-1-bigeasy@linutronix.de>

PREEMPT_RT does not report "serving softirq" because the tracing core
looks at the preemption counter while PREEMPT_RT does not update it
while processing softirqs in order to remain preemptible. The
information is stored somewhere else.
The in_serving_softirq() macro and the SOFTIRQ_OFFSET define are still
working but not on the preempt-counter.

Use in_serving_softirq() macro which works on PREEMPT_RT. On !PREEMPT_RT
the compiler (gcc-10 / clang-11) is smart enough to optimize the
in_serving_softirq() related read of the preemption counter away.
The only difference I noticed by using in_serving_softirq() on
!PREEMPT_RT is that gcc-10 implemented tracing_gen_ctx_flags() as
reading FLAG, jmp _tracing_gen_ctx_flags(). Without in_serving_softirq()
it inlined _tracing_gen_ctx_flags() into tracing_gen_ctx_flags().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 kernel/trace/trace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 679112d3b3da9..416b63e05960e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2596,8 +2596,7 @@ unsigned int _tracing_gen_ctx_flags(unsigned long irqflags)
 		trace_flags |= TRACE_FLAG_NMI;
 	if (pc & HARDIRQ_MASK)
 		trace_flags |= TRACE_FLAG_HARDIRQ;
-
-	if (pc & SOFTIRQ_OFFSET)
+	if (in_serving_softirq())
 		trace_flags |= TRACE_FLAG_SOFTIRQ;
 
 	if (tif_need_resched())
-- 
2.30.0


  parent reply	other threads:[~2021-01-12 23:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 23:00 [PATCH 0/3] tracing: Merge irqflags + preempt counter Sebastian Andrzej Siewior
2021-01-12 23:00 ` [PATCH 1/3] " Sebastian Andrzej Siewior
2021-01-22 22:07   ` Steven Rostedt
2021-01-25 14:05     ` Sebastian Andrzej Siewior
2021-01-25 19:03       ` Steven Rostedt
2021-01-25 19:45         ` [PATCH 0/4 v2] " Sebastian Andrzej Siewior
2021-01-25 19:45           ` [PATCH 1/4] " Sebastian Andrzej Siewior
2021-01-25 19:45           ` [PATCH 2/4] tracing: Inline tracing_gen_ctx_flags() Sebastian Andrzej Siewior
2021-01-25 19:45           ` [PATCH 3/4] tracing: Use in_serving_softirq() to deduct softirq status Sebastian Andrzej Siewior
2021-01-25 19:45           ` [PATCH 4/4] tracing: Remove NULL check from current in tracing_generic_entry_update() Sebastian Andrzej Siewior
2021-02-01 18:23           ` [PATCH 0/4 v2] tracing: Merge irqflags + preempt counter Sebastian Andrzej Siewior
2021-02-01 18:32             ` Steven Rostedt
2021-02-01 18:34               ` Sebastian Andrzej Siewior
2021-01-25 19:52         ` [PATCH 1/3] " Sebastian Andrzej Siewior
2021-01-25 19:55           ` Steven Rostedt
2021-01-12 23:00 ` Sebastian Andrzej Siewior [this message]
2021-01-22 22:11   ` [PATCH 2/3] tracing: Use in_serving_softirq() to deduct softirq status Steven Rostedt
2021-01-12 23:00 ` [PATCH 3/3] tracing: Remove NULL check from current in tracing_generic_entry_update() Sebastian Andrzej Siewior
2021-01-22 22:12   ` Steven Rostedt
2021-01-22 22:16     ` 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=20210112230057.2374308-3-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.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).