Skip to content

Commit bfc3f02

Browse files
committed
cputime: Default implementation of nsecs -> cputime conversion
The architectures that override cputime_t (s390, ppc) don't provide any version of nsecs_to_cputime(). Indeed this cputime_t implementation by backend only happens when CONFIG_VIRT_CPU_ACCOUNTING_NATIVE=y under which the core code doesn't make any use of nsecs_to_cputime(). At least for now. We are going to make a broader use of it so lets provide a default version with a per usecs granularity. It should be good enough for most usecases. Cc: Ingo Molnar <mingo@kernel.org> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Acked-by: Rik van Riel <riel@redhat.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
1 parent 69bb260 commit bfc3f02

7 files changed

Lines changed: 17 additions & 6 deletions

File tree

‎drivers/cpufreq/cpufreq_stats.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/cpufreq.h>
1414
#include <linux/module.h>
1515
#include <linux/slab.h>
16-
#include <asm/cputime.h>
16+
#include <linux/cputime.h>
1717

1818
static spinlock_t cpufreq_stats_lock;
1919

‎drivers/s390/cio/cio.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <asm/chpid.h>
2929
#include <asm/airq.h>
3030
#include <asm/isc.h>
31-
#include <asm/cputime.h>
31+
#include <linux/cputime.h>
3232
#include <asm/fcx.h>
3333
#include <asm/nmi.h>
3434
#include <asm/crw.h>

‎fs/proc/stat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/slab.h>
1010
#include <linux/time.h>
1111
#include <linux/irqnr.h>
12-
#include <asm/cputime.h>
12+
#include <linux/cputime.h>
1313
#include <linux/tick.h>
1414

1515
#ifndef arch_irq_stat_cpu

‎fs/proc/uptime.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <linux/seq_file.h>
66
#include <linux/time.h>
77
#include <linux/kernel_stat.h>
8-
#include <asm/cputime.h>
8+
#include <linux/cputime.h>
99

1010
static int uptime_proc_show(struct seq_file *m, void *v)
1111
{

‎include/linux/cputime.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef __LINUX_CPUTIME_H
2+
#define __LINUX_CPUTIME_H
3+
4+
#include <asm/cputime.h>
5+
6+
#ifndef nsecs_to_cputime
7+
# define nsecs_to_cputime(__nsecs) \
8+
usecs_to_cputime((__nsecs) / NSEC_PER_USEC)
9+
#endif
10+
11+
#endif /* __LINUX_CPUTIME_H */

‎include/linux/kernel_stat.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/sched.h>
1010
#include <linux/vtime.h>
1111
#include <asm/irq.h>
12-
#include <asm/cputime.h>
12+
#include <linux/cputime.h>
1313

1414
/*
1515
* 'kernel_stat.h' contains the definitions needed for doing

‎include/linux/sched.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct sched_param {
2727

2828
#include <asm/page.h>
2929
#include <asm/ptrace.h>
30-
#include <asm/cputime.h>
30+
#include <linux/cputime.h>
3131

3232
#include <linux/smp.h>
3333
#include <linux/sem.h>

0 commit comments

Comments
 (0)