[PATCH net-next v2 1/2] fs/crashdd: add API to collect hardware dump in second kernel
kbuild test robot
lkp at intel.com
Sun Mar 25 05:43:23 PDT 2018
Hi Rahul,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Rahul-Lakkireddy/fs-crashdd-add-API-to-collect-hardware-dump-in-second-kernel/20180325-191308
config: i386-randconfig-s0-03251817 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
In file included from fs//crashdd/crashdd.c:8:0:
fs//crashdd/crashdd_internal.h:13:23: error: field 'bin_attr' has incomplete type
struct bin_attribute bin_attr; /* Binary dump file's attributes */
^~~~~~~~
fs//crashdd/crashdd.c: In function 'crashdd_read':
fs//crashdd/crashdd.c:19:43: error: dereferencing pointer to incomplete type 'struct bin_attribute'
struct crashdd_dump_node *dump = bin_attr->private;
^~
fs//crashdd/crashdd.c: In function 'crashdd_mkdir':
fs//crashdd/crashdd.c:27:9: error: implicit declaration of function 'kobject_create_and_add' [-Werror=implicit-function-declaration]
return kobject_create_and_add(name, crashdd_kobj);
^~~~~~~~~~~~~~~~~~~~~~
fs//crashdd/crashdd.c:27:9: warning: return makes pointer from integer without a cast [-Wint-conversion]
return kobject_create_and_add(name, crashdd_kobj);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs//crashdd/crashdd.c: In function 'crashdd_add_file':
fs//crashdd/crashdd.c:39:9: error: implicit declaration of function 'sysfs_create_bin_file' [-Werror=implicit-function-declaration]
return sysfs_create_bin_file(kobj, &dump->bin_attr);
^~~~~~~~~~~~~~~~~~~~~
fs//crashdd/crashdd.c: In function 'crashdd_rmdir':
fs//crashdd/crashdd.c:44:2: error: implicit declaration of function 'kobject_put' [-Werror=implicit-function-declaration]
kobject_put(kobj);
^~~~~~~~~~~
In file included from include/linux/kernel.h:10:0,
from include/linux/list.h:9,
from include/linux/preempt.h:11,
from include/linux/spinlock.h:51,
from include/linux/vmalloc.h:5,
from fs//crashdd/crashdd.c:4:
fs//crashdd/crashdd.c: In function 'crashdd_get_driver':
fs//crashdd/crashdd.c:101:25: error: dereferencing pointer to incomplete type 'struct kobject'
if (!strcmp(node->kobj->name, name)) {
^
include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> fs//crashdd/crashdd.c:101:3: note: in expansion of macro 'if'
if (!strcmp(node->kobj->name, name)) {
^~
fs//crashdd/crashdd.c: In function 'crashdd_init':
fs//crashdd/crashdd.c:227:51: error: 'kernel_kobj' undeclared (first use in this function)
crashdd_kobj = kobject_create_and_add("crashdd", kernel_kobj);
^~~~~~~~~~~
fs//crashdd/crashdd.c:227:51: note: each undeclared identifier is reported only once for each function it appears in
fs//crashdd/crashdd.c: In function 'crashdd_add_file':
fs//crashdd/crashdd.c:40:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
cc1: some warnings being treated as errors
vim +/if +101 fs//crashdd/crashdd.c
3
> 4 #include <linux/vmalloc.h>
5 #include <linux/crash_dump.h>
6 #include <linux/crashdd.h>
7
8 #include "crashdd_internal.h"
9
10 static LIST_HEAD(crashdd_list);
11 static DEFINE_MUTEX(crashdd_mutex);
12
13 static struct kobject *crashdd_kobj;
14
15 static ssize_t crashdd_read(struct file *filp, struct kobject *kobj,
16 struct bin_attribute *bin_attr,
17 char *buf, loff_t fpos, size_t count)
18 {
19 struct crashdd_dump_node *dump = bin_attr->private;
20
21 memcpy(buf, dump->buf + fpos, count);
22 return count;
23 }
24
25 static struct kobject *crashdd_mkdir(const char *name)
26 {
27 return kobject_create_and_add(name, crashdd_kobj);
28 }
29
30 static int crashdd_add_file(struct kobject *kobj, const char *name,
31 struct crashdd_dump_node *dump)
32 {
33 dump->bin_attr.attr.name = name;
34 dump->bin_attr.attr.mode = 0444;
35 dump->bin_attr.size = dump->size;
36 dump->bin_attr.read = crashdd_read;
37 dump->bin_attr.private = dump;
38
39 return sysfs_create_bin_file(kobj, &dump->bin_attr);
40 }
41
42 static void crashdd_rmdir(struct kobject *kobj)
43 {
44 kobject_put(kobj);
45 }
46
47 /**
48 * crashdd_init_driver - create a sysfs driver entry.
49 * @name: Name of the directory.
50 *
51 * Creates a directory under /sys/kernel/crashdd/ with @name. Allocates
52 * and saves the sysfs entry. The sysfs entry is added to the global
53 * list and then returned to the caller. On failure, returns NULL.
54 */
55 static struct crashdd_driver_node *crashdd_init_driver(const char *name)
56 {
57 struct crashdd_driver_node *node;
58
59 node = vzalloc(sizeof(*node));
60 if (!node)
61 return NULL;
62
63 /* Create a driver's directory under /sys/kernel/crashdd/ */
64 node->kobj = crashdd_mkdir(name);
65 if (!node->kobj) {
66 vfree(node);
67 return NULL;
68 }
69
70 atomic_set(&node->refcnt, 1);
71
72 /* Initialize the list of dumps that go under this driver's
73 * directory.
74 */
75 INIT_LIST_HEAD(&node->dump_list);
76
77 /* Add the driver's entry to global list */
78 mutex_lock(&crashdd_mutex);
79 list_add_tail(&node->list, &crashdd_list);
80 mutex_unlock(&crashdd_mutex);
81
82 return node;
83 }
84
85 /**
86 * crashdd_get_driver - get an exisiting sysfs driver entry.
87 * @name: Name of the directory.
88 *
89 * Searches and fetches a sysfs entry having @name. If @name is
90 * found, then the reference count is incremented and the entry
91 * is returned. If @name is not found, NULL is returned.
92 */
93 static struct crashdd_driver_node *crashdd_get_driver(const char *name)
94 {
95 struct crashdd_driver_node *node;
96 int found = 0;
97
98 /* Search for an existing driver sysfs entry having @name */
99 mutex_lock(&crashdd_mutex);
100 list_for_each_entry(node, &crashdd_list, list) {
> 101 if (!strcmp(node->kobj->name, name)) {
102 atomic_inc(&node->refcnt);
103 found = 1;
104 break;
105 }
106 }
107 mutex_unlock(&crashdd_mutex);
108
109 if (found)
110 return node;
111
112 /* No driver with @name found */
113 return NULL;
114 }
115
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 32369 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kexec/attachments/20180325/55cee5f0/attachment-0001.gz>
More information about the kexec
mailing list