1. 16 May, 2022 5 commits
  2. 12 May, 2022 6 commits
    • Daniel Latypov's avatar
      kunit: tool: print clearer error message when there's no TAP output · 9660209d
      Daniel Latypov authored
      Before:
      $ ./tools/testing/kunit/kunit.py parse /dev/null
      ...
      [ERROR] Test : invalid KTAP input!
      
      After:
      $ ./tools/testing/kunit/kunit.py parse /dev/null
      ...
      [ERROR] Test <missing>: could not find any KTAP output!
      
      This error message gets printed out when extract_tap_output() yielded no
      lines. So while it could be because of malformed KTAP output from KUnit,
      it could also be due to not having any KTAP output at all.
      
      Try and make the error message here more clear.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      9660209d
    • Daniel Latypov's avatar
      kunit: tool: stop using a shell to run kernel under QEMU · 3f0a50f3
      Daniel Latypov authored
      Note: this potentially breaks custom qemu_configs if people are using
      them! But the fix for them is simple, don't specify multiple arguments
      in one string and don't add on a redundant ''.
      
      It feels a bit iffy to be using a shell in the first place.
      
      There's the usual shenanigans where people could pass in arbitrary shell
      commands via --kernel_arg (since we're just adding '' around the
      kernel_cmdline) or via a custom qemu_config.
      This isn't too much of a concern given the nature of this script (and
      the qemu_config file is in python, you can do w/e you want already).
      
      But it does have some other drawbacks.
      
      One example of a kunit-specific pain point:
      If the relevant qemu binary is missing, we get output like this:
      > /bin/sh: line 1: qemu-system-aarch64: command not found
      This in turn results in our KTAP parser complaining about
      missing/invalid KTAP, but we don't directly show the error!
      It's even more annoying to debug when you consider --raw_output only
      shows KUnit output by default, i.e. you need --raw_output=all to see it.
      
      Whereas directly invoking the binary, Python will raise a
      FileNotFoundError for us, which is a noisier but more clear.
      
      Making this change requires
      * splitting parameters like ['-m 256'] into ['-m', '256'] in
        kunit/qemu_configs/*.py
      * change [''] to [] in kunit/qemu_configs/*.py since otherwise
        QEMU fails w/ 'Device needs media, but drive is empty'
      * dropping explicit quoting of the kernel cmdline
      * using shlex.quote() when we print what command we're running
        so the user can copy-paste and run it
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      3f0a50f3
    • Daniel Latypov's avatar
      kunit: tool: update test counts summary line format · c2497643
      Daniel Latypov authored
      Before:
      > Testing complete. Passed: 137, Failed: 0, Crashed: 0, Skipped: 36, Errors: 0
      
      After:
      > Testing complete. Ran 173 tests: passed: 137, skipped: 36
      
      Even with our current set of statuses, the output is a bit verbose.
      It could get worse in the future if we add more (e.g. timeout, kasan).
      Let's only print the relevant ones.
      
      I had previously been sympathetic to the argument that always
      printing out all the statuses would make it easier to parse results.
      But now we have commit acd8e840 ("kunit: Print test statistics on
      failure"), there are test counts printed out in the raw output.
      We don't currently print out an overall total across all suites, but it
      would be easy to add, if we see a need for that.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Co-developed-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      c2497643
    • Daniel Latypov's avatar
      kunit: bail out of test filtering logic quicker if OOM · a02353f4
      Daniel Latypov authored
      When filtering what tests to run (suites and/or cases) via
      kunit.filter_glob (e.g. kunit.py run <glob>), we allocate copies of
      suites.
      
      These allocations can fail, and we largely don't handle that.
      Note: realistically, this probably doesn't matter much.
      We're not allocating much memory and this happens early in boot, so if
      we can't do that, then there's likely far bigger problems.
      
      This patch makes us immediately bail out from the top-level function
      (kunit_filter_suites) with -ENOMEM if any of the underlying kmalloc()
      calls return NULL.
      
      Implementation note: we used to return NULL pointers from some functions
      to indicate either that all suites/tests were filtered out or there was
      an error allocating the new array.
      
      We'll log a short error in this case and not run any tests or print a
      TAP header. From a kunit.py user's perspective, they'll get a message
      about missing/invalid TAP output and have to dig into the test.log to
      see it. Since hitting this error seems so unlikely, it's probably fine
      to not invent a way to plumb this error message more visibly.
      
      See also: https://lore.kernel.org/linux-kselftest/20220329103919.2376818-1-lv.ruyi@zte.com.cn/Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
      Reported-by: default avatarLv Ruyi <lv.ruyi@zte.com.cn>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      a02353f4
    • Daniel Latypov's avatar
      lib/Kconfig.debug: change KUnit tests to default to KUNIT_ALL_TESTS · dcbb2ee2
      Daniel Latypov authored
      This is in line with Documentation/dev-tools/kunit/style.rst.
      Some of these tests predate that so they don't follow this convention.
      
      With this and commit b0841b51 ("kunit: arch/um/configs: Enable
      KUNIT_ALL_TESTS by default"), kunit.py will now run these tests by
      default. This hopefully makes it easier to run and maintain the tests.
      If any of these were to start failing, people would notice much quicker.
      
      Note: this commit doesn't update LINEAR_RANGES_TEST since that would
      select its dependency (LINEAR_RANGES). We don't want KUNIT_ALL_TESTS
      to enable anything other than test kconfigs.
      Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarNico Pache <npache@redhat.com>
      Acked-by: default avatarNico Pache <npache@redhat.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      dcbb2ee2
    • David Gow's avatar
      kunit: Rework kunit_resource allocation policy · ad69172e
      David Gow authored
      KUnit's test-managed resources can be created in two ways:
      - Using the kunit_add_resource() family of functions, which accept a
        struct kunit_resource pointer, typically allocated statically or on
        the stack during the test.
      - Using the kunit_alloc_resource() family of functions, which allocate a
        struct kunit_resource using kzalloc() behind the scenes.
      
      Both of these families of functions accept a 'free' function to be
      called when the resource is finally disposed of.
      
      At present, KUnit will kfree() the resource if this 'free' function is
      specified, and will not if it is NULL. However, this can lead
      kunit_alloc_resource() to leak memory (if no 'free' function is passed
      in), or kunit_add_resource() to incorrectly kfree() memory which was
      allocated by some other means (on the stack, as part of a larger
      allocation, etc), if a 'free' function is provided.
      
      Instead, always kfree() if the resource was allocated with
      kunit_alloc_resource(), and never kfree() if it was passed into
      kunit_add_resource() by the user. (If the user of kunit_add_resource()
      wishes the resource be kfree()ed, they can call kfree() on the resource
      from within the 'free' function.
      
      This is implemented by adding a 'should_free' member to
      struct kunit_resource and setting it appropriately. To facilitate this,
      the various resource add/alloc functions have been refactored somewhat,
      making them all call a __kunit_add_resource() helper after setting the
      'should_free' member appropriately. In the process, all other functions
      have been made static inline functions.
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Tested-by: default avatarDaniel Latypov <dlatypov@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      ad69172e
  3. 02 May, 2022 4 commits
  4. 27 Apr, 2022 1 commit
  5. 05 Apr, 2022 2 commits
    • David Gow's avatar
      kunit: Make kunit_remove_resource() idempotent · 59729170
      David Gow authored
      The kunit_remove_resource() function is used to unlink a resource from
      the list of resources in the test, making it no longer show up in
      kunit_find_resource().
      
      However, this could lead to a race condition if two threads called
      kunit_remove_resource() on the same resource at the same time: the
      resource would be removed from the list twice (causing a crash at the
      second list_del()), and the refcount for the resource would be
      decremented twice (instead of once, for the reference held by the
      resource list).
      
      Fix both problems, the first by using list_del_init(), and the second by
      checking if the resource has already been removed using list_empty(),
      and only decrementing its refcount if it has not.
      
      Also add a KUnit test for the kunit_remove_resource() function which
      tests this behaviour.
      Reported-by: default avatarDaniel Latypov <dlatypov@google.com>
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      59729170
    • David Gow's avatar
      list: test: Test the hlist structure · 1ff522b6
      David Gow authored
      Add KUnit tests to the hlist linked-list structure which is used by
      hashtables. This should give coverage of every function and macro in
      list.h, as well as (combined with the KUnit tests for the hash
      functions) get very close to having tests for the hashtable structure.
      
      The tests here mirror the existing list tests, and are found in a new
      suite titled 'hlist'.
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      1ff522b6
  6. 04 Apr, 2022 18 commits
  7. 03 Apr, 2022 4 commits
    • Linus Torvalds's avatar
      Linux 5.18-rc1 · 31231092
      Linus Torvalds authored
      31231092
    • Linus Torvalds's avatar
      Merge tag 'trace-v5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace · 09bb8856
      Linus Torvalds authored
      Pull more tracing updates from Steven Rostedt:
      
       - Rename the staging files to give them some meaning. Just
         stage1,stag2,etc, does not show what they are for
      
       - Check for NULL from allocation in bootconfig
      
       - Hold event mutex for dyn_event call in user events
      
       - Mark user events to broken (to work on the API)
      
       - Remove eBPF updates from user events
      
       - Remove user events from uapi header to keep it from being installed.
      
       - Move ftrace_graph_is_dead() into inline as it is called from hot
         paths and also convert it into a static branch.
      
      * tag 'trace-v5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
        tracing: Move user_events.h temporarily out of include/uapi
        ftrace: Make ftrace_graph_is_dead() a static branch
        tracing: Set user_events to BROKEN
        tracing/user_events: Remove eBPF interfaces
        tracing/user_events: Hold event_mutex during dyn_event_add
        proc: bootconfig: Add null pointer check
        tracing: Rename the staging files for trace_events
      09bb8856
    • Linus Torvalds's avatar
      Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · 34a53ff9
      Linus Torvalds authored
      Pull clk fix from Stephen Boyd:
       "A single revert to fix a boot regression seen when clk_put() started
        dropping rate range requests. It's best to keep various systems
        booting so we'll kick this out and try again next time"
      
      * tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
        Revert "clk: Drop the rate range on clk_put()"
      34a53ff9
    • Linus Torvalds's avatar
      Merge tag 'x86-urgent-2022-04-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 8b5656bc
      Linus Torvalds authored
      Pull x86 fixes from Thomas Gleixner:
       "A set of x86 fixes and updates:
      
         - Make the prctl() for enabling dynamic XSTATE components correct so
           it adds the newly requested feature to the permission bitmap
           instead of overwriting it. Add a selftest which validates that.
      
         - Unroll string MMIO for encrypted SEV guests as the hypervisor
           cannot emulate it.
      
         - Handle supervisor states correctly in the FPU/XSTATE code so it
           takes the feature set of the fpstate buffer into account. The
           feature sets can differ between host and guest buffers. Guest
           buffers do not contain supervisor states. So far this was not an
           issue, but with enabling PASID it needs to be handled in the buffer
           offset calculation and in the permission bitmaps.
      
         - Avoid a gazillion of repeated CPUID invocations in by caching the
           values early in the FPU/XSTATE code.
      
         - Enable CONFIG_WERROR in x86 defconfig.
      
         - Make the X86 defconfigs more useful by adapting them to Y2022
           reality"
      
      * tag 'x86-urgent-2022-04-03' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/fpu/xstate: Consolidate size calculations
        x86/fpu/xstate: Handle supervisor states in XSTATE permissions
        x86/fpu/xsave: Handle compacted offsets correctly with supervisor states
        x86/fpu: Cache xfeature flags from CPUID
        x86/fpu/xsave: Initialize offset/size cache early
        x86/fpu: Remove unused supervisor only offsets
        x86/fpu: Remove redundant XCOMP_BV initialization
        x86/sev: Unroll string mmio with CC_ATTR_GUEST_UNROLL_STRING_IO
        x86/config: Make the x86 defconfigs a bit more usable
        x86/defconfig: Enable WERROR
        selftests/x86/amx: Update the ARCH_REQ_XCOMP_PERM test
        x86/fpu/xstate: Fix the ARCH_REQ_XCOMP_PERM implementation
      8b5656bc