28 Oct, 2020

1 commit


27 Oct, 2020

1 commit


09 Sep, 2020

1 commit


13 Aug, 2020

1 commit

  • Inspired by an original patch from Yury Norov: introduce a test for
    bitmap_cut() that also makes sure functionality is as described for
    partially overlapping src and dst.

    Signed-off-by: Stefano Brivio
    Signed-off-by: Andrew Morton
    Reviewed-by: Andy Shevchenko
    Cc: Pablo Neira Ayuso
    Cc: Rasmus Villemoes
    Cc: Yury Norov
    Link: http://lkml.kernel.org/r/5fc45e6bbd4fa837cd9577f8a0c1d639df90a4ce.1592155364.git.sbrivio@redhat.com
    Signed-off-by: Linus Torvalds

    Stefano Brivio
     

08 Apr, 2020

1 commit

  • Commit 30544ed5de43 ("lib/bitmap: introduce bitmap_replace() helper")
    introduced some new test cases to the test_bitmap.c module. Among these
    it also introduced an (unused) definition. Let's make use of
    EXP2_IN_BITS.

    Reported-by: Alex Shi
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Andrew Morton
    Reviewed-by: Alex Shi
    Link: http://lkml.kernel.org/r/20200121151847.75223-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     

04 Feb, 2020

2 commits

  • New version of bitmap_parse() is unified with bitmap_parse_list(),
    and therefore:

    - weakens rules on whitespaces and commas between hex chunks;

    - in addition to

    - allows passing UINT_MAX or any other big number as the length of input
    string instead of actual string length.

    The patch covers the cases.

    Link: http://lkml.kernel.org/r/20200102043031.30357-7-yury.norov@gmail.com
    Signed-off-by: Yury Norov
    Reviewed-by: Andy Shevchenko
    Cc: Amritha Nambiar
    Cc: Arnaldo Carvalho de Melo
    Cc: Chris Wilson
    Cc: Kees Cook
    Cc: Matthew Wilcox
    Cc: Miklos Szeredi
    Cc: Rasmus Villemoes
    Cc: Steffen Klassert
    Cc: "Tobin C . Harding"
    Cc: Vineet Gupta
    Cc: Will Deacon
    Cc: Willem de Bruijn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • The test is derived from bitmap_parselist() NO_LEN is reserved for use in
    following patches.

    [yury.norov@gmail.com: fix rebase issue]
    Link: http://lkml.kernel.org/r/20200102182659.6685-1-yury.norov@gmail.com
    [andriy.shevchenko@linux.intel.com: fix address space when test user buffer]
    Link: http://lkml.kernel.org/r/20200109103601.45929-2-andriy.shevchenko@linux.intel.com
    Link: http://lkml.kernel.org/r/20200102043031.30357-4-yury.norov@gmail.com
    Signed-off-by: Yury Norov
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Andy Shevchenko
    Cc: Amritha Nambiar
    Cc: Arnaldo Carvalho de Melo
    Cc: Chris Wilson
    Cc: Kees Cook
    Cc: Matthew Wilcox
    Cc: Miklos Szeredi
    Cc: Rasmus Villemoes
    Cc: Steffen Klassert
    Cc: "Tobin C . Harding"
    Cc: Vineet Gupta
    Cc: Will Deacon
    Cc: Willem de Bruijn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     

01 Feb, 2020

1 commit

  • On 32-bit platform the size of long is only 32 bits which makes wrong
    offset in the array of 64 bit size.

    Calculate offset based on BITS_PER_LONG.

    Link: http://lkml.kernel.org/r/20200109103601.45929-1-andriy.shevchenko@linux.intel.com
    Fixes: 30544ed5de43 ("lib/bitmap: introduce bitmap_replace() helper")
    Signed-off-by: Andy Shevchenko
    Reported-by: Guenter Roeck
    Cc: Rasmus Villemoes
    Cc: Yury Norov
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     

05 Dec, 2019

