Re: [RFC] tracing: Improve design of preemptirq tracepoints and its users

2018-02-06 Thread Steven Rostedt
On Mon, 5 Feb 2018 23:15:32 -0800
Joel Fernandes  wrote:

> On Mon, Feb 5, 2018 at 6:39 PM, Joel Fernandes  wrote:
> > This patch detaches the preemptirq tracepoints from the tracers and
> > keeps it separate. With this, several ifdefs are cleaner, and lockdep
> > and other users can use the preemptirq tracepoints by registering probes
> > onto them. This makes it much cleaner, but not just that: PROVE_LOCKING
> > and CONFIG_IRQSOFF_TRACER can be enabled now at the same time and we
> > get rid of all the horrific ifdeferry around PROVE_LOCKING.
> >  
> 
> Sorry for the misstatement, irqsoff tracer and PROVE_LOCKING can still
> be used at the same time (without this patch). I will correct the
> commit message in the next rev. However this patch avoids the
> complication that arises when enabling the 2 together, by eliminating
> time_hardirqs_on/off.
> 

Hi Joel,

This looks nice, but I currently don't have time to look at it. Please
ping me again if you don't hear from me by beginning of next week.

-- Steve


Re: [RFC] tracing: Improve design of preemptirq tracepoints and its users

2018-02-05 Thread Joel Fernandes
On Mon, Feb 5, 2018 at 6:39 PM, Joel Fernandes  wrote:
> This patch detaches the preemptirq tracepoints from the tracers and
> keeps it separate. With this, several ifdefs are cleaner, and lockdep
> and other users can use the preemptirq tracepoints by registering probes
> onto them. This makes it much cleaner, but not just that: PROVE_LOCKING
> and CONFIG_IRQSOFF_TRACER can be enabled now at the same time and we
> get rid of all the horrific ifdeferry around PROVE_LOCKING.
>

Sorry for the misstatement, irqsoff tracer and PROVE_LOCKING can still
be used at the same time (without this patch). I will correct the
commit message in the next rev. However this patch avoids the
complication that arises when enabling the 2 together, by eliminating
time_hardirqs_on/off.

thanks,

- Joel


[RFC] tracing: Improve design of preemptirq tracepoints and its users

2018-02-05 Thread Joel Fernandes
This patch detaches the preemptirq tracepoints from the tracers and
keeps it separate. With this, several ifdefs are cleaner, and lockdep
and other users can use the preemptirq tracepoints by registering probes
onto them. This makes it much cleaner, but not just that: PROVE_LOCKING
and CONFIG_IRQSOFF_TRACER can be enabled now at the same time and we
get rid of all the horrific ifdeferry around PROVE_LOCKING.

In the patch we introduce a new CONFIG option PREEMPTIRQ_TRACEPOINTS
as a single point for registering probes onto the tracepoints. With this,
the web of config options for preempt/irq toggle tracepoints and its
users becomes:

 PREEMPT_TRACER   PREEMPTIRQ_EVENTS  IRQSOFF_TRACER PROVE_LOCKING
   | | \ |   |
   \(selects)/  \\ (selects) /
  TRACE_PREEMPT_TOGGLE   > TRACE_IRQFLAGS
  \  /
   \ (depends on)   /
 PREEMPTIRQ_TRACEPOINTS

Three user's of the tracepoints exist after this: lockdep, the
preemptirq tracers and preemptirq trace events. I did sanity testing on
all of these to see expected results.

Cc: Steven Rostedt 
Cc: Peter Zilstra 
Cc: Ingo Molnar 
Cc: Mathieu Desnoyers 
Cc: Tom Zanussi 
Cc: Namhyung Kim 
Cc: kernel-t...@android.com
Signed-off-by: Joel Fernandes 
---
 include/linux/ftrace.h|  11 +-
 include/linux/irqflags.h  |  11 +-
 include/linux/lockdep.h   |   6 +-
 include/linux/preempt.h   |   2 +-
 include/trace/events/preemptirq.h |  23 +++--
 init/main.c   |   2 +-
 kernel/locking/lockdep.c  |  30 ++
 kernel/sched/core.c   |   2 +-
 kernel/trace/Kconfig  |  19 +++-
 kernel/trace/Makefile |   2 +-
 kernel/trace/trace_irqsoff.c  | 206 +-
 kernel/trace/trace_preemptirq.c   |  70 +
 12 files changed, 169 insertions(+), 215 deletions(-)
 create mode 100644 kernel/trace/trace_preemptirq.c

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 3319df9727aa..7488ada6e4e3 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -709,16 +709,7 @@ static inline unsigned long get_lock_parent_ip(void)
return CALLER_ADDR2;
 }
 
-#ifdef CONFIG_IRQSOFF_TRACER
-  extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
-  extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
-#else
-  static inline void time_hardirqs_on(unsigned long a0, unsigned long a1) { }
-  static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
-#endif
-
-#if defined(CONFIG_PREEMPT_TRACER) || \
-   (defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_PREEMPTIRQ_EVENTS))
+#ifdef CONFIG_TRACE_PREEMPT_TOGGLE
   extern void trace_preempt_on(unsigned long a0, unsigned long a1);
   extern void trace_preempt_off(unsigned long a0, unsigned long a1);
 #else
diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
index 1b3996ff3f16..9d72181d4a94 100644
--- a/include/linux/irqflags.h
+++ b/include/linux/irqflags.h
@@ -15,9 +15,16 @@
 #include 
 #include 
 
-#ifdef CONFIG_TRACE_IRQFLAGS
+/* Currently trace_softirqs_on/off is used only by lockdep */
+#ifdef CONFIG_PROVE_LOCKING
   extern void trace_softirqs_on(unsigned long ip);
   extern void trace_softirqs_off(unsigned long ip);
+#else
+# define trace_softirqs_on(ip) do { } while (0)
+# define trace_softirqs_off(ip)do { } while (0)
+#endif
+
+#ifdef CONFIG_TRACE_IRQFLAGS
   extern void trace_hardirqs_on(void);
   extern void trace_hardirqs_off(void);
 # define trace_hardirq_context(p)  ((p)->hardirq_context)
@@ -44,8 +51,6 @@ do {  \
 #else
 # define trace_hardirqs_on()   do { } while (0)
 # define trace_hardirqs_off()  do { } while (0)
-# define trace_softirqs_on(ip) do { } while (0)
-# define trace_softirqs_off(ip)do { } while (0)
 # define trace_hardirq_context(p)  0
 # define trace_softirq_context(p)  0
 # define trace_hardirqs_enabled(p) 0
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 3251d9c0d313..1a6dcc95bba8 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -266,7 +266,7 @@ struct held_lock {
 /*
  * Initialization, self-test and debugging-output methods:
  */
-extern void lockdep_info(void);
+extern void lockdep_init(void);
 extern void lockdep_reset(void);
 extern void lockdep_reset_lock(struct lockdep_map *lock);
 extern void lockdep_free_key_range(void *start, unsigned long size);
@@ -408,7 +408,7 @@ static inline void lockdep_on(void)
 # define lock_downgrade(l, i)  do { } while (0)
 # define lock_set_class(l, n, k, s, i) do { } while (0)
 # define lock_set_subclass(l, s, i)do { } while (0)
-# define lockdep_info()do { } while (0)
+# define lockdep_init()