+#include <stdio.h>
#include <string.h>
-#include <assert.h>
-
#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
* 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;
}
/**
- * 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
*
cur = merge(priv, cmp, part[lev], cur);
part[lev] = NULL;
}
- if (lev > max_lev)
- assert(lev < ARRAY_SIZE(part) - 1);
+ if (lev > max_lev) {
+ 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;
}