8 commits

  • In some drivers we want to have a single operation over bitmap which is
    an equivalent to:

    *dst = (*old & ~(*mask)) | (*new & *mask)

    Introduce bitmap_replace() helper for this.

    Link: http://lkml.kernel.org/r/20191022172922.61232-8-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Acked-by: Linus Walleij
    Cc: Rasmus Villemoes
    Cc: Bartosz Golaszewski
    Cc: Geert Uytterhoeven
    Cc: Marek Vasut
    Cc: Thomas Petazzoni
    Cc: William Breathitt Gray
    Cc: Yury Norov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • This test case file is about bitmap API, and not printf() facility.

    Link: http://lkml.kernel.org/r/20191022172922.61232-7-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Acked-by: Linus Walleij
    Cc: Bartosz Golaszewski
    Cc: Geert Uytterhoeven
    Cc: Marek Vasut
    Cc: Rasmus Villemoes
    Cc: Thomas Petazzoni
    Cc: William Breathitt Gray
    Cc: Yury Norov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Some test cases may re-use predefined exp1 and exp2 bitmaps. Move them
    upper in the file.

    Link: http://lkml.kernel.org/r/20191022172922.61232-6-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Acked-by: Linus Walleij
    Cc: Bartosz Golaszewski
    Cc: Geert Uytterhoeven
    Cc: Marek Vasut
    Cc: Rasmus Villemoes
    Cc: Thomas Petazzoni
    Cc: William Breathitt Gray
    Cc: Yury Norov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • One function is using exp as local variable. Avoid ambiguous naming by
    rename global one to exp1.

    Link: http://lkml.kernel.org/r/20191022172922.61232-5-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Acked-by: Linus Walleij
    Cc: Bartosz Golaszewski
    Cc: Geert Uytterhoeven
    Cc: Marek Vasut
    Cc: Rasmus Villemoes
    Cc: Thomas Petazzoni
    Cc: William Breathitt Gray
    Cc: Yury Norov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • EXP_BYTES has been wrongly named. It's a size of the exp array in bits.

    While here, go ahead and rename to EXP1_IN_BITS to avoid double renaming
    when exp will be renamed to exp1 in the next patch

    Link: http://lkml.kernel.org/r/20191022172922.61232-4-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Acked-by: Linus Walleij
    Cc: Bartosz Golaszewski
    Cc: Geert Uytterhoeven
    Cc: Marek Vasut
    Cc: Rasmus Villemoes
    Cc: Thomas Petazzoni
    Cc: William Breathitt Gray
    Cc: Yury Norov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • There is no need to keep step and ptest macros defined in entire file.

    Link: http://lkml.kernel.org/r/20191022172922.61232-3-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Acked-by: Linus Walleij
    Cc: Bartosz Golaszewski
    Cc: Geert Uytterhoeven
    Cc: Marek Vasut
    Cc: Rasmus Villemoes
    Cc: Thomas Petazzoni
    Cc: William Breathitt Gray
    Cc: Yury Norov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Patch series "gpio: pca953x: Convert to bitmap (extended) API", v2.

    While converting gpio-pca953x driver to bitmap API, I noticed that we
    have no function to replace bits.

    So, that's how patch 7 appears.

    First 6 patches are preparatory of the test suite (including some
    warning fixes, etc).

    Patches 8-9 are preparatory for the GPIO driver to be easier converted
    to bitmap API, conversion to which happens in patch 10.

    Patch 11 contains simple indentation fixes.

    This patch (of 11):

    Sparse complains:

    lib/test_bitmap.c:345:58: warning: incorrect type in argument 1 (different address spaces)
    lib/test_bitmap.c:345:58: expected char const [noderef] *ubuf
    lib/test_bitmap.c:345:58: got char const *const in

    Force argument of bitmap_parselist_user() to proper address space.

    Link: http://lkml.kernel.org/r/20191022172922.61232-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Acked-by: Linus Walleij
    Cc: Bartosz Golaszewski
    Cc: Rasmus Villemoes
    Cc: Yury Norov
    Cc: William Breathitt Gray
    Cc: Geert Uytterhoeven
    Cc: Thomas Petazzoni
    Cc: Marek Vasut
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • The introduction of the for_each_set_clump8 macro warrants test cases to
    verify the implementation. This patch adds test case checks for whether
    an out-of-bounds clump index is returned, a zero clump is returned, or
    the returned clump value differs from the expected clump value.

    Link: http://lkml.kernel.org/r/febc0fb8151e3e3fdd61c34da9193d1c4d7e6c12.1570641097.git.vilhelm.gray@gmail.com
    Signed-off-by: William Breathitt Gray
    Reviewed-by: Andy Shevchenko
    Reviewed-by: Linus Walleij
    Tested-by: Andy Shevchenko
    Cc: Rasmus Villemoes
    Cc: Arnd Bergmann
    Cc: Bartosz Golaszewski
    Cc: Geert Uytterhoeven
    Cc: Geert Uytterhoeven
    Cc: Lukas Wunner
    Cc: Masahiro Yamada
    Cc: Mathias Duckeck
    Cc: Morten Hein Tiljeset
    Cc: Phil Reid
    Cc: Sean Nyekjaer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    William Breathitt Gray
     

21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have MODULE_LICENCE("GPL*") inside which was used in the initial
    scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

15 May, 2019

