[PATCH] cputime:make function static

zhoumin posted 1 patch 3 months, 2 weeks ago
include/linux/kernel_stat.h | 1 -
kernel/sched/cputime.c      | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
[PATCH] cputime:make function static
Posted by zhoumin 3 months, 2 weeks ago
Make account_system_time static.

Signed-off-by: zhoumin <teczm@foxmail.com>
---
 include/linux/kernel_stat.h | 1 -
 kernel/sched/cputime.c      | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index b97ce2df376f..815400c81015 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -119,7 +119,6 @@ static inline void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu)
 
 extern void account_user_time(struct task_struct *, u64);
 extern void account_guest_time(struct task_struct *, u64);
-extern void account_system_time(struct task_struct *, int, u64);
 extern void account_system_index_time(struct task_struct *, u64,
 				      enum cpu_usage_stat);
 extern void account_steal_time(u64);
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 6dab4854c6c0..8c74b86f74f5 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -183,7 +183,7 @@ void account_system_index_time(struct task_struct *p,
  * @hardirq_offset: the offset to subtract from hardirq_count()
  * @cputime: the CPU time spent in kernel space since the last update
  */
-void account_system_time(struct task_struct *p, int hardirq_offset, u64 cputime)
+static void account_system_time(struct task_struct *p, int hardirq_offset, u64 cputime)
 {
 	int index;
 
-- 
2.43.0
Re: [PATCH] cputime:make function static
Posted by kernel test robot 3 months, 2 weeks ago
Hi zhoumin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on linus/master v6.18-rc2 next-20251021]
[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/zhoumin/cputime-make-function-static/20251020-235256
base:   tip/sched/core
patch link:    https://lore.kernel.org/r/tencent_C04F39CA166C38A5502D7CF206688E191307%40qq.com
patch subject: [PATCH] cputime:make function static
config: s390-randconfig-002-20251021 (https://download.01.org/0day-ci/archive/20251021/202510211821.9NudzdNn-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251021/202510211821.9NudzdNn-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/202510211821.9NudzdNn-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from kernel/sched/build_policy.c:57:
>> kernel/sched/cputime.c:189:13: warning: 'account_system_time' defined but not used [-Wunused-function]
     189 | static void account_system_time(struct task_struct *p, int hardirq_offset, u64 cputime)
         |             ^~~~~~~~~~~~~~~~~~~

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for I2C_K1
   Depends on [n]: I2C [=y] && HAS_IOMEM [=y] && (ARCH_SPACEMIT || COMPILE_TEST [=y]) && OF [=n]
   Selected by [y]:
   - MFD_SPACEMIT_P1 [=y] && HAS_IOMEM [=y] && (ARCH_SPACEMIT || COMPILE_TEST [=y]) && I2C [=y]


vim +/account_system_time +189 kernel/sched/cputime.c

   182	
   183	/*
   184	 * Account system CPU time to a process.
   185	 * @p: the process that the CPU time gets accounted to
   186	 * @hardirq_offset: the offset to subtract from hardirq_count()
   187	 * @cputime: the CPU time spent in kernel space since the last update
   188	 */
 > 189	static void account_system_time(struct task_struct *p, int hardirq_offset, u64 cputime)
   190	{
   191		int index;
   192	
   193		if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
   194			account_guest_time(p, cputime);
   195			return;
   196		}
   197	
   198		if (hardirq_count() - hardirq_offset)
   199			index = CPUTIME_IRQ;
   200		else if (in_serving_softirq())
   201			index = CPUTIME_SOFTIRQ;
   202		else
   203			index = CPUTIME_SYSTEM;
   204	
   205		account_system_index_time(p, cputime, index);
   206	}
   207	

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