Skip to content

Commit

Permalink
Merge branch 'timers-for-linus' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/tip/linux-2.6-tip

* 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  itimers: Add tracepoints for itimer
  hrtimer: Add tracepoint for hrtimers
  timers: Add tracepoints for timer_list timers
  cputime: Optimize jiffies_to_cputime(1)
  itimers: Simplify arm_timer() code a bit
  itimers: Fix periodic tics precision
  itimers: Merge ITIMER_VIRT and ITIMER_PROF

Trivial header file include conflicts in kernel/fork.c
  • Loading branch information
torvalds committed Sep 23, 2009
2 parents ff830b8 + 3f0a525 commit 31bbb9b
Show file tree
Hide file tree
Showing 13 changed files with 620 additions and 172 deletions.
1 change: 1 addition & 0 deletions arch/ia64/include/asm/cputime.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef u64 cputime_t;
typedef u64 cputime64_t;

#define cputime_zero ((cputime_t)0)
#define cputime_one_jiffy jiffies_to_cputime(1)
#define cputime_max ((~((cputime_t)0) >> 1) - 1)
#define cputime_add(__a, __b) ((__a) + (__b))
#define cputime_sub(__a, __b) ((__a) - (__b))
Expand Down
13 changes: 13 additions & 0 deletions arch/powerpc/include/asm/cputime.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

#ifndef CONFIG_VIRT_CPU_ACCOUNTING
#include <asm-generic/cputime.h>
#ifdef __KERNEL__
static inline void setup_cputime_one_jiffy(void) { }
#endif
#else

#include <linux/types.h>
Expand Down Expand Up @@ -48,6 +51,11 @@ typedef u64 cputime64_t;

#ifdef __KERNEL__

/*
* One jiffy in timebase units computed during initialization
*/
extern cputime_t cputime_one_jiffy;

/*
* Convert cputime <-> jiffies
*/
Expand Down Expand Up @@ -89,6 +97,11 @@ static inline cputime_t jiffies_to_cputime(const unsigned long jif)
return ct;
}

static inline void setup_cputime_one_jiffy(void)
{
cputime_one_jiffy = jiffies_to_cputime(1);
}

static inline cputime64_t jiffies64_to_cputime64(const u64 jif)
{
cputime_t ct;
Expand Down
4 changes: 4 additions & 0 deletions arch/powerpc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ EXPORT_SYMBOL(__cputime_clockt_factor);
DEFINE_PER_CPU(unsigned long, cputime_last_delta);
DEFINE_PER_CPU(unsigned long, cputime_scaled_last_delta);

cputime_t cputime_one_jiffy;

static void calc_cputime_factors(void)
{
struct div_result res;
Expand Down Expand Up @@ -501,6 +503,7 @@ static int __init iSeries_tb_recal(void)
tb_to_xs = divres.result_low;
vdso_data->tb_ticks_per_sec = tb_ticks_per_sec;
vdso_data->tb_to_xs = tb_to_xs;
setup_cputime_one_jiffy();
}
else {
printk( "Titan recalibrate: FAILED (difference > 4 percent)\n"
Expand Down Expand Up @@ -960,6 +963,7 @@ void __init time_init(void)
tb_ticks_per_usec = ppc_tb_freq / 1000000;
tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000);
calc_cputime_factors();
setup_cputime_one_jiffy();

/*
* Calculate the length of each tick in ns. It will not be
Expand Down
1 change: 1 addition & 0 deletions arch/s390/include/asm/cputime.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ __div(unsigned long long n, unsigned int base)
#endif /* __s390x__ */

#define cputime_zero (0ULL)
#define cputime_one_jiffy jiffies_to_cputime(1)
#define cputime_max ((~0UL >> 1) - 1)
#define cputime_add(__a, __b) ((__a) + (__b))
#define cputime_sub(__a, __b) ((__a) - (__b))
Expand Down
1 change: 1 addition & 0 deletions include/asm-generic/cputime.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
typedef unsigned long cputime_t;

#define cputime_zero (0UL)
#define cputime_one_jiffy jiffies_to_cputime(1)
#define cputime_max ((~0UL >> 1) - 1)
#define cputime_add(__a, __b) ((__a) + (__b))
#define cputime_sub(__a, __b) ((__a) - (__b))
Expand Down
16 changes: 13 additions & 3 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ struct pacct_struct {
unsigned long ac_minflt, ac_majflt;
};

struct cpu_itimer {
cputime_t expires;
cputime_t incr;
u32 error;
u32 incr_error;
};

/**
* struct task_cputime - collected CPU time counts
* @utime: time spent in user mode, in &cputime_t units
Expand Down Expand Up @@ -587,9 +594,12 @@ struct signal_struct {
struct pid *leader_pid;
ktime_t it_real_incr;

/* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */
cputime_t it_prof_expires, it_virt_expires;
cputime_t it_prof_incr, it_virt_incr;
/*
* ITIMER_PROF and ITIMER_VIRTUAL timers for the process, we use
* CPUCLOCK_PROF and CPUCLOCK_VIRT for indexing array as these
* values are defined to 0 and 1 respectively
*/
struct cpu_itimer it[2];

/*
* Thread group totals for process CPU timers.
Expand Down
Loading

0 comments on commit 31bbb9b

Please sign in to comment.