* [PATCH] locking/lockdep: Fix UBSAN warnings
@ 2019-06-12 5:49 Kobe Wu
[not found] ` <1560318544-27635-1-git-send-email-kobe-cp.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Kobe Wu @ 2019-06-12 5:49 UTC (permalink / raw
To: Peter Zijlstra, Ingo Molnar, Will Deacon
Cc: Eason Lin, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
wsd_upstream-NuS5LvNUpcJWk0Htik3J/w, Kobe Wu
Fix complaints from UBSAN about signed integer overflow.
========================================================================
UBSAN: Undefined behaviour in kernel/locking/lockdep.c:2998:3
signed integer overflow:
2147483647 + 1 cannot be represented in type 'int'
Call trace:
dump_backtrace+0x0/0x470
show_stack+0x14/0x20
dump_stack+0xc8/0x11c
ubsan_epilogue+0x14/0xa8
handle_overflow+0x138/0x1a8
__ubsan_handle_add_overflow+0x10/0x18
trace_hardirqs_off_caller+0x1a0/0x268
trace_hardirqs_off+0x1c/0x28
rcu_irq_enter_irqson+0x18/0x50
handle_IPI+0x4cc/0x898
gic_handle_irq+0x1f4/0x240
When system has been running for a long time, signed integer counters
are not enough for some lockdep statistics. Such as the warning above,
it occurs at debug_atomic_inc(hardirqs_off_events). Using unsigned long
counters can satisfy the requirement. Besides, most of other lockdep
statistics are unsigned. It is better to use unsigned int instead of int.
Remove unused variables.
- max_recursion_depth
- nr_cyclic_check_recursions
- nr_find_usage_forwards_recursions
- nr_find_usage_backwards_recursions
Signed-off-by: Kobe Wu <kobe-cp.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
kernel/locking/lockdep_internals.h | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h
index 150ec3f..cc83568 100644
--- a/kernel/locking/lockdep_internals.h
+++ b/kernel/locking/lockdep_internals.h
@@ -131,7 +131,6 @@ extern void get_usage_chars(struct lock_class *class,
extern unsigned int nr_softirq_chains;
extern unsigned int nr_process_chains;
extern unsigned int max_lockdep_depth;
-extern unsigned int max_recursion_depth;
extern unsigned int max_bfs_queue_depth;
@@ -160,25 +159,22 @@ extern void get_usage_chars(struct lock_class *class,
* and we want to avoid too much cache bouncing.
*/
struct lockdep_stats {
- int chain_lookup_hits;
- int chain_lookup_misses;
- int hardirqs_on_events;
- int hardirqs_off_events;
- int redundant_hardirqs_on;
- int redundant_hardirqs_off;
- int softirqs_on_events;
- int softirqs_off_events;
- int redundant_softirqs_on;
- int redundant_softirqs_off;
- int nr_unused_locks;
- int nr_redundant_checks;
- int nr_redundant;
- int nr_cyclic_checks;
- int nr_cyclic_check_recursions;
- int nr_find_usage_forwards_checks;
- int nr_find_usage_forwards_recursions;
- int nr_find_usage_backwards_checks;
- int nr_find_usage_backwards_recursions;
+ unsigned long chain_lookup_hits;
+ unsigned int chain_lookup_misses;
+ unsigned long hardirqs_on_events;
+ unsigned long hardirqs_off_events;
+ unsigned long redundant_hardirqs_on;
+ unsigned long redundant_hardirqs_off;
+ unsigned long softirqs_on_events;
+ unsigned long softirqs_off_events;
+ unsigned long redundant_softirqs_on;
+ unsigned long redundant_softirqs_off;
+ int nr_unused_locks;
+ unsigned int nr_redundant_checks;
+ unsigned int nr_redundant;
+ unsigned int nr_cyclic_checks;
+ unsigned int nr_find_usage_forwards_checks;
+ unsigned int nr_find_usage_backwards_checks;
/*
* Per lock class locking operation stat counts
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] locking/lockdep: Fix UBSAN warnings
[not found] ` <1560318544-27635-1-git-send-email-kobe-cp.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
@ 2019-06-12 7:34 ` Peter Zijlstra
[not found] ` <20190612073425.GD3436-Nxj+rRp3nVydTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2019-06-12 7:34 UTC (permalink / raw
To: Kobe Wu
Cc: linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Ingo Molnar,
Will Deacon, wsd_upstream-NuS5LvNUpcJWk0Htik3J/w, Eason Lin
On Wed, Jun 12, 2019 at 01:49:04PM +0800, Kobe Wu wrote:
> Fix complaints from UBSAN about signed integer overflow.
>
> ========================================================================
> UBSAN: Undefined behaviour in kernel/locking/lockdep.c:2998:3
> signed integer overflow:
I don't mind the patch, but this is an UBSAN bug and cannot therefore be
a reason.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] locking/lockdep: Fix UBSAN warnings
[not found] ` <20190612073425.GD3436-Nxj+rRp3nVydTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
@ 2019-06-12 12:35 ` Kobe-CP Wu
0 siblings, 0 replies; 3+ messages in thread
From: Kobe-CP Wu @ 2019-06-12 12:35 UTC (permalink / raw
To: Peter Zijlstra
Cc: linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Ingo Molnar,
Will Deacon, wsd_upstream-NuS5LvNUpcJWk0Htik3J/w, Eason Lin
On Wed, 2019-06-12 at 09:34 +0200, Peter Zijlstra wrote:
> On Wed, Jun 12, 2019 at 01:49:04PM +0800, Kobe Wu wrote:
> > Fix complaints from UBSAN about signed integer overflow.
> >
> > ========================================================================
> > UBSAN: Undefined behaviour in kernel/locking/lockdep.c:2998:3
> > signed integer overflow:
>
> I don't mind the patch, but this is an UBSAN bug and cannot therefore be
> a reason.
I think the description could be amended as follows.
There is unnecessary to mention the UBSAN bug.
locking/lockdep: add size of counters for lockdep statistics
When system has been running for a long time, signed integer counters
are not enough for some lockdep statistics. Using unsigned long counters
can satisfy the requirement. Besides, most of lockdep statistics are
unsigned. It is better to use unsigned int instead of int.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-12 12:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-12 5:49 [PATCH] locking/lockdep: Fix UBSAN warnings Kobe Wu
[not found] ` <1560318544-27635-1-git-send-email-kobe-cp.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-06-12 7:34 ` Peter Zijlstra
[not found] ` <20190612073425.GD3436-Nxj+rRp3nVydTX5a5knrm8zTDFooKrT+cvkQGrU6aU0@public.gmane.org>
2019-06-12 12:35 ` Kobe-CP Wu
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.