All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 1/6] softirq: reorder trace_softirqs_on to prevent lockdep splat
       [not found] <20180515224559.199279-1-joel@joelfernandes.org>
@ 2018-05-15 22:45 ` Joel Fernandes (Google)
  2018-05-15 23:19   ` Joel Fernandes
  2018-05-15 22:45 ` [PATCH v7 2/6] srcu: Add notrace variants of srcu_read_{lock,unlock} Joel Fernandes (Google)
  2018-05-15 22:45 ` [PATCH v7 4/6] trace/irqsoff: Split reset into separate functions Joel Fernandes (Google)
  2 siblings, 1 reply; 5+ messages in thread
From: Joel Fernandes (Google) @ 2018-05-15 22:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Joel Fernandes (Google)

I'm able to reproduce a lockdep splat with config options:
CONFIG_PROVE_LOCKING=y,
CONFIG_DEBUG_LOCK_ALLOC=y and
CONFIG_PREEMPTIRQ_EVENTS=y

$ echo 1 > /d/tracing/events/preemptirq/preempt_enable/enable
---
 kernel/softirq.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 177de3640c78..8a040bcaa033 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -139,9 +139,13 @@ static void __local_bh_enable(unsigned int cnt)
 {
 	lockdep_assert_irqs_disabled();
 
+	if (preempt_count() == cnt)
+		trace_preempt_on(CALLER_ADDR0, get_lock_parent_ip());
+
 	if (softirq_count() == (cnt & SOFTIRQ_MASK))
 		trace_softirqs_on(_RET_IP_);
-	preempt_count_sub(cnt);
+
+	__preempt_count_sub(cnt);
 }
 
 /*
-- 
2.17.0.441.gb46fe60e1d-goog

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v7 2/6] srcu: Add notrace variants of srcu_read_{lock,unlock}
       [not found] <20180515224559.199279-1-joel@joelfernandes.org>
  2018-05-15 22:45 ` [PATCH v7 1/6] softirq: reorder trace_softirqs_on to prevent lockdep splat Joel Fernandes (Google)
@ 2018-05-15 22:45 ` Joel Fernandes (Google)
  2018-05-15 23:56   ` Joel Fernandes
  2018-05-15 22:45 ` [PATCH v7 4/6] trace/irqsoff: Split reset into separate functions Joel Fernandes (Google)
  2 siblings, 1 reply; 5+ messages in thread
From: Joel Fernandes (Google) @ 2018-05-15 22:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Paul McKenney, Steven Rostedt, Peter Zilstra, Ingo Molnar,
	Mathieu Desnoyers, Tom Zanussi, Namhyung Kim, Thomas Glexiner,
	Boqun Feng, Frederic Weisbecker, Randy Dunlap, Masami Hiramatsu,
	Fenguang Wu, Baohong Liu, Vedang Patel, kernel-team,
	Joel Fernandes

From: Paul McKenney <paulmck@linux.vnet.ibm.com>

This is needed for a future tracepoint patch that uses srcu, and to make
sure it doesn't call into lockdep.

tracepoint code already calls notrace variants for rcu_read_lock_sched
so this patch does the same for srcu which will be used in a later
patch. Keeps it consistent with rcu-sched.

[Joel: Added commit message]

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zilstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Glexiner <tglx@linutronix.de>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Fenguang Wu <fengguang.wu@intel.com>
Cc: Baohong Liu <baohong.liu@intel.com>
Cc: Vedang Patel <vedang.patel@intel.com>
Cc: kernel-team@android.com
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Paul McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
 include/linux/srcu.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 33c1c698df09..2ec618979b20 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -161,6 +161,16 @@ static inline int srcu_read_lock(struct srcu_struct *sp) __acquires(sp)
 	return retval;
 }
 
+/* Used by tracing, cannot be traced and cannot invoke lockdep. */
+static inline notrace int
+srcu_read_lock_notrace(struct srcu_struct *sp) __acquires(sp)
+{
+	int retval;
+
+	retval = __srcu_read_lock(sp);
+	return retval;
+}
+
 /**
  * srcu_read_unlock - unregister a old reader from an SRCU-protected structure.
  * @sp: srcu_struct in which to unregister the old reader.
@@ -175,6 +185,13 @@ static inline void srcu_read_unlock(struct srcu_struct *sp, int idx)
 	__srcu_read_unlock(sp, idx);
 }
 
+/* Used by tracing, cannot be traced and cannot call lockdep. */
+static inline notrace void
+srcu_read_unlock_notrace(struct srcu_struct *sp, int idx) __releases(sp)
+{
+	__srcu_read_unlock(sp, idx);
+}
+
 /**
  * smp_mb__after_srcu_read_unlock - ensure full ordering after srcu_read_unlock
  *
-- 
2.17.0.441.gb46fe60e1d-goog

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v7 4/6] trace/irqsoff: Split reset into separate functions
       [not found] <20180515224559.199279-1-joel@joelfernandes.org>
  2018-05-15 22:45 ` [PATCH v7 1/6] softirq: reorder trace_softirqs_on to prevent lockdep splat Joel Fernandes (Google)
  2018-05-15 22:45 ` [PATCH v7 2/6] srcu: Add notrace variants of srcu_read_{lock,unlock} Joel Fernandes (Google)
@ 2018-05-15 22:45 ` Joel Fernandes (Google)
  2 siblings, 0 replies; 5+ messages in thread
From: Joel Fernandes (Google) @ 2018-05-15 22:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joel Fernandes (Google),
	Steven Rostedt, Peter Zilstra, Ingo Molnar, Mathieu Desnoyers,
	Tom Zanussi, Namhyung Kim, Thomas Glexiner, Boqun Feng,
	Paul McKenney, Frederic Weisbecker, Randy Dunlap,
	Masami Hiramatsu, Fenguang Wu, Baohong Liu, Vedang Patel,
	kernel-team

Split reset functions into seperate functions in preparation
of future patches that need to do tracer specific reset.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zilstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Glexiner <tglx@linutronix.de>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Fenguang Wu <fengguang.wu@intel.com>
Cc: Baohong Liu <baohong.liu@intel.com>
Cc: Vedang Patel <vedang.patel@intel.com>
Cc: kernel-team@android.com
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
 kernel/trace/trace_irqsoff.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 03ecb4465ee4..f8daa754cce2 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -634,7 +634,7 @@ static int __irqsoff_tracer_init(struct trace_array *tr)
 	return 0;
 }
 
-static void irqsoff_tracer_reset(struct trace_array *tr)
+static void __irqsoff_tracer_reset(struct trace_array *tr)
 {
 	int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
 	int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
@@ -665,6 +665,12 @@ static int irqsoff_tracer_init(struct trace_array *tr)
 
 	return __irqsoff_tracer_init(tr);
 }
+
+static void irqsoff_tracer_reset(struct trace_array *tr)
+{
+	__irqsoff_tracer_reset(tr);
+}
+
 static struct tracer irqsoff_tracer __read_mostly =
 {
 	.name		= "irqsoff",
@@ -697,11 +703,16 @@ static int preemptoff_tracer_init(struct trace_array *tr)
 	return __irqsoff_tracer_init(tr);
 }
 
+static void preemptoff_tracer_reset(struct trace_array *tr)
+{
+	__irqsoff_tracer_reset(tr);
+}
+
 static struct tracer preemptoff_tracer __read_mostly =
 {
 	.name		= "preemptoff",
 	.init		= preemptoff_tracer_init,
-	.reset		= irqsoff_tracer_reset,
+	.reset		= preemptoff_tracer_reset,
 	.start		= irqsoff_tracer_start,
 	.stop		= irqsoff_tracer_stop,
 	.print_max	= true,
@@ -731,11 +742,16 @@ static int preemptirqsoff_tracer_init(struct trace_array *tr)
 	return __irqsoff_tracer_init(tr);
 }
 
+static void preemptirqsoff_tracer_reset(struct trace_array *tr)
+{
+	__irqsoff_tracer_reset(tr);
+}
+
 static struct tracer preemptirqsoff_tracer __read_mostly =
 {
 	.name		= "preemptirqsoff",
 	.init		= preemptirqsoff_tracer_init,
-	.reset		= irqsoff_tracer_reset,
+	.reset		= preemptirqsoff_tracer_reset,
 	.start		= irqsoff_tracer_start,
 	.stop		= irqsoff_tracer_stop,
 	.print_max	= true,
-- 
2.17.0.441.gb46fe60e1d-goog

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v7 1/6] softirq: reorder trace_softirqs_on to prevent lockdep splat
  2018-05-15 22:45 ` [PATCH v7 1/6] softirq: reorder trace_softirqs_on to prevent lockdep splat Joel Fernandes (Google)
@ 2018-05-15 23:19   ` Joel Fernandes
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Fernandes @ 2018-05-15 23:19 UTC (permalink / raw)
  To: linux-kernel

This patch submission got completely screwed up, sorry, please ignore. I'll
repost soon. There's something messed up with my SMTP server too.

On Tue, May 15, 2018 at 03:45:54PM -0700, Joel Fernandes (Google) wrote:
> I'm able to reproduce a lockdep splat with config options:
> CONFIG_PROVE_LOCKING=y,
> CONFIG_DEBUG_LOCK_ALLOC=y and
> CONFIG_PREEMPTIRQ_EVENTS=y
> 
> $ echo 1 > /d/tracing/events/preemptirq/preempt_enable/enable
> ---
>  kernel/softirq.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/softirq.c b/kernel/softirq.c
> index 177de3640c78..8a040bcaa033 100644
> --- a/kernel/softirq.c
> +++ b/kernel/softirq.c
> @@ -139,9 +139,13 @@ static void __local_bh_enable(unsigned int cnt)
>  {
>  	lockdep_assert_irqs_disabled();
>  
> +	if (preempt_count() == cnt)
> +		trace_preempt_on(CALLER_ADDR0, get_lock_parent_ip());
> +
>  	if (softirq_count() == (cnt & SOFTIRQ_MASK))
>  		trace_softirqs_on(_RET_IP_);
> -	preempt_count_sub(cnt);
> +
> +	__preempt_count_sub(cnt);
>  }
>  
>  /*
> -- 
> 2.17.0.441.gb46fe60e1d-goog
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v7 2/6] srcu: Add notrace variants of srcu_read_{lock,unlock}
  2018-05-15 22:45 ` [PATCH v7 2/6] srcu: Add notrace variants of srcu_read_{lock,unlock} Joel Fernandes (Google)
@ 2018-05-15 23:56   ` Joel Fernandes
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Fernandes @ 2018-05-15 23:56 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Linux Kernel Mailing List, Paul McKenney, Steven Rostedt,
	Peter Zijlstra, Ingo Molnar, Mathieu Desnoyers, Tom Zanussi,
	Namhyung Kim, Thomas Gleixner, Boqun Feng, Frederic Weisbecker,
	Randy Dunlap, Masami Hiramatsu, Fenguang Wu, Baohong Liu,
	Vedang Patel, kernel-team

Something is majorly messed up with my SMTP server. Only half of the patches
in this series were sent out and the ones that did go out were random.

I keeping getting this as replies for the one's that didn't go out:
https://support.google.com/mail/answer/6596?visit_id=1-636620224226493206-2884214369&rd=1

And its intermittent too.. I am going to spend a bit of time to figure out
why it happened so it doesn't happen again. Sorry about the noise.

Sigh,

- Joel

On Tue, May 15, 2018 at 3:47 PM Joel Fernandes (Google) <
joel@joelfernandes.org> wrote:

> From: Paul McKenney <paulmck@linux.vnet.ibm.com>

> This is needed for a future tracepoint patch that uses srcu, and to make
> sure it doesn't call into lockdep.

> tracepoint code already calls notrace variants for rcu_read_lock_sched
> so this patch does the same for srcu which will be used in a later
> patch. Keeps it consistent with rcu-sched.

> [Joel: Added commit message]

> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Peter Zilstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Thomas Glexiner <tglx@linutronix.de>
> Cc: Boqun Feng <boqun.feng@gmail.com>
> Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Fenguang Wu <fengguang.wu@intel.com>
> Cc: Baohong Liu <baohong.liu@intel.com>
> Cc: Vedang Patel <vedang.patel@intel.com>
> Cc: kernel-team@android.com
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Signed-off-by: Paul McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> ---
>   include/linux/srcu.h | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)

> diff --git a/include/linux/srcu.h b/include/linux/srcu.h
> index 33c1c698df09..2ec618979b20 100644
> --- a/include/linux/srcu.h
> +++ b/include/linux/srcu.h
> @@ -161,6 +161,16 @@ static inline int srcu_read_lock(struct srcu_struct
*sp) __acquires(sp)
>          return retval;
>   }

> +/* Used by tracing, cannot be traced and cannot invoke lockdep. */
> +static inline notrace int
> +srcu_read_lock_notrace(struct srcu_struct *sp) __acquires(sp)
> +{
> +       int retval;
> +
> +       retval = __srcu_read_lock(sp);
> +       return retval;
> +}
> +
>   /**
>    * srcu_read_unlock - unregister a old reader from an SRCU-protected
structure.
>    * @sp: srcu_struct in which to unregister the old reader.
> @@ -175,6 +185,13 @@ static inline void srcu_read_unlock(struct
srcu_struct *sp, int idx)
>          __srcu_read_unlock(sp, idx);
>   }

> +/* Used by tracing, cannot be traced and cannot call lockdep. */
> +static inline notrace void
> +srcu_read_unlock_notrace(struct srcu_struct *sp, int idx) __releases(sp)
> +{
> +       __srcu_read_unlock(sp, idx);
> +}
> +
>   /**
>    * smp_mb__after_srcu_read_unlock - ensure full ordering after
srcu_read_unlock
>    *
> --
> 2.17.0.441.gb46fe60e1d-goog

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-15 23:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20180515224559.199279-1-joel@joelfernandes.org>
2018-05-15 22:45 ` [PATCH v7 1/6] softirq: reorder trace_softirqs_on to prevent lockdep splat Joel Fernandes (Google)
2018-05-15 23:19   ` Joel Fernandes
2018-05-15 22:45 ` [PATCH v7 2/6] srcu: Add notrace variants of srcu_read_{lock,unlock} Joel Fernandes (Google)
2018-05-15 23:56   ` Joel Fernandes
2018-05-15 22:45 ` [PATCH v7 4/6] trace/irqsoff: Split reset into separate functions Joel Fernandes (Google)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.