George Spelvin 043b3f7b63 lib/list_sort: simplify and remove MAX_LIST_LENGTH_BITS
Rather than a fixed-size array of pending sorted runs, use the ->prev
links to keep track of things.  This reduces stack usage, eliminates
some ugly overflow handling, and reduces the code size.

Also:
* merge() no longer needs to handle NULL inputs, so simplify.
* The same applies to merge_and_restore_back_links(), which is renamed
  to the less ponderous merge_final().  (It's a static helper function,
  so we don't need a super-descriptive name; comments will do.)
* Document the actual return value requirements on the (*cmp)()
  function; some callers are already using this feature.

x86-64 code size 1086 -> 739 bytes (-347)

(Yes, I see checkpatch complaining about no space after comma in
"__attribute__((nonnull(2,3,4,5)))".  Checkpatch is wrong.)

Feedback from Rasmus Villemoes, Andy Shevchenko and Geert Uytterhoeven.

[akpm@linux-foundation.org: remove __pure usage due to mysterious warning]
Link: http://lkml.kernel.org/r/f63c410e0ff76009c9b58e01027e751ff7fdb749.1552704200.git.lkml@sdf.org
Signed-off-by: George Spelvin <lkml@sdf.org>
Acked-by: Andrey Abramov <st5pub@yandex.ru>
Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Daniel Wagner <daniel.wagner@siemens.com>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Don Mullis <don.mullis@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-14 19:52:49 -07:00
..
2019-03-15 14:37:46 -07:00
2018-07-10 15:00:52 -06:00
2018-08-22 10:52:48 -07:00
2017-12-01 13:09:40 -08:00
2017-12-01 13:09:40 -08:00
2018-10-12 09:17:46 +02:00
2018-08-16 12:14:42 -07:00
2017-12-01 13:09:40 -08:00
2018-08-22 10:52:48 -07:00
2019-03-07 18:32:00 -08:00
2018-02-06 18:32:44 -08:00
2019-01-05 13:54:53 -08:00
2019-03-12 10:04:02 -07:00
2017-02-24 17:46:57 -08:00
2018-06-12 16:19:22 -07:00
2018-04-12 09:41:19 -07:00
2018-06-12 16:19:22 -07:00
2017-12-01 13:09:40 -08:00
2018-10-16 13:45:44 +02:00
2017-12-01 13:09:40 -08:00
2018-06-27 18:58:49 +03:00
2019-04-08 16:44:20 -06:00
2018-10-15 16:31:29 -04:00
2019-05-07 09:18:12 -07:00
2019-05-06 11:12:09 -07:00
2018-04-23 16:39:35 +01:00
2017-08-15 09:02:07 -07:00