All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/7] drm: shmobile: Reduce include dependencies
@ 2020-04-22 12:51 Andy Shevchenko
  2020-04-22 12:51 ` [PATCH v4 2/7] kernel.h: Drop unneeded <linux/kernel.h> inclusion from other headers Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Andy Shevchenko @ 2020-04-22 12:51 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Joe Perches
  Cc: Andy Shevchenko, Laurent Pinchart

This file doesn't need anything provided by <linux/kernel.h>.
All it needs are some types, which are provided by <drm/drm_mode.h>.

Drop unneeded <linux/kernel.h> completely.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
v4: new patch (reviewed by driver maintainer)
 include/linux/platform_data/shmob_drm.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/linux/platform_data/shmob_drm.h b/include/linux/platform_data/shmob_drm.h
index fe815d7d9f58c..d661399b217df 100644
--- a/include/linux/platform_data/shmob_drm.h
+++ b/include/linux/platform_data/shmob_drm.h
@@ -10,8 +10,6 @@
 #ifndef __SHMOB_DRM_H__
 #define __SHMOB_DRM_H__
 
-#include <linux/kernel.h>
-
 #include <drm/drm_mode.h>
 
 enum shmob_drm_clk_source {
-- 
2.26.1


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

* [PATCH v4 2/7] kernel.h: Drop unneeded <linux/kernel.h> inclusion from other headers
  2020-04-22 12:51 [PATCH v4 1/7] drm: shmobile: Reduce include dependencies Andy Shevchenko
@ 2020-04-22 12:51 ` Andy Shevchenko
  2020-04-22 12:51 ` [PATCH v4 3/7] kernel.h: Move oops_in_progress to printk.h Andy Shevchenko
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2020-04-22 12:51 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Joe Perches
  Cc: Andy Shevchenko

There is no evidence we need kernel.h inclusion in certain headers.
Drop unneeded <linux/kernel.h> inclusion from other headers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: new patch
 include/linux/rwsem.h    | 1 -
 include/linux/spinlock.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 7e5b2a4eb5606..03637adbd8b59 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -11,7 +11,6 @@
 #include <linux/linkage.h>
 
 #include <linux/types.h>
-#include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/atomic.h>
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index d3770b3f9d9a9..6c3789686bab8 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -53,7 +53,6 @@
 #include <linux/compiler.h>
 #include <linux/irqflags.h>
 #include <linux/thread_info.h>
-#include <linux/kernel.h>
 #include <linux/stringify.h>
 #include <linux/bottom_half.h>
 #include <asm/barrier.h>
-- 
2.26.1


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

* [PATCH v4 3/7] kernel.h: Move oops_in_progress to printk.h
  2020-04-22 12:51 [PATCH v4 1/7] drm: shmobile: Reduce include dependencies Andy Shevchenko
  2020-04-22 12:51 ` [PATCH v4 2/7] kernel.h: Drop unneeded <linux/kernel.h> inclusion from other headers Andy Shevchenko
