tree:
https://android.googlesource.com/kernel/common android12-5.10
head: 084fab46dd7c1be137dd7f5981bac7d38d1c0fb2
commit: 084fab46dd7c1be137dd7f5981bac7d38d1c0fb2 [2/2] ANDROID: ftrace: vendor hook for
ftrace dump on oops
config: i386-randconfig-r032-20210114 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
git remote add android-common
https://android.googlesource.com/kernel/common
git fetch --no-tags android-common android12-5.10
git checkout 084fab46dd7c1be137dd7f5981bac7d38d1c0fb2
# save the attached .config to linux build tree
make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
kernel/trace/trace.c: In function 'ftrace_dump':
> kernel/trace/trace.c:9323:16: warning: variable 'size'
set but not used [-Wunused-but-set-variable]
9323 | unsigned long size;
| ^~~~
vim +/size +9323 kernel/trace/trace.c
9312
9313 void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
9314 {
9315 /* use static because iter can be a bit big for the stack */
9316 static struct trace_iterator iter;
9317 static atomic_t dump_running;
9318 struct trace_array *tr = &global_trace;
9319 unsigned int old_userobj;
9320 unsigned long flags;
9321 int cnt = 0, cpu;
9322 bool ftrace_check = false;
9323 unsigned long size;
9324
9325 /* Only allow one dump user at a time. */
9326 if (atomic_inc_return(&dump_running) != 1) {
9327 atomic_dec(&dump_running);
9328 return;
9329 }
9330
9331 /*
9332 * Always turn off tracing when we dump.
9333 * We don't need to show trace output of what happens
9334 * between multiple crashes.
9335 *
9336 * If the user does a sysrq-z, then they can re-enable
9337 * tracing with echo 1 > tracing_on.
9338 */
9339 tracing_off();
9340
9341 local_irq_save(flags);
9342 printk_nmi_direct_enter();
9343
9344 /* Simulate the iterator */
9345 trace_init_global_iter(&iter);
9346 /* Can not use kmalloc for iter.temp */
9347 iter.temp = static_temp_buf;
9348 iter.temp_size = STATIC_TEMP_BUF_SIZE;
9349
9350 for_each_tracing_cpu(cpu) {
9351 atomic_inc(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled);
9352 size = ring_buffer_size(iter.array_buffer->buffer, cpu);
9353 trace_android_vh_ftrace_size_check(size, &ftrace_check);
9354 }
9355
9356 old_userobj = tr->trace_flags & TRACE_ITER_SYM_USEROBJ;
9357
9358 /* don't look at user memory in panic mode */
9359 tr->trace_flags &= ~TRACE_ITER_SYM_USEROBJ;
9360
9361 if (ftrace_check)
9362 goto out_enable;
9363
9364 switch (oops_dump_mode) {
9365 case DUMP_ALL:
9366 iter.cpu_file = RING_BUFFER_ALL_CPUS;
9367 break;
9368 case DUMP_ORIG:
9369 iter.cpu_file = raw_smp_processor_id();
9370 break;
9371 case DUMP_NONE:
9372 goto out_enable;
9373 default:
9374 printk(KERN_TRACE "Bad dumping mode, switching to all CPUs dump\n");
9375 iter.cpu_file = RING_BUFFER_ALL_CPUS;
9376 }
9377
9378 printk(KERN_TRACE "Dumping ftrace buffer:\n");
9379
9380 /* Did function tracer already get disabled? */
9381 if (ftrace_is_dead()) {
9382 printk("# WARNING: FUNCTION TRACING IS CORRUPTED\n");
9383 printk("# MAY BE MISSING FUNCTION EVENTS\n");
9384 }
9385
9386 /*
9387 * We need to stop all tracing on all CPUS to read
9388 * the next buffer. This is a bit expensive, but is
9389 * not done often. We fill all what we can read,
9390 * and then release the locks again.
9391 */
9392
9393 while (!trace_empty(&iter)) {
9394 ftrace_check = true;
9395
9396 if (!cnt)
9397 printk(KERN_TRACE "---------------------------------\n");
9398
9399 cnt++;
9400
9401 trace_iterator_reset(&iter);
9402 trace_android_vh_ftrace_format_check(&ftrace_check);
9403 if (ftrace_check)
9404 iter.iter_flags |= TRACE_FILE_LAT_FMT;
9405
9406 if (trace_find_next_entry_inc(&iter) != NULL) {
9407 int ret;
9408
9409 ret = print_trace_line(&iter);
9410 if (ret != TRACE_TYPE_NO_CONSUME)
9411 trace_consume(&iter);
9412 }
9413 touch_nmi_watchdog();
9414
9415 trace_printk_seq(&iter.seq);
9416 }
9417
9418 if (!cnt)
9419 printk(KERN_TRACE " (ftrace buffer empty)\n");
9420 else
9421 printk(KERN_TRACE "---------------------------------\n");
9422
9423 out_enable:
9424 tr->trace_flags |= old_userobj;
9425
9426 for_each_tracing_cpu(cpu) {
9427 atomic_dec(&per_cpu_ptr(iter.array_buffer->data, cpu)->disabled);
9428 }
9429 atomic_dec(&dump_running);
9430 printk_nmi_direct_exit();
9431 local_irq_restore(flags);
9432 }
9433 EXPORT_SYMBOL_GPL(ftrace_dump);
9434
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org