Skip to content

Commit

Permalink
cputime: Default implementation of nsecs -> cputime conversion
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Marcelo Tosatti <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Signed-off-by: Frederic Weisbecker <[email protected]>
  • Loading branch information
fweisbec committed Mar 13, 2014
1 parent 69bb260 commit bfc3f02
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drivers/cpufreq/cpufreq_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <linux/cpufreq.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <asm/cputime.h>
#include <linux/cputime.h>

static spinlock_t cpufreq_stats_lock;

Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/cio/cio.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <asm/chpid.h>
#include <asm/airq.h>
#include <asm/isc.h>
#include <asm/cputime.h>
#include <linux/cputime.h>
#include <asm/fcx.h>
#include <asm/nmi.h>
#include <asm/crw.h>
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/irqnr.h>
#include <asm/cputime.h>
#include <linux/cputime.h>
#include <linux/tick.h>

#ifndef arch_irq_stat_cpu
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/uptime.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <linux/seq_file.h>
#include <linux/time.h>
#include <linux/kernel_stat.h>
#include <asm/cputime.h>
#include <linux/cputime.h>

static int uptime_proc_show(struct seq_file *m, void *v)
{
Expand Down
11 changes: 11 additions & 0 deletions include/linux/cputime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __LINUX_CPUTIME_H
#define __LINUX_CPUTIME_H

#include <asm/cputime.h>

#ifndef nsecs_to_cputime
# define nsecs_to_cputime(__nsecs) \
usecs_to_cputime((__nsecs) / NSEC_PER_USEC)
#endif

#endif /* __LINUX_CPUTIME_H */
2 changes: 1 addition & 1 deletion include/linux/kernel_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/sched.h>
#include <linux/vtime.h>
#include <asm/irq.h>
#include <asm/cputime.h>
#include <linux/cputime.h>

/*
* 'kernel_stat.h' contains the definitions needed for doing
Expand Down
2 changes: 1 addition & 1 deletion include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct sched_param {

#include <asm/page.h>
#include <asm/ptrace.h>
#include <asm/cputime.h>
#include <linux/cputime.h>

#include <linux/smp.h>
#include <linux/sem.h>
Expand Down

0 comments on commit bfc3f02

Please sign in to comment.