Re: [PATCH] locking/lockdep: Dump state of percpu_rwsem upon hung up.

From: kbuild test robot
Date: Sat Jul 07 2018 - 07:32:12 EST


Hi Tetsuo,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20180706]
[also build test ERROR on v4.18-rc3]
[cannot apply to tip/auto-latest tip/sched/core linus/master v4.18-rc3 v4.18-rc2 v4.18-rc1]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Tetsuo-Handa/locking-lockdep-Dump-state-of-percpu_rwsem-upon-hung-up/20180707-143406
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 7.2.0-11) 7.2.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
GCC_VERSION=7.2.0 make.cross ARCH=mips

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

In file included from include/linux/kernel.h:14:0,
from include/asm-generic/bug.h:18,
from arch/mips/include/asm/bug.h:42,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:9,
from kernel/hung_task.c:8:
kernel/hung_task.c: In function 'dump_percpu_rwsem_state':
>> kernel/hung_task.c:95:20: error: passing argument 1 of 'atomic_long_read' from incompatible pointer type [-Werror=incompatible-pointer-types]
atomic_long_read(&sem->rw_sem.count));
^
include/linux/printk.h:311:34: note: in definition of macro 'pr_info'
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
In file included from include/linux/atomic.h:1309:0,
from arch/mips/include/asm/processor.h:14,
from arch/mips/include/asm/thread_info.h:16,
from include/linux/thread_info.h:38,
from include/asm-generic/preempt.h:5,
from ./arch/mips/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:81,
from include/linux/spinlock.h:51,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:6,
from include/linux/mm.h:10,
from kernel/hung_task.c:8:
include/asm-generic/atomic-long.h:41:20: note: expected 'const atomic_long_t * {aka const struct <anonymous> *}' but argument is of type '__s32 * {aka int *}'
static inline long atomic_long_read##mo(const atomic_long_t *l) \
^
>> include/asm-generic/atomic-long.h:47:1: note: in expansion of macro 'ATOMIC_LONG_READ_OP'
ATOMIC_LONG_READ_OP()
^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/atomic_long_read +95 kernel/hung_task.c

> 8 #include <linux/mm.h>
9 #include <linux/cpu.h>
10 #include <linux/nmi.h>
11 #include <linux/init.h>
12 #include <linux/delay.h>
13 #include <linux/freezer.h>
14 #include <linux/kthread.h>
15 #include <linux/lockdep.h>
16 #include <linux/export.h>
17 #include <linux/sysctl.h>
18 #include <linux/utsname.h>
19 #include <linux/sched/signal.h>
20 #include <linux/sched/debug.h>
21 #include <linux/percpu-rwsem.h>
22
23 #include <trace/events/sched.h>
24
25 /*
26 * The number of tasks checked:
27 */
28 int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;
29
30 /*
31 * Limit number of tasks checked in a batch.
32 *
33 * This value controls the preemptibility of khungtaskd since preemption
34 * is disabled during the critical section. It also controls the size of
35 * the RCU grace period. So it needs to be upper-bound.
36 */
37 #define HUNG_TASK_BATCHING 1024
38
39 /*
40 * Zero means infinite timeout - no checking done:
41 */
42 unsigned long __read_mostly sysctl_hung_task_timeout_secs = CONFIG_DEFAULT_HUNG_TASK_TIMEOUT;
43
44 /*
45 * Zero (default value) means use sysctl_hung_task_timeout_secs:
46 */
47 unsigned long __read_mostly sysctl_hung_task_check_interval_secs;
48
49 int __read_mostly sysctl_hung_task_warnings = 10;
50
51 static int __read_mostly did_panic;
52 static bool hung_task_show_lock;
53 static bool hung_task_call_panic;
54
55 static struct task_struct *watchdog_task;
56
57 /*
58 * Should we panic (and reboot, if panic_timeout= is set) when a
59 * hung task is detected:
60 */
61 unsigned int __read_mostly sysctl_hung_task_panic =
62 CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE;
63
64 static int __init hung_task_panic_setup(char *str)
65 {
66 int rc = kstrtouint(str, 0, &sysctl_hung_task_panic);
67
68 if (rc)
69 return rc;
70 return 1;
71 }
72 __setup("hung_task_panic=", hung_task_panic_setup);
73
74 static int
75 hung_task_panic(struct notifier_block *this, unsigned long event, void *ptr)
76 {
77 did_panic = 1;
78
79 return NOTIFY_DONE;
80 }
81
82 static struct notifier_block panic_block = {
83 .notifier_call = hung_task_panic,
84 };
85
86 static void dump_percpu_rwsem_state(struct percpu_rw_semaphore *sem)
87 {
88 unsigned int sum = 0;
89 int cpu;
90
91 if (!sem)
92 return;
93 pr_info("percpu_rw_semaphore(%p)\n", sem);
94 pr_info(" ->rw_sem.count=0x%lx\n",
> 95 atomic_long_read(&sem->rw_sem.count));
96 pr_info(" ->rss.gp_state=%d\n", sem->rss.gp_state);
97 pr_info(" ->rss.gp_count=%d\n", sem->rss.gp_count);
98 pr_info(" ->rss.cb_state=%d\n", sem->rss.cb_state);
99 pr_info(" ->rss.gp_type=%d\n", sem->rss.gp_type);
100 pr_info(" ->readers_block=%d\n", sem->readers_block);
101 for_each_possible_cpu(cpu)
102 sum += per_cpu(*sem->read_count, cpu);
103 pr_info(" ->read_count=%d\n", sum);
104 pr_info(" ->list_empty(rw_sem.wait_list)=%d\n",
105 list_empty(&sem->rw_sem.wait_list));
106 pr_info(" ->writer.task=%p\n", sem->writer.task);
107 }
108

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip