Re: [PATCH v2 1/4] tracing/dynevent: Delegate parsing to create function

From: kernel test robot
Date: Fri Oct 23 2020 - 19:04:00 EST


Hi Tom,

I love your patch! Perhaps something to improve:

[auto build test WARNING on trace/for-next]
[also build test WARNING on linus/master next-20201023]
[cannot apply to tip/perf/core linux/master v5.9]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Tom-Zanussi/tracing-More-synthetic-event-error-fixes/20201024-043714
base: https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next
config: s390-randconfig-r031-20201022 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 147b9497e79a98a8614b2b5eb4ba653b44f6b6f0)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://github.com/0day-ci/linux/commit/10ea63ba8aed09b6b543d606de36b21d0d2b7b88
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Tom-Zanussi/tracing-More-synthetic-event-error-fixes/20201024-043714
git checkout 10ea63ba8aed09b6b543d606de36b21d0d2b7b88
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

In file included from kernel/trace/trace_dynevent.h:14:
In file included from kernel/trace/trace.h:9:
In file included from include/linux/clocksource.h:21:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
___constant_swab32(x) : \
^
include/uapi/linux/swab.h:20:12: note: expanded from macro '___constant_swab32'
(((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
^
In file included from kernel/trace/trace_events_synth.c:21:
In file included from kernel/trace/trace_synth.h:5:
In file included from kernel/trace/trace_dynevent.h:14:
In file included from kernel/trace/trace.h:9:
In file included from include/linux/clocksource.h:21:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
___constant_swab32(x) : \
^
include/uapi/linux/swab.h:21:12: note: expanded from macro '___constant_swab32'
(((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
^
In file included from kernel/trace/trace_events_synth.c:21:
In file included from kernel/trace/trace_synth.h:5:
In file included from kernel/trace/trace_dynevent.h:14:
In file included from kernel/trace/trace.h:9:
In file included from include/linux/clocksource.h:21:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:119:21: note: expanded from macro '__swab32'
___constant_swab32(x) : \
^
include/uapi/linux/swab.h:22:12: note: expanded from macro '___constant_swab32'
(((__u32)(x) & (__u32)0xff000000UL) >> 24)))
^
In file included from kernel/trace/trace_events_synth.c:21:
In file included from kernel/trace/trace_synth.h:5:
In file included from kernel/trace/trace_dynevent.h:14:
In file included from kernel/trace/trace.h:9:
In file included from include/linux/clocksource.h:21:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:120:12: note: expanded from macro '__swab32'
__fswab32(x))
^
In file included from kernel/trace/trace_events_synth.c:21:
In file included from kernel/trace/trace_synth.h:5:
In file included from kernel/trace/trace_dynevent.h:14:
In file included from kernel/trace/trace.h:9:
In file included from include/linux/clocksource.h:21:
In file included from arch/s390/include/asm/io.h:72:
include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
>> kernel/trace/trace_events_synth.c:1211:3: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
i += consumed - 1;
^
kernel/trace/trace_events_synth.c:1146:7: note: initialize the variable 'i' to silence this warning
int i, argc, consumed = 0, n_fields = 0, ret = 0;
^
= 0
21 warnings generated.

vim +/i +1211 kernel/trace/trace_events_synth.c

726721a51838e39 Tom Zanussi 2020-05-28 1143
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1144 static int __create_synth_event(const char *name, const char *raw_fields)
726721a51838e39 Tom Zanussi 2020-05-28 1145 {
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1146 int i, argc, consumed = 0, n_fields = 0, ret = 0;
726721a51838e39 Tom Zanussi 2020-05-28 1147 struct synth_field *field, *fields[SYNTH_FIELDS_MAX];
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1148 char **argv, *field_str, *tmp_fields, *saved_fields = NULL;
726721a51838e39 Tom Zanussi 2020-05-28 1149 struct synth_event *event = NULL;
d4d704637d935ef Tom Zanussi 2020-10-13 1150
726721a51838e39 Tom Zanussi 2020-05-28 1151 /*
726721a51838e39 Tom Zanussi 2020-05-28 1152 * Argument syntax:
726721a51838e39 Tom Zanussi 2020-05-28 1153 * - Add synthetic event: <event_name> field[;field] ...
726721a51838e39 Tom Zanussi 2020-05-28 1154 * - Remove synthetic event: !<event_name> field[;field] ...
726721a51838e39 Tom Zanussi 2020-05-28 1155 * where 'field' = type field_name
726721a51838e39 Tom Zanussi 2020-05-28 1156 */
726721a51838e39 Tom Zanussi 2020-05-28 1157
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1158 mutex_lock(&event_mutex);
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1159
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1160 if (name[0] == '\0') {
d4d704637d935ef Tom Zanussi 2020-10-13 1161 synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1162 ret = -EINVAL;
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1163 goto out;
d4d704637d935ef Tom Zanussi 2020-10-13 1164 }
726721a51838e39 Tom Zanussi 2020-05-28 1165
9bbb33291f8e448 Tom Zanussi 2020-10-13 1166 if (!is_good_name(name)) {
d4d704637d935ef Tom Zanussi 2020-10-13 1167 synth_err(SYNTH_ERR_BAD_NAME, errpos(name));
9bbb33291f8e448 Tom Zanussi 2020-10-13 1168 ret = -EINVAL;
9bbb33291f8e448 Tom Zanussi 2020-10-13 1169 goto out;
9bbb33291f8e448 Tom Zanussi 2020-10-13 1170 }
9bbb33291f8e448 Tom Zanussi 2020-10-13 1171
726721a51838e39 Tom Zanussi 2020-05-28 1172 event = find_synth_event(name);
726721a51838e39 Tom Zanussi 2020-05-28 1173 if (event) {
d4d704637d935ef Tom Zanussi 2020-10-13 1174 synth_err(SYNTH_ERR_EVENT_EXISTS, errpos(name));
726721a51838e39 Tom Zanussi 2020-05-28 1175 ret = -EEXIST;
726721a51838e39 Tom Zanussi 2020-05-28 1176 goto out;
726721a51838e39 Tom Zanussi 2020-05-28 1177 }
726721a51838e39 Tom Zanussi 2020-05-28 1178
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1179 tmp_fields = saved_fields = kstrdup(raw_fields, GFP_KERNEL);
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1180 if (!tmp_fields) {
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1181 ret = -ENOMEM;
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1182 goto out;
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1183 }
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1184
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1185 while ((field_str = strsep(&tmp_fields, ";")) != NULL) {
726721a51838e39 Tom Zanussi 2020-05-28 1186 if (n_fields == SYNTH_FIELDS_MAX) {
d4d704637d935ef Tom Zanussi 2020-10-13 1187 synth_err(SYNTH_ERR_TOO_MANY_FIELDS, 0);
726721a51838e39 Tom Zanussi 2020-05-28 1188 ret = -EINVAL;
726721a51838e39 Tom Zanussi 2020-05-28 1189 goto err;
726721a51838e39 Tom Zanussi 2020-05-28 1190 }
726721a51838e39 Tom Zanussi 2020-05-28 1191
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1192 argv = argv_split(GFP_KERNEL, field_str, &argc);
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1193 if (!argv) {
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1194 ret = -ENOMEM;
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1195 goto err;
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1196 }
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1197
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1198 if (!argc)
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1199 continue;
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1200
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1201 field = parse_synth_field(argc, argv);
726721a51838e39 Tom Zanussi 2020-05-28 1202 if (IS_ERR(field)) {
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1203 argv_free(argv);
726721a51838e39 Tom Zanussi 2020-05-28 1204 ret = PTR_ERR(field);
726721a51838e39 Tom Zanussi 2020-05-28 1205 goto err;
726721a51838e39 Tom Zanussi 2020-05-28 1206 }
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1207
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1208 argv_free(argv);
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1209
726721a51838e39 Tom Zanussi 2020-05-28 1210 fields[n_fields++] = field;
726721a51838e39 Tom Zanussi 2020-05-28 @1211 i += consumed - 1;
726721a51838e39 Tom Zanussi 2020-05-28 1212 }
726721a51838e39 Tom Zanussi 2020-05-28 1213
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1214 if (n_fields == 0) {
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1215 synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
726721a51838e39 Tom Zanussi 2020-05-28 1216 ret = -EINVAL;
726721a51838e39 Tom Zanussi 2020-05-28 1217 goto err;
726721a51838e39 Tom Zanussi 2020-05-28 1218 }
726721a51838e39 Tom Zanussi 2020-05-28 1219
726721a51838e39 Tom Zanussi 2020-05-28 1220 event = alloc_synth_event(name, n_fields, fields);
726721a51838e39 Tom Zanussi 2020-05-28 1221 if (IS_ERR(event)) {
726721a51838e39 Tom Zanussi 2020-05-28 1222 ret = PTR_ERR(event);
726721a51838e39 Tom Zanussi 2020-05-28 1223 event = NULL;
726721a51838e39 Tom Zanussi 2020-05-28 1224 goto err;
726721a51838e39 Tom Zanussi 2020-05-28 1225 }
726721a51838e39 Tom Zanussi 2020-05-28 1226 ret = register_synth_event(event);
726721a51838e39 Tom Zanussi 2020-05-28 1227 if (!ret)
726721a51838e39 Tom Zanussi 2020-05-28 1228 dyn_event_add(&event->devent);
726721a51838e39 Tom Zanussi 2020-05-28 1229 else
726721a51838e39 Tom Zanussi 2020-05-28 1230 free_synth_event(event);
726721a51838e39 Tom Zanussi 2020-05-28 1231 out:
726721a51838e39 Tom Zanussi 2020-05-28 1232 mutex_unlock(&event_mutex);
726721a51838e39 Tom Zanussi 2020-05-28 1233
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1234 kfree(saved_fields);
10ea63ba8aed09b Masami Hiramatsu 2020-10-23 1235
726721a51838e39 Tom Zanussi 2020-05-28 1236 return ret;
726721a51838e39 Tom Zanussi 2020-05-28 1237 err:
726721a51838e39 Tom Zanussi 2020-05-28 1238 for (i = 0; i < n_fields; i++)
726721a51838e39 Tom Zanussi 2020-05-28 1239 free_synth_field(fields[i]);
726721a51838e39 Tom Zanussi 2020-05-28 1240
726721a51838e39 Tom Zanussi 2020-05-28 1241 goto out;
726721a51838e39 Tom Zanussi 2020-05-28 1242 }
726721a51838e39 Tom Zanussi 2020-05-28 1243

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

Attachment: .config.gz
Description: application/gzip