cputime: remove cputime_to_nsecs fallback

Message ID 20221220070705.2958959-1-npiggin@gmail.com
State New
Headers
Series cputime: remove cputime_to_nsecs fallback |

Commit Message

Nicholas Piggin Dec. 20, 2022, 7:07 a.m. UTC
  The archs that use cputime_to_nsecs() internally provide their own
definition and don't need the fallback. cputime_to_usecs() unused except
in this fallback, and is not defined anywhere.

This removes the final remnant of the cputime_t code from the kernel.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s390@vger.kernel.org
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
This required a couple of tweaks to s390 includes so we're not pulling
asm/cputime.h into the core header unnecessarily. In that case maybe
this can go via s390 tree because the patch should be otherwise quite
trivial. Could it get an ack or two from a core maintainer to support
that?

Thanks,
Nick

 arch/s390/kernel/idle.c       | 2 +-
 arch/s390/kernel/vtime.c      | 2 +-
 include/linux/sched/cputime.h | 9 ---------
 kernel/sched/cputime.c        | 4 ++++
 4 files changed, 6 insertions(+), 11 deletions(-)
  

Comments

kernel test robot Dec. 20, 2022, 4:25 p.m. UTC | #1
Hi Nicholas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on s390/features]
[also build test WARNING on tip/sched/core soc/for-next linus/master v6.1 next-20221220]
[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/Nicholas-Piggin/cputime-remove-cputime_to_nsecs-fallback/20221220-150845
base:   https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
patch link:    https://lore.kernel.org/r/20221220070705.2958959-1-npiggin%40gmail.com
patch subject: [PATCH] cputime: remove cputime_to_nsecs fallback
config: ia64-randconfig-c031-20221218
compiler: ia64-linux-gcc (GCC) 12.1.0
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
        # https://github.com/intel-lab-lkp/linux/commit/875582613c350eb1d2fe580ce2204756a0865a25
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Nicholas-Piggin/cputime-remove-cputime_to_nsecs-fallback/20221220-150845
        git checkout 875582613c350eb1d2fe580ce2204756a0865a25
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash arch/ia64/kernel/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> arch/ia64/kernel/time.c:110:6: warning: no previous prototype for 'arch_vtime_task_switch' [-Wmissing-prototypes]
     110 | void arch_vtime_task_switch(struct task_struct *prev)
         |      ^~~~~~~~~~~~~~~~~~~~~~
   arch/ia64/kernel/time.c:259:6: warning: no previous prototype for 'ia64_init_itm' [-Wmissing-prototypes]
     259 | void ia64_init_itm(void)
         |      ^~~~~~~~~~~~~
   arch/ia64/kernel/time.c:396:1: warning: no previous prototype for 'time_init' [-Wmissing-prototypes]
     396 | time_init (void)
         | ^~~~~~~~~


vim +/arch_vtime_task_switch +110 arch/ia64/kernel/time.c

5bf412cd769eb5 Frederic Weisbecker 2012-09-08  104  
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  105  /*
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  106   * Called from the context switch with interrupts disabled, to charge all
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  107   * accumulated times to the current process, and to prepare accounting on
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  108   * the next process.
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  109   */
e3942ba0405236 Frederic Weisbecker 2012-11-14 @110  void arch_vtime_task_switch(struct task_struct *prev)
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  111  {
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  112  	struct thread_info *pi = task_thread_info(prev);
baa36046d09ea6 Frederic Weisbecker 2012-06-18  113  	struct thread_info *ni = task_thread_info(current);
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  114  
8388d21468e7e7 Frederic Weisbecker 2017-01-05  115  	ni->ac_stamp = pi->ac_stamp;
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  116  	ni->ac_stime = ni->ac_utime = 0;
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  117  }
b64f34cdfe5bef Hidetoshi Seto      2008-01-29  118
  
Alexander Gordeev Dec. 21, 2022, 10:11 a.m. UTC | #2
On Tue, Dec 20, 2022 at 05:07:05PM +1000, Nicholas Piggin wrote:
> The archs that use cputime_to_nsecs() internally provide their own
> definition and don't need the fallback. cputime_to_usecs() unused except
> in this fallback, and is not defined anywhere.
> 
> This removes the final remnant of the cputime_t code from the kernel.
> 
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Rik van Riel <riel@surriel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-s390@vger.kernel.org
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> This required a couple of tweaks to s390 includes so we're not pulling
> asm/cputime.h into the core header unnecessarily. In that case maybe
> this can go via s390 tree because the patch should be otherwise quite
> trivial. Could it get an ack or two from a core maintainer to support
> that?
> 
> Thanks,
> Nick
> 
>  arch/s390/kernel/idle.c       | 2 +-
>  arch/s390/kernel/vtime.c      | 2 +-
>  include/linux/sched/cputime.h | 9 ---------
>  kernel/sched/cputime.c        | 4 ++++
>  4 files changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c
> index 4bf1ee293f2b..a6bbceaf7616 100644
> --- a/arch/s390/kernel/idle.c
> +++ b/arch/s390/kernel/idle.c
> @@ -12,9 +12,9 @@
>  #include <linux/notifier.h>
>  #include <linux/init.h>
>  #include <linux/cpu.h>
> -#include <linux/sched/cputime.h>
>  #include <trace/events/power.h>
>  #include <asm/cpu_mf.h>
> +#include <asm/cputime.h>
>  #include <asm/nmi.h>
>  #include <asm/smp.h>
>  #include "entry.h"
> diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
> index 9436f3053b88..e0a88dcaf5cb 100644
> --- a/arch/s390/kernel/vtime.c
> +++ b/arch/s390/kernel/vtime.c
> @@ -7,13 +7,13 @@
>   */
>  
>  #include <linux/kernel_stat.h>
> -#include <linux/sched/cputime.h>
>  #include <linux/export.h>
>  #include <linux/kernel.h>
>  #include <linux/timex.h>
>  #include <linux/types.h>
>  #include <linux/time.h>
>  #include <asm/alternative.h>
> +#include <asm/cputime.h>
>  #include <asm/vtimer.h>
>  #include <asm/vtime.h>
>  #include <asm/cpu_mf.h>
> diff --git a/include/linux/sched/cputime.h b/include/linux/sched/cputime.h
> index ce3c58286062..5f8fd5b24a2e 100644
> --- a/include/linux/sched/cputime.h
> +++ b/include/linux/sched/cputime.h
> @@ -8,15 +8,6 @@
>   * cputime accounting APIs:
>   */
>  
> -#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
> -#include <asm/cputime.h>
> -
> -#ifndef cputime_to_nsecs
> -# define cputime_to_nsecs(__ct)	\
> -	(cputime_to_usecs(__ct) * NSEC_PER_USEC)
> -#endif
> -#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
> -
>  #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
>  extern bool task_cputime(struct task_struct *t,
>  			 u64 *utime, u64 *stime);
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index 95fc77853743..af7952f12e6c 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -3,6 +3,10 @@
>   * Simple CPU accounting cgroup controller
>   */
>  
> +#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
> + #include <asm/cputime.h>
> +#endif
> +
>  #ifdef CONFIG_IRQ_TIME_ACCOUNTING
>  
>  /*

For s390:

Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
  

Patch

diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c
index 4bf1ee293f2b..a6bbceaf7616 100644
--- a/arch/s390/kernel/idle.c
+++ b/arch/s390/kernel/idle.c
@@ -12,9 +12,9 @@ 
 #include <linux/notifier.h>
 #include <linux/init.h>
 #include <linux/cpu.h>
-#include <linux/sched/cputime.h>
 #include <trace/events/power.h>
 #include <asm/cpu_mf.h>
+#include <asm/cputime.h>
 #include <asm/nmi.h>
 #include <asm/smp.h>
 #include "entry.h"
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 9436f3053b88..e0a88dcaf5cb 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -7,13 +7,13 @@ 
  */
 
 #include <linux/kernel_stat.h>
-#include <linux/sched/cputime.h>
 #include <linux/export.h>
 #include <linux/kernel.h>
 #include <linux/timex.h>
 #include <linux/types.h>
 #include <linux/time.h>
 #include <asm/alternative.h>
+#include <asm/cputime.h>
 #include <asm/vtimer.h>
 #include <asm/vtime.h>
 #include <asm/cpu_mf.h>
diff --git a/include/linux/sched/cputime.h b/include/linux/sched/cputime.h
index ce3c58286062..5f8fd5b24a2e 100644
--- a/include/linux/sched/cputime.h
+++ b/include/linux/sched/cputime.h
@@ -8,15 +8,6 @@ 
  * cputime accounting APIs:
  */
 
-#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-#include <asm/cputime.h>
-
-#ifndef cputime_to_nsecs
-# define cputime_to_nsecs(__ct)	\
-	(cputime_to_usecs(__ct) * NSEC_PER_USEC)
-#endif
-#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
-
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
 extern bool task_cputime(struct task_struct *t,
 			 u64 *utime, u64 *stime);
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 95fc77853743..af7952f12e6c 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -3,6 +3,10 @@ 
  * Simple CPU accounting cgroup controller
  */
 
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
+ #include <asm/cputime.h>
+#endif
+
 #ifdef CONFIG_IRQ_TIME_ACCOUNTING
 
 /*