@ 2020-04-22 12:51 ` Andy Shevchenko
  2020-04-22 12:51 ` [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers Andy Shevchenko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2020-04-22 12:51 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Joe Perches
  Cc: Andy Shevchenko

The oops_in_progress is defined in printk.c, so it's logical
to move oops_in_progress to printk.h.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: new patch
 include/linux/debug_locks.h | 2 +-
 include/linux/kernel.h      | 1 -
 include/linux/printk.h      | 2 ++
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h
index 257ab3c92cb8a..e5ffbc25475a0 100644
--- a/include/linux/debug_locks.h
+++ b/include/linux/debug_locks.h
@@ -2,9 +2,9 @@
 #ifndef __LINUX_DEBUG_LOCKING_H
 #define __LINUX_DEBUG_LOCKING_H
 
-#include <linux/kernel.h>
 #include <linux/atomic.h>
 #include <linux/bug.h>
+#include <linux/printk.h>
 
 struct task_struct;
 
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 04a5885cec1b4..899302e2b7554 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -527,7 +527,6 @@ extern unsigned int sysctl_oops_all_cpu_backtrace;
 #endif /* CONFIG_SMP */
 
 extern void bust_spinlocks(int yes);
-extern int oops_in_progress;		/* If set, an oops, panic(), BUG() or die() is in progress */
 extern int panic_timeout;
 extern unsigned long panic_print;
 extern int panic_on_oops;
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 768ac6bc637df..c59fdf688d36c 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -11,6 +11,8 @@
 extern const char linux_banner[];
 extern const char linux_proc_banner[];
 
+extern int oops_in_progress;	/* If set, an oops, panic(), BUG() or die() is in progress */
+
 #define PRINTK_MAX_SINGLE_HEADER_LEN 2
 
 static inline int printk_get_level(const char *buffer)
-- 
2.26.1


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

* [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers
  2020-04-22 12:51 [PATCH v4 1/7] drm: shmobile: Reduce include dependencies Andy Shevchenko
  2020-04-22 12:51 ` [PATCH v4 2/7] kernel.h: Drop unneeded <linux/kernel.h> inclusion from other headers Andy Shevchenko
  2020-04-22 12:51 ` [PATCH v4 3/7] kernel.h: Move oops_in_progress to printk.h Andy Shevchenko
@ 2020-04-22 12:51 ` Andy Shevchenko
  2020-04-22 14:52   ` Joe Perches
  2020-04-22 12:51 ` [PATCH v4 5/7] kernel.h: Split out mathematical helpers Andy Shevchenko
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2020-04-22 12:51 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Joe Perches
  Cc: Andy Shevchenko

kernel.h is being used as a dump for all kinds of stuff for a long time.
Here is the attempt to start cleaning it up by splitting out min()/max()
et al helpers.

At the same time convert users in header and lib folder to use new header.
Though for time being include new header back to kernel.h to avoid twisted
indirected includes for existing users.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: rebase on latest kernel
 include/linux/blkdev.h    |   1 +
 include/linux/bvec.h      |   6 +-
 include/linux/jiffies.h   |   3 +-
 include/linux/kernel.h    | 142 +------------------------------------
 include/linux/minmax.h    | 145 ++++++++++++++++++++++++++++++++++++++
 include/linux/nodemask.h  |   2 +-
 include/linux/uaccess.h   |   1 +
 kernel/range.c            |   3 +-
 lib/find_bit.c            |   1 +
 lib/hexdump.c             |   1 +
 lib/math/rational.c       |   2 +-
 lib/math/reciprocal_div.c |   1 +
 12 files changed, 162 insertions(+), 146 deletions(-)
 create mode 100644 include/linux/minmax.h

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 32868fbedc9e9..e39853ebf9c21 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -11,6 +11,7 @@
 #include <linux/genhd.h>
 #include <linux/list.h>
 #include <linux/llist.h>
+#include <linux/minmax.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/pagemap.h>
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index a81c13ac19728..56d4dec749263 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -7,10 +7,14 @@
 #ifndef __LINUX_BVEC_ITER_H
 #define __LINUX_BVEC_ITER_H
 
-#include <linux/kernel.h>
 #include <linux/bug.h>
 #include <linux/errno.h>
+#include <linux/limits.h>
+#include <linux/minmax.h>
 #include <linux/mm.h>
+#include <linux/types.h>
+
+struct page;
 
 /*
  * was unsigned short, but we might as well be ready for > 64kB I/O pages
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index fed6ba96c5278..5e13f801c9021 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -3,8 +3,9 @@
 #define _LINUX_JIFFIES_H
 
 #include <linux/cache.h>
+#include <linux/limits.h>
 #include <linux/math64.h>
-#include <linux/kernel.h>
+#include <linux/minmax.h>
 #include <linux/types.h>
 #include <linux/time.h>
 #include <linux/timex.h>
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 899302e2b7554..cbdbfe81a535c 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -11,6 +11,7 @@
 #include <linux/compiler.h>
 #include <linux/bitops.h>
 #include <linux/log2.h>
+#include <linux/minmax.h>
 #include <linux/typecheck.h>
 #include <linux/printk.h>
 #include <linux/build_bug.h>
@@ -831,147 +832,6 @@ ftrace_vprintk(const char *fmt, va_list ap)
 static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 #endif /* CONFIG_TRACING */
 
-/*
- * min()/max()/clamp() macros must accomplish three things:
- *
- * - avoid multiple evaluations of the arguments (so side-effects like
- *   "x++" happen only once) when non-constant.
- * - perform strict type-checking (to generate warnings instead of
- *   nasty runtime surprises). See the "unnecessary" pointer comparison
- *   in __typecheck().
- * - retain result as a constant expressions when called with only
- *   constant expressions (to avoid tripping VLA warnings in stack
- *   allocation usage).
- */
-#define __typecheck(x, y) \
-		(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
-
-/*
- * This returns a constant expression while determining if an argument is
- * a constant expression, most importantly without evaluating the argument.
- * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de>
- */
-#define __is_constexpr(x) \
-	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
-
-#define __no_side_effects(x, y) \
-		(__is_constexpr(x) && __is_constexpr(y))
-
-#define __safe_cmp(x, y) \
-		(__typecheck(x, y) && __no_side_effects(x, y))
-
-#define __cmp(x, y, op)	((x) op (y) ? (x) : (y))
-
-#define __cmp_once(x, y, unique_x, unique_y, op) ({	\
-		typeof(x) unique_x = (x);		\
-		typeof(y) unique_y = (y);		\
-		__cmp(unique_x, unique_y, op); })
-
-#define __careful_cmp(x, y, op) \
-	__builtin_choose_expr(__safe_cmp(x, y), \
-		__cmp(x, y, op), \
-		__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
-
-/**
- * min - return minimum of two values of the same or compatible types
- * @x: first value
- * @y: second value
- */
-#define min(x, y)	__careful_cmp(x, y, <)
-
-/**
- * max - return maximum of two values of the same or compatible types
- * @x: first value
- * @y: second value
- */
-#define max(x, y)	__careful_cmp(x, y, >)
-
-/**
- * min3 - return minimum of three values
- * @x: first value
- * @y: second value
- * @z: third value
- */
-#define min3(x, y, z) min((typeof(x))min(x, y), z)
-
-/**
- * max3 - return maximum of three values
- * @x: first value
- * @y: second value
- * @z: third value
- */
-#define max3(x, y, z) max((typeof(x))max(x, y), z)
-
-/**
- * min_not_zero - return the minimum that is _not_ zero, unless both are zero
- * @x: value1
- * @y: value2
- */
-#define min_not_zero(x, y) ({			\
-	typeof(x) __x = (x);			\
-	typeof(y) __y = (y);			\
-	__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
-
-/**
- * clamp - return a value clamped to a given range with strict typechecking
- * @val: current value
- * @lo: lowest allowable value
- * @hi: highest allowable value
- *
- * This macro does strict typechecking of @lo/@hi to make sure they are of the
- * same type as @val.  See the unnecessary pointer comparisons.
- */
-#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
-
-/*
- * ..and if you can't take the strict
- * types, you can specify one yourself.
- *
- * Or not use min/max/clamp at all, of course.
- */
-
-/**
- * min_t - return minimum of two values, using the specified type
- * @type: data type to use
- * @x: first value
- * @y: second value
- */
-#define min_t(type, x, y)	__careful_cmp((type)(x), (type)(y), <)
-
-/**
- * max_t - return maximum of two values, using the specified type
- * @type: data type to use
- * @x: first value
- * @y: second value
- */
-#define max_t(type, x, y)	__careful_cmp((type)(x), (type)(y), >)
-
-/**
- * clamp_t - return a value clamped to a given range using a given type
- * @type: the type of variable to use
- * @val: current value
- * @lo: minimum allowable value
- * @hi: maximum allowable value
- *
- * This macro does no typechecking and uses temporary variables of type
- * @type to make all the comparisons.
- */
-#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
-
-/**
- * clamp_val - return a value clamped to a given range using val's type
- * @val: current value
- * @lo: minimum allowable value
- * @hi: maximum allowable value
- *
- * This macro does no typechecking and uses temporary variables of whatever
- * type the input argument @val is.  This is useful when @val is an unsigned
- * type and @lo and @hi are literals that will otherwise be assigned a signed
- * integer type.
- */
-#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
-
-
 /**
  * swap - swap values of @a and @b
  * @a: first value
diff --git a/include/linux/minmax.h b/include/linux/minmax.h
new file mode 100644
index 0000000000000..bfd6ad8229147
--- /dev/null
+++ b/include/linux/minmax.h
@@ -0,0 +1,145 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_MINMAX_H
+#define _LINUX_MINMAX_H
+
+/*
+ * min()/max()/clamp() macros must accomplish three things:
+ *
+ * - avoid multiple evaluations of the arguments (so side-effects like
+ *   "x++" happen only once) when non-constant.
+ * - perform strict type-checking (to generate warnings instead of
+ *   nasty runtime surprises). See the "unnecessary" pointer comparison
+ *   in __typecheck().
+ * - retain result as a constant expressions when called with only
+ *   constant expressions (to avoid tripping VLA warnings in stack
+ *   allocation usage).
+ */
+#define __typecheck(x, y) \
+	(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
+
+/*
+ * This returns a constant expression while determining if an argument is
+ * a constant expression, most importantly without evaluating the argument.
+ * Glory to Martin Uecker <Martin.Uecker@med.uni-goettingen.de>
+ */
+#define __is_constexpr(x) \
+	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
+
+#define __no_side_effects(x, y) \
+		(__is_constexpr(x) && __is_constexpr(y))
+
+#define __safe_cmp(x, y) \
+		(__typecheck(x, y) && __no_side_effects(x, y))
+
+#define __cmp(x, y, op)	((x) op (y) ? (x) : (y))
+
+#define __cmp_once(x, y, unique_x, unique_y, op) ({	\
+		typeof(x) unique_x = (x);		\
+		typeof(y) unique_y = (y);		\
+		__cmp(unique_x, unique_y, op); })
+
+#define __careful_cmp(x, y, op) \
+	__builtin_choose_expr(__safe_cmp(x, y), \
+		__cmp(x, y, op), \
+		__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
+
+/**
+ * min - return minimum of two values of the same or compatible types
+ * @x: first value
+ * @y: second value
+ */
+#define min(x, y)	__careful_cmp(x, y, <)
+
+/**
+ * max - return maximum of two values of the same or compatible types
+ * @x: first value
+ * @y: second value
+ */
+#define max(x, y)	__careful_cmp(x, y, >)
+
+/**
+ * min3 - return minimum of three values
+ * @x: first value
+ * @y: second value
+ * @z: third value
+ */
+#define min3(x, y, z) min((typeof(x))min(x, y), z)
+
+/**
+ * max3 - return maximum of three values
+ * @x: first value
+ * @y: second value
+ * @z: third value
+ */
+#define max3(x, y, z) max((typeof(x))max(x, y), z)
+
+/**
+ * min_not_zero - return the minimum that is _not_ zero, unless both are zero
+ * @x: value1
+ * @y: value2
+ */
+#define min_not_zero(x, y) ({			\
+	typeof(x) __x = (x);			\
+	typeof(y) __y = (y);			\
+	__x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
+
+/**
+ * clamp - return a value clamped to a given range with strict typechecking
+ * @val: current value
+ * @lo: lowest allowable value
+ * @hi: highest allowable value
+ *
+ * This macro does strict typechecking of @lo/@hi to make sure they are of the
+ * same type as @val.  See the unnecessary pointer comparisons.
+ */
+#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
+
+/*
+ * ..and if you can't take the strict
+ * types, you can specify one yourself.
+ *
+ * Or not use min/max/clamp at all, of course.
+ */
+
+/**
+ * min_t - return minimum of two values, using the specified type
+ * @type: data type to use
+ * @x: first value
+ * @y: second value
+ */
+#define min_t(type, x, y)	__careful_cmp((type)(x), (type)(y), <)
+
+/**
+ * max_t - return maximum of two values, using the specified type
+ * @type: data type to use
+ * @x: first value
+ * @y: second value
+ */
+#define max_t(type, x, y)	__careful_cmp((type)(x), (type)(y), >)
+
+/**
+ * clamp_t - return a value clamped to a given range using a given type
+ * @type: the type of variable to use
+ * @val: current value
+ * @lo: minimum allowable value
+ * @hi: maximum allowable value
+ *
+ * This macro does no typechecking and uses temporary variables of type
+ * @type to make all the comparisons.
+ */
+#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
+
+/**
+ * clamp_val - return a value clamped to a given range using val's type
+ * @val: current value
+ * @lo: minimum allowable value
+ * @hi: maximum allowable value
+ *
+ * This macro does no typechecking and uses temporary variables of whatever
+ * type the input argument @val is.  This is useful when @val is an unsigned
+ * type and @lo and @hi are literals that will otherwise be assigned a signed
+ * integer type.
+ */
+#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
+
+#endif	/* _LINUX_MINMAX_H */
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 27e7fa36f707f..7f38399cc9fe7 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -90,9 +90,9 @@
  * for such situations. See below and CPUMASK_ALLOC also.
  */
 
-#include <linux/kernel.h>
 #include <linux/threads.h>
 #include <linux/bitmap.h>
+#include <linux/minmax.h>
 #include <linux/numa.h>
 
 typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 8a215c5c1aed8..cb11957a017f6 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -3,6 +3,7 @@
 #define __LINUX_UACCESS_H__
 
 #include <linux/instrumented.h>
+#include <linux/minmax.h>
 #include <linux/sched.h>
 #include <linux/thread_info.h>
 
diff --git a/kernel/range.c b/kernel/range.c
index d84de6766472d..56435f96da73b 100644
--- a/kernel/range.c
+++ b/kernel/range.c
@@ -2,8 +2,9 @@
 /*
  * Range add and subtract
  */
-#include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/minmax.h>
+#include <linux/printk.h>
 #include <linux/sort.h>
 #include <linux/string.h>
 #include <linux/range.h>
diff --git a/lib/find_bit.c b/lib/find_bit.c
index 49f875f1baf7e..4a8751010d59f 100644
--- a/lib/find_bit.c
+++ b/lib/find_bit.c
@@ -16,6 +16,7 @@
 #include <linux/bitmap.h>
 #include <linux/export.h>
 #include <linux/kernel.h>
+#include <linux/minmax.h>
 
 #if !defined(find_next_bit) || !defined(find_next_zero_bit) ||			\
 	!defined(find_next_bit_le) || !defined(find_next_zero_bit_le) ||	\
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 147133f8eb2fc..9301578f98e8c 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -7,6 +7,7 @@
 #include <linux/ctype.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/minmax.h>
 #include <linux/export.h>
 #include <asm/unaligned.h>
 
diff --git a/lib/math/rational.c b/lib/math/rational.c
index 31fb27db2deb5..d8e985850d10c 100644
--- a/lib/math/rational.c
+++ b/lib/math/rational.c
@@ -11,7 +11,7 @@
 #include <linux/rational.h>
 #include <linux/compiler.h>
 #include <linux/export.h>
-#include <linux/kernel.h>
+#include <linux/minmax.h>
 
 /*
  * calculate best rational approximation for a given fraction
diff --git a/lib/math/reciprocal_div.c b/lib/math/reciprocal_div.c
index bf043258fa008..32436dd4171e9 100644
--- a/lib/math/reciprocal_div.c
+++ b/lib/math/reciprocal_div.c
@@ -4,6 +4,7 @@
 #include <asm/div64.h>
 #include <linux/reciprocal_div.h>
 #include <linux/export.h>
+#include <linux/minmax.h>
 
 /*
  * For a description of the algorithm please have a look at
-- 
2.26.1


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

* [PATCH v4 5/7] kernel.h: Split out mathematical helpers
  2020-04-22 12:51 [PATCH v4 1/7] drm: shmobile: Reduce include dependencies Andy Shevchenko
                   ` (2 preceding siblings ...)
  2020-04-22 12:51 ` [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers Andy Shevchenko
@ 2020-04-22 12:51 ` Andy Shevchenko
  2020-04-22 12:52 ` [PATCH v4 6/7] kernel.h: Split out panic and oops helpers Andy Shevchenko
  2020-04-22 12:52 ` [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends Andy Shevchenko
  5 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2020-04-22 12:51 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Joe Perches
  Cc: Andy Shevchenko

kernel.h is being used as a dump for all kinds of stuff for a long time.
Here is the attempt to start cleaning it up by splitting out mathematical
helpers.

At the same time convert users in header and lib folder to use new header.
Though for time being include new header back to kernel.h to avoid twisted
indirected includes for existing users.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: rebase on latest kernel
 fs/nfs/callback_proc.c        |   5 +
 include/linux/bitops.h        |  11 ++-
 include/linux/dcache.h        |   1 +
 include/linux/iommu-helper.h  |   4 +-
 include/linux/kernel.h        | 174 +--------------------------------
 include/linux/math.h          | 177 ++++++++++++++++++++++++++++++++++
 include/linux/rcu_node_tree.h |   2 +
 include/linux/units.h         |   2 +-
 lib/errname.c                 |   1 +
 lib/find_bit.c                |   3 +-
 lib/math/div64.c              |   3 +-
 lib/math/int_pow.c            |   2 +-
 lib/math/int_sqrt.c           |   3 +-
 lib/math/reciprocal_div.c     |   9 +-
 14 files changed, 213 insertions(+), 184 deletions(-)
 create mode 100644 include/linux/math.h

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index e61dbc9b86ae2..f7786e00a6a7f 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -6,10 +6,15 @@
  *
  * NFSv4 callback procedures
  */
+
+#include <linux/errno.h>
+#include <linux/math.h>
 #include <linux/nfs4.h>
 #include <linux/nfs_fs.h>
 #include <linux/slab.h>
 #include <linux/rcupdate.h>
+#include <linux/types.h>
+
 #include "nfs4_fs.h"
 #include "callback.h"
 #include "delegation.h"
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 9acf654f0b191..72c911779f45d 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -1,9 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _LINUX_BITOPS_H
 #define _LINUX_BITOPS_H
+
 #include <asm/types.h>
 #include <linux/bits.h>
 
+#include <uapi/linux/kernel.h>
+
 /* Set bits in the first 'n' bytes when loaded from memory */
 #ifdef __LITTLE_ENDIAN
 #  define aligned_byte_mask(n) ((1UL << 8*(n))-1)
@@ -12,10 +15,10 @@
 #endif
 
 #define BITS_PER_TYPE(type)	(sizeof(type) * BITS_PER_BYTE)
-#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
-#define BITS_TO_U64(nr)		DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))
-#define BITS_TO_U32(nr)		DIV_ROUND_UP(nr, BITS_PER_TYPE(u32))
-#define BITS_TO_BYTES(nr)	DIV_ROUND_UP(nr, BITS_PER_TYPE(char))
+#define BITS_TO_LONGS(nr)	__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
+#define BITS_TO_U64(nr)		__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))
+#define BITS_TO_U32(nr)		__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u32))
+#define BITS_TO_BYTES(nr)	__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(char))
 
 extern unsigned int __sw_hweight8(unsigned int w);
 extern unsigned int __sw_hweight16(unsigned int w);
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index c1488cc84fd94..096e04b7f38dc 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -4,6 +4,7 @@
 
 #include <linux/atomic.h>
 #include <linux/list.h>
+#include <linux/math.h>
 #include <linux/rculist.h>
 #include <linux/rculist_bl.h>
 #include <linux/spinlock.h>
diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h
index 70d01edcbf8be..74be34f3a20ac 100644
--- a/include/linux/iommu-helper.h
+++ b/include/linux/iommu-helper.h
@@ -3,7 +3,9 @@
 #define _LINUX_IOMMU_HELPER_H
 
 #include <linux/bug.h>
-#include <linux/kernel.h>
+#include <linux/log2.h>
+#include <linux/math.h>
+#include <linux/types.h>
 
 static inline unsigned long iommu_device_max_index(unsigned long size,
 						   unsigned long offset,
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index cbdbfe81a535c..8a0e5ed1b905a 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -2,7 +2,6 @@
 #ifndef _LINUX_KERNEL_H
 #define _LINUX_KERNEL_H
 
-
 #include <stdarg.h>
 #include <linux/limits.h>
 #include <linux/linkage.h>
@@ -11,14 +10,15 @@
 #include <linux/compiler.h>
 #include <linux/bitops.h>
 #include <linux/log2.h>
+#include <linux/math.h>
 #include <linux/minmax.h>
 #include <linux/typecheck.h>
 #include <linux/printk.h>
 #include <linux/build_bug.h>
+
 #include <asm/byteorder.h>
-#include <asm/div64.h>
+
 #include <uapi/linux/kernel.h>
-#include <asm/div64.h>
 
 #define STACK_MAGIC	0xdeadbeef
 
@@ -54,125 +54,11 @@
 }					\
 )
 
-/*
- * This looks more complex than it should be. But we need to
- * get the type for the ~ right in round_down (it needs to be
- * as wide as the result!), and we want to evaluate the macro
- * arguments just once each.
- */
-#define __round_mask(x, y) ((__typeof__(x))((y)-1))
-/**
- * round_up - round up to next specified power of 2
- * @x: the value to round
- * @y: multiple to round up to (must be a power of 2)
- *
- * Rounds @x up to next multiple of @y (which must be a power of 2).
- * To perform arbitrary rounding up, use roundup() below.
- */
-#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
-/**
- * round_down - round down to next specified power of 2
- * @x: the value to round
- * @y: multiple to round down to (must be a power of 2)
- *
- * Rounds @x down to next multiple of @y (which must be a power of 2).
- * To perform arbitrary rounding down, use rounddown() below.
- */
-#define round_down(x, y) ((x) & ~__round_mask(x, y))
-
 #define typeof_member(T, m)	typeof(((T*)0)->m)
 
-#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
-
-#define DIV_ROUND_DOWN_ULL(ll, d) \
-	({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })
-
-#define DIV_ROUND_UP_ULL(ll, d) \
-	DIV_ROUND_DOWN_ULL((unsigned long long)(ll) + (d) - 1, (d))
-
-#if BITS_PER_LONG == 32
-# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d)
-#else
-# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP(ll,d)
-#endif
-
-/**
- * roundup - round up to the next specified multiple
- * @x: the value to up
- * @y: multiple to round up to
- *
- * Rounds @x up to next multiple of @y. If @y will always be a power
- * of 2, consider using the faster round_up().
- */
-#define roundup(x, y) (					\
-{							\
-	typeof(y) __y = y;				\
-	(((x) + (__y - 1)) / __y) * __y;		\
-}							\
-)
-/**
- * rounddown - round down to next specified multiple
- * @x: the value to round
- * @y: multiple to round down to
- *
- * Rounds @x down to next multiple of @y. If @y will always be a power
- * of 2, consider using the faster round_down().
- */
-#define rounddown(x, y) (				\
-{							\
-	typeof(x) __x = (x);				\
-	__x - (__x % (y));				\
-}							\
-)
-
-/*
- * Divide positive or negative dividend by positive or negative divisor
- * and round to closest integer. Result is undefined for negative
- * divisors if the dividend variable type is unsigned and for negative
- * dividends if the divisor variable type is unsigned.
- */
-#define DIV_ROUND_CLOSEST(x, divisor)(			\
-{							\
-	typeof(x) __x = x;				\
-	typeof(divisor) __d = divisor;			\
-	(((typeof(x))-1) > 0 ||				\
-	 ((typeof(divisor))-1) > 0 ||			\
-	 (((__x) > 0) == ((__d) > 0))) ?		\
-		(((__x) + ((__d) / 2)) / (__d)) :	\
-		(((__x) - ((__d) / 2)) / (__d));	\
-}							\
-)
-/*
- * Same as above but for u64 dividends. divisor must be a 32-bit
- * number.
- */
-#define DIV_ROUND_CLOSEST_ULL(x, divisor)(		\
-{							\
-	typeof(divisor) __d = divisor;			\
-	unsigned long long _tmp = (x) + (__d) / 2;	\
-	do_div(_tmp, __d);				\
-	_tmp;						\
-}							\
-)
-
-/*
- * Multiplies an integer by a fraction, while avoiding unnecessary
- * overflow or loss of precision.
- */
-#define mult_frac(x, numer, denom)(			\
-{							\
-	typeof(x) quot = (x) / (denom);			\
-	typeof(x) rem  = (x) % (denom);			\
-	(quot * (numer)) + ((rem * (numer)) / (denom));	\
-}							\
-)
-
-
 #define _RET_IP_		(unsigned long)__builtin_return_address(0)
 #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
 