3 commits

  • Propagate existing bitmap_parselist() tests to bitmap_parselist_user().

    Link: http://lkml.kernel.org/r/20190405173211.11373-6-ynorov@marvell.com
    Signed-off-by: Yury Norov
    Reviewed-by: Andy Shevchenko
    Cc: Arnd Bergmann
    Cc: Kees Cook
    Cc: Matthew Wilcox
    Cc: Mike Travis
    Cc: Rasmus Villemoes
    Cc: Tetsuo Handa
    Cc: Guenter Roeck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • Add tests for non-number character, empty regions, integer overflow.

    [ynorov@marvell.com: v5]
    Link: http://lkml.kernel.org/r/20190416063801.20134-5-ynorov@marvell.com
    Link: http://lkml.kernel.org/r/20190405173211.11373-5-ynorov@marvell.com
    Signed-off-by: Yury Norov
    Reviewed-by: Andy Shevchenko
    Cc: Arnd Bergmann
    Cc: Kees Cook
    Cc: Matthew Wilcox
    Cc: Mike Travis
    Cc: Rasmus Villemoes
    Cc: Tetsuo Handa
    Cc: Guenter Roeck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • test_bitmap_parselist currently uses get_cycles which is not implemented
    on some platforms, so use ktime_get() instead.

    Link: http://lkml.kernel.org/r/20190405173211.11373-4-ynorov@marvell.com
    Signed-off-by: Yury Norov
    Reviewed-by: Andy Shevchenko
    Cc: Arnd Bergmann
    Cc: Kees Cook
    Cc: Matthew Wilcox
    Cc: Mike Travis
    Cc: Rasmus Villemoes
    Cc: Tetsuo Handa
    Cc: Guenter Roeck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     

09 Apr, 2019

1 commit

  • We just added a new C header file for use with test modules that are
    intended to be run with kselftest. We can reduce code duplication by
    using this header.

    Use new kselftest header to reduce code duplication in test_printf and
    test_bitmap test modules.

    Acked-by: Kees Cook
    Signed-off-by: Tobin C. Harding
    Signed-off-by: Shuah Khan

    Tobin C. Harding
     

19 May, 2018

