[PATCH v1] sched/debug: Update print_task formatin /sys/kernel/debug/sched/debug

Junwen Wu posted 1 patch 2 years ago
kernel/sched/debug.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
[PATCH v1] sched/debug: Update print_task formatin /sys/kernel/debug/sched/debug
Posted by Junwen Wu 2 years ago
For the sched_debug interface, print_task function  has  output
sum_exec_runtime twice, and the promt message not align with
the output, so optimize the output.

Signed-off-by: Junwen Wu <wudaemon@163.com>
---
 kernel/sched/debug.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 4580a450700e..459109c12d68 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -579,13 +579,12 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
 	else
 		SEQ_printf(m, " %c", task_state_to_char(p));
 
-	SEQ_printf(m, "%15s %5d %9Ld.%06ld %c %9Ld.%06ld %9Ld.%06ld %9Ld.%06ld %9Ld %5d ",
+	SEQ_printf(m, "%15s %5d %9Ld.%06ld %c %9Ld.%06ld %9Ld.%06ld %9Ld %5d ",
 		p->comm, task_pid_nr(p),
 		SPLIT_NS(p->se.vruntime),
 		entity_eligible(cfs_rq_of(&p->se), &p->se) ? 'E' : 'N',
 		SPLIT_NS(p->se.deadline),
 		SPLIT_NS(p->se.slice),
-		SPLIT_NS(p->se.sum_exec_runtime),
 		(long long)(p->nvcsw + p->nivcsw),
 		p->prio);
 
@@ -596,10 +595,10 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
 		SPLIT_NS(schedstat_val_or_zero(p->stats.sum_block_runtime)));
 
 #ifdef CONFIG_NUMA_BALANCING
-	SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
+	SEQ_printf(m, "   %d   %d", task_node(p), task_numa_group_id(p));
 #endif
 #ifdef CONFIG_CGROUP_SCHED
-	SEQ_printf_task_group_path(m, task_group(p), " %s")
+	SEQ_printf_task_group_path(m, task_group(p), "   %s")
 #endif
 
 	SEQ_printf(m, "\n");
@@ -611,11 +610,18 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
 
 	SEQ_printf(m, "\n");
 	SEQ_printf(m, "runnable tasks:\n");
