aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-06 11:33:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-06 11:44:54 -0500
commit0db49b72bce26341274b74fd968501489a361ae3 (patch)
treecdb076827aefb38d719d4c42f8ef291c36072fa8 /arch/s390/include
parent35b740e4662ef386f0c60e1b60aaf5b44db9914c (diff)
parent1ac9bc6943edf7d181b4b1cc734981350d4f6bae (diff)
Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
* 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (40 commits) sched/tracing: Add a new tracepoint for sleeptime sched: Disable scheduler warnings during oopses sched: Fix cgroup movement of waking process sched: Fix cgroup movement of newly created process sched: Fix cgroup movement of forking process sched: Remove cfs bandwidth period check in tg_set_cfs_period() sched: Fix load-balance lock-breaking sched: Replace all_pinned with a generic flags field sched: Only queue remote wakeups when crossing cache boundaries sched: Add missing rcu_dereference() around ->real_parent usage [S390] fix cputime overflow in uptime_proc_show [S390] cputime: add sparse checking and cleanup sched: Mark parent and real_parent as __rcu sched, nohz: Fix missing RCU read lock sched, nohz: Set the NOHZ_BALANCE_KICK flag for idle load balancer sched, nohz: Fix the idle cpu check in nohz_idle_balance sched: Use jump_labels for sched_feat sched/accounting: Fix parameter passing in task_group_account_field sched/accounting: Fix user/system tick double accounting sched/accounting: Re-use scheduler statistics for the root cgroup ... Fix up conflicts in - arch/ia64/include/asm/cputime.h, include/asm-generic/cputime.h usecs_to_cputime64() vs the sparse cleanups - kernel/sched/fair.c, kernel/time/tick-sched.c scheduler changes in multiple branches
Diffstat (limited to 'arch/s390/include')
-rw-r--r--arch/s390/include/asm/cputime.h140
1 files changed, 63 insertions, 77 deletions
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index b9acaaa175d8..c23c3900c304 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -16,75 +16,60 @@
16 16
17/* We want to use full resolution of the CPU timer: 2**-12 micro-seconds. */ 17/* We want to use full resolution of the CPU timer: 2**-12 micro-seconds. */
18 18
19typedef unsigned long long cputime_t; 19typedef unsigned long long __nocast cputime_t;
20typedef unsigned long long cputime64_t; 20typedef unsigned long long __nocast cputime64_t;
21 21
22#ifndef __s390x__ 22static inline unsigned long __div(unsigned long long n, unsigned long base)
23
24static inline unsigned int
25__div(unsigned long long n, unsigned int base)
26{ 23{
24#ifndef __s390x__
27 register_pair rp; 25 register_pair rp;
28 26
29 rp.pair = n >> 1; 27 rp.pair = n >> 1;
30 asm ("dr %0,%1" : "+d" (rp) : "d" (base >> 1)); 28 asm ("dr %0,%1" : "+d" (rp) : "d" (base >> 1));
31 return rp.subreg.odd; 29 return rp.subreg.odd;
30#else /* __s390x__ */
31 return n / base;
32#endif /* __s390x__ */
32} 33}
33 34
34#else /* __s390x__ */ 35#define cputime_one_jiffy jiffies_to_cputime(1)
35 36
36static inline unsigned int 37/*
37__div(unsigned long long n, unsigned int base) 38 * Convert cputime to jiffies and back.
39 */
40static inline unsigned long cputime_to_jiffies(const cputime_t cputime)
38{ 41{
39 return n / base; 42 return __div((__force unsigned long long) cputime, 4096000000ULL / HZ);
40} 43}
41 44
42#endif /* __s390x__ */ 45static inline cputime_t jiffies_to_cputime(const unsigned int jif)
46{
47 return (__force cputime_t)(jif * (4096000000ULL / HZ));
48}
43 49
44#define cputime_zero (0ULL) 50static inline u64 cputime64_to_jiffies64(cputime64_t cputime)
45#define cputime_one_jiffy jiffies_to_cputime(1) 51{
46#define cputime_max ((~0UL >> 1) - 1) 52 unsigned long long jif = (__force unsigned long long) cputime;
47#define cputime_add(__a, __b) ((__a) + (__b)) 53 do_div(jif, 4096000000ULL / HZ);
48#define cputime_sub(__a, __b) ((__a) - (__b)) 54 return jif;
49#define cputime_div(__a, __n) ({ \ 55}
50 unsigned long long __div = (__a); \ 56
51 do_div(__div,__n); \ 57static inline cputime64_t jiffies64_to_cputime64(const u64 jif)
52 __div; \ 58{
53}) 59 return (__force cputime64_t)(jif * (4096000000ULL / HZ));
54#define cputime_halve(__a) ((__a) >> 1)
55#define cputime_eq(__a, __b) ((__a) == (__b))
56#define cputime_gt(__a, __b) ((__a) > (__b))
57#define cputime_ge(__a, __b) ((__a) >= (__b))
58#define cputime_lt(__a, __b) ((__a) < (__b))
59#define cputime_le(__a, __b) ((__a) <= (__b))
60#define cputime_to_jiffies(__ct) (__div((__ct), 4096000000ULL / HZ))
61#define cputime_to_scaled(__ct) (__ct)
62#define jiffies_to_cputime(__hz) ((cputime_t)(__hz) * (4096000000ULL / HZ))
63
64#define cputime64_zero (0ULL)
65#define cputime64_add(__a, __b) ((__a) + (__b))
66#define cputime_to_cputime64(__ct) (__ct)
67
68static inline u64
69cputime64_to_jiffies64(cputime64_t cputime)
70{
71 do_div(cputime, 4096000000ULL / HZ);
72 return cputime;
73} 60}
74 61
75/* 62/*
76 * Convert cputime to microseconds and back. 63 * Convert cputime to microseconds and back.
77 */ 64 */
78static inline unsigned int 65static inline unsigned int cputime_to_usecs(const cputime_t cputime)
79cputime_to_usecs(const cputime_t cputime)
80{ 66{
81 return cputime_div(cputime, 4096); 67 return (__force unsigned long long) cputime >> 12;
82} 68}
83 69
84static inline cputime_t 70static inline cputime_t usecs_to_cputime(const unsigned int m)
85usecs_to_cputime(const unsigned int m)
86{ 71{
87 return (cputime_t) m * 4096; 72 return (__force cputime_t)(m * 4096ULL);
88} 73}
89 74
90#define usecs_to_cputime64(m) usecs_to_cputime(m) 75#define usecs_to_cputime64(m) usecs_to_cputime(m)
@@ -92,40 +77,39 @@ usecs_to_cputime(const unsigned int m)
92/* 77/*
93 * Convert cputime to milliseconds and back. 78 * Convert cputime to milliseconds and back.
94 */ 79 */
95static inline unsigned int 80static inline unsigned int cputime_to_secs(const cputime_t cputime)
96cputime_to_secs(const cputime_t cputime)
97{ 81{
98 return __div(cputime, 2048000000) >> 1; 82 return __div((__force unsigned long long) cputime, 2048000000) >> 1;
99} 83}
100 84
101static inline cputime_t 85static inline cputime_t secs_to_cputime(const unsigned int s)
102secs_to_cputime(const unsigned int s)
103{ 86{
104 return (cputime_t) s * 4096000000ULL; 87 return (__force cputime_t)(s * 4096000000ULL);
105} 88}
106 89
107/* 90/*
108 * Convert cputime to timespec and back. 91 * Convert cputime to timespec and back.
109 */ 92 */
110static inline cputime_t 93static inline cputime_t timespec_to_cputime(const struct timespec *value)
111timespec_to_cputime(const struct timespec *value)
112{ 94{
113 return value->tv_nsec * 4096 / 1000 + (u64) value->tv_sec * 4096000000ULL; 95 unsigned long long ret = value->tv_sec * 4096000000ULL;
96 return (__force cputime_t)(ret + value->tv_nsec * 4096 / 1000);
114} 97}
115 98
116static inline void 99static inline void cputime_to_timespec(const cputime_t cputime,
117cputime_to_timespec(const cputime_t cputime, struct timespec *value) 100 struct timespec *value)
118{ 101{
102 unsigned long long __cputime = (__force unsigned long long) cputime;
119#ifndef __s390x__ 103#ifndef __s390x__
120 register_pair rp; 104 register_pair rp;
121 105
122 rp.pair = cputime >> 1; 106 rp.pair = __cputime >> 1;
123 asm ("dr %0,%1" : "+d" (rp) : "d" (2048000000UL)); 107 asm ("dr %0,%1" : "+d" (rp) : "d" (2048000000UL));
124 value->tv_nsec = rp.subreg.even * 1000 / 4096; 108 value->tv_nsec = rp.subreg.even * 1000 / 4096;
125 value->tv_sec = rp.subreg.odd; 109 value->tv_sec = rp.subreg.odd;
126#else 110#else
127 value->tv_nsec = (cputime % 4096000000ULL) * 1000 / 4096; 111 value->tv_nsec = (__cputime % 4096000000ULL) * 1000 / 4096;
128 value->tv_sec = cputime / 4096000000ULL; 112 value->tv_sec = __cputime / 4096000000ULL;
129#endif 113#endif
130} 114}
131 115
@@ -134,50 +118,52 @@ cputime_to_timespec(const cputime_t cputime, struct timespec *value)
134 * Since cputime and timeval have the same resolution (microseconds) 118 * Since cputime and timeval have the same resolution (microseconds)
135 * this is easy. 119 * this is easy.
136 */ 120 */
137static inline cputime_t 121static inline cputime_t timeval_to_cputime(const struct timeval *value)
138timeval_to_cputime(const struct timeval *value)
139{ 122{
140 return value->tv_usec * 4096 + (u64) value->tv_sec * 4096000000ULL; 123 unsigned long long ret = value->tv_sec * 4096000000ULL;
124 return (__force cputime_t)(ret + value->tv_usec * 4096ULL);
141} 125}
142 126
143static inline void 127static inline void cputime_to_timeval(const cputime_t cputime,
144cputime_to_timeval(const cputime_t cputime, struct timeval *value) 128 struct timeval *value)
145{ 129{
130 unsigned long long __cputime = (__force unsigned long long) cputime;
146#ifndef __s390x__ 131#ifndef __s390x__
147 register_pair rp; 132 register_pair rp;
148 133
149 rp.pair = cputime >> 1; 134 rp.pair = __cputime >> 1;
150 asm ("dr %0,%1" : "+d" (rp) : "d" (2048000000UL)); 135 asm ("dr %0,%1" : "+d" (rp) : "d" (2048000000UL));
151 value->tv_usec = rp.subreg.even / 4096; 136 value->tv_usec = rp.subreg.even / 4096;
152 value->tv_sec = rp.subreg.odd; 137 value->tv_sec = rp.subreg.odd;
153#else 138#else
154 value->tv_usec = (cputime % 4096000000ULL) / 4096; 139 value->tv_usec = (__cputime % 4096000000ULL) / 4096;
155 value->tv_sec = cputime / 4096000000ULL; 140 value->tv_sec = __cputime / 4096000000ULL;
156#endif 141#endif
157} 142}
158 143
159/* 144/*
160 * Convert cputime to clock and back. 145 * Convert cputime to clock and back.
161 */ 146 */
162static inline clock_t 147static inline clock_t cputime_to_clock_t(cputime_t cputime)
163cputime_to_clock_t(cputime_t cputime)
164{ 148{
165 return cputime_div(cputime, 4096000000ULL / USER_HZ); 149 unsigned long long clock = (__force unsigned long long) cputime;
150 do_div(clock, 4096000000ULL / USER_HZ);
151 return clock;
166} 152}
167 153
168static inline cputime_t 154static inline cputime_t clock_t_to_cputime(unsigned long x)
169clock_t_to_cputime(unsigned long x)
170{ 155{
171 return (cputime_t) x * (4096000000ULL / USER_HZ); 156 return (__force cputime_t)(x * (4096000000ULL / USER_HZ));
172} 157}
173 158
174/* 159/*
175 * Convert cputime64 to clock. 160 * Convert cputime64 to clock.
176 */ 161 */
177static inline clock_t 162static inline clock_t cputime64_to_clock_t(cputime64_t cputime)
178cputime64_to_clock_t(cputime64_t cputime)
179{ 163{
180 return cputime_div(cputime, 4096000000ULL / USER_HZ); 164 unsigned long long clock = (__force unsigned long long) cputime;
165 do_div(clock, 4096000000ULL / USER_HZ);
166 return clock;
181} 167}
182 168
183struct s390_idle_data { 169struct s390_idle_data {