Re: [PATCH 3/4] fs/proc: apply timens offset for start_boottime of processes

From: kernel test robot
Date: Wed Oct 07 2020 - 18:39:15 EST


Hi "Michael,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/timers/core]
[also build test ERROR on kselftest/next linux/master linus/master v5.9-rc8 next-20201007]
[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/Michael-Wei/time-namespace-aware-system-boot-time/20201008-042240
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 1b80043ed21894eca888157145b955df02887995
config: i386-randconfig-s031-20201008 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-218-gc0e96d6d-dirty
# https://github.com/0day-ci/linux/commit/7896182eb6f184679138887429b286006d1c5172
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Michael-Wei/time-namespace-aware-system-boot-time/20201008-042240
git checkout 7896182eb6f184679138887429b286006d1c5172
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386

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

All errors (new ones prefixed by >>):

fs/proc/array.c: In function 'do_task_stat':
>> fs/proc/array.c:539:19: error: implicit declaration of function 'timens_add_boottime_ns'; did you mean 'timens_add_boottime'? [-Werror=implicit-function-declaration]
539 | nsec_to_clock_t(timens_add_boottime_ns(task->start_boottime));
| ^~~~~~~~~~~~~~~~~~~~~~
| timens_add_boottime
cc1: some warnings being treated as errors

vim +539 fs/proc/array.c

431
432 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
433 struct pid *pid, struct task_struct *task, int whole)
434 {
435 unsigned long vsize, eip, esp, wchan = 0;
436 int priority, nice;
437 int tty_pgrp = -1, tty_nr = 0;
438 sigset_t sigign, sigcatch;
439 char state;
440 pid_t ppid = 0, pgid = -1, sid = -1;
441 int num_threads = 0;
442 int permitted;
443 struct mm_struct *mm;
444 unsigned long long start_time;
445 unsigned long cmin_flt = 0, cmaj_flt = 0;
446 unsigned long min_flt = 0, maj_flt = 0;
447 u64 cutime, cstime, utime, stime;
448 u64 cgtime, gtime;
449 unsigned long rsslim = 0;
450 unsigned long flags;
451
452 state = *get_task_state(task);
453 vsize = eip = esp = 0;
454 permitted = ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS | PTRACE_MODE_NOAUDIT);
455 mm = get_task_mm(task);
456 if (mm) {
457 vsize = task_vsize(mm);
458 /*
459 * esp and eip are intentionally zeroed out. There is no
460 * non-racy way to read them without freezing the task.
461 * Programs that need reliable values can use ptrace(2).
462 *
463 * The only exception is if the task is core dumping because
464 * a program is not able to use ptrace(2) in that case. It is
465 * safe because the task has stopped executing permanently.
466 */
467 if (permitted && (task->flags & (PF_EXITING|PF_DUMPCORE))) {
468 if (try_get_task_stack(task)) {
469 eip = KSTK_EIP(task);
470 esp = KSTK_ESP(task);
471 put_task_stack(task);
472 }
473 }
474 }
475
476 sigemptyset(&sigign);
477 sigemptyset(&sigcatch);
478 cutime = cstime = utime = stime = 0;
479 cgtime = gtime = 0;
480
481 if (lock_task_sighand(task, &flags)) {
482 struct signal_struct *sig = task->signal;
483
484 if (sig->tty) {
485 struct pid *pgrp = tty_get_pgrp(sig->tty);
486 tty_pgrp = pid_nr_ns(pgrp, ns);
487 put_pid(pgrp);
488 tty_nr = new_encode_dev(tty_devnum(sig->tty));
489 }
490
491 num_threads = get_nr_threads(task);
492 collect_sigign_sigcatch(task, &sigign, &sigcatch);
493
494 cmin_flt = sig->cmin_flt;
495 cmaj_flt = sig->cmaj_flt;
496 cutime = sig->cutime;
497 cstime = sig->cstime;
498 cgtime = sig->cgtime;
499 rsslim = READ_ONCE(sig->rlim[RLIMIT_RSS].rlim_cur);
500
501 /* add up live thread stats at the group level */
502 if (whole) {
503 struct task_struct *t = task;
504 do {
505 min_flt += t->min_flt;
506 maj_flt += t->maj_flt;
507 gtime += task_gtime(t);
508 } while_each_thread(task, t);
509
510 min_flt += sig->min_flt;
511 maj_flt += sig->maj_flt;
512 thread_group_cputime_adjusted(task, &utime, &stime);
513 gtime += sig->gtime;
514 }
515
516 sid = task_session_nr_ns(task, ns);
517 ppid = task_tgid_nr_ns(task->real_parent, ns);
518 pgid = task_pgrp_nr_ns(task, ns);
519
520 unlock_task_sighand(task, &flags);
521 }
522
523 if (permitted && (!whole || num_threads < 2))
524 wchan = get_wchan(task);
525 if (!whole) {
526 min_flt = task->min_flt;
527 maj_flt = task->maj_flt;
528 task_cputime_adjusted(task, &utime, &stime);
529 gtime = task_gtime(task);
530 }
531
532 /* scale priority and nice values from timeslices to -20..20 */
533 /* to make it look like a "normal" Unix priority/nice value */
534 priority = task_prio(task);
535 nice = task_nice(task);
536
537 /* apply timens offset for boottime and convert nsec -> ticks */
538 start_time =
> 539 nsec_to_clock_t(timens_add_boottime_ns(task->start_boottime));
540
541 seq_put_decimal_ull(m, "", pid_nr_ns(pid, ns));
542 seq_puts(m, " (");
543 proc_task_name(m, task, false);
544 seq_puts(m, ") ");
545 seq_putc(m, state);
546 seq_put_decimal_ll(m, " ", ppid);
547 seq_put_decimal_ll(m, " ", pgid);
548 seq_put_decimal_ll(m, " ", sid);
549 seq_put_decimal_ll(m, " ", tty_nr);
550 seq_put_decimal_ll(m, " ", tty_pgrp);
551 seq_put_decimal_ull(m, " ", task->flags);
552 seq_put_decimal_ull(m, " ", min_flt);
553 seq_put_decimal_ull(m, " ", cmin_flt);
554 seq_put_decimal_ull(m, " ", maj_flt);
555 seq_put_decimal_ull(m, " ", cmaj_flt);
556 seq_put_decimal_ull(m, " ", nsec_to_clock_t(utime));
557 seq_put_decimal_ull(m, " ", nsec_to_clock_t(stime));
558 seq_put_decimal_ll(m, " ", nsec_to_clock_t(cutime));
559 seq_put_decimal_ll(m, " ", nsec_to_clock_t(cstime));
560 seq_put_decimal_ll(m, " ", priority);
561 seq_put_decimal_ll(m, " ", nice);
562 seq_put_decimal_ll(m, " ", num_threads);
563 seq_put_decimal_ull(m, " ", 0);
564 seq_put_decimal_ull(m, " ", start_time);
565 seq_put_decimal_ull(m, " ", vsize);
566 seq_put_decimal_ull(m, " ", mm ? get_mm_rss(mm) : 0);
567 seq_put_decimal_ull(m, " ", rsslim);
568 seq_put_decimal_ull(m, " ", mm ? (permitted ? mm->start_code : 1) : 0);
569 seq_put_decimal_ull(m, " ", mm ? (permitted ? mm->end_code : 1) : 0);
570 seq_put_decimal_ull(m, " ", (permitted && mm) ? mm->start_stack : 0);
571 seq_put_decimal_ull(m, " ", esp);
572 seq_put_decimal_ull(m, " ", eip);
573 /* The signal information here is obsolete.
574 * It must be decimal for Linux 2.0 compatibility.
575 * Use /proc/#/status for real-time signals.
576 */
577 seq_put_decimal_ull(m, " ", task->pending.signal.sig[0] & 0x7fffffffUL);
578 seq_put_decimal_ull(m, " ", task->blocked.sig[0] & 0x7fffffffUL);
579 seq_put_decimal_ull(m, " ", sigign.sig[0] & 0x7fffffffUL);
580 seq_put_decimal_ull(m, " ", sigcatch.sig[0] & 0x7fffffffUL);
581
582 /*
583 * We used to output the absolute kernel address, but that's an
584 * information leak - so instead we show a 0/1 flag here, to signal
585 * to user-space whether there's a wchan field in /proc/PID/wchan.
586 *
587 * This works with older implementations of procps as well.
588 */
589 if (wchan)
590 seq_puts(m, " 1");
591 else
592 seq_puts(m, " 0");
593
594 seq_put_decimal_ull(m, " ", 0);
595 seq_put_decimal_ull(m, " ", 0);
596 seq_put_decimal_ll(m, " ", task->exit_signal);
597 seq_put_decimal_ll(m, " ", task_cpu(task));
598 seq_put_decimal_ull(m, " ", task->rt_priority);
599 seq_put_decimal_ull(m, " ", task->policy);
600 seq_put_decimal_ull(m, " ", delayacct_blkio_ticks(task));
601 seq_put_decimal_ull(m, " ", nsec_to_clock_t(gtime));
602 seq_put_decimal_ll(m, " ", nsec_to_clock_t(cgtime));
603
604 if (mm && permitted) {
605 seq_put_decimal_ull(m, " ", mm->start_data);
606 seq_put_decimal_ull(m, " ", mm->end_data);
607 seq_put_decimal_ull(m, " ", mm->start_brk);
608 seq_put_decimal_ull(m, " ", mm->arg_start);
609 seq_put_decimal_ull(m, " ", mm->arg_end);
610 seq_put_decimal_ull(m, " ", mm->env_start);
611 seq_put_decimal_ull(m, " ", mm->env_end);
612 } else
613 seq_puts(m, " 0 0 0 0 0 0 0");
614
615 if (permitted)
616 seq_put_decimal_ll(m, " ", task->exit_code);
617 else
618 seq_puts(m, " 0");
619
620 seq_putc(m, '\n');
621 if (mm)
622 mmput(mm);
623 return 0;
624 }
625

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

Attachment: .config.gz
Description: application/gzip