Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1422317 > unrolled thread
| Started by | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| First post | 2016-06-14 22:50 +0200 |
| Last post | 2016-06-14 23:40 +0200 |
| Articles | 9 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/7] Fixes for liblockdep Ben Hutchings <ben@decadent.org.uk> - 2016-06-14 22:50 +0200
[PATCH 3/7] liblockdep: Define the ARRAY_SIZE() macro Ben Hutchings <ben@decadent.org.uk> - 2016-06-14 22:50 +0200
[PATCH 5/7] liblockdep: Fix 'unused value' warnings Ben Hutchings <ben@decadent.org.uk> - 2016-06-14 22:50 +0200
[PATCH 4/7] liblockdep: Enable -Wall by default Ben Hutchings <ben@decadent.org.uk> - 2016-06-14 22:50 +0200
[PATCH 1/7] liblockdep: Fix undefined symbol prandom_u32 Ben Hutchings <ben@decadent.org.uk> - 2016-06-14 22:50 +0200
Re: [PATCH 1/7] liblockdep: Fix undefined symbol prandom_u32 Sasha Levin <sasha.levin@oracle.com> - 2016-06-14 23:40 +0200
[PATCH 2/7] liblockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain::depth Ben Hutchings <ben@decadent.org.uk> - 2016-06-14 22:50 +0200
Re: [PATCH 2/7] liblockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain::depth Peter Zijlstra <peterz@infradead.org> - 2016-06-14 23:20 +0200
Re: [PATCH 0/7] Fixes for liblockdep Sasha Levin <sasha.levin@oracle.com> - 2016-06-14 23:40 +0200
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2016-06-14 22:50 +0200 |
| Subject | [PATCH 0/7] Fixes for liblockdep |
| Message-ID | <rK3rz-1nX-3@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
Here are a number of fixes for liblockdep. The first three need to
go into 4.7 and 4.6-stable; the second should probably go to all
stable branches.
Ben.
Ben Hutchings (7):
liblockdep: Fix undefined symbol prandom_u32
liblockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing
lock_chain::depth
liblockdep: Define the ARRAY_SIZE() macro
liblockdep: Enable -Wall by default
liblockdep: Fix 'unused value' warnings
liblockdep: Fix 'set but not used' warnings
liblockdep: Fix 'defined but not used' warning for init_utsname()
tools/lib/lockdep/Makefile | 1 +
tools/lib/lockdep/common.c | 6 ++++++
tools/lib/lockdep/lockdep.c | 10 ++++++++++
tools/lib/lockdep/uinclude/linux/debug_locks.h | 2 +-
tools/lib/lockdep/uinclude/linux/irqflags.h | 8 ++++----
tools/lib/lockdep/uinclude/linux/kernel.h | 14 +++++++++++---
tools/lib/lockdep/uinclude/linux/lockdep.h | 18 ++++++------------
7 files changed, 39 insertions(+), 20 deletions(-)
[toc] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2016-06-14 22:50 +0200 |
| Subject | [PATCH 3/7] liblockdep: Define the ARRAY_SIZE() macro |
| Message-ID | <rK3rz-1nX-11@gated-at.bofh.it> |
| In reply to | #1422317 |
[Multipart message — attachments visible in raw view] — view raw
lockdep.c now uses ARRAY_SIZE().
Fixes: 75dd602a5198 ("lockdep: Fix lock_chain::base size")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
tools/lib/lockdep/uinclude/linux/kernel.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/lib/lockdep/uinclude/linux/kernel.h b/tools/lib/lockdep/uinclude/linux/kernel.h
index 276c7a8b2ed1..da87bd9ad2c1 100644
--- a/tools/lib/lockdep/uinclude/linux/kernel.h
+++ b/tools/lib/lockdep/uinclude/linux/kernel.h
@@ -7,6 +7,8 @@
#include <linux/hardirq.h>
#include <linux/kern_levels.h>
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
#ifndef container_of
#define container_of(ptr, type, member) ({ \
const typeof(((type *)0)->member) * __mptr = (ptr); \
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2016-06-14 22:50 +0200 |
| Subject | [PATCH 5/7] liblockdep: Fix 'unused value' warnings |
| Message-ID | <rK3rz-1nX-15@gated-at.bofh.it> |
| In reply to | #1422317 |
[Multipart message — attachments visible in raw view] — view raw
liblockdep defines various macros that may expand to an expression
with no effect, while the in-kernel definition does have an effect.
This results in warnings from gcc when -Wunused-value is enabled, and
is is enabled by -Wall. Fix this by introducing trivial functions,
as function return values are generally allowed to be ignored.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
tools/lib/lockdep/uinclude/linux/debug_locks.h | 2 +-
tools/lib/lockdep/uinclude/linux/kernel.h | 12 +++++++++---
tools/lib/lockdep/uinclude/linux/lockdep.h | 6 +++++-
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/tools/lib/lockdep/uinclude/linux/debug_locks.h b/tools/lib/lockdep/uinclude/linux/debug_locks.h
index f38eb64df794..1d4fbec5c649 100644
--- a/tools/lib/lockdep/uinclude/linux/debug_locks.h
+++ b/tools/lib/lockdep/uinclude/linux/debug_locks.h
@@ -4,7 +4,7 @@
#include <stddef.h>
#include <linux/compiler.h>
-#define DEBUG_LOCKS_WARN_ON(x) (x)
+#define DEBUG_LOCKS_WARN_ON(x) WARN_ON(x)
extern bool debug_locks;
extern bool debug_locks_silent;
diff --git a/tools/lib/lockdep/uinclude/linux/kernel.h b/tools/lib/lockdep/uinclude/linux/kernel.h
index da87bd9ad2c1..021cff4f4e3d 100644
--- a/tools/lib/lockdep/uinclude/linux/kernel.h
+++ b/tools/lib/lockdep/uinclude/linux/kernel.h
@@ -22,10 +22,16 @@
_max1 > _max2 ? _max1 : _max2; })
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-#define WARN_ON(x) (x)
-#define WARN_ON_ONCE(x) (x)
+
+static inline int lockdep_warn(int condition)
+{
+ return condition;
+}
+#define WARN_ON(x) lockdep_warn(x)
+#define WARN_ON_ONCE(x) WARN_ON(x)
+#define WARN(x, y...) WARN_ON(x)
+
#define likely(x) (x)
-#define WARN(x, y...) (x)
#define uninitialized_var(x) x
#define __init
#define noinline
diff --git a/tools/lib/lockdep/uinclude/linux/lockdep.h b/tools/lib/lockdep/uinclude/linux/lockdep.h
index d30214221920..d1079034a14d 100644
--- a/tools/lib/lockdep/uinclude/linux/lockdep.h
+++ b/tools/lib/lockdep/uinclude/linux/lockdep.h
@@ -29,7 +29,11 @@ extern struct task_struct *__curr(void);
#define current (__curr())
-#define debug_locks_off() 1
+static inline int debug_locks_off(void)
+{
+ return 1;
+}
+
#define task_pid_nr(tsk) ((tsk)->pid)
#define KSYM_NAME_LEN 128
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2016-06-14 22:50 +0200 |
| Subject | [PATCH 4/7] liblockdep: Enable -Wall by default |
| Message-ID | <rK3rA-1nX-31@gated-at.bofh.it> |
| In reply to | #1422317 |
[Multipart message — attachments visible in raw view] — view raw
Regressions in liblockdep may be missed because it doesn't enable warnings. Adding -Wall immediately introduces a lot of warnings, but those will be fixed by the following commits. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> --- tools/lib/lockdep/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile index 1d57af56814b..710a0edfe1b1 100644 --- a/tools/lib/lockdep/Makefile +++ b/tools/lib/lockdep/Makefile @@ -79,6 +79,7 @@ INCLUDES = -I. -I./uinclude -I./include -I../../include $(CONFIG_INCLUDES) # Set compile option CFLAGS if not set elsewhere CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g CFLAGS += -fPIC +CFLAGS += -Wall override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ)
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2016-06-14 22:50 +0200 |
| Subject | [PATCH 1/7] liblockdep: Fix undefined symbol prandom_u32 |
| Message-ID | <rK3rA-1nX-41@gated-at.bofh.it> |
| In reply to | #1422317 |
[Multipart message — attachments visible in raw view] — view raw
__lock_pin_lock() now calls prandom_u32() which is not defined in
liblockdep. __lock_pin_lock() and its caller lock_pin_lock() are dead
code in liblockdep, but we still need to provide a definition of
prandom_u32() in case lazy binding is disabled.
Fixes: e7904a28f533 ("locking/lockdep, sched/core: Implement a better ...")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
tools/lib/lockdep/common.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/lib/lockdep/common.c b/tools/lib/lockdep/common.c
index d1c89cc06f5f..405c17667c4d 100644
--- a/tools/lib/lockdep/common.c
+++ b/tools/lib/lockdep/common.c
@@ -1,5 +1,6 @@
#include <stddef.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <linux/compiler.h>
#include <linux/lockdep.h>
#include <unistd.h>
@@ -10,6 +11,11 @@ static __thread struct task_struct current_obj;
/* lockdep wants these */
bool debug_locks = true;
bool debug_locks_silent;
+u32 prandom_u32(void)
+{
+ /* Used only by lock_pin_lock() which is dead code */
+ abort();
+}
__attribute__((destructor)) static void liblockdep_exit(void)
{
[toc] | [prev] | [next] | [standalone]
| From | Sasha Levin <sasha.levin@oracle.com> |
|---|---|
| Date | 2016-06-14 23:40 +0200 |
| Subject | Re: [PATCH 1/7] liblockdep: Fix undefined symbol prandom_u32 |
| Message-ID | <rK4dY-1WX-9@gated-at.bofh.it> |
| In reply to | #1422326 |
[Multipart message — attachments visible in raw view] — view raw
On 06/14/2016 04:47 PM, Ben Hutchings wrote:
> __lock_pin_lock() now calls prandom_u32() which is not defined in
> liblockdep. __lock_pin_lock() and its caller lock_pin_lock() are dead
> code in liblockdep, but we still need to provide a definition of
> prandom_u32() in case lazy binding is disabled.
>
> Fixes: e7904a28f533 ("locking/lockdep, sched/core: Implement a better ...")
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> tools/lib/lockdep/common.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/lib/lockdep/common.c b/tools/lib/lockdep/common.c
> index d1c89cc06f5f..405c17667c4d 100644
> --- a/tools/lib/lockdep/common.c
> +++ b/tools/lib/lockdep/common.c
> @@ -1,5 +1,6 @@
> #include <stddef.h>
> #include <stdbool.h>
> +#include <stdlib.h>
> #include <linux/compiler.h>
> #include <linux/lockdep.h>
> #include <unistd.h>
> @@ -10,6 +11,11 @@ static __thread struct task_struct current_obj;
> /* lockdep wants these */
> bool debug_locks = true;
> bool debug_locks_silent;
> +u32 prandom_u32(void)
> +{
> + /* Used only by lock_pin_lock() which is dead code */
> + abort();
> +}
I had to place this bit in lockdep.c rather than common.c, since lockdep.c
is the one building kernel/lockdep.c.
Thanks,
Sasha
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2016-06-14 22:50 +0200 |
| Subject | [PATCH 2/7] liblockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain::depth |
| Message-ID | <rK3rA-1nX-33@gated-at.bofh.it> |
| In reply to | #1422317 |
[Multipart message — attachments visible in raw view] — view raw
liblockdep has been broken since commit 75dd602a5198 ("lockdep: Fix
lock_chain::base size"), as that adds a check that MAX_LOCK_DEPTH is
within the range of lock_chain::depth and in liblockdep it is much
too large.
That should have resulted in a compiler error, but didn't because:
- the check uses ARRAY_SIZE(), which isn't yet defined in liblockdep
so is assumed to be an (undeclared) function
- putting a function call inside a BUILD_BUG_ON() expression quietly
turns it into some nonsense involving a variable-length array
It did produce a compiler warning, but I didn't notice because
liblockdep already produces too many warnings if -Wall is enabled
(which I'll fix shortly).
Even before that commit, which reduced lock_chain::depth from 8 bits
to 6, MAX_LOCK_DEPTH was too large.
Cc: <stable@vger.kernel.org> # for versions before 4.6, use a value of 255
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
tools/lib/lockdep/uinclude/linux/lockdep.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/lockdep/uinclude/linux/lockdep.h b/tools/lib/lockdep/uinclude/linux/lockdep.h
index c808c7d02d21..d30214221920 100644
--- a/tools/lib/lockdep/uinclude/linux/lockdep.h
+++ b/tools/lib/lockdep/uinclude/linux/lockdep.h
@@ -8,7 +8,7 @@
#include <linux/utsname.h>
#include <linux/compiler.h>
-#define MAX_LOCK_DEPTH 2000UL
+#define MAX_LOCK_DEPTH 63UL
#define asmlinkage
#define __visible
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-06-14 23:20 +0200 |
| Subject | Re: [PATCH 2/7] liblockdep: Reduce MAX_LOCK_DEPTH to avoid overflowing lock_chain::depth |
| Message-ID | <rK3UB-1OB-13@gated-at.bofh.it> |
| In reply to | #1422327 |
On Tue, Jun 14, 2016 at 09:47:53PM +0100, Ben Hutchings wrote: > Even before that commit, which reduced lock_chain::depth from 8 bits > to 6, MAX_LOCK_DEPTH was too large. > -#define MAX_LOCK_DEPTH 2000UL > +#define MAX_LOCK_DEPTH 63UL So per that commit; there still is a 4 byte hole we could fill. So if a bigger number is desired here, there is room to make that happen. Good to see those assertions did their job, albeit somewhat belated.
[toc] | [prev] | [next] | [standalone]
| From | Sasha Levin <sasha.levin@oracle.com> |
|---|---|
| Date | 2016-06-14 23:40 +0200 |
| Message-ID | <rK4dY-1WX-23@gated-at.bofh.it> |
| In reply to | #1422317 |
On 06/14/2016 04:44 PM, Ben Hutchings wrote: > Here are a number of fixes for liblockdep. The first three need to > go into 4.7 and 4.6-stable; the second should probably go to all > stable branches. Thanks Ben! I've added it all to the queue and will send it along. Thanks, Sasha
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web