-#define sector_div(a, b) do_div(a, b)
-
 /**
  * upper_32_bits - return bits 32-63 of a number
  * @n: the number we're accessing
@@ -265,48 +151,6 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset);
 # define cant_migrate()		do { } while (0)
 #endif
 
-/**
- * abs - return absolute value of an argument
- * @x: the value.  If it is unsigned type, it is converted to signed type first.
- *     char is treated as if it was signed (regardless of whether it really is)
- *     but the macro's return type is preserved as char.
- *
- * Return: an absolute value of x.
- */
-#define abs(x)	__abs_choose_expr(x, long long,				\
-		__abs_choose_expr(x, long,				\
-		__abs_choose_expr(x, int,				\
-		__abs_choose_expr(x, short,				\
-		__abs_choose_expr(x, char,				\
-		__builtin_choose_expr(					\
-			__builtin_types_compatible_p(typeof(x), char),	\
-			(char)({ signed char __x = (x); __x<0?-__x:__x; }), \
-			((void)0)))))))
-
-#define __abs_choose_expr(x, type, other) __builtin_choose_expr(	\
-	__builtin_types_compatible_p(typeof(x),   signed type) ||	\
-	__builtin_types_compatible_p(typeof(x), unsigned type),		\
-	({ signed type __x = (x); __x < 0 ? -__x : __x; }), other)
-
-/**
- * reciprocal_scale - "scale" a value into range [0, ep_ro)
- * @val: value
- * @ep_ro: right open interval endpoint
- *
- * Perform a "reciprocal multiplication" in order to "scale" a value into
- * range [0, @ep_ro), where the upper interval endpoint is right-open.
- * This is useful, e.g. for accessing a index of an array containing
- * @ep_ro elements, for example. Think of it as sort of modulus, only that
- * the result isn't that of modulo. ;) Note that if initial input is a
- * small value, then result will return 0.
- *
- * Return: a result based on @val in interval [0, @ep_ro).
- */
-static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
-{
-	return (u32)(((u64) val * ep_ro) >> 32);
-}
-
 #if defined(CONFIG_MMU) && \
 	(defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP))
 #define might_fault() __might_fault(__FILE__, __LINE__)
@@ -509,18 +353,6 @@ extern int __kernel_text_address(unsigned long addr);
 extern int kernel_text_address(unsigned long addr);
 extern int func_ptr_is_kernel_text(void *ptr);
 
-u64 int_pow(u64 base, unsigned int exp);
-unsigned long int_sqrt(unsigned long);
-
-#if BITS_PER_LONG < 64
-u32 int_sqrt64(u64 x);
-#else
-static inline u32 int_sqrt64(u64 x)
-{
-	return (u32)int_sqrt(x);
-}
-#endif
-
 #ifdef CONFIG_SMP
 extern unsigned int sysctl_oops_all_cpu_backtrace;
 #else
diff --git a/include/linux/math.h b/include/linux/math.h
new file mode 100644
index 0000000000000..53674a327e39b
--- /dev/null
+++ b/include/linux/math.h
@@ -0,0 +1,177 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_MATH_H
+#define _LINUX_MATH_H
+
+#include <asm/div64.h>
+#include <uapi/linux/kernel.h>
+
+/*
+ * This looks more complex than it should be. But we need to
+ * get the type for the ~ right in round_down (it needs to be
+ * as wide as the result!), and we want to evaluate the macro
+ * arguments just once each.
+ */
+#define __round_mask(x, y) ((__typeof__(x))((y)-1))
+
+/**
+ * round_up - round up to next specified power of 2
+ * @x: the value to round
+ * @y: multiple to round up to (must be a power of 2)
+ *
+ * Rounds @x up to next multiple of @y (which must be a power of 2).
+ * To perform arbitrary rounding up, use roundup() below.
+ */
+#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
+
+/**
+ * round_down - round down to next specified power of 2
+ * @x: the value to round
+ * @y: multiple to round down to (must be a power of 2)
+ *
+ * Rounds @x down to next multiple of @y (which must be a power of 2).
+ * To perform arbitrary rounding down, use rounddown() below.
+ */
+#define round_down(x, y) ((x) & ~__round_mask(x, y))
+
+#define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
+
+#define DIV_ROUND_DOWN_ULL(ll, d) \
+	({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })
+
+#define DIV_ROUND_UP_ULL(ll, d) \
+	DIV_ROUND_DOWN_ULL((unsigned long long)(ll) + (d) - 1, (d))
+
+#if BITS_PER_LONG == 32
+# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d)
+#else
+# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP(ll,d)
+#endif
+
+/**
+ * roundup - round up to the next specified multiple
+ * @x: the value to up
+ * @y: multiple to round up to
+ *
+ * Rounds @x up to next multiple of @y. If @y will always be a power
+ * of 2, consider using the faster round_up().
+ */
+#define roundup(x, y) (					\
+{							\
+	typeof(y) __y = y;				\
+	(((x) + (__y - 1)) / __y) * __y;		\
+}							\
+)
+/**
+ * rounddown - round down to next specified multiple
+ * @x: the value to round
+ * @y: multiple to round down to
+ *
+ * Rounds @x down to next multiple of @y. If @y will always be a power
+ * of 2, consider using the faster round_down().
+ */
+#define rounddown(x, y) (				\
+{							\
+	typeof(x) __x = (x);				\
+	__x - (__x % (y));				\
+}							\
+)
+
+/*
+ * Divide positive or negative dividend by positive or negative divisor
+ * and round to closest integer. Result is undefined for negative
+ * divisors if the dividend variable type is unsigned and for negative
+ * dividends if the divisor variable type is unsigned.
+ */
+#define DIV_ROUND_CLOSEST(x, divisor)(			\
+{							\
+	typeof(x) __x = x;				\
+	typeof(divisor) __d = divisor;			\
+	(((typeof(x))-1) > 0 ||				\
+	 ((typeof(divisor))-1) > 0 ||			\
+	 (((__x) > 0) == ((__d) > 0))) ?		\
+		(((__x) + ((__d) / 2)) / (__d)) :	\
+		(((__x) - ((__d) / 2)) / (__d));	\
+}							\
+)
+/*
+ * Same as above but for u64 dividends. divisor must be a 32-bit
+ * number.
+ */
+#define DIV_ROUND_CLOSEST_ULL(x, divisor)(		\
+{							\
+	typeof(divisor) __d = divisor;			\
+	unsigned long long _tmp = (x) + (__d) / 2;	\
+	do_div(_tmp, __d);				\
+	_tmp;						\
+}							\
+)
+
+/*
+ * Multiplies an integer by a fraction, while avoiding unnecessary
+ * overflow or loss of precision.
+ */
+#define mult_frac(x, numer, denom)(			\
+{							\
+	typeof(x) quot = (x) / (denom);			\
+	typeof(x) rem  = (x) % (denom);			\
+	(quot * (numer)) + ((rem * (numer)) / (denom));	\
+}							\
+)
+
+#define sector_div(a, b) do_div(a, b)
+
+/**
+ * abs - return absolute value of an argument
+ * @x: the value.  If it is unsigned type, it is converted to signed type first.
+ *     char is treated as if it was signed (regardless of whether it really is)
+ *     but the macro's return type is preserved as char.
+ *
+ * Return: an absolute value of x.
+ */
+#define abs(x)	__abs_choose_expr(x, long long,				\
+		__abs_choose_expr(x, long,				\
+		__abs_choose_expr(x, int,				\
+		__abs_choose_expr(x, short,				\
+		__abs_choose_expr(x, char,				\
+		__builtin_choose_expr(					\
+			__builtin_types_compatible_p(typeof(x), char),	\
+			(char)({ signed char __x = (x); __x<0?-__x:__x; }), \
+			((void)0)))))))
+
+#define __abs_choose_expr(x, type, other) __builtin_choose_expr(	\
+	__builtin_types_compatible_p(typeof(x),   signed type) ||	\
+	__builtin_types_compatible_p(typeof(x), unsigned type),		\
+	({ signed type __x = (x); __x < 0 ? -__x : __x; }), other)
+
+/**
+ * reciprocal_scale - "scale" a value into range [0, ep_ro)
+ * @val: value
+ * @ep_ro: right open interval endpoint
+ *
+ * Perform a "reciprocal multiplication" in order to "scale" a value into
+ * range [0, @ep_ro), where the upper interval endpoint is right-open.
+ * This is useful, e.g. for accessing a index of an array containing
+ * @ep_ro elements, for example. Think of it as sort of modulus, only that
+ * the result isn't that of modulo. ;) Note that if initial input is a
+ * small value, then result will return 0.
+ *
+ * Return: a result based on @val in interval [0, @ep_ro).
+ */
+static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
+{
+	return (u32)(((u64) val * ep_ro) >> 32);
+}
+
+u64 int_pow(u64 base, unsigned int exp);
+unsigned long int_sqrt(unsigned long);
+
+#if BITS_PER_LONG < 64
+u32 int_sqrt64(u64 x);
+#else
+static inline u32 int_sqrt64(u64 x)
+{
+	return (u32)int_sqrt(x);
+}
+#endif
+
+#endif	/* _LINUX_MATH_H */
diff --git a/include/linux/rcu_node_tree.h b/include/linux/rcu_node_tree.h
index b8e094b125ee6..78feb8ba73585 100644
--- a/include/linux/rcu_node_tree.h
+++ b/include/linux/rcu_node_tree.h
@@ -20,6 +20,8 @@
 #ifndef __LINUX_RCU_NODE_TREE_H
 #define __LINUX_RCU_NODE_TREE_H
 
+#include <linux/math.h>
+
 /*
  * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and
  * CONFIG_RCU_FANOUT_LEAF.
diff --git a/include/linux/units.h b/include/linux/units.h
index aaf716364ec34..5c115c809507f 100644
--- a/include/linux/units.h
+++ b/include/linux/units.h
@@ -2,7 +2,7 @@
 #ifndef _LINUX_UNITS_H
 #define _LINUX_UNITS_H
 
-#include <linux/kernel.h>
+#include <linux/math.h>
 
 #define ABSOLUTE_ZERO_MILLICELSIUS -273150
 
diff --git a/lib/errname.c b/lib/errname.c
index 0c4d3e66170e9..05cbf731545f0 100644
--- a/lib/errname.c
+++ b/lib/errname.c
@@ -3,6 +3,7 @@
 #include <linux/errno.h>
 #include <linux/errname.h>
 #include <linux/kernel.h>
+#include <linux/math.h>
 
 /*
  * Ensure these tables do not accidentally become gigantic if some
diff --git a/lib/find_bit.c b/lib/find_bit.c
index 4a8751010d59f..f67f86fd2f620 100644
--- a/lib/find_bit.c
+++ b/lib/find_bit.c
@@ -15,8 +15,9 @@
 #include <linux/bitops.h>
 #include <linux/bitmap.h>
 #include <linux/export.h>
-#include <linux/kernel.h>
+#include <linux/math.h>
 #include <linux/minmax.h>
+#include <linux/swab.h>
 
 #if !defined(find_next_bit) || !defined(find_next_zero_bit) ||			\
 	!defined(find_next_bit_le) || !defined(find_next_zero_bit_le) ||	\
diff --git a/lib/math/div64.c b/lib/math/div64.c
index 368ca7fd0d828..259303233610e 100644
--- a/lib/math/div64.c
+++ b/lib/math/div64.c
@@ -18,8 +18,9 @@
  * or by defining a preprocessor macro in arch/include/asm/div64.h.
  */
 
+#include <linux/bitops.h>
 #include <linux/export.h>
-#include <linux/kernel.h>
+#include <linux/math.h>
 #include <linux/math64.h>
 
 /* Not needed on 64bit architectures */
diff --git a/lib/math/int_pow.c b/lib/math/int_pow.c
index 622fc1ab3c745..0cf426e69bdaa 100644
--- a/lib/math/int_pow.c
+++ b/lib/math/int_pow.c
@@ -6,7 +6,7 @@
  */
 
 #include <linux/export.h>
-#include <linux/kernel.h>
+#include <linux/math.h>
 #include <linux/types.h>
 
 /**
diff --git a/lib/math/int_sqrt.c b/lib/math/int_sqrt.c
index 30e0f9770f88c..a8170bb9142f3 100644
--- a/lib/math/int_sqrt.c
+++ b/lib/math/int_sqrt.c
@@ -6,9 +6,10 @@
  *  square root from Guy L. Steele.
  */
 
-#include <linux/kernel.h>
 #include <linux/export.h>
 #include <linux/bitops.h>
