aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/kvm/kvm-ia64.c3
-rw-r--r--arch/x86/kvm/i8254.c6
-rw-r--r--arch/x86/kvm/lapic.c6
-rw-r--r--include/asm-arm/div64.h2
-rw-r--r--include/asm-generic/div64.h7
-rw-r--r--include/asm-m68k/div64.h1
-rw-r--r--include/asm-mips/div64.h6
-rw-r--r--include/asm-mn10300/div64.h3
-rw-r--r--include/asm-um/div64.h1
-rw-r--r--include/asm-x86/div64.h2
-rw-r--r--include/linux/math64.h12
-rw-r--r--kernel/sched.c6
-rw-r--r--kernel/sched_debug.c4
-rw-r--r--lib/div64.c12
-rw-r--r--net/ipv4/tcp_cubic.c4
-rw-r--r--net/netfilter/xt_connbytes.c5
16 files changed, 34 insertions, 46 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 6df073240135..318b81100623 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1,4 +1,3 @@
1
2/* 1/*
3 * kvm_ia64.c: Basic KVM suppport On Itanium series processors 2 * kvm_ia64.c: Basic KVM suppport On Itanium series processors
4 * 3 *
@@ -431,7 +430,7 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu)
431 if (itc_diff < 0) 430 if (itc_diff < 0)
432 itc_diff = -itc_diff; 431 itc_diff = -itc_diff;
433 432
434 expires = div64_64(itc_diff, cyc_per_usec); 433 expires = div64_u64(itc_diff, cyc_per_usec);
435 kt = ktime_set(0, 1000 * expires); 434 kt = ktime_set(0, 1000 * expires);
436 vcpu->arch.ht_active = 1; 435 vcpu->arch.ht_active = 1;
437 hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS); 436 hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS);
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 361e31611276..4c943eabacc3 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -35,7 +35,7 @@
35#include "i8254.h" 35#include "i8254.h"
36 36
37#ifndef CONFIG_X86_64 37#ifndef CONFIG_X86_64
38#define mod_64(x, y) ((x) - (y) * div64_64(x, y)) 38#define mod_64(x, y) ((x) - (y) * div64_u64(x, y))
39#else 39#else
40#define mod_64(x, y) ((x) % (y)) 40#define mod_64(x, y) ((x) % (y))
41#endif 41#endif
@@ -60,8 +60,8 @@ static u64 muldiv64(u64 a, u32 b, u32 c)
60 rl = (u64)u.l.low * (u64)b; 60 rl = (u64)u.l.low * (u64)b;
61 rh = (u64)u.l.high * (u64)b; 61 rh = (u64)u.l.high * (u64)b;
62 rh += (rl >> 32); 62 rh += (rl >> 32);
63 res.l.high = div64_64(rh, c); 63 res.l.high = div64_u64(rh, c);
64 res.l.low = div64_64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c); 64 res.l.low = div64_u64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c);
65 return res.ll; 65 return res.ll;
66} 66}
67 67
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 57ac4e4c556a..36809d79788b 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -25,13 +25,13 @@
25#include <linux/hrtimer.h> 25#include <linux/hrtimer.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/math64.h>
28#include <asm/processor.h> 29#include <asm/processor.h>
29#include <asm/msr.h> 30#include <asm/msr.h>
30#include <asm/page.h> 31#include <asm/page.h>
31#include <asm/current.h> 32#include <asm/current.h>
32#include <asm/apicdef.h> 33#include <asm/apicdef.h>
33#include <asm/atomic.h> 34#include <asm/atomic.h>
34#include <asm/div64.h>
35#include "irq.h" 35#include "irq.h"
36 36
37#define PRId64 "d" 37#define PRId64 "d"
@@ -526,8 +526,8 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
526 } else 526 } else
527 passed = ktime_sub(now, apic->timer.last_update); 527 passed = ktime_sub(now, apic->timer.last_update);
528 528
529 counter_passed = div64_64(ktime_to_ns(passed), 529 counter_passed = div64_u64(ktime_to_ns(passed),
530 (APIC_BUS_CYCLE_NS * apic->timer.divide_count)); 530 (APIC_BUS_CYCLE_NS * apic->timer.divide_count));
531 531
532 if (counter_passed > tmcct) { 532 if (counter_passed > tmcct) {
533 if (unlikely(!apic_lvtt_period(apic))) { 533 if (unlikely(!apic_lvtt_period(apic))) {
diff --git a/include/asm-arm/div64.h b/include/asm-arm/div64.h
index 0b5f881c3d85..5001390be958 100644
--- a/include/asm-arm/div64.h
+++ b/include/asm-arm/div64.h
@@ -224,6 +224,4 @@
224 224
225#endif 225#endif
226 226
227extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
228
229#endif 227#endif
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index a4a49370793c..8f4e3193342e 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -30,11 +30,6 @@
30 __rem; \ 30 __rem; \
31 }) 31 })
32 32
33static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
34{
35 return dividend / divisor;
36}
37
38#elif BITS_PER_LONG == 32 33#elif BITS_PER_LONG == 32
39 34
40extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); 35extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
@@ -54,8 +49,6 @@ extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
54 __rem; \ 49 __rem; \
55 }) 50 })
56 51
57extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
58
59#else /* BITS_PER_LONG == ?? */ 52#else /* BITS_PER_LONG == ?? */
60 53
61# error do_div() does not yet support the C64 54# error do_div() does not yet support the C64
diff --git a/include/asm-m68k/div64.h b/include/asm-m68k/div64.h
index 33caad1628d4..8243c931b5c0 100644
--- a/include/asm-m68k/div64.h
+++ b/include/asm-m68k/div64.h
@@ -25,5 +25,4 @@
25 __rem; \ 25 __rem; \
26}) 26})
27 27
28extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
29#endif /* _M68K_DIV64_H */ 28#endif /* _M68K_DIV64_H */
diff --git a/include/asm-mips/div64.h b/include/asm-mips/div64.h
index 716371bd0980..d1d699105c11 100644
--- a/include/asm-mips/div64.h
+++ b/include/asm-mips/div64.h
@@ -82,7 +82,6 @@
82 (n) = __quot; \ 82 (n) = __quot; \
83 __mod; }) 83 __mod; })
84 84
85extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
86#endif /* (_MIPS_SZLONG == 32) */ 85#endif /* (_MIPS_SZLONG == 32) */
87 86
88#if (_MIPS_SZLONG == 64) 87#if (_MIPS_SZLONG == 64)
@@ -106,11 +105,6 @@ extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
106 (n) = __quot; \ 105 (n) = __quot; \
107 __mod; }) 106 __mod; })
108 107
109static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
110{
111 return dividend / divisor;
112}
113
114#endif /* (_MIPS_SZLONG == 64) */ 108#endif /* (_MIPS_SZLONG == 64) */
115 109
116#endif /* _ASM_DIV64_H */ 110#endif /* _ASM_DIV64_H */
diff --git a/include/asm-mn10300/div64.h b/include/asm-mn10300/div64.h
index bf9c515a998c..3a8329b3e869 100644
--- a/include/asm-mn10300/div64.h
+++ b/include/asm-mn10300/div64.h
@@ -97,7 +97,4 @@ signed __muldiv64s(signed val, signed mult, signed div)
97 return result; 97 return result;
98} 98}
99 99
100extern __attribute__((const))
101uint64_t div64_64(uint64_t dividend, uint64_t divisor);
102
103#endif /* _ASM_DIV64 */ 100#endif /* _ASM_DIV64 */
diff --git a/include/asm-um/div64.h b/include/asm-um/div64.h
index 7b73b2cd5b34..1e17f7409cab 100644
--- a/include/asm-um/div64.h
+++ b/include/asm-um/div64.h
@@ -3,5 +3,4 @@
3 3
4#include "asm/arch/div64.h" 4#include "asm/arch/div64.h"
5 5
6extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
7#endif 6#endif
diff --git a/include/asm-x86/div64.h b/include/asm-x86/div64.h
index c7892cfe9ce6..32fdbddaae55 100644
--- a/include/asm-x86/div64.h
+++ b/include/asm-x86/div64.h
@@ -71,8 +71,6 @@ static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71} 71}
72#define div_u64_rem div_u64_rem 72#define div_u64_rem div_u64_rem
73 73
74extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
75
76#else 74#else
77# include <asm-generic/div64.h> 75# include <asm-generic/div64.h>
78#endif /* CONFIG_X86_32 */ 76#endif /* CONFIG_X86_32 */
diff --git a/include/linux/math64.h b/include/linux/math64.h
index 6d1716641008..c1a5f81501ff 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -27,6 +27,14 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
27 return dividend / divisor; 27 return dividend / divisor;
28} 28}
29 29
30/**
31 * div64_u64 - unsigned 64bit divide with 64bit divisor
32 */
33static inline u64 div64_u64(u64 dividend, u64 divisor)
34{
35 return dividend / divisor;
36}
37
30#elif BITS_PER_LONG == 32 38#elif BITS_PER_LONG == 32
31 39
32#ifndef div_u64_rem 40#ifndef div_u64_rem
@@ -41,6 +49,10 @@ static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
41extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder); 49extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
42#endif 50#endif
43 51
52#ifndef div64_u64
53extern u64 div64_u64(u64 dividend, u64 divisor);
54#endif
55
44#endif /* BITS_PER_LONG */ 56#endif /* BITS_PER_LONG */
45 57
46/** 58/**
diff --git a/kernel/sched.c b/kernel/sched.c
index e2f7f5acc807..34bcc5bc120e 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -8025,7 +8025,7 @@ static void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
8025 8025
8026 se->my_q = cfs_rq; 8026 se->my_q = cfs_rq;
8027 se->load.weight = tg->shares; 8027 se->load.weight = tg->shares;
8028 se->load.inv_weight = div64_64(1ULL<<32, se->load.weight); 8028 se->load.inv_weight = div64_u64(1ULL<<32, se->load.weight);
8029 se->parent = parent; 8029 se->parent = parent;
8030} 8030}
8031#endif 8031#endif
@@ -8692,7 +8692,7 @@ static void __set_se_shares(struct sched_entity *se, unsigned long shares)
8692 dequeue_entity(cfs_rq, se, 0); 8692 dequeue_entity(cfs_rq, se, 0);
8693 8693
8694 se->load.weight = shares; 8694 se->load.weight = shares;
8695 se->load.inv_weight = div64_64((1ULL<<32), shares); 8695 se->load.inv_weight = div64_u64((1ULL<<32), shares);
8696 8696
8697 if (on_rq) 8697 if (on_rq)
8698 enqueue_entity(cfs_rq, se, 0); 8698 enqueue_entity(cfs_rq, se, 0);
@@ -8787,7 +8787,7 @@ static unsigned long to_ratio(u64 period, u64 runtime)
8787 if (runtime == RUNTIME_INF) 8787 if (runtime == RUNTIME_INF)
8788 return 1ULL << 16; 8788 return 1ULL << 16;
8789 8789
8790 return div64_64(runtime << 16, period); 8790 return div64_u64(runtime << 16, period);
8791} 8791}
8792 8792
8793#ifdef CONFIG_CGROUP_SCHED 8793#ifdef CONFIG_CGROUP_SCHED
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 8a9498e7c831..6b4a12558e88 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -357,8 +357,8 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
357 357
358 avg_per_cpu = p->se.sum_exec_runtime; 358 avg_per_cpu = p->se.sum_exec_runtime;
359 if (p->se.nr_migrations) { 359 if (p->se.nr_migrations) {
360 avg_per_cpu = div64_64(avg_per_cpu, 360 avg_per_cpu = div64_u64(avg_per_cpu,
361 p->se.nr_migrations); 361 p->se.nr_migrations);
362 } else { 362 } else {
363 avg_per_cpu = -1LL; 363 avg_per_cpu = -1LL;
364 } 364 }
diff --git a/lib/div64.c b/lib/div64.c
index 689bd76833fa..bb5bd0c0f030 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -78,9 +78,10 @@ EXPORT_SYMBOL(div_s64_rem);
78#endif 78#endif
79 79
80/* 64bit divisor, dividend and result. dynamic precision */ 80/* 64bit divisor, dividend and result. dynamic precision */
81uint64_t div64_64(uint64_t dividend, uint64_t divisor) 81#ifndef div64_u64
82u64 div64_u64(u64 dividend, u64 divisor)
82{ 83{
83 uint32_t high, d; 84 u32 high, d;
84 85
85 high = divisor >> 32; 86 high = divisor >> 32;
86 if (high) { 87 if (high) {
@@ -91,10 +92,9 @@ uint64_t div64_64(uint64_t dividend, uint64_t divisor)
91 } else 92 } else
92 d = divisor; 93 d = divisor;
93 94
94 do_div(dividend, d); 95 return div_u64(dividend, d);
95
96 return dividend;
97} 96}
98EXPORT_SYMBOL(div64_64); 97EXPORT_SYMBOL(div64_u64);
98#endif
99 99
100#endif /* BITS_PER_LONG == 32 */ 100#endif /* BITS_PER_LONG == 32 */
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index eb5b9854c8c7..4a1221e5e8ee 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -15,8 +15,8 @@
15 15
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/math64.h>
18#include <net/tcp.h> 19#include <net/tcp.h>
19#include <asm/div64.h>
20 20
21#define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation 21#define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation
22 * max_cwnd = snd_cwnd * beta 22 * max_cwnd = snd_cwnd * beta
@@ -128,7 +128,7 @@ static u32 cubic_root(u64 a)
128 * x = ( 2 * x + a / x ) / 3 128 * x = ( 2 * x + a / x ) / 3
129 * k+1 k k 129 * k+1 k k
130 */ 130 */
131 x = (2 * x + (u32)div64_64(a, (u64)x * (u64)(x - 1))); 131 x = (2 * x + (u32)div64_u64(a, (u64)x * (u64)(x - 1)));
132 x = ((x * 341) >> 10); 132 x = ((x * 341) >> 10);
133 return x; 133 return x;
134} 134}
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index b15e7e2fa143..d7e8983cd37f 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -4,12 +4,11 @@
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/bitops.h> 5#include <linux/bitops.h>
6#include <linux/skbuff.h> 6#include <linux/skbuff.h>
7#include <linux/math64.h>
7#include <linux/netfilter/x_tables.h> 8#include <linux/netfilter/x_tables.h>
8#include <linux/netfilter/xt_connbytes.h> 9#include <linux/netfilter/xt_connbytes.h>
9#include <net/netfilter/nf_conntrack.h> 10#include <net/netfilter/nf_conntrack.h>
10 11
11#include <asm/div64.h>
12
13MODULE_LICENSE("GPL"); 12MODULE_LICENSE("GPL");
14MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 13MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
15MODULE_DESCRIPTION("Xtables: Number of packets/bytes per connection matching"); 14MODULE_DESCRIPTION("Xtables: Number of packets/bytes per connection matching");
@@ -82,7 +81,7 @@ connbytes_mt(const struct sk_buff *skb, const struct net_device *in,
82 break; 81 break;
83 } 82 }
84 if (pkts != 0) 83 if (pkts != 0)
85 what = div64_64(bytes, pkts); 84 what = div64_u64(bytes, pkts);
86 break; 85 break;
87 } 86 }
88 87