Hello there, The following patch adds an obvious speedup for 64 bit data to lib/sort.c
In tests on a 64 bit machine, the code at the end of the lib/sort.c file executed some 40% faster. The patch is against kernel version 3.16-rc6 Regards David Binderman Signed-off-by: David Binderman <dcb...@hotmail.com> --- linux-3.16-rc6/lib/sort.c.old 2014-07-23 16:47:59.120299115 +0100 +++ linux-3.16-rc6/lib/sort.c 2014-07-23 17:33:21.405251903 +0100 @@ -16,6 +16,13 @@ static void u32_swap(void *a, void *b, i *(u32 *)b = t; } +static void u64_swap(void *a, void *b, int size) +{ + u64 t = *(u64 *)a; + *(u64 *)a = *(u64 *)b; + *(u64 *)b = t; +} + static void generic_swap(void *a, void *b, int size) { char t; @@ -51,8 +58,14 @@ void sort(void *base, size_t num, size_t /* pre-scale counters for performance */ int i = (num/2 - 1) * size, n = num * size, c, r; - if (!swap_func) - swap_func = (size == 4 ? u32_swap : generic_swap); + if (!swap_func) { + if (size == 4) + swap_func = u32_swap; + else if (size == 8) + swap_func = u64_swap; + else + swap_func = generic_swap; + } /* heapify */ for ( ; i>= 0; i -= size) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/