* [patch 2/2] div64_64: common code
@ 2007-03-06 10:42 akpm
2007-03-06 18:11 ` David Miller
2007-03-06 19:46 ` Ralf Baechle
0 siblings, 2 replies; 7+ messages in thread
From: akpm @ 2007-03-06 10:42 UTC (permalink / raw)
To: davem; +Cc: netdev, akpm, shemminger, chris, geert, jdike, ralf, rmk, zippel
From: Stephen Hemminger <shemminger@linux-foundation.org>
Implement div64_64(): 64-bit by 64-bit division. Needed by networking (at
least).
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/asm-arm/div64.h | 3 +++
include/asm-generic/div64.h | 7 +++++++
include/asm-i386/div64.h | 4 ++++
include/asm-m68k/div64.h | 3 +++
include/asm-mips/div64.h | 4 ++++
include/asm-um/div64.h | 1 +
include/asm-xtensa/div64.h | 6 ++++++
lib/Makefile | 5 +++--
lib/div64.c | 22 ++++++++++++++++++++++
net/ipv4/tcp_cubic.c | 21 ---------------------
net/netfilter/xt_connbytes.c | 16 ----------------
11 files changed, 53 insertions(+), 39 deletions(-)
diff -puN include/asm-arm/div64.h~div64_64-common-code include/asm-arm/div64.h
--- a/include/asm-arm/div64.h~div64_64-common-code
+++ a/include/asm-arm/div64.h
@@ -2,6 +2,7 @@
#define __ASM_ARM_DIV64
#include <asm/system.h>
+#include <linux/types.h>
/*
* The semantics of do_div() are:
@@ -223,4 +224,6 @@
#endif
+extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
+
#endif
diff -puN include/asm-generic/div64.h~div64_64-common-code include/asm-generic/div64.h
--- a/include/asm-generic/div64.h~div64_64-common-code
+++ a/include/asm-generic/div64.h
@@ -30,6 +30,11 @@
__rem; \
})
+static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
+{
+ return dividend / divisor;
+}
+
#elif BITS_PER_LONG == 32
extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
@@ -49,6 +54,8 @@ extern uint32_t __div64_32(uint64_t *div
__rem; \
})
+extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
+
#else /* BITS_PER_LONG == ?? */
# error do_div() does not yet support the C64
diff -puN include/asm-i386/div64.h~div64_64-common-code include/asm-i386/div64.h
--- a/include/asm-i386/div64.h~div64_64-common-code
+++ a/include/asm-i386/div64.h
@@ -1,6 +1,8 @@
#ifndef __I386_DIV64
#define __I386_DIV64
+#include <linux/types.h>
+
/*
* do_div() is NOT a C function. It wants to return
* two values (the quotient and the remainder), but
@@ -45,4 +47,6 @@ div_ll_X_l_rem(long long divs, long div,
return dum2;
}
+
+extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
#endif
diff -puN include/asm-m68k/div64.h~div64_64-common-code include/asm-m68k/div64.h
--- a/include/asm-m68k/div64.h~div64_64-common-code
+++ a/include/asm-m68k/div64.h
@@ -1,6 +1,8 @@
#ifndef _M68K_DIV64_H
#define _M68K_DIV64_H
+#include <linux/types.h>
+
/* n = n / base; return rem; */
#define do_div(n, base) ({ \
@@ -23,4 +25,5 @@
__rem; \
})
+extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
#endif /* _M68K_DIV64_H */
diff -puN include/asm-mips/div64.h~div64_64-common-code include/asm-mips/div64.h
--- a/include/asm-mips/div64.h~div64_64-common-code
+++ a/include/asm-mips/div64.h
@@ -9,6 +9,8 @@
#ifndef _ASM_DIV64_H
#define _ASM_DIV64_H
+#include <linux/types.h>
+
#if (_MIPS_SZLONG == 32)
#include <asm/compiler.h>
@@ -78,6 +80,8 @@
__quot = __quot << 32 | __low; \
(n) = __quot; \
__mod; })
+
+extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
#endif /* (_MIPS_SZLONG == 32) */
#if (_MIPS_SZLONG == 64)
diff -puN include/asm-um/div64.h~div64_64-common-code include/asm-um/div64.h
--- a/include/asm-um/div64.h~div64_64-common-code
+++ a/include/asm-um/div64.h
@@ -3,4 +3,5 @@
#include "asm/arch/div64.h"
+extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
#endif
diff -puN include/asm-xtensa/div64.h~div64_64-common-code include/asm-xtensa/div64.h
--- a/include/asm-xtensa/div64.h~div64_64-common-code
+++ a/include/asm-xtensa/div64.h
@@ -11,9 +11,15 @@
#ifndef _XTENSA_DIV64_H
#define _XTENSA_DIV64_H
+#include <linux/types.h>
+
#define do_div(n,base) ({ \
int __res = n % ((unsigned int) base); \
n /= (unsigned int) base; \
__res; })
+static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
+{
+ return dividend / divisor;
+}
#endif
diff -puN lib/Makefile~div64_64-common-code lib/Makefile
--- a/lib/Makefile~div64_64-common-code
+++ a/lib/Makefile
@@ -4,7 +4,7 @@
lib-y := ctype.o string.o vsprintf.o cmdline.o \
rbtree.o radix-tree.o dump_stack.o \
- idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \
+ idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \
sha1.o irq_regs.o reciprocal_div.o
lib-$(CONFIG_MMU) += ioremap.o
@@ -12,7 +12,8 @@ lib-$(CONFIG_SMP) += cpumask.o
lib-y += kobject.o kref.o kobject_uevent.o klist.o
-obj-y += sort.o parser.o halfmd4.o debug_locks.o random32.o bust_spinlocks.o
+obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
+ bust_spinlocks.o
ifeq ($(CONFIG_DEBUG_KOBJECT),y)
CFLAGS_kobject.o += -DDEBUG
diff -puN lib/div64.c~div64_64-common-code lib/div64.c
--- a/lib/div64.c~div64_64-common-code
+++ a/lib/div64.c
@@ -58,4 +58,26 @@ uint32_t __div64_32(uint64_t *n, uint32_
EXPORT_SYMBOL(__div64_32);
+/* 64bit divisor, dividend and result. dynamic precision */
+uint64_t div64_64(uint64_t dividend, uint64_t divisor)
+{
+ uint32_t d = divisor;
+
+ if (divisor > 0xffffffffULL) {
+ unsigned int shift = fls(divisor >> 32);
+
+ d = divisor >> shift;
+ dividend >>= shift;
+ }
+
+ /* avoid 64 bit division if possible */
+ if (dividend >> 32)
+ do_div(dividend, d);
+ else
+ dividend = (uint32_t) dividend / d;
+
+ return dividend;
+}
+EXPORT_SYMBOL(div64_64);
+
#endif /* BITS_PER_LONG == 32 */
diff -puN net/ipv4/tcp_cubic.c~div64_64-common-code net/ipv4/tcp_cubic.c
--- a/net/ipv4/tcp_cubic.c~div64_64-common-code
+++ a/net/ipv4/tcp_cubic.c
@@ -93,27 +93,6 @@ static void bictcp_init(struct sock *sk)
tcp_sk(sk)->snd_ssthresh = initial_ssthresh;
}
-/* 64bit divisor, dividend and result. dynamic precision */
-static inline u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor)
-{
- u_int32_t d = divisor;
-
- if (divisor > 0xffffffffULL) {
- unsigned int shift = fls(divisor >> 32);
-
- d = divisor >> shift;
- dividend >>= shift;
- }
-
- /* avoid 64 bit division if possible */
- if (dividend >> 32)
- do_div(dividend, d);
- else
- dividend = (uint32_t) dividend / d;
-
- return dividend;
-}
-
/*
* calculate the cubic root of x using Newton-Raphson
*/
diff -puN net/netfilter/xt_connbytes.c~div64_64-common-code net/netfilter/xt_connbytes.c
--- a/net/netfilter/xt_connbytes.c~div64_64-common-code
+++ a/net/netfilter/xt_connbytes.c
@@ -24,22 +24,6 @@ MODULE_AUTHOR("Harald Welte <laforge@net
MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection");
MODULE_ALIAS("ipt_connbytes");
-/* 64bit divisor, dividend and result. dynamic precision */
-static u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor)
-{
- u_int32_t d = divisor;
-
- if (divisor > 0xffffffffULL) {
- unsigned int shift = fls(divisor >> 32);
-
- d = divisor >> shift;
- dividend >>= shift;
- }
-
- do_div(dividend, d);
- return dividend;
-}
-
static int
match(const struct sk_buff *skb,
const struct net_device *in,
_
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [patch 2/2] div64_64: common code
2007-03-06 10:42 [patch 2/2] div64_64: common code akpm
@ 2007-03-06 18:11 ` David Miller
2007-03-06 22:32 ` Andrew Morton
2007-03-06 19:46 ` Ralf Baechle
1 sibling, 1 reply; 7+ messages in thread
From: David Miller @ 2007-03-06 18:11 UTC (permalink / raw)
To: akpm; +Cc: netdev, shemminger, chris, geert, jdike, ralf, rmk, zippel
From: akpm@linux-foundation.org
Date: Tue, 06 Mar 2007 02:42:28 -0800
> From: Stephen Hemminger <shemminger@linux-foundation.org>
>
> Implement div64_64(): 64-bit by 64-bit division. Needed by networking (at
> least).
This patch, with the types.h fixes of your's, is already in my
net-2.6.22 GIT tree if you'd like to start pulling from there
Andrew.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch 2/2] div64_64: common code
2007-03-06 18:11 ` David Miller
@ 2007-03-06 22:32 ` Andrew Morton
2007-03-06 23:21 ` David Miller
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2007-03-06 22:32 UTC (permalink / raw)
To: David Miller; +Cc: netdev, shemminger, chris, geert, jdike, ralf, rmk, zippel
On Tue, 06 Mar 2007 10:11:40 -0800 (PST)
David Miller <davem@davemloft.net> wrote:
> From: akpm@linux-foundation.org
> Date: Tue, 06 Mar 2007 02:42:28 -0800
>
> > From: Stephen Hemminger <shemminger@linux-foundation.org>
> >
> > Implement div64_64(): 64-bit by 64-bit division. Needed by networking (at
> > least).
>
> This patch, with the types.h fixes of your's, is already in my
> net-2.6.22 GIT tree if you'd like to start pulling from there
> Andrew.
ho hum, I didn't know that, so we missed rc2-mm2.
Could I have symlinks in /pub/scm/linux/kernel/git/davem/ to net-latest and
sparc-latest please?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch 2/2] div64_64: common code
2007-03-06 22:32 ` Andrew Morton
@ 2007-03-06 23:21 ` David Miller
2007-03-07 0:04 ` Andrew Morton
0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2007-03-06 23:21 UTC (permalink / raw)
To: akpm; +Cc: netdev, shemminger, chris, geert, jdike, ralf, rmk, zippel
From: Andrew Morton <akpm@linux-foundation.org>
Date: Tue, 6 Mar 2007 14:32:06 -0800
> ho hum, I didn't know that, so we missed rc2-mm2.
>
> Could I have symlinks in /pub/scm/linux/kernel/git/davem/ to net-latest and
> sparc-latest please?
When we are in a merge window, I have only one tree for sparc
and networking.
But when we're in RC mode, I've got multiple trees, one each
for bug fixes and one for stuff which will get submitted in
the next merge window.
When Linus pulls in the bug fixes, I rebase the merge window trees so
that all the fixes get integrated to the merge tree and I can resolve
any conflicts, if any.
So, which one(s) do you want? :-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch 2/2] div64_64: common code
2007-03-06 23:21 ` David Miller
@ 2007-03-07 0:04 ` Andrew Morton
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2007-03-07 0:04 UTC (permalink / raw)
To: David Miller; +Cc: netdev, shemminger, chris, geert, jdike, ralf, rmk, zippel
On Tue, 06 Mar 2007 15:21:40 -0800 (PST)
David Miller <davem@davemloft.net> wrote:
> From: Andrew Morton <akpm@linux-foundation.org>
> Date: Tue, 6 Mar 2007 14:32:06 -0800
>
> > ho hum, I didn't know that, so we missed rc2-mm2.
> >
> > Could I have symlinks in /pub/scm/linux/kernel/git/davem/ to net-latest and
> > sparc-latest please?
>
> When we are in a merge window, I have only one tree for sparc
> and networking.
>
> But when we're in RC mode, I've got multiple trees, one each
> for bug fixes and one for stuff which will get submitted in
> the next merge window.
>
> When Linus pulls in the bug fixes, I rebase the merge window trees so
> that all the fixes get integrated to the merge tree and I can resolve
> any conflicts, if any.
>
> So, which one(s) do you want? :-)
The merge-window things, generally.
I assume from the above that the merge-window tree doesn't contain the
paterial in the bugfixes tree? If so, I guess I'd need both. If not, the
merge-window tree should contain everything?
I dunno - you know your trees better than I. The bottom line is I want
everything you've got, and it'd be nice to fix this problem where I don't
know that a new tree has been opened up, so I miss it - how can we do this?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch 2/2] div64_64: common code
2007-03-06 10:42 [patch 2/2] div64_64: common code akpm
2007-03-06 18:11 ` David Miller
@ 2007-03-06 19:46 ` Ralf Baechle
2007-03-06 21:46 ` David Miller
1 sibling, 1 reply; 7+ messages in thread
From: Ralf Baechle @ 2007-03-06 19:46 UTC (permalink / raw)
To: akpm; +Cc: davem, netdev, shemminger, chris, geert, jdike, rmk, zippel
On Tue, Mar 06, 2007 at 02:42:28AM -0800, akpm@linux-foundation.org wrote:
> Implement div64_64(): 64-bit by 64-bit division. Needed by networking (at
> least).
Your patch only implements div64_64() for 32-bit MIPS. Below patch adds
the trivial 64-bit bits.
Ralf
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
include/asm-mips/div64.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Index: linux-mips/include/asm-mips/div64.h
===================================================================
--- linux-mips.orig/include/asm-mips/div64.h
+++ linux-mips/include/asm-mips/div64.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2000, 2004 Maciej W. Rozycki
- * Copyright (C) 2003 Ralf Baechle
+ * Copyright (C) 2003, 07 Ralf Baechle (ralf@linux-mips.org)
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
@@ -105,6 +105,11 @@ extern uint64_t div64_64(uint64_t divide
(n) = __quot; \
__mod; })
+static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
+{
+ return dividend / divisor;
+}
+
#endif /* (_MIPS_SZLONG == 64) */
#endif /* _ASM_DIV64_H */
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [patch 2/2] div64_64: common code
2007-03-06 19:46 ` Ralf Baechle
@ 2007-03-06 21:46 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2007-03-06 21:46 UTC (permalink / raw)
To: ralf; +Cc: akpm, netdev, shemminger, chris, geert, jdike, rmk, zippel
From: Ralf Baechle <ralf@linux-mips.org>
Date: Tue, 6 Mar 2007 19:46:32 +0000
> On Tue, Mar 06, 2007 at 02:42:28AM -0800, akpm@linux-foundation.org wrote:
>
> > Implement div64_64(): 64-bit by 64-bit division. Needed by networking (at
> > least).
>
> Your patch only implements div64_64() for 32-bit MIPS. Below patch adds
> the trivial 64-bit bits.
>
> Ralf
>
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Applied to net-2.6.22, thanks Ralf.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-03-07 0:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-06 10:42 [patch 2/2] div64_64: common code akpm
2007-03-06 18:11 ` David Miller
2007-03-06 22:32 ` Andrew Morton
2007-03-06 23:21 ` David Miller
2007-03-07 0:04 ` Andrew Morton
2007-03-06 19:46 ` Ralf Baechle
2007-03-06 21:46 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).