+#include <linux/limits.h>
+#include <linux/math.h>
 
 /**
  * int_sqrt - computes the integer square root
diff --git a/lib/math/reciprocal_div.c b/lib/math/reciprocal_div.c
index 32436dd4171e9..6cb4adbb81d27 100644
--- a/lib/math/reciprocal_div.c
+++ b/lib/math/reciprocal_div.c
@@ -1,10 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <linux/bitops.h>
 #include <linux/bug.h>
-#include <linux/kernel.h>
-#include <asm/div64.h>
-#include <linux/reciprocal_div.h>
 #include <linux/export.h>
+#include <linux/limits.h>
+#include <linux/math.h>
 #include <linux/minmax.h>
+#include <linux/types.h>
+
+#include <linux/reciprocal_div.h>
 
 /*
  * For a description of the algorithm please have a look at
-- 
2.26.1


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

* [PATCH v4 6/7] kernel.h: Split out panic and oops helpers
  2020-04-22 12:51 [PATCH v4 1/7] drm: shmobile: Reduce include dependencies Andy Shevchenko
                   ` (3 preceding siblings ...)
  2020-04-22 12:51 ` [PATCH v4 5/7] kernel.h: Split out mathematical helpers Andy Shevchenko
@ 2020-04-22 12:52 ` Andy Shevchenko
  2020-04-24 17:04     ` kbuild test robot
  2020-04-24 17:27     ` kbuild test robot
  2020-04-22 12:52 ` [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends Andy Shevchenko
  5 siblings, 2 replies; 19+ messages in thread
From: Andy Shevchenko @ 2020-04-22 12:52 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Joe Perches
  Cc: Andy Shevchenko

kernel.h is being used as a dump for all kinds of stuff for a long time.
Here is the attempt to start cleaning it up by splitting out panic and
oops helpers.

At the same time convert users in header and lib folder to use new header.
Though for time being include new header back to kernel.h to avoid twisted
indirected includes for existing users.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: new patch
 arch/x86/include/asm/desc.h    |  1 +
 arch/x86/kernel/setup.c        |  1 +
 include/asm-generic/bug.h      |  3 +-
 include/linux/kernel.h         | 67 +-----------------------------
 include/linux/ktime.h          |  2 +
 include/linux/panic.h          | 75 ++++++++++++++++++++++++++++++++++
 include/linux/panic_notifier.h | 12 ++++++
 include/linux/thread_info.h    |  1 +
 kernel/kexec_core.c            |  1 +
 kernel/panic.c                 |  1 +
 kernel/rcu/tree.c              |  2 +
 kernel/trace/trace.c           |  1 +
 lib/errseq.c                   |  1 +
 13 files changed, 101 insertions(+), 67 deletions(-)
 create mode 100644 include/linux/panic.h
 create mode 100644 include/linux/panic_notifier.h

diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index 68a99d2a5f335..ac3878ac07091 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -9,6 +9,7 @@
 #include <asm/irq_vectors.h>
 #include <asm/cpu_entry_area.h>
 
+#include <linux/debug_locks.h>
 #include <linux/smp.h>
 #include <linux/percpu.h>
 
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index a3767e74c758c..821960a2b412d 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -13,6 +13,7 @@
 #include <linux/initrd.h>
 #include <linux/iscsi_ibft.h>
 #include <linux/memblock.h>
+#include <linux/panic_notifier.h>
 #include <linux/pci.h>
 #include <linux/root_dev.h>
 #include <linux/sfi.h>
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 384b5c835ced3..d3ae3e5b3643e 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -16,7 +16,8 @@
 #endif
 
 #ifndef __ASSEMBLY__
-#include <linux/kernel.h>
+#include <linux/panic.h>
+#include <linux/printk.h>
 
 #ifdef CONFIG_BUG
 
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 8a0e5ed1b905a..cd83a57c1b244 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -13,6 +13,7 @@
 #include <linux/math.h>
 #include <linux/minmax.h>
 #include <linux/typecheck.h>
+#include <linux/panic.h>
 #include <linux/printk.h>
 #include <linux/build_bug.h>
 
@@ -76,7 +77,6 @@
 #define lower_32_bits(n) ((u32)(n))
 
 struct completion;
-struct pt_regs;
 struct user;
 
 #ifdef CONFIG_PREEMPT_VOLUNTARY
@@ -159,15 +159,6 @@ void __might_fault(const char *file, int line);
 static inline void might_fault(void) { }
 #endif
 
-extern struct atomic_notifier_head panic_notifier_list;
-extern long (*panic_blink)(int state);
-__printf(1, 2)
-void panic(const char *fmt, ...) __noreturn __cold;
-void nmi_panic(struct pt_regs *regs, const char *msg);
-extern void oops_enter(void);
-extern void oops_exit(void);
-void print_oops_end_marker(void);
-extern int oops_may_print(void);
 void do_exit(long error_code) __noreturn;
 void complete_and_exit(struct completion *, long) __noreturn;
 
@@ -360,34 +351,7 @@ extern unsigned int sysctl_oops_all_cpu_backtrace;
 #endif /* CONFIG_SMP */
 
 extern void bust_spinlocks(int yes);
-extern int panic_timeout;
-extern unsigned long panic_print;
-extern int panic_on_oops;
-extern int panic_on_unrecovered_nmi;
-extern int panic_on_io_nmi;
-extern int panic_on_warn;
-extern int sysctl_panic_on_rcu_stall;
-extern int sysctl_panic_on_stackoverflow;
 