-	SEQ_printf(m, " S            task   PID         tree-key  switches  prio"
-		   "     wait-time             sum-exec        sum-sleep\n");
-	SEQ_printf(m, "-------------------------------------------------------"
-		   "------------------------------------------------------\n");
-
+	SEQ_printf(m, " S            task   PID         tree-key          deadline"
+		"            slice  switches   prio"
+		"       wait-time         sum-exec        sum-sleep        sum-block"
+#ifdef CONFIG_NUMA_BALANCING
+		"  node_id"
+#endif
+#ifdef CONFIG_CGROUP_SCHED
+		"  group\n");
+#endif
+	SEQ_printf(m, "-----------------------------------------------------------------"
+			"--------------------------------------------------------------------"
+			"------------------------------------------\n");
 	rcu_read_lock();
 	for_each_process_thread(g, p) {
 		if (task_cpu(p) != rq_cpu)
-- 
2.34.1
Re: [PATCH v1] sched/debug: Update print_task formatin /sys/kernel/debug/sched/debug
Posted by kernel test robot 2 years ago
Hi Junwen,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on peterz-queue/sched/core linus/master v6.7-rc5 next-20231215]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Junwen-Wu/sched-debug-Update-print_task-formatin-sys-kernel-debug-sched-debug/20231216-234714
base:   tip/sched/core
patch link:    https://lore.kernel.org/r/20231216154412.613443-1-wudaemon%40163.com
patch subject: [PATCH v1] sched/debug: Update print_task formatin  /sys/kernel/debug/sched/debug
config: i386-randconfig-014-20231217 (https://download.01.org/0day-ci/archive/20231217/202312171356.HVYTuiSz-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231217/202312171356.HVYTuiSz-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312171356.HVYTuiSz-lkp@intel.com/

All warnings (new ones prefixed by >>):

     221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   kernel/sched/membarrier.c:614:1: note: in expansion of macro 'SYSCALL_DEFINE3'
     614 | SYSCALL_DEFINE3(membarrier, int, cmd, unsigned int, flags, int, cpu_id)
         | ^~~~~~~~~~~~~~~
   kernel/sched/membarrier.c: In function 'print_rq':
   arch/x86/include/asm/syscall_wrapper.h:240:28: error: invalid storage class for function '__do_sys_membarrier'
     240 |         static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
         |                            ^~~~~~~~
   include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     230 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   kernel/sched/membarrier.c:614:1: note: in expansion of macro 'SYSCALL_DEFINE3'
     614 | SYSCALL_DEFINE3(membarrier, int, cmd, unsigned int, flags, int, cpu_id)
         | ^~~~~~~~~~~~~~~
   kernel/sched/build_utility.c:101: error: expected declaration or statement at end of input
     101 | #endif
         | 
   In file included from kernel/sched/build_utility.c:52:
   kernel/sched/stop_task.c:106:20: warning: unused variable 'stop_sched_class' [-Wunused-variable]
     106 | DEFINE_SCHED_CLASS(stop) = {
         |                    ^~~~
   kernel/sched/sched.h:2335:26: note: in definition of macro 'DEFINE_SCHED_CLASS'
    2335 | const struct sched_class name##_sched_class \
         |                          ^~~~
   In file included from kernel/sched/build_utility.c:72:
   kernel/sched/debug.c:609:33: warning: unused variable 'p' [-Wunused-variable]
     609 |         struct task_struct *g, *p;
         |                                 ^
   kernel/sched/debug.c:609:29: warning: unused variable 'g' [-Wunused-variable]
     609 |         struct task_struct *g, *p;
         |                             ^
   In file included from include/linux/syscalls.h:100,
                    from include/linux/syscalls_api.h:1,
                    from kernel/sched/sched.h:61,
                    from kernel/sched/build_utility.c:52:
   At top level:
   arch/x86/include/asm/syscall_wrapper.h:233:21: warning: '__se_sys_membarrier' defined but not used [-Wunused-function]
     233 |         static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))      \
         |                     ^~~~~~~~
   include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     230 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   kernel/sched/membarrier.c:614:1: note: in expansion of macro 'SYSCALL_DEFINE3'
     614 | SYSCALL_DEFINE3(membarrier, int, cmd, unsigned int, flags, int, cpu_id)
         | ^~~~~~~~~~~~~~~
   arch/x86/include/asm/syscall_wrapper.h:77:14: warning: '__ia32_sys_membarrier' defined but not used [-Wunused-function]
      77 |         long __##abi##_##name(const struct pt_regs *regs)               \
         |              ^~
   arch/x86/include/asm/syscall_wrapper.h:117:9: note: in expansion of macro '__SYS_STUBx'
     117 |         __SYS_STUBx(ia32, sys##name,                                    \
         |         ^~~~~~~~~~~
   arch/x86/include/asm/syscall_wrapper.h:232:9: note: in expansion of macro '__IA32_SYS_STUBx'
     232 |         __IA32_SYS_STUBx(x, name, __VA_ARGS__)                          \
         |         ^~~~~~~~~~~~~~~~
   include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     230 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   kernel/sched/membarrier.c:614:1: note: in expansion of macro 'SYSCALL_DEFINE3'
     614 | SYSCALL_DEFINE3(membarrier, int, cmd, unsigned int, flags, int, cpu_id)
         | ^~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:100:
   kernel/sched/membarrier.c:233:6: warning: 'membarrier_update_current_mm' defined but not used [-Wunused-function]
     233 | void membarrier_update_current_mm(struct mm_struct *next_mm)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/membarrier.c:217:6: warning: 'membarrier_exec_mmap' defined but not used [-Wunused-function]
     217 | void membarrier_exec_mmap(struct mm_struct *mm)
         |      ^~~~~~~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:96:
   kernel/sched/psi.c:1190:6: warning: 'psi_cgroup_restart' defined but not used [-Wunused-function]
    1190 | void psi_cgroup_restart(struct psi_group *group)
         |      ^~~~~~~~~~~~~~~~~~
   kernel/sched/psi.c:1135:6: warning: 'cgroup_move_task' defined but not used [-Wunused-function]
    1135 | void cgroup_move_task(struct task_struct *task, struct css_set *to)
         |      ^~~~~~~~~~~~~~~~
   kernel/sched/psi.c:1111:6: warning: 'psi_cgroup_free' defined but not used [-Wunused-function]
    1111 | void psi_cgroup_free(struct cgroup *cgroup)
         |      ^~~~~~~~~~~~~~~
   kernel/sched/psi.c:1092:5: warning: 'psi_cgroup_alloc' defined but not used [-Wunused-function]
    1092 | int psi_cgroup_alloc(struct cgroup *cgroup)
         |     ^~~~~~~~~~~~~~~~
   kernel/sched/psi.c:916:6: warning: 'psi_task_switch' defined but not used [-Wunused-function]
     916 | void psi_task_switch(struct task_struct *prev, struct task_struct *next,
         |      ^~~~~~~~~~~~~~~
   kernel/sched/psi.c:730:13: warning: 'poll_timer_fn' defined but not used [-Wunused-function]
     730 | static void poll_timer_fn(struct timer_list *t)
         |             ^~~~~~~~~~~~~
   kernel/sched/psi.c:206:13: warning: 'psi_init' defined but not used [-Wunused-function]
     206 | void __init psi_init(void)
         |             ^~~~~~~~
   In file included from kernel/sched/build_utility.c:92:
>> kernel/sched/core_sched.c:289:6: warning: '__sched_core_tick' defined but not used [-Wunused-function]
     289 | void __sched_core_tick(struct rq *rq)
         |      ^~~~~~~~~~~~~~~~~
>> kernel/sched/core_sched.c:129:5: warning: 'sched_core_share_pid' defined but not used [-Wunused-function]
     129 | int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
         |     ^~~~~~~~~~~~~~~~~~~~
>> kernel/sched/core_sched.c:116:6: warning: 'sched_core_free' defined but not used [-Wunused-function]
     116 | void sched_core_free(struct task_struct *p)
         |      ^~~~~~~~~~~~~~~
>> kernel/sched/core_sched.c:110:6: warning: 'sched_core_fork' defined but not used [-Wunused-function]
     110 | void sched_core_fork(struct task_struct *p)
         |      ^~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:88:
   kernel/sched/topology.c:2789:6: warning: 'partition_sched_domains' defined but not used [-Wunused-function]
    2789 | void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
         |      ^~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:2599:12: warning: 'sched_init_domains' defined but not used [-Wunused-function]
    2599 | int __init sched_init_domains(const struct cpumask *cpu_map)
         |            ^~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:2276:13: warning: '__sdt_free' defined but not used [-Wunused-function]
    2276 | static void __sdt_free(const struct cpumask *cpu_map)
         |             ^~~~~~~~~~
   kernel/sched/topology.c:2207:12: warning: '__sdt_alloc' defined but not used [-Wunused-function]
    2207 | static int __sdt_alloc(const struct cpumask *cpu_map)
         |            ^~~~~~~~~~~
   kernel/sched/topology.c:1710:13: warning: 'set_sched_topology' defined but not used [-Wunused-function]
    1710 | void __init set_sched_topology(struct sched_domain_topology_level *tl)
         |             ^~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:585:13: warning: 'init_defrootdomain' defined but not used [-Wunused-function]
     585 | void __init init_defrootdomain(void)
         |             ^~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:531:6: warning: 'sched_put_rd' defined but not used [-Wunused-function]
     531 | void sched_put_rd(struct root_domain *rd)
         |      ^~~~~~~~~~~~
   kernel/sched/topology.c:526:6: warning: 'sched_get_rd' defined but not used [-Wunused-function]
     526 | void sched_get_rd(struct root_domain *rd)
         |      ^~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:86:
   kernel/sched/cpupri.c:210:6: warning: 'cpupri_set' defined but not used [-Wunused-function]
     210 | void cpupri_set(struct cpupri *cp, int cpu, int newpri)
         |      ^~~~~~~~~~
   kernel/sched/cpupri.c:144:5: warning: 'cpupri_find_fitness' defined but not used [-Wunused-function]
     144 | int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p,
         |     ^~~~~~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:83:
   kernel/sched/wait.c:209:6: warning: '__wake_up_pollfree' defined but not used [-Wunused-function]
     209 | void __wake_up_pollfree(struct wait_queue_head *wq_head)
         |      ^~~~~~~~~~~~~~~~~~
   kernel/sched/wait.c:131:6: warning: '__wake_up_on_current_cpu' defined but not used [-Wunused-function]
     131 | void __wake_up_on_current_cpu(struct wait_queue_head *wq_head, unsigned int mode, void *key)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:82:
   kernel/sched/wait_bit.c:245:13: warning: 'wait_bit_init' defined but not used [-Wunused-function]
     245 | void __init wait_bit_init(void)
         |             ^~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:81:
   kernel/sched/swait.c:125:6: warning: '__finish_swait' defined but not used [-Wunused-function]
     125 | void __finish_swait(struct swait_queue_head *q, struct swait_queue *wait)
         |      ^~~~~~~~~~~~~~
   kernel/sched/swait.c:41:6: warning: 'swake_up_all_locked' defined but not used [-Wunused-function]
      41 | void swake_up_all_locked(struct swait_queue_head *q)
         |      ^~~~~~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:80:
   kernel/sched/completion.c:28:6: warning: 'complete_on_current_cpu' defined but not used [-Wunused-function]
      28 | void complete_on_current_cpu(struct completion *x)
         |      ^~~~~~~~~~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:79:
   kernel/sched/loadavg.c:385:6: warning: 'calc_global_load_tick' defined but not used [-Wunused-function]
     385 | void calc_global_load_tick(struct rq *this_rq)
         |      ^~~~~~~~~~~~~~~~~~~~~
   kernel/sched/loadavg.c:349:6: warning: 'calc_global_load' defined but not used [-Wunused-function]
     349 | void calc_global_load(void)
         |      ^~~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:72:
   kernel/sched/debug.c:607:13: warning: 'print_rq' defined but not used [-Wunused-function]
     607 | static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
         |             ^~~~~~~~
   In file included from kernel/sched/build_utility.c:79:
   kernel/sched/loadavg.c:71:6: warning: 'get_avenrun' defined but not used [-Wunused-function]
      71 | void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
         |      ^~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:72:
   kernel/sched/debug.c:575:1: warning: 'print_task' defined but not used [-Wunused-function]
     575 | print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
         | ^~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/__sched_core_tick +289 kernel/sched/core_sched.c

6e33cad0af4933 Peter Zijlstra       2021-03-26  109  
85dd3f61203c5c Peter Zijlstra       2021-03-29 @110  void sched_core_fork(struct task_struct *p)
85dd3f61203c5c Peter Zijlstra       2021-03-29  111  {
85dd3f61203c5c Peter Zijlstra       2021-03-29  112  	RB_CLEAR_NODE(&p->core_node);
85dd3f61203c5c Peter Zijlstra       2021-03-29  113  	p->core_cookie = sched_core_clone_cookie(current);
85dd3f61203c5c Peter Zijlstra       2021-03-29  114  }
85dd3f61203c5c Peter Zijlstra       2021-03-29  115  
6e33cad0af4933 Peter Zijlstra       2021-03-26 @116  void sched_core_free(struct task_struct *p)
6e33cad0af4933 Peter Zijlstra       2021-03-26  117  {
6e33cad0af4933 Peter Zijlstra       2021-03-26  118  	sched_core_put_cookie(p->core_cookie);
6e33cad0af4933 Peter Zijlstra       2021-03-26  119  }
7ac592aa35a684 Chris Hyser          2021-03-24  120  
7ac592aa35a684 Chris Hyser          2021-03-24  121  static void __sched_core_set(struct task_struct *p, unsigned long cookie)
7ac592aa35a684 Chris Hyser          2021-03-24  122  {
7ac592aa35a684 Chris Hyser          2021-03-24  123  	cookie = sched_core_get_cookie(cookie);
7ac592aa35a684 Chris Hyser          2021-03-24  124  	cookie = sched_core_update_cookie(p, cookie);
7ac592aa35a684 Chris Hyser          2021-03-24  125  	sched_core_put_cookie(cookie);
7ac592aa35a684 Chris Hyser          2021-03-24  126  }
7ac592aa35a684 Chris Hyser          2021-03-24  127  
7ac592aa35a684 Chris Hyser          2021-03-24  128  /* Called from prctl interface: PR_SCHED_CORE */
7ac592aa35a684 Chris Hyser          2021-03-24 @129  int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
7ac592aa35a684 Chris Hyser          2021-03-24  130  			 unsigned long uaddr)
7ac592aa35a684 Chris Hyser          2021-03-24  131  {
7ac592aa35a684 Chris Hyser          2021-03-24  132  	unsigned long cookie = 0, id = 0;
7ac592aa35a684 Chris Hyser          2021-03-24  133  	struct task_struct *task, *p;
7ac592aa35a684 Chris Hyser          2021-03-24  134  	struct pid *grp;
7ac592aa35a684 Chris Hyser          2021-03-24  135  	int err = 0;
7ac592aa35a684 Chris Hyser          2021-03-24  136  
7ac592aa35a684 Chris Hyser          2021-03-24  137  	if (!static_branch_likely(&sched_smt_present))
7ac592aa35a684 Chris Hyser          2021-03-24  138  		return -ENODEV;
7ac592aa35a684 Chris Hyser          2021-03-24  139  
61bc346ce64a38 Eugene Syromiatnikov 2021-08-25  140  	BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD != PIDTYPE_PID);
61bc346ce64a38 Eugene Syromiatnikov 2021-08-25  141  	BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD_GROUP != PIDTYPE_TGID);
61bc346ce64a38 Eugene Syromiatnikov 2021-08-25  142  	BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_PROCESS_GROUP != PIDTYPE_PGID);
61bc346ce64a38 Eugene Syromiatnikov 2021-08-25  143  
7ac592aa35a684 Chris Hyser          2021-03-24  144  	if (type > PIDTYPE_PGID || cmd >= PR_SCHED_CORE_MAX || pid < 0 ||
7ac592aa35a684 Chris Hyser          2021-03-24  145  	    (cmd != PR_SCHED_CORE_GET && uaddr))
7ac592aa35a684 Chris Hyser          2021-03-24  146  		return -EINVAL;
7ac592aa35a684 Chris Hyser          2021-03-24  147  
7ac592aa35a684 Chris Hyser          2021-03-24  148  	rcu_read_lock();
7ac592aa35a684 Chris Hyser          2021-03-24  149  	if (pid == 0) {
7ac592aa35a684 Chris Hyser          2021-03-24  150  		task = current;
7ac592aa35a684 Chris Hyser          2021-03-24  151  	} else {
7ac592aa35a684 Chris Hyser          2021-03-24  152  		task = find_task_by_vpid(pid);
7ac592aa35a684 Chris Hyser          2021-03-24  153  		if (!task) {
7ac592aa35a684 Chris Hyser          2021-03-24  154  			rcu_read_unlock();
7ac592aa35a684 Chris Hyser          2021-03-24  155  			return -ESRCH;
7ac592aa35a684 Chris Hyser          2021-03-24  156  		}
7ac592aa35a684 Chris Hyser          2021-03-24  157  	}
7ac592aa35a684 Chris Hyser          2021-03-24  158  	get_task_struct(task);
7ac592aa35a684 Chris Hyser          2021-03-24  159  	rcu_read_unlock();
7ac592aa35a684 Chris Hyser          2021-03-24  160  
7ac592aa35a684 Chris Hyser          2021-03-24  161  	/*
7ac592aa35a684 Chris Hyser          2021-03-24  162  	 * Check if this process has the right to modify the specified
7ac592aa35a684 Chris Hyser          2021-03-24  163  	 * process. Use the regular "ptrace_may_access()" checks.
7ac592aa35a684 Chris Hyser          2021-03-24  164  	 */
7ac592aa35a684 Chris Hyser          2021-03-24  165  	if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
7ac592aa35a684 Chris Hyser          2021-03-24  166  		err = -EPERM;
7ac592aa35a684 Chris Hyser          2021-03-24  167  		goto out;
7ac592aa35a684 Chris Hyser          2021-03-24  168  	}
7ac592aa35a684 Chris Hyser          2021-03-24  169  
7ac592aa35a684 Chris Hyser          2021-03-24  170  	switch (cmd) {
7ac592aa35a684 Chris Hyser          2021-03-24  171  	case PR_SCHED_CORE_GET:
7ac592aa35a684 Chris Hyser          2021-03-24  172  		if (type != PIDTYPE_PID || uaddr & 7) {
7ac592aa35a684 Chris Hyser          2021-03-24  173  			err = -EINVAL;
7ac592aa35a684 Chris Hyser          2021-03-24  174  			goto out;
7ac592aa35a684 Chris Hyser          2021-03-24  175  		}
7ac592aa35a684 Chris Hyser          2021-03-24  176  		cookie = sched_core_clone_cookie(task);
7ac592aa35a684 Chris Hyser          2021-03-24  177  		if (cookie) {
7ac592aa35a684 Chris Hyser          2021-03-24  178  			/* XXX improve ? */
7ac592aa35a684 Chris Hyser          2021-03-24  179  			ptr_to_hashval((void *)cookie, &id);
7ac592aa35a684 Chris Hyser          2021-03-24  180  		}
7ac592aa35a684 Chris Hyser          2021-03-24  181  		err = put_user(id, (u64 __user *)uaddr);
7ac592aa35a684 Chris Hyser          2021-03-24  182  		goto out;
7ac592aa35a684 Chris Hyser          2021-03-24  183  
7ac592aa35a684 Chris Hyser          2021-03-24  184  	case PR_SCHED_CORE_CREATE:
7ac592aa35a684 Chris Hyser          2021-03-24  185  		cookie = sched_core_alloc_cookie();
7ac592aa35a684 Chris Hyser          2021-03-24  186  		if (!cookie) {
7ac592aa35a684 Chris Hyser          2021-03-24  187  			err = -ENOMEM;
7ac592aa35a684 Chris Hyser          2021-03-24  188  			goto out;
7ac592aa35a684 Chris Hyser          2021-03-24  189  		}
7ac592aa35a684 Chris Hyser          2021-03-24  190  		break;
7ac592aa35a684 Chris Hyser          2021-03-24  191  
7ac592aa35a684 Chris Hyser          2021-03-24  192  	case PR_SCHED_CORE_SHARE_TO:
7ac592aa35a684 Chris Hyser          2021-03-24  193  		cookie = sched_core_clone_cookie(current);
7ac592aa35a684 Chris Hyser          2021-03-24  194  		break;
7ac592aa35a684 Chris Hyser          2021-03-24  195  
7ac592aa35a684 Chris Hyser          2021-03-24  196  	case PR_SCHED_CORE_SHARE_FROM:
7ac592aa35a684 Chris Hyser          2021-03-24  197  		if (type != PIDTYPE_PID) {
7ac592aa35a684 Chris Hyser          2021-03-24  198  			err = -EINVAL;
7ac592aa35a684 Chris Hyser          2021-03-24  199  			goto out;
7ac592aa35a684 Chris Hyser          2021-03-24  200  		}
7ac592aa35a684 Chris Hyser          2021-03-24  201  		cookie = sched_core_clone_cookie(task);
7ac592aa35a684 Chris Hyser          2021-03-24  202  		__sched_core_set(current, cookie);
7ac592aa35a684 Chris Hyser          2021-03-24  203  		goto out;
7ac592aa35a684 Chris Hyser          2021-03-24  204  
7ac592aa35a684 Chris Hyser          2021-03-24  205  	default:
7ac592aa35a684 Chris Hyser          2021-03-24  206  		err = -EINVAL;
7ac592aa35a684 Chris Hyser          2021-03-24  207  		goto out;
8648f92a66a323 Xin Gao              2022-07-19  208  	}
7ac592aa35a684 Chris Hyser          2021-03-24  209  
7ac592aa35a684 Chris Hyser          2021-03-24  210  	if (type == PIDTYPE_PID) {
7ac592aa35a684 Chris Hyser          2021-03-24  211  		__sched_core_set(task, cookie);
7ac592aa35a684 Chris Hyser          2021-03-24  212  		goto out;
7ac592aa35a684 Chris Hyser          2021-03-24  213  	}
7ac592aa35a684 Chris Hyser          2021-03-24  214  
7ac592aa35a684 Chris Hyser          2021-03-24  215  	read_lock(&tasklist_lock);
7ac592aa35a684 Chris Hyser          2021-03-24  216  	grp = task_pid_type(task, type);
7ac592aa35a684 Chris Hyser          2021-03-24  217  
7ac592aa35a684 Chris Hyser          2021-03-24  218  	do_each_pid_thread(grp, type, p) {
7ac592aa35a684 Chris Hyser          2021-03-24  219  		if (!ptrace_may_access(p, PTRACE_MODE_READ_REALCREDS)) {
7ac592aa35a684 Chris Hyser          2021-03-24  220  			err = -EPERM;
7ac592aa35a684 Chris Hyser          2021-03-24  221  			goto out_tasklist;
7ac592aa35a684 Chris Hyser          2021-03-24  222  		}
7ac592aa35a684 Chris Hyser          2021-03-24  223  	} while_each_pid_thread(grp, type, p);
7ac592aa35a684 Chris Hyser          2021-03-24  224  
7ac592aa35a684 Chris Hyser          2021-03-24  225  	do_each_pid_thread(grp, type, p) {
7ac592aa35a684 Chris Hyser          2021-03-24  226  		__sched_core_set(p, cookie);
7ac592aa35a684 Chris Hyser          2021-03-24  227  	} while_each_pid_thread(grp, type, p);
7ac592aa35a684 Chris Hyser          2021-03-24  228  out_tasklist:
7ac592aa35a684 Chris Hyser          2021-03-24  229  	read_unlock(&tasklist_lock);
7ac592aa35a684 Chris Hyser          2021-03-24  230  
7ac592aa35a684 Chris Hyser          2021-03-24  231  out:
7ac592aa35a684 Chris Hyser          2021-03-24  232  	sched_core_put_cookie(cookie);
7ac592aa35a684 Chris Hyser          2021-03-24  233  	put_task_struct(task);
7ac592aa35a684 Chris Hyser          2021-03-24  234  	return err;
7ac592aa35a684 Chris Hyser          2021-03-24  235  }
7ac592aa35a684 Chris Hyser          2021-03-24  236  
4feee7d12603de Josh Don             2021-10-18  237  #ifdef CONFIG_SCHEDSTATS
4feee7d12603de Josh Don             2021-10-18  238  
4feee7d12603de Josh Don             2021-10-18  239  /* REQUIRES: rq->core's clock recently updated. */
4feee7d12603de Josh Don             2021-10-18  240  void __sched_core_account_forceidle(struct rq *rq)
4feee7d12603de Josh Don             2021-10-18  241  {
4feee7d12603de Josh Don             2021-10-18  242  	const struct cpumask *smt_mask = cpu_smt_mask(cpu_of(rq));
4feee7d12603de Josh Don             2021-10-18  243  	u64 delta, now = rq_clock(rq->core);
4feee7d12603de Josh Don             2021-10-18  244  	struct rq *rq_i;
4feee7d12603de Josh Don             2021-10-18  245  	struct task_struct *p;
4feee7d12603de Josh Don             2021-10-18  246  	int i;
4feee7d12603de Josh Don             2021-10-18  247  
4feee7d12603de Josh Don             2021-10-18  248  	lockdep_assert_rq_held(rq);
4feee7d12603de Josh Don             2021-10-18  249  
4feee7d12603de Josh Don             2021-10-18  250  	WARN_ON_ONCE(!rq->core->core_forceidle_count);
4feee7d12603de Josh Don             2021-10-18  251  
4feee7d12603de Josh Don             2021-10-18  252  	if (rq->core->core_forceidle_start == 0)
4feee7d12603de Josh Don             2021-10-18  253  		return;
4feee7d12603de Josh Don             2021-10-18  254  
4feee7d12603de Josh Don             2021-10-18  255  	delta = now - rq->core->core_forceidle_start;
4feee7d12603de Josh Don             2021-10-18  256  	if (unlikely((s64)delta <= 0))
4feee7d12603de Josh Don             2021-10-18  257  		return;
4feee7d12603de Josh Don             2021-10-18  258  
4feee7d12603de Josh Don             2021-10-18  259  	rq->core->core_forceidle_start = now;
4feee7d12603de Josh Don             2021-10-18  260  
4feee7d12603de Josh Don             2021-10-18  261  	if (WARN_ON_ONCE(!rq->core->core_forceidle_occupation)) {
4feee7d12603de Josh Don             2021-10-18  262  		/* can't be forced idle without a running task */
4feee7d12603de Josh Don             2021-10-18  263  	} else if (rq->core->core_forceidle_count > 1 ||
4feee7d12603de Josh Don             2021-10-18  264  		   rq->core->core_forceidle_occupation > 1) {
4feee7d12603de Josh Don             2021-10-18  265  		/*
4feee7d12603de Josh Don             2021-10-18  266  		 * For larger SMT configurations, we need to scale the charged
4feee7d12603de Josh Don             2021-10-18  267  		 * forced idle amount since there can be more than one forced
4feee7d12603de Josh Don             2021-10-18  268  		 * idle sibling and more than one running cookied task.
4feee7d12603de Josh Don             2021-10-18  269  		 */
4feee7d12603de Josh Don             2021-10-18  270  		delta *= rq->core->core_forceidle_count;
4feee7d12603de Josh Don             2021-10-18  271  		delta = div_u64(delta, rq->core->core_forceidle_occupation);
4feee7d12603de Josh Don             2021-10-18  272  	}
4feee7d12603de Josh Don             2021-10-18  273  
4feee7d12603de Josh Don             2021-10-18  274  	for_each_cpu(i, smt_mask) {
4feee7d12603de Josh Don             2021-10-18  275  		rq_i = cpu_rq(i);
4feee7d12603de Josh Don             2021-10-18  276  		p = rq_i->core_pick ?: rq_i->curr;
4feee7d12603de Josh Don             2021-10-18  277  
b171501f258063 Cruz Zhao            2022-01-11  278  		if (p == rq_i->idle)
4feee7d12603de Josh Don             2021-10-18  279  			continue;
4feee7d12603de Josh Don             2021-10-18  280  
1fcf54deb767d4 Josh Don             2022-06-29  281  		/*
1fcf54deb767d4 Josh Don             2022-06-29  282  		 * Note: this will account forceidle to the current cpu, even
1fcf54deb767d4 Josh Don             2022-06-29  283  		 * if it comes from our SMT sibling.
1fcf54deb767d4 Josh Don             2022-06-29  284  		 */
1fcf54deb767d4 Josh Don             2022-06-29  285  		__account_forceidle_time(p, delta);
4feee7d12603de Josh Don             2021-10-18  286  	}
4feee7d12603de Josh Don             2021-10-18  287  }
4feee7d12603de Josh Don             2021-10-18  288  
4feee7d12603de Josh Don             2021-10-18 @289  void __sched_core_tick(struct rq *rq)
4feee7d12603de Josh Don             2021-10-18  290  {
4feee7d12603de Josh Don             2021-10-18  291  	if (!rq->core->core_forceidle_count)
4feee7d12603de Josh Don             2021-10-18  292  		return;
4feee7d12603de Josh Don             2021-10-18  293  
4feee7d12603de Josh Don             2021-10-18  294  	if (rq != rq->core)
4feee7d12603de Josh Don             2021-10-18  295  		update_rq_clock(rq->core);
4feee7d12603de Josh Don             2021-10-18  296  
4feee7d12603de Josh Don             2021-10-18  297  	__sched_core_account_forceidle(rq);
4feee7d12603de Josh Don             2021-10-18  298  }
4feee7d12603de Josh Don             2021-10-18  299  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v1] sched/debug: Update print_task formatin /sys/kernel/debug/sched/debug
Posted by kernel test robot 2 years ago
Hi Junwen,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on peterz-queue/sched/core linus/master v6.7-rc5 next-20231215]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Junwen-Wu/sched-debug-Update-print_task-formatin-sys-kernel-debug-sched-debug/20231216-234714
base:   tip/sched/core
patch link:    https://lore.kernel.org/r/20231216154412.613443-1-wudaemon%40163.com
patch subject: [PATCH v1] sched/debug: Update print_task formatin  /sys/kernel/debug/sched/debug
config: parisc-defconfig (https://download.01.org/0day-ci/archive/20231217/202312171141.Q5MmfuLK-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231217/202312171141.Q5MmfuLK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312171141.Q5MmfuLK-lkp@intel.com/

All warnings (new ones prefixed by >>):

   kernel/sched/isolation.c:241:22: note: (near initialization for '__setup_housekeeping_isolcpus_setup.setup_func')
     241 | __setup("isolcpus=", housekeeping_isolcpus_setup);
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/init.h:340:46: note: in definition of macro '__setup_param'
     340 |                 = { __setup_str_##unique_id, fn, early }
         |                                              ^~
   kernel/sched/isolation.c:241:1: note: in expansion of macro '__setup'
     241 | __setup("isolcpus=", housekeeping_isolcpus_setup);
         | ^~~~~~~
   kernel/sched/build_utility.c:105: error: expected declaration or statement at end of input
     105 | #endif
         | 
   kernel/sched/stop_task.c:106:20: warning: unused variable 'stop_sched_class' [-Wunused-variable]
     106 | DEFINE_SCHED_CLASS(stop) = {
         |                    ^~~~
   kernel/sched/sched.h:2335:26: note: in definition of macro 'DEFINE_SCHED_CLASS'
    2335 | const struct sched_class name##_sched_class \
         |                          ^~~~
   kernel/sched/debug.c:609:33: warning: unused variable 'p' [-Wunused-variable]
     609 |         struct task_struct *g, *p;
         |                                 ^
   kernel/sched/debug.c:609:29: warning: unused variable 'g' [-Wunused-variable]
     609 |         struct task_struct *g, *p;
         |                             ^
   kernel/sched/isolation.c: At top level:
   kernel/sched/isolation.c:82:13: warning: 'housekeeping_init' defined but not used [-Wunused-function]
      82 | void __init housekeeping_init(void)
         |             ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:249:25: warning: '__se_sys_membarrier' defined but not used [-Wunused-function]
     249 |         asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))  \
         |                         ^~~~~~~~
   include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
     230 |         __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
         |         ^~~~~~~~~~~~~~~~~
   include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
     221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
         |                                    ^~~~~~~~~~~~~~~
   kernel/sched/membarrier.c:614:1: note: in expansion of macro 'SYSCALL_DEFINE3'
     614 | SYSCALL_DEFINE3(membarrier, int, cmd, unsigned int, flags, int, cpu_id)
         | ^~~~~~~~~~~~~~~
   kernel/sched/membarrier.c:233:6: warning: 'membarrier_update_current_mm' defined but not used [-Wunused-function]
     233 | void membarrier_update_current_mm(struct mm_struct *next_mm)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/membarrier.c:217:6: warning: 'membarrier_exec_mmap' defined but not used [-Wunused-function]
     217 | void membarrier_exec_mmap(struct mm_struct *mm)
         |      ^~~~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:2789:6: warning: 'partition_sched_domains' defined but not used [-Wunused-function]
    2789 | void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
         |      ^~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:2599:12: warning: 'sched_init_domains' defined but not used [-Wunused-function]
    2599 | int __init sched_init_domains(const struct cpumask *cpu_map)
         |            ^~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:2276:13: warning: '__sdt_free' defined but not used [-Wunused-function]
    2276 | static void __sdt_free(const struct cpumask *cpu_map)
         |             ^~~~~~~~~~
   kernel/sched/topology.c:2207:12: warning: '__sdt_alloc' defined but not used [-Wunused-function]
    2207 | static int __sdt_alloc(const struct cpumask *cpu_map)
         |            ^~~~~~~~~~~
   kernel/sched/topology.c:1710:13: warning: 'set_sched_topology' defined but not used [-Wunused-function]
    1710 | void __init set_sched_topology(struct sched_domain_topology_level *tl)
         |             ^~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:585:13: warning: 'init_defrootdomain' defined but not used [-Wunused-function]
     585 | void __init init_defrootdomain(void)
         |             ^~~~~~~~~~~~~~~~~~
   kernel/sched/topology.c:531:6: warning: 'sched_put_rd' defined but not used [-Wunused-function]
     531 | void sched_put_rd(struct root_domain *rd)
         |      ^~~~~~~~~~~~
   kernel/sched/topology.c:526:6: warning: 'sched_get_rd' defined but not used [-Wunused-function]
     526 | void sched_get_rd(struct root_domain *rd)
         |      ^~~~~~~~~~~~
   kernel/sched/cpupri.c:210:6: warning: 'cpupri_set' defined but not used [-Wunused-function]
     210 | void cpupri_set(struct cpupri *cp, int cpu, int newpri)
         |      ^~~~~~~~~~
   kernel/sched/cpupri.c:144:5: warning: 'cpupri_find_fitness' defined but not used [-Wunused-function]
     144 | int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p,
         |     ^~~~~~~~~~~~~~~~~~~
   kernel/sched/wait.c:209:6: warning: '__wake_up_pollfree' defined but not used [-Wunused-function]
     209 | void __wake_up_pollfree(struct wait_queue_head *wq_head)
         |      ^~~~~~~~~~~~~~~~~~
   kernel/sched/wait.c:131:6: warning: '__wake_up_on_current_cpu' defined but not used [-Wunused-function]
     131 | void __wake_up_on_current_cpu(struct wait_queue_head *wq_head, unsigned int mode, void *key)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/wait_bit.c:245:13: warning: 'wait_bit_init' defined but not used [-Wunused-function]
     245 | void __init wait_bit_init(void)
         |             ^~~~~~~~~~~~~
   kernel/sched/swait.c:125:6: warning: '__finish_swait' defined but not used [-Wunused-function]
     125 | void __finish_swait(struct swait_queue_head *q, struct swait_queue *wait)
         |      ^~~~~~~~~~~~~~
   kernel/sched/swait.c:41:6: warning: 'swake_up_all_locked' defined but not used [-Wunused-function]
      41 | void swake_up_all_locked(struct swait_queue_head *q)
         |      ^~~~~~~~~~~~~~~~~~~
   kernel/sched/completion.c:28:6: warning: 'complete_on_current_cpu' defined but not used [-Wunused-function]
      28 | void complete_on_current_cpu(struct completion *x)
         |      ^~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/loadavg.c:385:6: warning: 'calc_global_load_tick' defined but not used [-Wunused-function]
     385 | void calc_global_load_tick(struct rq *this_rq)
         |      ^~~~~~~~~~~~~~~~~~~~~
   kernel/sched/loadavg.c:349:6: warning: 'calc_global_load' defined but not used [-Wunused-function]
     349 | void calc_global_load(void)
         |      ^~~~~~~~~~~~~~~~
>> kernel/sched/loadavg.c:156:1: warning: 'calc_load_n' defined but not used [-Wunused-function]
     156 | calc_load_n(unsigned long load, unsigned long exp,
         | ^~~~~~~~~~~
   kernel/sched/debug.c:607:13: warning: 'print_rq' defined but not used [-Wunused-function]
     607 | static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
         |             ^~~~~~~~
   kernel/sched/loadavg.c:71:6: warning: 'get_avenrun' defined but not used [-Wunused-function]
      71 | void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
         |      ^~~~~~~~~~~
   kernel/sched/debug.c:575:1: warning: 'print_task' defined but not used [-Wunused-function]
     575 | print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
         | ^~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/calc_load_n +156 kernel/sched/loadavg.c

5c54f5b9edb1aa Johannes Weiner 2018-10-26  131  
5c54f5b9edb1aa Johannes Weiner 2018-10-26  132  /*
5c54f5b9edb1aa Johannes Weiner 2018-10-26  133   * a1 = a0 * e + a * (1 - e)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  134   *
5c54f5b9edb1aa Johannes Weiner 2018-10-26  135   * a2 = a1 * e + a * (1 - e)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  136   *    = (a0 * e + a * (1 - e)) * e + a * (1 - e)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  137   *    = a0 * e^2 + a * (1 - e) * (1 + e)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  138   *
5c54f5b9edb1aa Johannes Weiner 2018-10-26  139   * a3 = a2 * e + a * (1 - e)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  140   *    = (a0 * e^2 + a * (1 - e) * (1 + e)) * e + a * (1 - e)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  141   *    = a0 * e^3 + a * (1 - e) * (1 + e + e^2)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  142   *
5c54f5b9edb1aa Johannes Weiner 2018-10-26  143   *  ...
5c54f5b9edb1aa Johannes Weiner 2018-10-26  144   *
5c54f5b9edb1aa Johannes Weiner 2018-10-26  145   * an = a0 * e^n + a * (1 - e) * (1 + e + ... + e^n-1) [1]
5c54f5b9edb1aa Johannes Weiner 2018-10-26  146   *    = a0 * e^n + a * (1 - e) * (1 - e^n)/(1 - e)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  147   *    = a0 * e^n + a * (1 - e^n)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  148   *
5c54f5b9edb1aa Johannes Weiner 2018-10-26  149   * [1] application of the geometric series:
5c54f5b9edb1aa Johannes Weiner 2018-10-26  150   *
5c54f5b9edb1aa Johannes Weiner 2018-10-26  151   *              n         1 - x^(n+1)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  152   *     S_n := \Sum x^i = -------------
5c54f5b9edb1aa Johannes Weiner 2018-10-26  153   *             i=0          1 - x
5c54f5b9edb1aa Johannes Weiner 2018-10-26  154   */
5c54f5b9edb1aa Johannes Weiner 2018-10-26  155  unsigned long
5c54f5b9edb1aa Johannes Weiner 2018-10-26 @156  calc_load_n(unsigned long load, unsigned long exp,
5c54f5b9edb1aa Johannes Weiner 2018-10-26  157  	    unsigned long active, unsigned int n)
5c54f5b9edb1aa Johannes Weiner 2018-10-26  158  {
5c54f5b9edb1aa Johannes Weiner 2018-10-26  159  	return calc_load(load, fixed_power_int(exp, FSHIFT, n), active);
5c54f5b9edb1aa Johannes Weiner 2018-10-26  160  }
5c54f5b9edb1aa Johannes Weiner 2018-10-26  161  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v1] sched/debug: Update print_task formatin /sys/kernel/debug/sched/debug
Posted by kernel test robot 2 years ago
Hi Junwen,

kernel test robot noticed the following build errors:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on linus/master v6.7-rc5 next-20231215]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Junwen-Wu/sched-debug-Update-print_task-formatin-sys-kernel-debug-sched-debug/20231216-234714
base:   tip/sched/core
patch link:    https://lore.kernel.org/r/20231216154412.613443-1-wudaemon%40163.com
patch subject: [PATCH v1] sched/debug: Update print_task formatin  /sys/kernel/debug/sched/debug
config: arm-hisi_defconfig (https://download.01.org/0day-ci/archive/20231217/202312171007.tDZmSAZV-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231217/202312171007.tDZmSAZV-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312171007.tDZmSAZV-lkp@intel.com/

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

   In file included from kernel/sched/build_utility.c:72:
   kernel/sched/debug.c: In function 'print_rq':
>> kernel/sched/debug.c:1129:2: error: unterminated argument list invoking macro "SEQ_printf"
    1129 | }
         |  ^
