Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-03-01 Thread Andrew Morton
Matt Mackall <[EMAIL PROTECTED]> wrote: > > I'll queue this > up for after the sort and ACL stuff gets merged. Whew! I don't know how long the ACL changes will take to get merged up - is up to Trond and he had quite a lot of rather robust comments on the first iteration. - To unsubscribe from th

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-03-01 Thread Matt Mackall
On Tue, Mar 01, 2005 at 08:06:22PM +0100, Christophe Saout wrote: > Am Sonntag, den 27.02.2005, 13:25 -0800 schrieb Matt Mackall: > > > Which kernel? There was an off-by-one for odd array sizes in the > > original posted version that was quickly spotted: > > > > http://www.kernel.org/pub/linux/ke

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-03-01 Thread Christophe Saout
Am Sonntag, den 27.02.2005, 13:25 -0800 schrieb Matt Mackall: > Which kernel? There was an off-by-one for odd array sizes in the > original posted version that was quickly spotted: > > http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.11-rc4/2.6.11-rc4-mm1/broken-out/sort-fix.pat

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-03-01 Thread Andreas Gruenbacher
On Sun, 2005-02-27 at 22:25, Matt Mackall wrote: > On Sun, Feb 27, 2005 at 02:17:51PM +0100, Andreas Gruenbacher wrote: > > Matt, > > > > On Monday 31 January 2005 08:34, Matt Mackall wrote: > > > This patch adds a generic array sorting library routine. This is meant > > > to replace qsort, which

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-27 Thread Andreas Gruenbacher
On Sunday 27 February 2005 22:53, Andreas Gruenbacher wrote: > Okay, I didn't notice the off-by-one fix. It's still broken though; see the > attached user-space test. Found it. I didn't have the off-by-one fix and the bug triggered; then the test case had a useless comparison function: int cmp(c

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-27 Thread Andreas Gruenbacher
On Sunday 27 February 2005 22:25, Matt Mackall wrote: > On Sun, Feb 27, 2005 at 02:17:51PM +0100, Andreas Gruenbacher wrote: > > Matt, > > > > On Monday 31 January 2005 08:34, Matt Mackall wrote: > > > This patch adds a generic array sorting library routine. This is meant > > > to replace qsort, wh

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-27 Thread Matt Mackall
On Sun, Feb 27, 2005 at 02:17:51PM +0100, Andreas Gruenbacher wrote: > Matt, > > On Monday 31 January 2005 08:34, Matt Mackall wrote: > > This patch adds a generic array sorting library routine. This is meant > > to replace qsort, which has two problem areas for kernel use. > > the sort function

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-27 Thread Andreas Gruenbacher
Matt, On Monday 31 January 2005 08:34, Matt Mackall wrote: > This patch adds a generic array sorting library routine. This is meant > to replace qsort, which has two problem areas for kernel use. the sort function is broken. When sorting the integer array {1, 2, 3, 4, 5}, I'm getting {2, 3, 4, 5

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-03 Thread Junio C Hamano
> "AG" == Andreas Gruenbacher <[EMAIL PROTECTED]> writes: AG> On Wed, 2005-02-02 at 11:50, Herbert Xu wrote: >> What if a/b aren't aligned? AG> If people sort arrays that are unaligned even though the AG> element size is a multiple of sizeof(long) (or sizeof(u32) AG> as Matt proposes), they a

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-02 Thread Andreas Gruenbacher
On Wed, 2005-02-02 at 11:50, Herbert Xu wrote: > Andreas Gruenbacher <[EMAIL PROTECTED]> wrote: > > > > static inline void swap(void *a, void *b, int size) > > { > >if (size % sizeof(long)) { > >char t; > >do { > >t = *(char *)a; > >

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-02 Thread Herbert Xu
Andreas Gruenbacher <[EMAIL PROTECTED]> wrote: > > static inline void swap(void *a, void *b, int size) > { >if (size % sizeof(long)) { >char t; >do { >t = *(char *)a; >*(char *)a++ = *(char *)b; >

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-01 Thread Horst von Brand
Andreas Gruenbacher <[EMAIL PROTECTED]> said: [...] > Yes, because a custom swap routine isn't very useful generally. It's > over-engineered IMHO. It shouldn't swap, but juggle elements around like so: t --->+ ^ | | v x <-- x <-- x <--

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-01 Thread Andreas Gruenbacher
On Tue, 2005-02-01 at 19:11, linux-os wrote: > This uses an GNU-ISM where you are doing pointer arithmetic > on a pointer-to-void. NotGood(tm) [...] That's perfectly fine inside the kernel. -- Andreas. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a mes

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-01 Thread linux-os
On Tue, 1 Feb 2005, linux-os wrote: On Tue, 1 Feb 2005, Andreas Gruenbacher wrote: On Mon, 2005-01-31 at 18:30, Paulo Marques wrote: Andreas Gruenbacher wrote: [...] static inline void swap(void *a, void *b, int size) { if (size % sizeof(long)) { char t; do {

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-01 Thread linux-os
On Tue, 1 Feb 2005, Andreas Gruenbacher wrote: On Mon, 2005-01-31 at 18:30, Paulo Marques wrote: Andreas Gruenbacher wrote: [...] static inline void swap(void *a, void *b, int size) { if (size % sizeof(long)) { char t; do { t = *(char

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-01 Thread Andreas Gruenbacher
On Mon, 2005-01-31 at 18:30, Paulo Marques wrote: > Andreas Gruenbacher wrote: > > [...] > > > > static inline void swap(void *a, void *b, int size) > > { > > if (size % sizeof(long)) { > > char t; > > do { > > t = *(char *)a; > >

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-02-01 Thread Andreas Gruenbacher
On Mon, 2005-01-31 at 20:30, Matt Mackall wrote: > On Mon, Jan 31, 2005 at 06:16:23PM +0100, Andreas Gruenbacher wrote: > > Hello, > > > > On Mon, 2005-01-31 at 08:34, Matt Mackall wrote: > > > This patch adds a generic array sorting library routine. This is meant > > > to replace qsort, which has

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-01-31 Thread Horst von Brand
Matt Mackall <[EMAIL PROTECTED]> said: > This patch adds a generic array sorting library routine. This is meant > to replace qsort, which has two problem areas for kernel use. Another problem is the GPL license. It will certainly be wanted from non-GPL (e.g., binary) modules. Please just EXPORT_SY

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-01-31 Thread Matt Mackall
On Mon, Jan 31, 2005 at 06:16:23PM +0100, Andreas Gruenbacher wrote: > Hello, > > On Mon, 2005-01-31 at 08:34, Matt Mackall wrote: > > This patch adds a generic array sorting library routine. This is meant > > to replace qsort, which has two problem areas for kernel use. > > looks reasonable. >

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-01-31 Thread Paulo Marques
Andreas Gruenbacher wrote: [...] static inline void swap(void *a, void *b, int size) { if (size % sizeof(long)) { char t; do { t = *(char *)a; *(char *)a++ = *(char *)b; *(char *)b++ = t;

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-01-31 Thread Andreas Gruenbacher
Hello, On Mon, 2005-01-31 at 08:34, Matt Mackall wrote: > This patch adds a generic array sorting library routine. This is meant > to replace qsort, which has two problem areas for kernel use. looks reasonable. > Note that this function has an extra parameter for passing in an > optimized swappi

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-01-31 Thread Matt Mackall
On Mon, Jan 31, 2005 at 01:52:57PM +0200, Alexey Dobriyan wrote: > On Mon, 31 Jan 2005 01:34:59 -0600, Matt Mackall wrote: > > > This patch adds a generic array sorting library routine. This is meant > > to replace qsort, which has two problem areas for kernel use. > > > --- /dev/null > > +++ mm2

Re: [PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-01-31 Thread Alexey Dobriyan
On Mon, 31 Jan 2005 01:34:59 -0600, Matt Mackall wrote: > This patch adds a generic array sorting library routine. This is meant > to replace qsort, which has two problem areas for kernel use. > --- /dev/null > +++ mm2/include/linux/sort.h > @@ -0,0 +1,8 @@ > +void sort(void *base, size_t num, s

[PATCH 1/8] lib/sort: Heapsort implementation of sort()

2005-01-31 Thread Matt Mackall
This patch adds a generic array sorting library routine. This is meant to replace qsort, which has two problem areas for kernel use. The first issue is quadratic worst-case performance. While quicksort worst-case datasets are rarely encountered in normal scenarios, it is in fact quite easy to cons