-extern bool crash_kexec_post_notifiers;
-
-/*
- * panic_cpu is used for synchronizing panic() and crash_kexec() execution. It
- * holds a CPU number which is executing panic() currently. A value of
- * PANIC_CPU_INVALID means no CPU has entered panic() or crash_kexec().
- */
-extern atomic_t panic_cpu;
-#define PANIC_CPU_INVALID	-1
-
-/*
- * Only to be used by arch init code. If the user over-wrote the default
- * CONFIG_PANIC_TIMEOUT, honor it.
- */
-static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
-{
-	if (panic_timeout == arch_default_timeout)
-		panic_timeout = timeout;
-}
 extern const char *print_tainted(void);
 enum lockdep_ok {
 	LOCKDEP_STILL_OK,
@@ -414,35 +378,6 @@ extern enum system_states {
 	SYSTEM_SUSPEND,
 } system_state;
 
-/* This cannot be an enum because some may be used in assembly source. */
-#define TAINT_PROPRIETARY_MODULE	0
-#define TAINT_FORCED_MODULE		1
-#define TAINT_CPU_OUT_OF_SPEC		2
-#define TAINT_FORCED_RMMOD		3
-#define TAINT_MACHINE_CHECK		4
-#define TAINT_BAD_PAGE			5
-#define TAINT_USER			6
-#define TAINT_DIE			7
-#define TAINT_OVERRIDDEN_ACPI_TABLE	8
-#define TAINT_WARN			9
-#define TAINT_CRAP			10
-#define TAINT_FIRMWARE_WORKAROUND	11
-#define TAINT_OOT_MODULE		12
-#define TAINT_UNSIGNED_MODULE		13
-#define TAINT_SOFTLOCKUP		14
-#define TAINT_LIVEPATCH			15
-#define TAINT_AUX			16
-#define TAINT_RANDSTRUCT		17
-#define TAINT_FLAGS_COUNT		18
-
-struct taint_flag {
-	char c_true;	/* character printed when tainted */
-	char c_false;	/* character printed when not tainted */
-	bool module;	/* also show as a per-module taint flag */
-};
-
-extern const struct taint_flag taint_flags[TAINT_FLAGS_COUNT];
-
 extern const char hex_asc[];
 #define hex_asc_lo(x)	hex_asc[((x) & 0x0f)]
 #define hex_asc_hi(x)	hex_asc[((x) & 0xf0) >> 4]
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 42d2e6ac35f29..c7aa465a85f77 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -24,6 +24,8 @@
 #include <linux/time.h>
 #include <linux/jiffies.h>
 
+#include <asm/bug.h>
+
 /* Nanosecond scalar representation for kernel time values */
 typedef s64	ktime_t;
 
diff --git a/include/linux/panic.h b/include/linux/panic.h
new file mode 100644
index 0000000000000..a06e775a5c37f
--- /dev/null
+++ b/include/linux/panic.h
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_PANIC_H
+#define _LINUX_PANIC_H
+
+#include <linux/types.h>
+
+struct pt_regs;
+
+extern long (*panic_blink)(int state);
+__printf(1, 2)
+void panic(const char *fmt, ...) __noreturn __cold;
+void nmi_panic(struct pt_regs *regs, const char *msg);
+extern void oops_enter(void);
+extern void oops_exit(void);
+void print_oops_end_marker(void);
+extern int oops_may_print(void);
+
+extern int panic_timeout;
+extern unsigned long panic_print;
+extern int panic_on_oops;
+extern int panic_on_unrecovered_nmi;
+extern int panic_on_io_nmi;
+extern int panic_on_warn;
+
+extern int sysctl_panic_on_rcu_stall;
+extern int sysctl_panic_on_stackoverflow;
+
+/*
+ * panic_cpu is used for synchronizing panic() and crash_kexec() execution. It
+ * holds a CPU number which is executing panic() currently. A value of
+ * PANIC_CPU_INVALID means no CPU has entered panic() or crash_kexec().
+ */
+extern atomic_t panic_cpu;
+#define PANIC_CPU_INVALID	-1
+
+/*
+ * Only to be used by arch init code. If the user over-wrote the default
+ * CONFIG_PANIC_TIMEOUT, honor it.
+ */
+static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
+{
+	if (panic_timeout == arch_default_timeout)
+		panic_timeout = timeout;
+}
+
+/* This cannot be an enum because some may be used in assembly source. */
+#define TAINT_PROPRIETARY_MODULE	0
+#define TAINT_FORCED_MODULE		1
+#define TAINT_CPU_OUT_OF_SPEC		2
+#define TAINT_FORCED_RMMOD		3
+#define TAINT_MACHINE_CHECK		4
+#define TAINT_BAD_PAGE			5
+#define TAINT_USER			6
+#define TAINT_DIE			7
+#define TAINT_OVERRIDDEN_ACPI_TABLE	8
+#define TAINT_WARN			9
+#define TAINT_CRAP			10
+#define TAINT_FIRMWARE_WORKAROUND	11
+#define TAINT_OOT_MODULE		12
+#define TAINT_UNSIGNED_MODULE		13
+#define TAINT_SOFTLOCKUP		14
+#define TAINT_LIVEPATCH			15
+#define TAINT_AUX			16
+#define TAINT_RANDSTRUCT		17
+#define TAINT_FLAGS_COUNT		18
+
+struct taint_flag {
+	char c_true;	/* character printed when tainted */
+	char c_false;	/* character printed when not tainted */
+	bool module;	/* also show as a per-module taint flag */
+};
+
+extern const struct taint_flag taint_flags[TAINT_FLAGS_COUNT];
+
+#endif	/* _LINUX_PANIC_H */
diff --git a/include/linux/panic_notifier.h b/include/linux/panic_notifier.h
new file mode 100644
index 0000000000000..41e32483d7a7b
--- /dev/null
+++ b/include/linux/panic_notifier.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_PANIC_NOTIFIERS_H
+#define _LINUX_PANIC_NOTIFIERS_H
+
+#include <linux/notifier.h>
+#include <linux/types.h>
+
+extern struct atomic_notifier_head panic_notifier_list;
+
+extern bool crash_kexec_post_notifiers;
+
+#endif	/* _LINUX_PANIC_NOTIFIERS_H */
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index e93e249a4e9bf..7a3033aef28cd 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -35,6 +35,7 @@ enum {
 	GOOD_STACK,
 };
 
+#include <asm/bug.h>
 #include <asm/thread_info.h>
 
 #ifdef __KERNEL__
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index ba1d91e868ca7..077fcf31d5ce9 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -28,6 +28,7 @@
 #include <linux/suspend.h>
 #include <linux/device.h>
 #include <linux/freezer.h>
+#include <linux/panic_notifier.h>
 #include <linux/pfn.h>
 #include <linux/pm.h>
 #include <linux/cpu.h>
diff --git a/kernel/panic.c b/kernel/panic.c
index ec6d7d788ce75..f28a7478e0161 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -23,6 +23,7 @@
 #include <linux/reboot.h>
 #include <linux/delay.h>
 #include <linux/kexec.h>
+#include <linux/panic_notifier.h>
 #include <linux/sched.h>
 #include <linux/sysrq.h>
 #include <linux/init.h>
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 6d39485f7f517..8611f400acd91 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -32,6 +32,8 @@
 #include <linux/export.h>
 #include <linux/completion.h>
 #include <linux/moduleparam.h>
+#include <linux/panic.h>
+#include <linux/panic_notifier.h>
 #include <linux/percpu.h>
 #include <linux/notifier.h>
 #include <linux/cpu.h>
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8d2b988126250..f23b6ae084b5c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -39,6 +39,7 @@
 #include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/init.h>
+#include <linux/panic_notifier.h>
 #include <linux/poll.h>
 #include <linux/nmi.h>
 #include <linux/fs.h>
diff --git a/lib/errseq.c b/lib/errseq.c
index 81f9e33aa7e72..93e9b94358dc6 100644
--- a/lib/errseq.c
+++ b/lib/errseq.c
@@ -3,6 +3,7 @@
 #include <linux/bug.h>
 #include <linux/atomic.h>
 #include <linux/errseq.h>
+#include <linux/log2.h>
 
 /*
  * An errseq_t is a way of recording errors in one place, and allowing any
-- 
2.26.1


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

* [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends
  2020-04-22 12:51 [PATCH v4 1/7] drm: shmobile: Reduce include dependencies Andy Shevchenko
                   ` (4 preceding siblings ...)
  2020-04-22 12:52 ` [PATCH v4 6/7] kernel.h: Split out panic and oops helpers Andy Shevchenko
@ 2020-04-22 12:52 ` Andy Shevchenko
  2020-04-24 15:49     ` kbuild test robot
  2020-04-24 17:45     ` kbuild test robot
  5 siblings, 2 replies; 19+ messages in thread
From: Andy Shevchenko @ 2020-04-22 12:52 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Joe Perches
  Cc: Andy Shevchenko

kernel.h is being used as a dump for all kinds of stuff for a long time.
Here is the attempt to start cleaning it up by splitting out might_sleep()
and friends.

At the same time convert users in header and crypto folder to use new header.
Though for time being include new header back to kernel.h to avoid twisted
indirected includes for existing users.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: rebase on latest kernel and previous patches in the series
 crypto/asymmetric_keys/pkcs7_trust.c |  3 +-
 include/linux/kernel.h               | 67 +------------------------
 include/linux/might_sleep.h          | 73 ++++++++++++++++++++++++++++
 include/linux/percpu-rwsem.h         |  1 +
 include/linux/sched.h                |  1 +
 include/linux/wait_bit.h             |  1 +
 6 files changed, 79 insertions(+), 67 deletions(-)
 create mode 100644 include/linux/might_sleep.h

diff --git a/crypto/asymmetric_keys/pkcs7_trust.c b/crypto/asymmetric_keys/pkcs7_trust.c
index 61af3c4d82ccf..9a3f0c3cafa27 100644
--- a/crypto/asymmetric_keys/pkcs7_trust.c
+++ b/crypto/asymmetric_keys/pkcs7_trust.c
@@ -6,8 +6,9 @@
  */
 
 #define pr_fmt(fmt) "PKCS7: "fmt
-#include <linux/kernel.h>
 #include <linux/export.h>
+#include <linux/might_sleep.h>
+#include <linux/printk.h>
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/asn1.h>
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index cd83a57c1b244..4558a6af90399 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -11,6 +11,7 @@
 #include <linux/bitops.h>
 #include <linux/log2.h>
 #include <linux/math.h>
+#include <linux/might_sleep.h>
 #include <linux/minmax.h>
 #include <linux/typecheck.h>
 #include <linux/panic.h>
@@ -77,72 +78,6 @@
 #define lower_32_bits(n) ((u32)(n))
 
 struct completion;
-struct user;
-
-#ifdef CONFIG_PREEMPT_VOLUNTARY
-extern int _cond_resched(void);
-# define might_resched() _cond_resched()
-#else
-# define might_resched() do { } while (0)
-#endif
-
-#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
-extern void ___might_sleep(const char *file, int line, int preempt_offset);
-extern void __might_sleep(const char *file, int line, int preempt_offset);
-extern void __cant_sleep(const char *file, int line, int preempt_offset);
-
-/**
- * might_sleep - annotation for functions that can sleep
- *
- * this macro will print a stack trace if it is executed in an atomic
- * context (spinlock, irq-handler, ...). Additional sections where blocking is
- * not allowed can be annotated with non_block_start() and non_block_end()
- * pairs.
- *
- * This is a useful debugging help to be able to catch problems early and not
- * be bitten later when the calling function happens to sleep when it is not
- * supposed to.
- */
-# define might_sleep() \
-	do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
-/**
- * cant_sleep - annotation for functions that cannot sleep
- *
- * this macro will print a stack trace if it is executed with preemption enabled
- */
-# define cant_sleep() \
-	do { __cant_sleep(__FILE__, __LINE__, 0); } while (0)
-# define sched_annotate_sleep()	(current->task_state_change = 0)
-/**
- * non_block_start - annotate the start of section where sleeping is prohibited
- *
- * This is on behalf of the oom reaper, specifically when it is calling the mmu
- * notifiers. The problem is that if the notifier were to block on, for example,
- * mutex_lock() and if the process which holds that mutex were to perform a
- * sleeping memory allocation, the oom reaper is now blocked on completion of
- * that memory allocation. Other blocking calls like wait_event() pose similar
- * issues.
- */
-# define non_block_start() (current->non_block_count++)
-/**
- * non_block_end - annotate the end of section where sleeping is prohibited
- *
- * Closes a section opened by non_block_start().
- */
-# define non_block_end() WARN_ON(current->non_block_count-- == 0)
-#else
-  static inline void ___might_sleep(const char *file, int line,
-				   int preempt_offset) { }
-  static inline void __might_sleep(const char *file, int line,
-				   int preempt_offset) { }
-# define might_sleep() do { might_resched(); } while (0)
-# define cant_sleep() do { } while (0)
-# define sched_annotate_sleep() do { } while (0)
-# define non_block_start() do { } while (0)
-# define non_block_end() do { } while (0)
-#endif
-
-#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
 
 #ifndef CONFIG_PREEMPT_RT
 # define cant_migrate()		cant_sleep()
diff --git a/include/linux/might_sleep.h b/include/linux/might_sleep.h
new file mode 100644
index 0000000000000..dbf0097113337
--- /dev/null
+++ b/include/linux/might_sleep.h
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_MIGHT_SLEEP_H
+#define _LINUX_MIGHT_SLEEP_H
+
+#include <asm/bug.h>
+#include <asm/current.h>
+
+#ifdef CONFIG_PREEMPT_VOLUNTARY
+extern int _cond_resched(void);
+# define might_resched() _cond_resched()
+#else
+# define might_resched() do { } while (0)
+#endif
+
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
+extern void ___might_sleep(const char *file, int line, int preempt_offset);
+extern void __might_sleep(const char *file, int line, int preempt_offset);
+extern void __cant_sleep(const char *file, int line, int preempt_offset);
+
+/**
+ * might_sleep - annotation for functions that can sleep
+ *
+ * this macro will print a stack trace if it is executed in an atomic
+ * context (spinlock, irq-handler, ...). Additional sections where blocking is
+ * not allowed can be annotated with non_block_start() and non_block_end()
+ * pairs.
+ *
+ * This is a useful debugging help to be able to catch problems early and not
+ * be bitten later when the calling function happens to sleep when it is not
+ * supposed to.
+ */
+# define might_sleep() \
+	do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
+/**
+ * cant_sleep - annotation for functions that cannot sleep
+ *
+ * this macro will print a stack trace if it is executed with preemption enabled
+ */
+# define cant_sleep() \
+	do { __cant_sleep(__FILE__, __LINE__, 0); } while (0)
+# define sched_annotate_sleep()	(current->task_state_change = 0)
+/**
+ * non_block_start - annotate the start of section where sleeping is prohibited
+ *
+ * This is on behalf of the oom reaper, specifically when it is calling the mmu
+ * notifiers. The problem is that if the notifier were to block on, for example,
+ * mutex_lock() and if the process which holds that mutex were to perform a
+ * sleeping memory allocation, the oom reaper is now blocked on completion of
+ * that memory allocation. Other blocking calls like wait_event() pose similar
+ * issues.
+ */
+# define non_block_start() (current->non_block_count++)
+/**
+ * non_block_end - annotate the end of section where sleeping is prohibited
+ *
+ * Closes a section opened by non_block_start().
+ */
+# define non_block_end() WARN_ON(current->non_block_count-- == 0)
+#else
+  static inline void ___might_sleep(const char *file, int line,
+				   int preempt_offset) { }
+  static inline void __might_sleep(const char *file, int line,
+				   int preempt_offset) { }
+# define might_sleep() do { might_resched(); } while (0)
+# define cant_sleep() do { } while (0)
+# define sched_annotate_sleep() do { } while (0)
+# define non_block_start() do { } while (0)
+# define non_block_end() do { } while (0)
+#endif
+
+#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
+
+#endif	/* _LINUX_MIGHT_SLEEP_H */
diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
index 5e033fe1ff4e9..504cb587cf7ea 100644
--- a/include/linux/percpu-rwsem.h
+++ b/include/linux/percpu-rwsem.h
@@ -3,6 +3,7 @@
 #define _LINUX_PERCPU_RWSEM_H
 
 #include <linux/atomic.h>
+#include <linux/might_sleep.h>
 #include <linux/percpu.h>
 #include <linux/rcuwait.h>
 #include <linux/wait.h>
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 36306c7d2afcc..7acc5a2df398e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -15,6 +15,7 @@
 #include <linux/sem.h>
 #include <linux/shm.h>
 #include <linux/kcov.h>
+#include <linux/might_sleep.h>
 #include <linux/mutex.h>
 #include <linux/plist.h>
 #include <linux/hrtimer.h>
diff --git a/include/linux/wait_bit.h b/include/linux/wait_bit.h
index 7dec36aecbd9f..324cdbf5b4a49 100644
--- a/include/linux/wait_bit.h
+++ b/include/linux/wait_bit.h
@@ -5,6 +5,7 @@
 /*
  * Linux wait-bit related types and methods:
  */
+#include <linux/might_sleep.h>
 #include <linux/wait.h>
 
 struct wait_bit_key {
-- 
2.26.1


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

* Re: [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers
  2020-04-22 12:51 ` [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers Andy Shevchenko
@ 2020-04-22 14:52   ` Joe Perches
  2020-04-22 15:44     ` Andy Shevchenko
  2020-04-23  9:33     ` Rasmus Villemoes
  0 siblings, 2 replies; 19+ messages in thread
From: Joe Perches @ 2020-04-22 14:52 UTC (permalink / raw)
  To: Andy Shevchenko, Andrew Morton, linux-kernel, Steven Rostedt,
	Rasmus Villemoes
  Cc: Linus Torvalds

On Wed, 2020-04-22 at 15:51 +0300, Andy Shevchenko wrote:
> kernel.h is being used as a dump for all kinds of stuff for a long time.
> Here is the attempt to start cleaning it up by splitting out min()/max()
> et al helpers.

While adding organization into kernel.h by splitting
out various bits into separate files is a fine idea,
I believe removing the generic #include <linux/kernel.h>
from various files and substituting the sub-includes
is not a good idea.

> At the same time convert users in header and lib folder to use new header.
> Though for time being include new header back to kernel.h to avoid twisted
> indirected includes for existing users.

Yeah, that's the difficult bit and it could make
using precompiled headers very cumbersome.

I'd rather make #include <linux/kernel.h>" _more_
common or even used as the mandatory first #include
for all kernel .c files.

That would also ensure that common kernel facilities
are not duplicated or have naming conflicts with other
files.



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

* Re: [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers
  2020-04-22 14:52   ` Joe Perches
@ 2020-04-22 15:44     ` Andy Shevchenko
  2020-04-22 15:51       ` Joe Perches
  2020-04-23  9:33     ` Rasmus Villemoes
  1 sibling, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2020-04-22 15:44 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Linus Torvalds

On Wed, Apr 22, 2020 at 07:52:32AM -0700, Joe Perches wrote:
> On Wed, 2020-04-22 at 15:51 +0300, Andy Shevchenko wrote:
> > kernel.h is being used as a dump for all kinds of stuff for a long time.
> > Here is the attempt to start cleaning it up by splitting out min()/max()
> > et al helpers.
> 
> While adding organization into kernel.h by splitting
> out various bits into separate files is a fine idea,
> I believe removing the generic #include <linux/kernel.h>
> from various files and substituting the sub-includes
> is not a good idea.

Are you sure?

> > At the same time convert users in header and lib folder to use new header.
> > Though for time being include new header back to kernel.h to avoid twisted
> > indirected includes for existing users.
> 
> Yeah, that's the difficult bit and it could make
> using precompiled headers very cumbersome.
> 
> I'd rather make #include <linux/kernel.h>" _more_
> common or even used as the mandatory first #include
> for all kernel .c files.

Huh?

Perhaps we may just cat include/linux/* > include/linux/kernel.h?

> That would also ensure that common kernel facilities
> are not duplicated or have naming conflicts with other
> files.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers
  2020-04-22 15:44     ` Andy Shevchenko
@ 2020-04-22 15:51       ` Joe Perches
  0 siblings, 0 replies; 19+ messages in thread
From: Joe Perches @ 2020-04-22 15:51 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andrew Morton, linux-kernel, Steven Rostedt, Rasmus Villemoes,
	Linus Torvalds

On Wed, 2020-04-22 at 18:44 +0300, Andy Shevchenko wrote:
> On Wed, Apr 22, 2020 at 07:52:32AM -0700, Joe Perches wrote:
> > On Wed, 2020-04-22 at 15:51 +0300, Andy Shevchenko wrote:
> > > kernel.h is being used as a dump for all kinds of stuff for a long time.
> > > Here is the attempt to start cleaning it up by splitting out min()/max()
> > > et al helpers.
> > 
> > While adding organization into kernel.h by splitting
> > out various bits into separate files is a fine idea,
> > I believe removing the generic #include <linux/kernel.h>
> > from various files and substituting the sub-includes
> > is not a good idea.
> 
> Are you sure?

Yes.

> Perhaps we may just cat include/linux/* > include/linux/kernel.h?

Silly argument,  There's a real argument to be made to
tmove many of the files in include/linux to separate
directories or out of include/ altogether to subsystem
specific locations.



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

* Re: [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers
  2020-04-22 14:52   ` Joe Perches
  2020-04-22 15:44     ` Andy Shevchenko
@ 2020-04-23  9:33     ` Rasmus Villemoes
  1 sibling, 0 replies; 19+ messages in thread
From: Rasmus Villemoes @ 2020-04-23  9:33 UTC (permalink / raw)
  To: Joe Perches, Andy Shevchenko, Andrew Morton, linux-kernel,
	Steven Rostedt
  Cc: Linus Torvalds

On 22/04/2020 16.52, Joe Perches wrote:
> On Wed, 2020-04-22 at 15:51 +0300, Andy Shevchenko wrote:

>> At the same time convert users in header and lib folder to use new header.
>> Though for time being include new header back to kernel.h to avoid twisted
>> indirected includes for existing users.
> 
> Yeah, that's the difficult bit and it could make
> using precompiled headers very cumbersome.

You mentioned precompiled headers last time as well, but you haven't
demonstrated that using those is either feasible or advantageous - and
if at some distant future time it turns out that they are a good idea,
it's not really any more difficult at that time to do a
linux/kitchen_sink.h that includes whatever common set of headers seems
to provide a reasonable speedup.

Meanwhile, the sheer size of the headers that gets pulled into each and
every TU currently slows down the build:

https://wildmoose.dk/header-bloat/

so anything that reduces the size of common headers like kernel.h will
improve build times (the slowdown is "death by a thousand cuts", hence
so will any individual improvement be hard or impossible to measure by
itself - that doesn't mean it's not worth doing them). Of course, the
include of minmax.h (et al) from kernel.h must be removed, but that's
the kind of thing that can easily take a couple of cycles to get done,
unlike the damage that adding #include <linux/foo.h> to bar.h
immediately causes.

> I'd rather make #include <linux/kernel.h>" _more_
> common or even used as the mandatory first #include
> for all kernel .c files.

No. Please no.

> That would also ensure that common kernel facilities
> are not duplicated or have naming conflicts with other
> files.

What? People duplicate functionality because they're not aware it
already exists, forcing an #include of a declaration of some function
doesn't make any developer know about it.

Rasmus

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

* Re: [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends
  2020-04-22 12:52 ` [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends Andy Shevchenko
@ 2020-04-24 15:49     ` kbuild test robot
  2020-04-24 17:45     ` kbuild test robot
  1 sibling, 0 replies; 19+ messages in thread
From: kbuild test robot @ 2020-04-24 15:49 UTC (permalink / raw)
  To: Andy Shevchenko, Andrew Morton, linux-kernel, Steven Rostedt,
	Rasmus Villemoes, Joe Perches
  Cc: kbuild-all, Linux Memory Management List, Andy Shevchenko

[-- Attachment #1: Type: text/plain, Size: 4040 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200423]
[cannot apply to tip/locking/core rcu/dev linus/master tip/x86/core v5.7-rc2 v5.7-rc1 v5.6 v5.7-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/drm-shmobile-Reduce-include-dependencies/20200424-044529
base:    aefe184e814492e36b2ca350c1522bd71b09b520
config: mips-malta_kvm_guest_defconfig (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/cpumask.h:12,
                    from arch/mips/include/asm/processor.h:15,
                    from arch/mips/include/asm/thread_info.h:16,
                    from include/linux/thread_info.h:39,
                    from include/asm-generic/current.h:5,
                    from ./arch/mips/include/generated/asm/current.h:1,
                    from include/linux/might_sleep.h:6,
                    from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/preempt.h:11,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/compat.h:10,
                    from arch/mips/kernel/asm-offsets.c:12:
   include/linux/bitmap.h: In function 'bitmap_equal':
>> include/linux/bitmap.h:339:6: error: implicit declaration of function 'IS_ALIGNED' [-Werror=implicit-function-declaration]
     339 |      IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
         |      ^~~~~~~~~~
   cc1: some warnings being treated as errors
   make[2]: *** [scripts/Makefile.build:100: arch/mips/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1142: prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:180: sub-make] Error 2

vim +/IS_ALIGNED +339 include/linux/bitmap.h

21035965f60b050 Omar Sandoval      2018-04-02  332  
^1da177e4c3f415 Linus Torvalds     2005-04-16  333  static inline int bitmap_equal(const unsigned long *src1,
3d6684f4e6a46f3 Rasmus Villemoes   2014-08-06  334  			const unsigned long *src2, unsigned int nbits)
^1da177e4c3f415 Linus Torvalds     2005-04-16  335  {
4b0bc0bca83f3fb Rusty Russell      2008-12-30  336  	if (small_const_nbits(nbits))
^1da177e4c3f415 Linus Torvalds     2005-04-16  337  		return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
21035965f60b050 Omar Sandoval      2018-04-02  338  	if (__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
21035965f60b050 Omar Sandoval      2018-04-02 @339  	    IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
7dd968163f7c12b Martin Schwidefsky 2016-05-25  340  		return !memcmp(src1, src2, nbits / 8);
^1da177e4c3f415 Linus Torvalds     2005-04-16  341  	return __bitmap_equal(src1, src2, nbits);
^1da177e4c3f415 Linus Torvalds     2005-04-16  342  }
^1da177e4c3f415 Linus Torvalds     2005-04-16  343  

:::::: The code at line 339 was first introduced by commit
:::::: 21035965f60b0502fc6537b232839389bb4ce664 bitmap: fix memset optimization on big-endian systems

:::::: TO: Omar Sandoval <osandov@fb.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 20998 bytes --]

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

* Re: [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends
@ 2020-04-24 15:49     ` kbuild test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kbuild test robot @ 2020-04-24 15:49 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4117 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200423]
[cannot apply to tip/locking/core rcu/dev linus/master tip/x86/core v5.7-rc2 v5.7-rc1 v5.6 v5.7-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/drm-shmobile-Reduce-include-dependencies/20200424-044529
base:    aefe184e814492e36b2ca350c1522bd71b09b520
config: mips-malta_kvm_guest_defconfig (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/cpumask.h:12,
                    from arch/mips/include/asm/processor.h:15,
                    from arch/mips/include/asm/thread_info.h:16,
                    from include/linux/thread_info.h:39,
                    from include/asm-generic/current.h:5,
                    from ./arch/mips/include/generated/asm/current.h:1,
                    from include/linux/might_sleep.h:6,
                    from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/preempt.h:11,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/compat.h:10,
                    from arch/mips/kernel/asm-offsets.c:12:
   include/linux/bitmap.h: In function 'bitmap_equal':
>> include/linux/bitmap.h:339:6: error: implicit declaration of function 'IS_ALIGNED' [-Werror=implicit-function-declaration]
     339 |      IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
         |      ^~~~~~~~~~
   cc1: some warnings being treated as errors
   make[2]: *** [scripts/Makefile.build:100: arch/mips/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1142: prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:180: sub-make] Error 2

vim +/IS_ALIGNED +339 include/linux/bitmap.h

21035965f60b050 Omar Sandoval      2018-04-02  332  
^1da177e4c3f415 Linus Torvalds     2005-04-16  333  static inline int bitmap_equal(const unsigned long *src1,
3d6684f4e6a46f3 Rasmus Villemoes   2014-08-06  334  			const unsigned long *src2, unsigned int nbits)
^1da177e4c3f415 Linus Torvalds     2005-04-16  335  {
4b0bc0bca83f3fb Rusty Russell      2008-12-30  336  	if (small_const_nbits(nbits))
^1da177e4c3f415 Linus Torvalds     2005-04-16  337  		return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
21035965f60b050 Omar Sandoval      2018-04-02  338  	if (__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
21035965f60b050 Omar Sandoval      2018-04-02 @339  	    IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
7dd968163f7c12b Martin Schwidefsky 2016-05-25  340  		return !memcmp(src1, src2, nbits / 8);
^1da177e4c3f415 Linus Torvalds     2005-04-16  341  	return __bitmap_equal(src1, src2, nbits);
^1da177e4c3f415 Linus Torvalds     2005-04-16  342  }
^1da177e4c3f415 Linus Torvalds     2005-04-16  343  

:::::: The code at line 339 was first introduced by commit
:::::: 21035965f60b0502fc6537b232839389bb4ce664 bitmap: fix memset optimization on big-endian systems

:::::: TO: Omar Sandoval <osandov@fb.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 20998 bytes --]

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

* Re: [PATCH v4 6/7] kernel.h: Split out panic and oops helpers
  2020-04-22 12:52 ` [PATCH v4 6/7] kernel.h: Split out panic and oops helpers Andy Shevchenko
@ 2020-04-24 17:04     ` kbuild test robot
  2020-04-24 17:27     ` kbuild test robot
  1 sibling, 0 replies; 19+ messages in thread
From: kbuild test robot @ 2020-04-24 17:04 UTC (permalink / raw)
  To: Andy Shevchenko, Andrew Morton, linux-kernel, Steven Rostedt,
	Rasmus Villemoes, Joe Perches
  Cc: kbuild-all, Linux Memory Management List, Andy Shevchenko

[-- Attachment #1: Type: text/plain, Size: 12664 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200423]
[cannot apply to tip/locking/core rcu/dev linus/master tip/x86/core v5.7-rc2 v5.7-rc1 v5.6 v5.7-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/drm-shmobile-Reduce-include-dependencies/20200424-044529
base:    aefe184e814492e36b2ca350c1522bd71b09b520
config: powerpc-allnoconfig (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   arch/powerpc/kernel/setup-common.c: In function 'setup_panic':
>> arch/powerpc/kernel/setup-common.c:737:35: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     737 |   atomic_notifier_chain_register(&panic_notifier_list,
         |                                   ^~~~~~~~~~~~~~~~~~~
         |                                   reboot_notifier_list
   arch/powerpc/kernel/setup-common.c:737:35: note: each undeclared identifier is reported only once for each function it appears in
--
   In file included from arch/powerpc/include/asm/atomic.h:11,
                    from include/linux/atomic.h:7,
                    from include/linux/jump_label.h:249,
                    from arch/powerpc/lib/feature-fixups.c:12:
   arch/powerpc/include/asm/cmpxchg.h: In function '__xchg_u8_local':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:83:1: note: in expansion of macro 'XCHG_GEN'
      83 | XCHG_GEN(u8, _local, "memory");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:12:61: note: each undeclared identifier is reported only once for each function it appears in
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:83:1: note: in expansion of macro 'XCHG_GEN'
      83 | XCHG_GEN(u8, _local, "memory");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__xchg_u8_relaxed':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:84:1: note: in expansion of macro 'XCHG_GEN'
      84 | XCHG_GEN(u8, _relaxed, "cc");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__xchg_u16_local':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:85:1: note: in expansion of macro 'XCHG_GEN'
      85 | XCHG_GEN(u16, _local, "memory");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__xchg_u16_relaxed':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:86:1: note: in expansion of macro 'XCHG_GEN'
      86 | XCHG_GEN(u16, _relaxed, "cc");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u8':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:213:1: note: in expansion of macro 'CMPXCHG_GEN'
     213 | CMPXCHG_GEN(u8, , PPC_ATOMIC_ENTRY_BARRIER, PPC_ATOMIC_EXIT_BARRIER, "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u8_local':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:214:1: note: in expansion of macro 'CMPXCHG_GEN'
     214 | CMPXCHG_GEN(u8, _local, , , "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u8_acquire':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:215:1: note: in expansion of macro 'CMPXCHG_GEN'
     215 | CMPXCHG_GEN(u8, _acquire, , PPC_ACQUIRE_BARRIER, "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u8_relaxed':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:216:1: note: in expansion of macro 'CMPXCHG_GEN'
     216 | CMPXCHG_GEN(u8, _relaxed, , , "cc");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u16':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:217:1: note: in expansion of macro 'CMPXCHG_GEN'
     217 | CMPXCHG_GEN(u16, , PPC_ATOMIC_ENTRY_BARRIER, PPC_ATOMIC_EXIT_BARRIER, "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u16_local':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:218:1: note: in expansion of macro 'CMPXCHG_GEN'
     218 | CMPXCHG_GEN(u16, _local, , , "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u16_acquire':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:219:1: note: in expansion of macro 'CMPXCHG_GEN'
     219 | CMPXCHG_GEN(u16, _acquire, , PPC_ACQUIRE_BARRIER, "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u16_relaxed':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:220:1: note: in expansion of macro 'CMPXCHG_GEN'
     220 | CMPXCHG_GEN(u16, _relaxed, , , "cc");
         | ^~~~~~~~~~~

vim +737 arch/powerpc/kernel/setup-common.c

921a79b7802078 Jason Yan       2019-09-20  733  
ab9dbf771ff9b6 David Gibson    2017-12-04  734  void __init setup_panic(void)
ab9dbf771ff9b6 David Gibson    2017-12-04  735  {
921a79b7802078 Jason Yan       2019-09-20  736  	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0)
921a79b7802078 Jason Yan       2019-09-20 @737  		atomic_notifier_chain_register(&panic_notifier_list,
921a79b7802078 Jason Yan       2019-09-20  738  					       &kernel_offset_notifier);
921a79b7802078 Jason Yan       2019-09-20  739  
855b6232dda2b6 Nicholas Piggin 2018-05-19  740  	/* PPC64 always does a hard irq disable in its panic handler */
855b6232dda2b6 Nicholas Piggin 2018-05-19  741  	if (!IS_ENABLED(CONFIG_PPC64) && !ppc_md.panic)
ab9dbf771ff9b6 David Gibson    2017-12-04  742  		return;
ab9dbf771ff9b6 David Gibson    2017-12-04  743  	atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
ab9dbf771ff9b6 David Gibson    2017-12-04  744  }
ab9dbf771ff9b6 David Gibson    2017-12-04  745  

:::::: The code at line 737 was first introduced by commit
:::::: 921a79b7802078fab3787c7eae561536906cb8f3 powerpc/fsl_booke/kaslr: dump out kernel offset information on panic

:::::: TO: Jason Yan <yanaijie@huawei.com>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 6465 bytes --]

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

* Re: [PATCH v4 6/7] kernel.h: Split out panic and oops helpers
@ 2020-04-24 17:04     ` kbuild test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kbuild test robot @ 2020-04-24 17:04 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 12857 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200423]
[cannot apply to tip/locking/core rcu/dev linus/master tip/x86/core v5.7-rc2 v5.7-rc1 v5.6 v5.7-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/drm-shmobile-Reduce-include-dependencies/20200424-044529
base:    aefe184e814492e36b2ca350c1522bd71b09b520
config: powerpc-allnoconfig (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   arch/powerpc/kernel/setup-common.c: In function 'setup_panic':
>> arch/powerpc/kernel/setup-common.c:737:35: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     737 |   atomic_notifier_chain_register(&panic_notifier_list,
         |                                   ^~~~~~~~~~~~~~~~~~~
         |                                   reboot_notifier_list
   arch/powerpc/kernel/setup-common.c:737:35: note: each undeclared identifier is reported only once for each function it appears in
--
   In file included from arch/powerpc/include/asm/atomic.h:11,
                    from include/linux/atomic.h:7,
                    from include/linux/jump_label.h:249,
                    from arch/powerpc/lib/feature-fixups.c:12:
   arch/powerpc/include/asm/cmpxchg.h: In function '__xchg_u8_local':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:83:1: note: in expansion of macro 'XCHG_GEN'
      83 | XCHG_GEN(u8, _local, "memory");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:12:61: note: each undeclared identifier is reported only once for each function it appears in
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:83:1: note: in expansion of macro 'XCHG_GEN'
      83 | XCHG_GEN(u8, _local, "memory");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__xchg_u8_relaxed':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:84:1: note: in expansion of macro 'XCHG_GEN'
      84 | XCHG_GEN(u8, _relaxed, "cc");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__xchg_u16_local':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:85:1: note: in expansion of macro 'XCHG_GEN'
      85 | XCHG_GEN(u16, _local, "memory");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__xchg_u16_relaxed':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:23:11: note: in expansion of macro 'BITOFF_CAL'
      23 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:86:1: note: in expansion of macro 'XCHG_GEN'
      86 | XCHG_GEN(u16, _relaxed, "cc");
         | ^~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u8':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
>> arch/powerpc/include/asm/cmpxchg.h:213:1: note: in expansion of macro 'CMPXCHG_GEN'
     213 | CMPXCHG_GEN(u8, , PPC_ATOMIC_ENTRY_BARRIER, PPC_ATOMIC_EXIT_BARRIER, "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u8_local':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:214:1: note: in expansion of macro 'CMPXCHG_GEN'
     214 | CMPXCHG_GEN(u8, _local, , , "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u8_acquire':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:215:1: note: in expansion of macro 'CMPXCHG_GEN'
     215 | CMPXCHG_GEN(u8, _acquire, , PPC_ACQUIRE_BARRIER, "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u8_relaxed':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:216:1: note: in expansion of macro 'CMPXCHG_GEN'
     216 | CMPXCHG_GEN(u8, _relaxed, , , "cc");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u16':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:217:1: note: in expansion of macro 'CMPXCHG_GEN'
     217 | CMPXCHG_GEN(u16, , PPC_ATOMIC_ENTRY_BARRIER, PPC_ATOMIC_EXIT_BARRIER, "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u16_local':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:218:1: note: in expansion of macro 'CMPXCHG_GEN'
     218 | CMPXCHG_GEN(u16, _local, , , "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u16_acquire':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:219:1: note: in expansion of macro 'CMPXCHG_GEN'
     219 | CMPXCHG_GEN(u16, _acquire, , PPC_ACQUIRE_BARRIER, "memory");
         | ^~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h: In function '__cmpxchg_u16_relaxed':
>> arch/powerpc/include/asm/cmpxchg.h:12:61: error: 'BITS_PER_BYTE' undeclared (first use in this function); did you mean 'BITS_PER_LONG'?
      12 | #define BITOFF_CAL(size, off) ((sizeof(u32) - size - off) * BITS_PER_BYTE)
         |                                                             ^~~~~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:49:11: note: in expansion of macro 'BITOFF_CAL'
      49 |  bitoff = BITOFF_CAL(sizeof(type), off);   \
         |           ^~~~~~~~~~
   arch/powerpc/include/asm/cmpxchg.h:220:1: note: in expansion of macro 'CMPXCHG_GEN'
     220 | CMPXCHG_GEN(u16, _relaxed, , , "cc");
         | ^~~~~~~~~~~

vim +737 arch/powerpc/kernel/setup-common.c

921a79b7802078 Jason Yan       2019-09-20  733  
ab9dbf771ff9b6 David Gibson    2017-12-04  734  void __init setup_panic(void)
ab9dbf771ff9b6 David Gibson    2017-12-04  735  {
921a79b7802078 Jason Yan       2019-09-20  736  	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0)
921a79b7802078 Jason Yan       2019-09-20 @737  		atomic_notifier_chain_register(&panic_notifier_list,
921a79b7802078 Jason Yan       2019-09-20  738  					       &kernel_offset_notifier);
921a79b7802078 Jason Yan       2019-09-20  739  
855b6232dda2b6 Nicholas Piggin 2018-05-19  740  	/* PPC64 always does a hard irq disable in its panic handler */
855b6232dda2b6 Nicholas Piggin 2018-05-19  741  	if (!IS_ENABLED(CONFIG_PPC64) && !ppc_md.panic)
ab9dbf771ff9b6 David Gibson    2017-12-04  742  		return;
ab9dbf771ff9b6 David Gibson    2017-12-04  743  	atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
ab9dbf771ff9b6 David Gibson    2017-12-04  744  }
ab9dbf771ff9b6 David Gibson    2017-12-04  745  

:::::: The code at line 737 was first introduced by commit
:::::: 921a79b7802078fab3787c7eae561536906cb8f3 powerpc/fsl_booke/kaslr: dump out kernel offset information on panic

:::::: TO: Jason Yan <yanaijie@huawei.com>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 6465 bytes --]

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

* Re: [PATCH v4 6/7] kernel.h: Split out panic and oops helpers
  2020-04-22 12:52 ` [PATCH v4 6/7] kernel.h: Split out panic and oops helpers Andy Shevchenko
@ 2020-04-24 17:27     ` kbuild test robot
  2020-04-24 17:27     ` kbuild test robot
  1 sibling, 0 replies; 19+ messages in thread
From: kbuild test robot @ 2020-04-24 17:27 UTC (permalink / raw)
  To: Andy Shevchenko, Andrew Morton, linux-kernel, Steven Rostedt,
	Rasmus Villemoes, Joe Perches
  Cc: kbuild-all, Linux Memory Management List, Andy Shevchenko

[-- Attachment #1: Type: text/plain, Size: 9794 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200423]
[cannot apply to tip/locking/core rcu/dev linus/master tip/x86/core v5.7-rc2 v5.7-rc1 v5.6 v5.7-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/drm-shmobile-Reduce-include-dependencies/20200424-044529
base:    aefe184e814492e36b2ca350c1522bd71b09b520
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/char/ipmi/ipmi_msghandler.c: In function 'ipmi_init_msghandler':
>> drivers/char/ipmi/ipmi_msghandler.c:5145:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
    5145 |  atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/char/ipmi/ipmi_msghandler.c:5145:34: note: each undeclared identifier is reported only once for each function it appears in
   drivers/char/ipmi/ipmi_msghandler.c: In function 'cleanup_ipmi':
   drivers/char/ipmi/ipmi_msghandler.c:5172:37: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
    5172 |   atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                     ^~~~~~~~~~~~~~~~~~~
         |                                     reboot_notifier_list
--
   drivers/misc/pvpanic.c: In function 'pvpanic_mmio_probe':
>> drivers/misc/pvpanic.c:156:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     156 |  atomic_notifier_chain_register(&panic_notifier_list,
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/misc/pvpanic.c:156:34: note: each undeclared identifier is reported only once for each function it appears in
   drivers/misc/pvpanic.c: In function 'pvpanic_mmio_remove':
   drivers/misc/pvpanic.c:165:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     165 |  atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/remoteproc/remoteproc_core.c: In function 'rproc_init_panic':
>> drivers/remoteproc/remoteproc_core.c:2383:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
    2383 |  atomic_notifier_chain_register(&panic_notifier_list, &rproc_panic_nb);
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/remoteproc/remoteproc_core.c:2383:34: note: each undeclared identifier is reported only once for each function it appears in
   drivers/remoteproc/remoteproc_core.c: In function 'rproc_exit_panic':
   drivers/remoteproc/remoteproc_core.c:2388:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
    2388 |  atomic_notifier_chain_unregister(&panic_notifier_list, &rproc_panic_nb);
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/power/reset/ltc2952-poweroff.c: In function 'ltc2952_poweroff_probe':
>> drivers/power/reset/ltc2952-poweroff.c:276:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     276 |  atomic_notifier_chain_register(&panic_notifier_list,
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/power/reset/ltc2952-poweroff.c:276:34: note: each undeclared identifier is reported only once for each function it appears in
   drivers/power/reset/ltc2952-poweroff.c: In function 'ltc2952_poweroff_remove':
   drivers/power/reset/ltc2952-poweroff.c:290:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     290 |  atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/leds/trigger/ledtrig-heartbeat.c: In function 'heartbeat_trig_init':
>> drivers/leds/trigger/ledtrig-heartbeat.c:192:35: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     192 |   atomic_notifier_chain_register(&panic_notifier_list,
         |                                   ^~~~~~~~~~~~~~~~~~~
         |                                   reboot_notifier_list
   drivers/leds/trigger/ledtrig-heartbeat.c:192:35: note: each undeclared identifier is reported only once for each function it appears in
   drivers/leds/trigger/ledtrig-heartbeat.c: In function 'heartbeat_trig_exit':
   drivers/leds/trigger/ledtrig-heartbeat.c:202:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     202 |  atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/leds/trigger/ledtrig-activity.c: In function 'activity_init':
>> drivers/leds/trigger/ledtrig-activity.c:249:35: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     249 |   atomic_notifier_chain_register(&panic_notifier_list,
         |                                   ^~~~~~~~~~~~~~~~~~~
         |                                   reboot_notifier_list
   drivers/leds/trigger/ledtrig-activity.c:249:35: note: each undeclared identifier is reported only once for each function it appears in
   drivers/leds/trigger/ledtrig-activity.c: In function 'activity_exit':
   drivers/leds/trigger/ledtrig-activity.c:259:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     259 |  atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/leds/trigger/ledtrig-panic.c: In function 'ledtrig_panic_init':
>> drivers/leds/trigger/ledtrig-panic.c:66:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
      66 |  atomic_notifier_chain_register(&panic_notifier_list,
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/leds/trigger/ledtrig-panic.c:66:34: note: each undeclared identifier is reported only once for each function it appears in

vim +5145 drivers/char/ipmi/ipmi_msghandler.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  5128  
^1da177e4c3f41 Linus Torvalds 2005-04-16  5129  static int ipmi_init_msghandler(void)
^1da177e4c3f41 Linus Torvalds 2005-04-16  5130  {
50c812b2b9513e Corey Minyard  2006-03-26  5131  	int rv;
^1da177e4c3f41 Linus Torvalds 2005-04-16  5132  
913a89f009d98c Corey Minyard  2018-12-20  5133  	mutex_lock(&ipmi_interfaces_mutex);
913a89f009d98c Corey Minyard  2018-12-20  5134  	rv = ipmi_register_driver();
913a89f009d98c Corey Minyard  2018-12-20  5135  	if (rv)
913a89f009d98c Corey Minyard  2018-12-20  5136  		goto out;
^1da177e4c3f41 Linus Torvalds 2005-04-16  5137  	if (initialized)
913a89f009d98c Corey Minyard  2018-12-20  5138  		goto out;
50c812b2b9513e Corey Minyard  2006-03-26  5139  
913a89f009d98c Corey Minyard  2018-12-20  5140  	init_srcu_struct(&ipmi_interfaces_srcu);
^1da177e4c3f41 Linus Torvalds 2005-04-16  5141  
e99e88a9d2b067 Kees Cook      2017-10-16  5142  	timer_setup(&ipmi_timer, ipmi_timeout, 0);
409035e088ce15 Corey Minyard  2006-06-28  5143  	mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
^1da177e4c3f41 Linus Torvalds 2005-04-16  5144  
e041c683412d5b Alan Stern     2006-03-27 @5145  	atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
^1da177e4c3f41 Linus Torvalds 2005-04-16  5146  
913a89f009d98c Corey Minyard  2018-12-20  5147  	initialized = true;
^1da177e4c3f41 Linus Torvalds 2005-04-16  5148  
913a89f009d98c Corey Minyard  2018-12-20  5149  out:
913a89f009d98c Corey Minyard  2018-12-20  5150  	mutex_unlock(&ipmi_interfaces_mutex);
913a89f009d98c Corey Minyard  2018-12-20  5151  	return rv;
^1da177e4c3f41 Linus Torvalds 2005-04-16  5152  }
^1da177e4c3f41 Linus Torvalds 2005-04-16  5153  

:::::: The code at line 5145 was first introduced by commit
:::::: e041c683412d5bf44dc2b109053e3b837b71742d [PATCH] Notifier chain update: API changes

:::::: TO: Alan Stern <stern@rowland.harvard.edu>
:::::: CC: Linus Torvalds <torvalds@g5.osdl.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 54973 bytes --]

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

* Re: [PATCH v4 6/7] kernel.h: Split out panic and oops helpers
@ 2020-04-24 17:27     ` kbuild test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kbuild test robot @ 2020-04-24 17:27 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 9938 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200423]
[cannot apply to tip/locking/core rcu/dev linus/master tip/x86/core v5.7-rc2 v5.7-rc1 v5.6 v5.7-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/drm-shmobile-Reduce-include-dependencies/20200424-044529
base:    aefe184e814492e36b2ca350c1522bd71b09b520
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/char/ipmi/ipmi_msghandler.c: In function 'ipmi_init_msghandler':
>> drivers/char/ipmi/ipmi_msghandler.c:5145:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
    5145 |  atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/char/ipmi/ipmi_msghandler.c:5145:34: note: each undeclared identifier is reported only once for each function it appears in
   drivers/char/ipmi/ipmi_msghandler.c: In function 'cleanup_ipmi':
   drivers/char/ipmi/ipmi_msghandler.c:5172:37: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
    5172 |   atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                     ^~~~~~~~~~~~~~~~~~~
         |                                     reboot_notifier_list
--
   drivers/misc/pvpanic.c: In function 'pvpanic_mmio_probe':
>> drivers/misc/pvpanic.c:156:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     156 |  atomic_notifier_chain_register(&panic_notifier_list,
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/misc/pvpanic.c:156:34: note: each undeclared identifier is reported only once for each function it appears in
   drivers/misc/pvpanic.c: In function 'pvpanic_mmio_remove':
   drivers/misc/pvpanic.c:165:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     165 |  atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/remoteproc/remoteproc_core.c: In function 'rproc_init_panic':
>> drivers/remoteproc/remoteproc_core.c:2383:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
    2383 |  atomic_notifier_chain_register(&panic_notifier_list, &rproc_panic_nb);
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/remoteproc/remoteproc_core.c:2383:34: note: each undeclared identifier is reported only once for each function it appears in
   drivers/remoteproc/remoteproc_core.c: In function 'rproc_exit_panic':
   drivers/remoteproc/remoteproc_core.c:2388:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
    2388 |  atomic_notifier_chain_unregister(&panic_notifier_list, &rproc_panic_nb);
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/power/reset/ltc2952-poweroff.c: In function 'ltc2952_poweroff_probe':
>> drivers/power/reset/ltc2952-poweroff.c:276:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     276 |  atomic_notifier_chain_register(&panic_notifier_list,
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/power/reset/ltc2952-poweroff.c:276:34: note: each undeclared identifier is reported only once for each function it appears in
   drivers/power/reset/ltc2952-poweroff.c: In function 'ltc2952_poweroff_remove':
   drivers/power/reset/ltc2952-poweroff.c:290:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     290 |  atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/leds/trigger/ledtrig-heartbeat.c: In function 'heartbeat_trig_init':
>> drivers/leds/trigger/ledtrig-heartbeat.c:192:35: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     192 |   atomic_notifier_chain_register(&panic_notifier_list,
         |                                   ^~~~~~~~~~~~~~~~~~~
         |                                   reboot_notifier_list
   drivers/leds/trigger/ledtrig-heartbeat.c:192:35: note: each undeclared identifier is reported only once for each function it appears in
   drivers/leds/trigger/ledtrig-heartbeat.c: In function 'heartbeat_trig_exit':
   drivers/leds/trigger/ledtrig-heartbeat.c:202:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     202 |  atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/leds/trigger/ledtrig-activity.c: In function 'activity_init':
>> drivers/leds/trigger/ledtrig-activity.c:249:35: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     249 |   atomic_notifier_chain_register(&panic_notifier_list,
         |                                   ^~~~~~~~~~~~~~~~~~~
         |                                   reboot_notifier_list
   drivers/leds/trigger/ledtrig-activity.c:249:35: note: each undeclared identifier is reported only once for each function it appears in
   drivers/leds/trigger/ledtrig-activity.c: In function 'activity_exit':
   drivers/leds/trigger/ledtrig-activity.c:259:36: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
     259 |  atomic_notifier_chain_unregister(&panic_notifier_list,
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    reboot_notifier_list
--
   drivers/leds/trigger/ledtrig-panic.c: In function 'ledtrig_panic_init':
>> drivers/leds/trigger/ledtrig-panic.c:66:34: error: 'panic_notifier_list' undeclared (first use in this function); did you mean 'reboot_notifier_list'?
      66 |  atomic_notifier_chain_register(&panic_notifier_list,
         |                                  ^~~~~~~~~~~~~~~~~~~
         |                                  reboot_notifier_list
   drivers/leds/trigger/ledtrig-panic.c:66:34: note: each undeclared identifier is reported only once for each function it appears in

vim +5145 drivers/char/ipmi/ipmi_msghandler.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  5128  
^1da177e4c3f41 Linus Torvalds 2005-04-16  5129  static int ipmi_init_msghandler(void)
^1da177e4c3f41 Linus Torvalds 2005-04-16  5130  {
50c812b2b9513e Corey Minyard  2006-03-26  5131  	int rv;
^1da177e4c3f41 Linus Torvalds 2005-04-16  5132  
913a89f009d98c Corey Minyard  2018-12-20  5133  	mutex_lock(&ipmi_interfaces_mutex);
913a89f009d98c Corey Minyard  2018-12-20  5134  	rv = ipmi_register_driver();
913a89f009d98c Corey Minyard  2018-12-20  5135  	if (rv)
913a89f009d98c Corey Minyard  2018-12-20  5136  		goto out;
^1da177e4c3f41 Linus Torvalds 2005-04-16  5137  	if (initialized)
913a89f009d98c Corey Minyard  2018-12-20  5138  		goto out;
50c812b2b9513e Corey Minyard  2006-03-26  5139  
913a89f009d98c Corey Minyard  2018-12-20  5140  	init_srcu_struct(&ipmi_interfaces_srcu);
^1da177e4c3f41 Linus Torvalds 2005-04-16  5141  
e99e88a9d2b067 Kees Cook      2017-10-16  5142  	timer_setup(&ipmi_timer, ipmi_timeout, 0);
409035e088ce15 Corey Minyard  2006-06-28  5143  	mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
^1da177e4c3f41 Linus Torvalds 2005-04-16  5144  
e041c683412d5b Alan Stern     2006-03-27 @5145  	atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
^1da177e4c3f41 Linus Torvalds 2005-04-16  5146  
913a89f009d98c Corey Minyard  2018-12-20  5147  	initialized = true;
^1da177e4c3f41 Linus Torvalds 2005-04-16  5148  
913a89f009d98c Corey Minyard  2018-12-20  5149  out:
913a89f009d98c Corey Minyard  2018-12-20  5150  	mutex_unlock(&ipmi_interfaces_mutex);
913a89f009d98c Corey Minyard  2018-12-20  5151  	return rv;
^1da177e4c3f41 Linus Torvalds 2005-04-16  5152  }
^1da177e4c3f41 Linus Torvalds 2005-04-16  5153  

:::::: The code at line 5145 was first introduced by commit
:::::: e041c683412d5bf44dc2b109053e3b837b71742d [PATCH] Notifier chain update: API changes

:::::: TO: Alan Stern <stern@rowland.harvard.edu>
:::::: CC: Linus Torvalds <torvalds@g5.osdl.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 54973 bytes --]

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

* Re: [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends
  2020-04-22 12:52 ` [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends Andy Shevchenko
@ 2020-04-24 17:45     ` kbuild test robot
  2020-04-24 17:45     ` kbuild test robot
  1 sibling, 0 replies; 19+ messages in thread
From: kbuild test robot @ 2020-04-24 17:45 UTC (permalink / raw)
  To: Andy Shevchenko, Andrew Morton, linux-kernel, Steven Rostedt,
	Rasmus Villemoes, Joe Perches
  Cc: kbuild-all, Linux Memory Management List, Andy Shevchenko

[-- Attachment #1: Type: text/plain, Size: 4519 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200423]
[cannot apply to tip/locking/core rcu/dev linus/master tip/x86/core v5.7-rc2 v5.7-rc1 v5.6 v5.7-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/drm-shmobile-Reduce-include-dependencies/20200424-044529
base:    aefe184e814492e36b2ca350c1522bd71b09b520
config: parisc-allnoconfig (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=parisc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/asm-generic/current.h:5,
                    from ./arch/parisc/include/generated/asm/current.h:1,
                    from include/linux/might_sleep.h:6,
                    from include/linux/kernel.h:14,
                    from arch/parisc/include/asm/bug.h:5,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
   include/linux/thread_info.h: In function 'copy_overflow':
>> include/linux/thread_info.h:135:2: error: implicit declaration of function 'WARN' [-Werror=implicit-function-declaration]
     135 |  WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
         |  ^~~~
   include/linux/thread_info.h: In function 'check_copy_size':
>> include/linux/thread_info.h:151:6: error: implicit declaration of function 'WARN_ON_ONCE' [-Werror=implicit-function-declaration]
     151 |  if (WARN_ON_ONCE(bytes > INT_MAX))
         |      ^~~~~~~~~~~~
   cc1: some warnings being treated as errors
   make[2]: *** [scripts/Makefile.build:100: kernel/bounds.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1142: prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:180: sub-make] Error 2

vim +/WARN +135 include/linux/thread_info.h

b0377fedb65280 Al Viro   2017-06-29  132  
b0377fedb65280 Al Viro   2017-06-29  133  static inline void copy_overflow(int size, unsigned long count)
b0377fedb65280 Al Viro   2017-06-29  134  {
b0377fedb65280 Al Viro   2017-06-29 @135  	WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
b0377fedb65280 Al Viro   2017-06-29  136  }
b0377fedb65280 Al Viro   2017-06-29  137  
9dd819a15162f8 Kees Cook 2019-09-25  138  static __always_inline __must_check bool
b0377fedb65280 Al Viro   2017-06-29  139  check_copy_size(const void *addr, size_t bytes, bool is_source)
b0377fedb65280 Al Viro   2017-06-29  140  {
b0377fedb65280 Al Viro   2017-06-29  141  	int sz = __compiletime_object_size(addr);
b0377fedb65280 Al Viro   2017-06-29  142  	if (unlikely(sz >= 0 && sz < bytes)) {
b0377fedb65280 Al Viro   2017-06-29  143  		if (!__builtin_constant_p(bytes))
b0377fedb65280 Al Viro   2017-06-29  144  			copy_overflow(sz, bytes);
b0377fedb65280 Al Viro   2017-06-29  145  		else if (is_source)
b0377fedb65280 Al Viro   2017-06-29  146  			__bad_copy_from();
b0377fedb65280 Al Viro   2017-06-29  147  		else
b0377fedb65280 Al Viro   2017-06-29  148  			__bad_copy_to();
b0377fedb65280 Al Viro   2017-06-29  149  		return false;
b0377fedb65280 Al Viro   2017-06-29  150  	}
6d13de1489b6bf Kees Cook 2019-12-04 @151  	if (WARN_ON_ONCE(bytes > INT_MAX))
6d13de1489b6bf Kees Cook 2019-12-04  152  		return false;
b0377fedb65280 Al Viro   2017-06-29  153  	check_object_size(addr, bytes, is_source);
b0377fedb65280 Al Viro   2017-06-29  154  	return true;
b0377fedb65280 Al Viro   2017-06-29  155  }
b0377fedb65280 Al Viro   2017-06-29  156  

:::::: The code at line 135 was first introduced by commit
:::::: b0377fedb6528087ed319b0d054d6ed82240372c copy_{to,from}_user(): consolidate object size checks

:::::: TO: Al Viro <viro@zeniv.linux.org.uk>
:::::: CC: Al Viro <viro@zeniv.linux.org.uk>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 5611 bytes --]

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

* Re: [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends
@ 2020-04-24 17:45     ` kbuild test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kbuild test robot @ 2020-04-24 17:45 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4606 bytes --]

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200423]
[cannot apply to tip/locking/core rcu/dev linus/master tip/x86/core v5.7-rc2 v5.7-rc1 v5.6 v5.7-rc2]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/drm-shmobile-Reduce-include-dependencies/20200424-044529
base:    aefe184e814492e36b2ca350c1522bd71b09b520
config: parisc-allnoconfig (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=parisc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/asm-generic/current.h:5,
                    from ./arch/parisc/include/generated/asm/current.h:1,
                    from include/linux/might_sleep.h:6,
                    from include/linux/kernel.h:14,
                    from arch/parisc/include/asm/bug.h:5,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
   include/linux/thread_info.h: In function 'copy_overflow':
>> include/linux/thread_info.h:135:2: error: implicit declaration of function 'WARN' [-Werror=implicit-function-declaration]
     135 |  WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
         |  ^~~~
   include/linux/thread_info.h: In function 'check_copy_size':
>> include/linux/thread_info.h:151:6: error: implicit declaration of function 'WARN_ON_ONCE' [-Werror=implicit-function-declaration]
     151 |  if (WARN_ON_ONCE(bytes > INT_MAX))
         |      ^~~~~~~~~~~~
   cc1: some warnings being treated as errors
   make[2]: *** [scripts/Makefile.build:100: kernel/bounds.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1142: prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:180: sub-make] Error 2

vim +/WARN +135 include/linux/thread_info.h

b0377fedb65280 Al Viro   2017-06-29  132  
b0377fedb65280 Al Viro   2017-06-29  133  static inline void copy_overflow(int size, unsigned long count)
b0377fedb65280 Al Viro   2017-06-29  134  {
b0377fedb65280 Al Viro   2017-06-29 @135  	WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
b0377fedb65280 Al Viro   2017-06-29  136  }
b0377fedb65280 Al Viro   2017-06-29  137  
9dd819a15162f8 Kees Cook 2019-09-25  138  static __always_inline __must_check bool
b0377fedb65280 Al Viro   2017-06-29  139  check_copy_size(const void *addr, size_t bytes, bool is_source)
b0377fedb65280 Al Viro   2017-06-29  140  {
b0377fedb65280 Al Viro   2017-06-29  141  	int sz = __compiletime_object_size(addr);
b0377fedb65280 Al Viro   2017-06-29  142  	if (unlikely(sz >= 0 && sz < bytes)) {
b0377fedb65280 Al Viro   2017-06-29  143  		if (!__builtin_constant_p(bytes))
b0377fedb65280 Al Viro   2017-06-29  144  			copy_overflow(sz, bytes);
b0377fedb65280 Al Viro   2017-06-29  145  		else if (is_source)
b0377fedb65280 Al Viro   2017-06-29  146  			__bad_copy_from();
b0377fedb65280 Al Viro   2017-06-29  147  		else
b0377fedb65280 Al Viro   2017-06-29  148  			__bad_copy_to();
b0377fedb65280 Al Viro   2017-06-29  149  		return false;
b0377fedb65280 Al Viro   2017-06-29  150  	}
6d13de1489b6bf Kees Cook 2019-12-04 @151  	if (WARN_ON_ONCE(bytes > INT_MAX))
6d13de1489b6bf Kees Cook 2019-12-04  152  		return false;
b0377fedb65280 Al Viro   2017-06-29  153  	check_object_size(addr, bytes, is_source);
b0377fedb65280 Al Viro   2017-06-29  154  	return true;
b0377fedb65280 Al Viro   2017-06-29  155  }
b0377fedb65280 Al Viro   2017-06-29  156  

:::::: The code at line 135 was first introduced by commit
:::::: b0377fedb6528087ed319b0d054d6ed82240372c copy_{to,from}_user(): consolidate object size checks

:::::: TO: Al Viro <viro@zeniv.linux.org.uk>
:::::: CC: Al Viro <viro@zeniv.linux.org.uk>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 5611 bytes --]

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

end of thread, other threads:[~2020-04-24 17:46 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22 12:51 [PATCH v4 1/7] drm: shmobile: Reduce include dependencies Andy Shevchenko
2020-04-22 12:51 ` [PATCH v4 2/7] kernel.h: Drop unneeded <linux/kernel.h> inclusion from other headers Andy Shevchenko
2020-04-22 12:51 ` [PATCH v4 3/7] kernel.h: Move oops_in_progress to printk.h Andy Shevchenko
2020-04-22 12:51 ` [PATCH v4 4/7] kernel.h: Split out min()/max() et al helpers Andy Shevchenko
2020-04-22 14:52   ` Joe Perches
2020-04-22 15:44     ` Andy Shevchenko
2020-04-22 15:51       ` Joe Perches
2020-04-23  9:33     ` Rasmus Villemoes
2020-04-22 12:51 ` [PATCH v4 5/7] kernel.h: Split out mathematical helpers Andy Shevchenko
2020-04-22 12:52 ` [PATCH v4 6/7] kernel.h: Split out panic and oops helpers Andy Shevchenko
2020-04-24 17:04   ` kbuild test robot
2020-04-24 17:04     ` kbuild test robot
2020-04-24 17:27   ` kbuild test robot
2020-04-24 17:27     ` kbuild test robot
2020-04-22 12:52 ` [PATCH v4 7/7] kernel.h: Split out might_sleep() and friends Andy Shevchenko
2020-04-24 15:49   ` kbuild test robot
2020-04-24 15:49     ` kbuild test robot
2020-04-24 17:45   ` kbuild test robot
2020-04-24 17:45     ` kbuild test robot

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.