1 commit

  • I had neglected to increment the error counter when the tests failed,
    which made the tests noisy when they fail, but not actually return an
    error code.

    Link: http://lkml.kernel.org/r/20180509114328.9887-1-mpe@ellerman.id.au
    Fixes: 3cc78125a081 ("lib/test_bitmap.c: add optimisation tests")
    Signed-off-by: Matthew Wilcox
    Signed-off-by: Michael Ellerman
    Reported-by: Michael Ellerman
    Tested-by: Michael Ellerman
    Reviewed-by: Kees Cook
    Cc: Yury Norov
    Cc: Andy Shevchenko
    Cc: Geert Uytterhoeven
    Cc: [4.13+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     

12 Apr, 2018

1 commit

  • This avoids an accidental stack VLA (since the compiler thinks the value
    of "len" can change, even when marked "const"). This just replaces it
    with a #define so it will DTRT.

    Seen with -Wvla. Fixed as part of the directive to remove all VLAs from
    the kernel: https://lkml.org/lkml/2018/3/7/621

    Link: http://lkml.kernel.org/r/20180307212555.GA17927@beast
    Signed-off-by: Kees Cook
    Reviewed-by: Andrew Morton
    Cc: Yury Norov
    Cc: Andy Shevchenko
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kees Cook
     

06 Apr, 2018

1 commit

  • syzbot is catching stalls at __bitmap_parselist()
    (https://syzkaller.appspot.com/bug?id=ad7e0351fbc90535558514a71cd3edc11681997a).
    The trigger is

    unsigned long v = 0;
    bitmap_parselist("7:,", &v, BITS_PER_LONG);

    which results in hitting infinite loop at

    while (a
    Reported-by: Tetsuo Handa
    Reported-by: syzbot
    Cc: Noam Camus
    Cc: Rasmus Villemoes
    Cc: Matthew Wilcox
    Cc: Mauro Carvalho Chehab
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     

07 Feb, 2018

4 commits

  • Since we have separate explicit test cases for bitmap_zero() /
    bitmap_clear() and bitmap_fill() / bitmap_set(), clean up
    test_zero_fill_copy() to only test bitmap_copy() functionality and thus
    rename a function to reflect the changes.

    While here, replace bitmap_fill() by bitmap_set() with proper values.

    Link: http://lkml.kernel.org/r/20180109172430.87452-3-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Yury Norov
    Cc: Randy Dunlap
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Explicitly test bitmap_fill() and bitmap_set() functions.

    For bitmap_fill() we expect a consistent behaviour as in bitmap_zero(),
    i.e. the trailing bits will be set up to unsigned long boundary.

    Link: http://lkml.kernel.org/r/20180109172430.87452-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Yury Norov
    Cc: Randy Dunlap
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Explicitly test bitmap_zero() and bitmap_clear() functions.

    Link: http://lkml.kernel.org/r/20180109172430.87452-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Yury Norov
    Cc: Rasmus Villemoes
    Cc: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • with bitmap_{from,to}_arr32 over the kernel. Additionally to it:
    * __check_eq_bitmap() now takes single nbits argument.
    * __check_eq_u32_array is not used in new test but may be used in
    future. So I don't remove it here, but annotate as __used.

    Tested on arm64 and 32-bit BE mips.

    [arnd@arndb.de: perf: arm_dsu_pmu: convert to bitmap_from_arr32]
    Link: http://lkml.kernel.org/r/20180201172508.5739-2-ynorov@caviumnetworks.com
    [ynorov@caviumnetworks.com: fix net/core/ethtool.c]
    Link: http://lkml.kernel.org/r/20180205071747.4ekxtsbgxkj5b2fz@yury-thinkpad
    Link: http://lkml.kernel.org/r/20171228150019.27953-2-ynorov@caviumnetworks.com
    Signed-off-by: Yury Norov
    Signed-off-by: Arnd Bergmann
    Cc: Ben Hutchings
    Cc: David Decotigny ,
    Cc: David S. Miller ,
    Cc: Geert Uytterhoeven
    Cc: Matthew Wilcox
    Cc: Rasmus Villemoes
    Cc: Heiner Kallweit
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     

14 Sep, 2017

1 commit

  • With gcc 4.1.2:

    lib/test_bitmap.c:189: warning: integer constant is too large for `long' type
    lib/test_bitmap.c:190: warning: integer constant is too large for `long' type
    lib/test_bitmap.c:194: warning: integer constant is too large for `long' type
    lib/test_bitmap.c:195: warning: integer constant is too large for `long' type

    Add the missing "ULL" suffix to fix this.

    Link: http://lkml.kernel.org/r/1505040523-31230-1-git-send-email-geert@linux-m68k.org
    Fixes: 60ef690018b262dd ("bitmap: introduce BITMAP_FROM_U64()")
    Signed-off-by: Geert Uytterhoeven
    Acked-by: Yury Norov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Geert Uytterhoeven
     

09 Sep, 2017

2 commits

  • The macro is the compile-time analogue of bitmap_from_u64() with the same
    purpose: convert the 64-bit number to the properly ordered pair of 32-bit
    parts, suitable for filling the bitmap in 32-bit BE environment.

    Use it to make test_bitmap_parselist() correct for 32-bit BE ABIs.

    Tested on BE mips/qemu.

    [akpm@linux-foundation.org: tweak code comment]
    Link: http://lkml.kernel.org/r/20170810172916.24144-1-ynorov@caviumnetworks.com
    Signed-off-by: Yury Norov
    Cc: Noam Camus
    Cc: Rasmus Villemoes
    Cc: Matthew Wilcox
    Cc: Mauro Carvalho Chehab
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • Do some basic checks for bitmap_parselist().

    [akpm@linux-foundation.org: fix printk warning]
    Link: http://lkml.kernel.org/r/20170807225438.16161-2-ynorov@caviumnetworks.com
    Signed-off-by: Yury Norov
    Cc: Noam Camus
    Cc: Rasmus Villemoes
    Cc: Matthew Wilcox
    Cc: Mauro Carvalho Chehab
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     

11 Jul, 2017

2 commits

  • We have eight users calling bitmap_clear for a single bit and seventeen
    calling bitmap_set for a single bit. Rather than fix all of them to
    call __clear_bit or __set_bit, turn bitmap_clear and bitmap_set into
    inline functions and make this special case efficient.

    Link: http://lkml.kernel.org/r/20170628153221.11322-3-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Acked-by: Rasmus Villemoes
    Cc: Martin Schwidefsky
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     
  • Patch series "Bitmap optimisations", v2.

    These three bitmap patches use more efficient specialisations when the
    compiler can figure out that it's safe to do so. Thanks to Rasmus's
    eagle eyes, a nasty bug in v1 was avoided, and I've added a test case
    which would have caught it.

    This patch (of 4):

    This version of the test is actually a no-op; the next patch will enable
    it.

    Link: http://lkml.kernel.org/r/20170628153221.11322-2-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Cc: Rasmus Villemoes
    Cc: Martin Schwidefsky
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     

20 Feb, 2016

1 commit