[PATCH v2 0/5] lib: rework bitmap_parselist and tests

From: Yury Norov
Date: Wed Feb 20 2019 - 03:37:15 EST


bitmap_parselist has been evolved from a pretty simple idea for long and
now lacks for refactoring. It is not structured, has nested loops and a
set of opaque-named variables. All this leads to extremely hard
understanding of the code. Once during the optimization of it I missed a
scenario which leads to kernel hangup. Tetsuo Handa spotted this and found
it simpler to rewrite the code instead fixing it. (Though, that attempt
had some flaws.)
https://lkml.org/lkml/2018/4/1/93

Things are more complicated than they may be because bitmap_parselist()
is part of user interface, and its behavior should not change.

In this patchset
- __bitmap_parselist() is reworked (patches 2 and 3);
- time measurement in test_bitmap_parselist switched to ktime_get
(patch 4);
- new tests introduced (patch 5), and
- bitmap_parselist_user() testing enabled with the same testset as
bitmap_parselist() (patch 6).

Patch 1 is a fix and may be applied separately.

V1: https://lkml.org/lkml/2018/12/23/50
v2: - use PTR_ERR() and ERR_PTR() where appropriate;
- fix parser logic (last byte of string handling);
- tests for bitmap_parselist_user() in patch 5.

Yury Norov (4):
bitmap_parselist: don't calculate length of the input string
bitmap_parselist: move non-parser logic to helpers
bitmap_parselist: rework input string parser
lib/test_bitmap: switch test_bitmap_parselist to ktime_get()
lib/test_bitmap: add testcases for bitmap_parselist
lib/test_bitmap: add tests for bitmap_parselist_user

lib/bitmap.c | 293 ++++++++++++++++++++++++++++++----------------
lib/test_bitmap.c | 67 +++++++++--
2 files changed, 245 insertions(+), 115 deletions(-)

--
2.17.1