>> kernel/sched/debug.c:613:9: error: unknown type name 'SEQ_printf'
     613 |         SEQ_printf(m, " S            task   PID         tree-key          deadline"
         |         ^~~~~~~~~~
   In file included from kernel/sched/build_utility.c:79:
>> kernel/sched/loadavg.c:58:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'calc_load_tasks'
      58 | atomic_long_t calc_load_tasks;
         |               ^~~~~~~~~~~~~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/kernel.h:18,
                    from include/linux/cpumask.h:10,
                    from include/linux/smp.h:13,
                    from include/linux/sched/clock.h:5,
                    from kernel/sched/build_utility.c:12:
>> kernel/sched/loadavg.c:61:15: error: extern declaration of 'avenrun' follows declaration with no linkage
      61 | EXPORT_SYMBOL(avenrun); /* should be removed */
         |               ^~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/loadavg.c:61:1: note: in expansion of macro 'EXPORT_SYMBOL'
      61 | EXPORT_SYMBOL(avenrun); /* should be removed */
         | ^~~~~~~~~~~~~
   kernel/sched/loadavg.c:60:15: note: previous declaration of 'avenrun' with type 'long unsigned int[3]'
      60 | unsigned long avenrun[3];
         |               ^~~~~~~
>> kernel/sched/loadavg.c:109:1: error: invalid storage class for function 'fixed_power_int'
     109 | fixed_power_int(unsigned long x, unsigned int frac_bits, unsigned int n)
         | ^~~~~~~~~~~~~~~
>> kernel/sched/loadavg.c:208:19: error: invalid storage class for function 'calc_load_write_idx'
     208 | static inline int calc_load_write_idx(void)
         |                   ^~~~~~~~~~~~~~~~~~~
>> kernel/sched/loadavg.c:228:19: error: invalid storage class for function 'calc_load_read_idx'
     228 | static inline int calc_load_read_idx(void)
         |                   ^~~~~~~~~~~~~~~~~~
>> kernel/sched/loadavg.c:233:13: error: invalid storage class for function 'calc_load_nohz_fold'
     233 | static void calc_load_nohz_fold(struct rq *rq)
         |             ^~~~~~~~~~~~~~~~~~~
>> kernel/sched/loadavg.c:283:13: error: invalid storage class for function 'calc_load_nohz_read'
     283 | static long calc_load_nohz_read(void)
         |             ^~~~~~~~~~~~~~~~~~~
>> kernel/sched/loadavg.c:303:13: error: invalid storage class for function 'calc_global_nohz'
     303 | static void calc_global_nohz(void)
         |             ^~~~~~~~~~~~~~~~
   In file included from kernel/sched/build_utility.c:80:
>> kernel/sched/completion.c:16:13: error: invalid storage class for function 'complete_with_flags'
      16 | static void complete_with_flags(struct completion *x, int wake_flags)
         |             ^~~~~~~~~~~~~~~~~~~
>> kernel/sched/completion.c:49:15: error: non-static declaration of 'complete' follows static declaration
      49 | EXPORT_SYMBOL(complete);
         |               ^~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:49:1: note: in expansion of macro 'EXPORT_SYMBOL'
      49 | EXPORT_SYMBOL(complete);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:45:6: note: previous definition of 'complete' with type 'void(struct completion *)'
      45 | void complete(struct completion *x)
         |      ^~~~~~~~
>> kernel/sched/completion.c:78:15: error: non-static declaration of 'complete_all' follows static declaration
      78 | EXPORT_SYMBOL(complete_all);
         |               ^~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:78:1: note: in expansion of macro 'EXPORT_SYMBOL'
      78 | EXPORT_SYMBOL(complete_all);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:67:6: note: previous definition of 'complete_all' with type 'void(struct completion *)'
      67 | void complete_all(struct completion *x)
         |      ^~~~~~~~~~~~
>> kernel/sched/completion.c:81:1: error: invalid storage class for function 'do_wait_for_common'
      81 | do_wait_for_common(struct completion *x,
         | ^~~~~~~~~~~~~~~~~~
>> kernel/sched/completion.c:108:1: error: invalid storage class for function '__wait_for_common'
     108 | __wait_for_common(struct completion *x,
         | ^~~~~~~~~~~~~~~~~
>> kernel/sched/completion.c:125:1: error: invalid storage class for function 'wait_for_common'
     125 | wait_for_common(struct completion *x, long timeout, int state)
         | ^~~~~~~~~~~~~~~
>> kernel/sched/completion.c:131:1: error: invalid storage class for function 'wait_for_common_io'
     131 | wait_for_common_io(struct completion *x, long timeout, int state)
         | ^~~~~~~~~~~~~~~~~~
>> kernel/sched/completion.c:150:15: error: non-static declaration of 'wait_for_completion' follows static declaration
     150 | EXPORT_SYMBOL(wait_for_completion);
         |               ^~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:150:1: note: in expansion of macro 'EXPORT_SYMBOL'
     150 | EXPORT_SYMBOL(wait_for_completion);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:146:14: note: previous definition of 'wait_for_completion' with type 'void(struct completion *)'
     146 | void __sched wait_for_completion(struct completion *x)
         |              ^~~~~~~~~~~~~~~~~~~
>> kernel/sched/completion.c:169:15: error: non-static declaration of 'wait_for_completion_timeout' follows static declaration
     169 | EXPORT_SYMBOL(wait_for_completion_timeout);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:169:1: note: in expansion of macro 'EXPORT_SYMBOL'
     169 | EXPORT_SYMBOL(wait_for_completion_timeout);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:165:1: note: previous definition of 'wait_for_completion_timeout' with type 'long unsigned int(struct completion *, long unsigned int)'
     165 | wait_for_completion_timeout(struct completion *x, unsigned long timeout)
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/sched/completion.c:183:15: error: non-static declaration of 'wait_for_completion_io' follows static declaration
     183 | EXPORT_SYMBOL(wait_for_completion_io);
         |               ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:183:1: note: in expansion of macro 'EXPORT_SYMBOL'
     183 | EXPORT_SYMBOL(wait_for_completion_io);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:179:14: note: previous definition of 'wait_for_completion_io' with type 'void(struct completion *)'
     179 | void __sched wait_for_completion_io(struct completion *x)
         |              ^~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/completion.c:203:15: error: non-static declaration of 'wait_for_completion_io_timeout' follows static declaration
     203 | EXPORT_SYMBOL(wait_for_completion_io_timeout);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:203:1: note: in expansion of macro 'EXPORT_SYMBOL'
     203 | EXPORT_SYMBOL(wait_for_completion_io_timeout);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:199:1: note: previous definition of 'wait_for_completion_io_timeout' with type 'long unsigned int(struct completion *, long unsigned int)'
     199 | wait_for_completion_io_timeout(struct completion *x, unsigned long timeout)
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/completion.c:222:15: error: non-static declaration of 'wait_for_completion_interruptible' follows static declaration
     222 | EXPORT_SYMBOL(wait_for_completion_interruptible);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:222:1: note: in expansion of macro 'EXPORT_SYMBOL'
     222 | EXPORT_SYMBOL(wait_for_completion_interruptible);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:214:13: note: previous definition of 'wait_for_completion_interruptible' with type 'int(struct completion *)'
     214 | int __sched wait_for_completion_interruptible(struct completion *x)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/completion.c:241:15: error: non-static declaration of 'wait_for_completion_interruptible_timeout' follows static declaration
     241 | EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:241:1: note: in expansion of macro 'EXPORT_SYMBOL'
     241 | EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:236:1: note: previous definition of 'wait_for_completion_interruptible_timeout' with type 'long int(struct completion *, long unsigned int)'
     236 | wait_for_completion_interruptible_timeout(struct completion *x,
         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/completion.c:260:15: error: non-static declaration of 'wait_for_completion_killable' follows static declaration
     260 | EXPORT_SYMBOL(wait_for_completion_killable);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:260:1: note: in expansion of macro 'EXPORT_SYMBOL'
     260 | EXPORT_SYMBOL(wait_for_completion_killable);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:252:13: note: previous definition of 'wait_for_completion_killable' with type 'int(struct completion *)'
     252 | int __sched wait_for_completion_killable(struct completion *x)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/completion.c:270:15: error: non-static declaration of 'wait_for_completion_state' follows static declaration
     270 | EXPORT_SYMBOL(wait_for_completion_state);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:270:1: note: in expansion of macro 'EXPORT_SYMBOL'
     270 | EXPORT_SYMBOL(wait_for_completion_state);
         | ^~~~~~~~~~~~~
   kernel/sched/completion.c:262:13: note: previous definition of 'wait_for_completion_state' with type 'int(struct completion *, unsigned int)'
     262 | int __sched wait_for_completion_state(struct completion *x, unsigned int state)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/completion.c:290:15: error: non-static declaration of 'wait_for_completion_killable_timeout' follows static declaration
     290 | EXPORT_SYMBOL(wait_for_completion_killable_timeout);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:74:28: note: in definition of macro '__EXPORT_SYMBOL'
      74 |         extern typeof(sym) sym;                                 \
         |                            ^~~
   include/linux/export.h:86:41: note: in expansion of macro '_EXPORT_SYMBOL'
      86 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   kernel/sched/completion.c:290:1: note: in expansion of macro 'EXPORT_SYMBOL'
     290 | EXPORT_SYMBOL(wait_for_completion_killable_timeout);


vim +/SEQ_printf +1129 kernel/sched/debug.c

c006fac556e401 Paul Turner 2021-04-16  1120  
c006fac556e401 Paul Turner 2021-04-16  1121  void resched_latency_warn(int cpu, u64 latency)
c006fac556e401 Paul Turner 2021-04-16  1122  {
c006fac556e401 Paul Turner 2021-04-16  1123  	static DEFINE_RATELIMIT_STATE(latency_check_ratelimit, 60 * 60 * HZ, 1);
c006fac556e401 Paul Turner 2021-04-16  1124  
c006fac556e401 Paul Turner 2021-04-16  1125  	WARN(__ratelimit(&latency_check_ratelimit),
c006fac556e401 Paul Turner 2021-04-16  1126  	     "sched: CPU %d need_resched set for > %llu ns (%d ticks) "
c006fac556e401 Paul Turner 2021-04-16  1127  	     "without schedule\n",
c006fac556e401 Paul Turner 2021-04-16  1128  	     cpu, latency, cpu_rq(cpu)->ticks_without_resched);
c006fac556e401 Paul Turner 2021-04-16 @1129  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki