X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=lib%2Fflist_sort.c;h=1c91cc457ca97ea091ad2b9287c3379b0e995e66;hb=9d918187e8eceda6637544b7cb0fa3ee734ee5c0;hp=9a2da8412593240323df728b99920bfe8a83bc6c;hpb=045396879167669c3809474422bc20866c81f6d0;p=fio.git diff --git a/lib/flist_sort.c b/lib/flist_sort.c index 9a2da841..1c91cc45 100644 --- a/lib/flist_sort.c +++ b/lib/flist_sort.c @@ -1,14 +1,9 @@ +#include #include -#include - #include "../flist.h" -#include "../flist_sort.h" - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -#endif +#include "../log.h" -#define MAX_LIST_LENGTH_BITS 65 +#define MAX_LIST_LENGTH_BITS 20 /* * Returns a list organized in an intermediate format suited @@ -74,7 +69,7 @@ static void merge_and_restore_back_links(void *priv, * element comparison is needed, so the client's cmp() * routine can invoke cond_resched() periodically. */ - cmp(priv, tail, tail); + (*cmp)(priv, tail->next, tail->next); tail->next->prev = tail; tail = tail->next; @@ -85,8 +80,8 @@ static void merge_and_restore_back_links(void *priv, } /** - * flist_sort - sort a list - * @priv: private data, opaque to flist_sort(), passed to @cmp + * list_sort - sort a list + * @priv: private data, opaque to list_sort(), passed to @cmp * @head: the list to sort * @cmp: the elements comparison function * @@ -126,7 +121,12 @@ void flist_sort(void *priv, struct flist_head *head, part[lev] = NULL; } if (lev > max_lev) { - assert(lev < ARRAY_SIZE(part) - 1); + if (lev >= MAX_LIST_LENGTH_BITS) { + log_err("fio: list passed to" + " list_sort() too long for" + " efficiency\n"); + lev--; + } max_lev = lev; } part[lev] = cur;