Re: [patch V3 00/29] stacktrace: Consolidate stack trace usage

2019-04-25 Thread Josh Poimboeuf
On Thu, Apr 25, 2019 at 11:44:53AM +0200, Thomas Gleixner wrote:
> This is an update to V2 which can be found here:
> 
>   https://lkml.kernel.org/r/20190418084119.056416...@linutronix.de
> 
> Changes vs. V2:
> 
>   - Fixed the kernel-doc issue pointed out by Mike
> 
>   - Removed the '-1' oddity from the tracer
> 
>   - Restricted the tracer nesting to 4
> 
>   - Restored the lockdep magic to prevent redundant stack traces
> 
>   - Addressed the small nitpicks here and there
> 
>   - Picked up Acked/Reviewed tags

Other than the 2 minor nits:

Reviewed-by: Josh Poimboeuf 

-- 
Josh
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Re: [patch V3 00/29] stacktrace: Consolidate stack trace usage

2019-04-25 Thread Ingo Molnar


* Thomas Gleixner  wrote:

> - if (unlikely(!ret))
> + if (unlikely(!ret)) {
> + if (!trace->nr_entries) {
> + /*
> +  * If save_trace fails here, the printing might
> +  * trigger a WARN but because of the !nr_entries it
> +  * should not do bad things.
> +  */
> + save_trace(trace);
> + }
>   return print_circular_bug(, target_entry, next, prev);
> + }
>   else if (unlikely(ret < 0))
>   return print_bfs_bug(ret);

Just a minor style nit: the 'else' should probably on the same line as 
the '}' it belongs to, to make it really obvious that the 'if' has an 
'else' branch?

At that point the condition should probably also use balanced curly 
braces.

Interdiff looks good otherwise.

Thanks,

Ingo
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


[patch V3 00/29] stacktrace: Consolidate stack trace usage

2019-04-25 Thread Thomas Gleixner
This is an update to V2 which can be found here:

  https://lkml.kernel.org/r/20190418084119.056416...@linutronix.de

Changes vs. V2:

  - Fixed the kernel-doc issue pointed out by Mike

  - Removed the '-1' oddity from the tracer

  - Restricted the tracer nesting to 4

  - Restored the lockdep magic to prevent redundant stack traces

  - Addressed the small nitpicks here and there

  - Picked up Acked/Reviewed tags

The series is based on:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core/stacktrace

which contains the removal of the inconsistent and pointless ULONG_MAX
termination of stacktraces.

It's also available from git:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.core/stacktrace

   up to 5160eb663575 ("x86/stacktrace: Use common infrastructure")

Delta patch vs. v2 below.

Thanks,

tglx

8<-
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index 654949dc1c16..f0cfd12cb45e 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -32,14 +32,13 @@ unsigned int stack_trace_save_user(unsigned long *store, 
unsigned int size);
  * @reliable:  True when the stack entry is reliable. Required by
  * some printk based consumers.
  *
- * Returns:True, if the entry was consumed or skipped
+ * Return: True, if the entry was consumed or skipped
  * False, if there is no space left to store
  */
 typedef bool (*stack_trace_consume_fn)(void *cookie, unsigned long addr,
   bool reliable);
 /**
  * arch_stack_walk - Architecture specific function to walk the stack
-
  * @consume_entry: Callback which is invoked by the architecture code for
  * each entry.
  * @cookie:Caller supplied pointer which is handed back to
@@ -47,10 +46,12 @@ typedef bool (*stack_trace_consume_fn)(void *cookie, 
unsigned long addr,
  * @task:  Pointer to a task struct, can be NULL
  * @regs:  Pointer to registers, can be NULL
  *
- * @task   @regs:
- * NULLNULLStack trace from current
+ *  === 
+ * taskregs
+ *  === 
  * taskNULLStack trace from task (can be current)
- * NULLregsStack trace starting on regs->stackpointer
+ * current regsStack trace starting on regs->stackpointer
+ *  === 
  */
 void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
 struct task_struct *task, struct pt_regs *regs);
diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index 1e8e246edaad..badd77670d00 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -705,7 +705,8 @@ static struct dma_debug_entry *dma_entry_alloc(void)
 
 #ifdef CONFIG_STACKTRACE
entry->stack_len = stack_trace_save(entry->stack_entries,
-   ARRAY_SIZE(entry->stack_entries), 
1);
+   ARRAY_SIZE(entry->stack_entries),
+   1);
 #endif
return entry;
 }
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 84423f0bb0b0..45bcaf2e4cb6 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2160,12 +2160,11 @@ check_deadlock(struct task_struct *curr, struct 
held_lock *next,
  */
 static int
 check_prev_add(struct task_struct *curr, struct held_lock *prev,
-  struct held_lock *next, int distance)
+  struct held_lock *next, int distance, struct lock_trace *trace)
 {
struct lock_list *uninitialized_var(target_entry);
struct lock_list *entry;
struct lock_list this;
-   struct lock_trace trace;
int ret;
 
if (!hlock_class(prev)->key || !hlock_class(next)->key) {
@@ -2198,8 +2197,17 @@ check_prev_add(struct task_struct *curr, struct 
held_lock *prev,
this.class = hlock_class(next);
this.parent = NULL;
ret = check_noncircular(, hlock_class(prev), _entry);
-   if (unlikely(!ret))
+   if (unlikely(!ret)) {
+   if (!trace->nr_entries) {
+   /*
+* If save_trace fails here, the printing might
+* trigger a WARN but because of the !nr_entries it
+* should not do bad things.
+*/
+   save_trace(trace);
+   }
return print_circular_bug(, target_entry, next, prev);
+   }
else if (unlikely(ret < 0))
return print_bfs_bug(ret);
 
@@ -2246,7 +2254,7 @@ check_prev_add(struct task_struct *curr, struct held_lock 
*prev,
return print_bfs_bug(ret);
 
 
-   if (!save_trace())
+   if (!trace->nr_entries &&