2022-12-20 07:27:30

by Nicholas Piggin

[permalink] [raw]
Subject: [PATCH] cputime: remove cputime_to_nsecs fallback

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 <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Sven Schnelle <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Nicholas Piggin <[email protected]>
---
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

/*
--
2.37.2


2022-12-20 16:40:34

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] cputime: remove cputime_to_nsecs fallback

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 <[email protected]>

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

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (3.67 kB)
config (169.43 kB)
Download all attachments

2022-12-21 10:49:39

by Alexander Gordeev

[permalink] [raw]
Subject: Re: [PATCH] cputime: remove cputime_to_nsecs fallback

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 <[email protected]>
> Cc: Rik van Riel <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Frederic Weisbecker <[email protected]>
> Cc: Sven Schnelle <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Nicholas Piggin <[email protected]>
> ---
> 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 <[email protected]>

2022-12-27 12:31:14

by tip-bot2 for Jacob Pan

[permalink] [raw]
Subject: [tip: sched/core] cputime: remove cputime_to_nsecs fallback

The following commit has been merged into the sched/core branch of tip:

Commit-ID: c89970202a1153b2fc230e89f90c180bd5bcbcef
Gitweb: https://git.kernel.org/tip/c89970202a1153b2fc230e89f90c180bd5bcbcef
Author: Nicholas Piggin <[email protected]>
AuthorDate: Tue, 20 Dec 2022 17:07:05 +10:00
Committer: Peter Zijlstra <[email protected]>
CommitterDate: Tue, 27 Dec 2022 12:52:17 +01:00

cputime: remove cputime_to_nsecs fallback

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.

Signed-off-by: Nicholas Piggin <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Alexander Gordeev <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
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 4bf1ee2..a6bbcea 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 9436f30..e0a88dc 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 ce3c582..5f8fd5b 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 95fc778..af7952f 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

/*