An error occurred fetching the project authors.
  1. 21 Mar, 2020 1 commit
    • Peter Zijlstra's avatar
      lockdep: Introduce wait-type checks · de8f5e4f
      Peter Zijlstra authored
      Extend lockdep to validate lock wait-type context.
      
      The current wait-types are:
      
      	LD_WAIT_FREE,		/* wait free, rcu etc.. */
      	LD_WAIT_SPIN,		/* spin loops, raw_spinlock_t etc.. */
      	LD_WAIT_CONFIG,		/* CONFIG_PREEMPT_LOCK, spinlock_t etc.. */
      	LD_WAIT_SLEEP,		/* sleeping locks, mutex_t etc.. */
      
      Where lockdep validates that the current lock (the one being acquired)
      fits in the current wait-context (as generated by the held stack).
      
      This ensures that there is no attempt to acquire mutexes while holding
      spinlocks, to acquire spinlocks while holding raw_spinlocks and so on. In
      other words, its a more fancy might_sleep().
      
      Obviously RCU made the entire ordeal more complex than a simple single
      value test because RCU can be acquired in (pretty much) any context and
      while it presents a context to nested locks it is not the same as it
      got acquired in.
      
      Therefore its necessary to split the wait_type into two values, one
      representing the acquire (outer) and one representing the nested context
      (inner). For most 'normal' locks these two are the same.
      
      [ To make static initialization easier we have the rule that:
        .outer == INV means .outer == .inner; because INV == 0. ]
      
      It further means that its required to find the minimal .inner of the held
      stack to compare against the outer of the new lock; because while 'normal'
      RCU presents a CONFIG type to nested locks, if it is taken while already
      holding a SPIN type it obviously doesn't relax the rules.
      
      Below is an example output generated by the trivial test code:
      
        raw_spin_lock(&foo);
        spin_lock(&bar);
        spin_unlock(&bar);
        raw_spin_unlock(&foo);
      
       [ BUG: Invalid wait context ]
       -----------------------------
       swapper/0/1 is trying to lock:
       ffffc90000013f20 (&bar){....}-{3:3}, at: kernel_init+0xdb/0x187
       other info that might help us debug this:
       1 lock held by swapper/0/1:
        #0: ffffc90000013ee0 (&foo){+.+.}-{2:2}, at: kernel_init+0xd1/0x187
      
      The way to read it is to look at the new -{n,m} part in the lock
      description; -{3:3} for the attempted lock, and try and match that up to
      the held locks, which in this case is the one: -{2,2}.
      
      This tells that the acquiring lock requires a more relaxed environment than
      presented by the lock stack.
      
      Currently only the normal locks and RCU are converted, the rest of the
      lockdep users defaults to .inner = INV which is ignored. More conversions
      can be done when desired.
      
      The check for spinlock_t nesting is not enabled by default. It's a separate
      config option for now as there are known problems which are currently
      addressed. The config option allows to identify these problems and to
      verify that the solutions found are indeed solving them.
      
      The config switch will be removed and the checks will permanently enabled
      once the vast majority of issues has been addressed.
      
      [ bigeasy: Move LD_WAIT_FREE,… out of CONFIG_LOCKDEP to avoid compile
      	   failure with CONFIG_DEBUG_SPINLOCK + !CONFIG_LOCKDEP]
      [ tglx: Add the config option ]
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20200321113242.427089655@linutronix.de
      de8f5e4f
  2. 09 Jan, 2020 1 commit
    • Alan Maguire's avatar
      kunit: allow kunit tests to be loaded as a module · c475c77d
      Alan Maguire authored
      As tests are added to kunit, it will become less feasible to execute
      all built tests together.  By supporting modular tests we provide
      a simple way to do selective execution on a running system; specifying
      
      CONFIG_KUNIT=y
      CONFIG_KUNIT_EXAMPLE_TEST=m
      
      ...means we can simply "insmod example-test.ko" to run the tests.
      
      To achieve this we need to do the following:
      
      o export the required symbols in kunit
      o string-stream tests utilize non-exported symbols so for now we skip
        building them when CONFIG_KUNIT_TEST=m.
      o drivers/base/power/qos-test.c contains a few unexported interface
        references, namely freq_qos_read_value() and freq_constraints_init().
        Both of these could be potentially defined as static inline functions
        in include/linux/pm_qos.h, but for now we simply avoid supporting
        module build for that test suite.
      o support a new way of declaring test suites.  Because a module cannot
        do multiple late_initcall()s, we provide a kunit_test_suites() macro
        to declare multiple suites within the same module at once.
      o some test module names would have been too general ("test-test"
        and "example-test" for kunit tests, "inode-test" for ext4 tests);
        rename these as appropriate ("kunit-test", "kunit-example-test"
        and "ext4-inode-test" respectively).
      
      Also define kunit_test_suite() via kunit_test_suites()
      as callers in other trees may need the old definition.
      Co-developed-by: default avatarKnut Omang <knut.omang@oracle.com>
      Signed-off-by: default avatarKnut Omang <knut.omang@oracle.com>
      Signed-off-by: default avatarAlan Maguire <alan.maguire@oracle.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Acked-by: Theodore Ts'o <tytso@mit.edu> # for ext4 bits
      Acked-by: David Gow <davidgow@google.com> # For list-test
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      c475c77d
  3. 18 Dec, 2019 1 commit
  4. 08 Dec, 2019 1 commit
  5. 07 Dec, 2019 10 commits
  6. 22 Nov, 2019 1 commit
  7. 14 Nov, 2019 1 commit
    • Masahiro Yamada's avatar
      kbuild: move headers_check rule to usr/include/Makefile · 7ecaf069
      Masahiro Yamada authored
      Currently, some sanity checks for uapi headers are done by
      scripts/headers_check.pl, which is wired up to the 'headers_check'
      target in the top Makefile.
      
      It is true compiling headers has better test coverage, but there
      are still several headers excluded from the compile test. I like
      to keep headers_check.pl for a while, but we can delete a lot of
      code by moving the build rule to usr/include/Makefile.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      7ecaf069
  8. 01 Nov, 2019 1 commit
    • David Gow's avatar
      lib/list-test: add a test for the 'list' doubly linked list · ea2dd7c0
      David Gow authored
      Add a KUnit test for the kernel doubly linked list implementation in
      include/linux/list.h
      
      Each test case (list_test_x) is focused on testing the behaviour of the
      list function/macro 'x'. None of the tests pass invalid lists to these
      macros, and so should behave identically with DEBUG_LIST enabled and
      disabled.
      
      Note that, at present, it only tests the list_ types (not the
      singly-linked hlist_), and does not yet test all of the
      list_for_each_entry* macros (and some related things like
      list_prepare_entry).
      
      Ignoring checkpatch.pl spurious errors related to its handling of for_each
      and other list macros. checkpatch.pl expects anything with for_each in its
      name to be a loop and expects that the open brace is placed on the same
      line as for a for loop. In this case, test case naming scheme includes
      name of the macro it is testing, which results in the spurious errors.
      Commit message updated by Shuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarDavid Gow <davidgow@google.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Tested-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      ea2dd7c0
  9. 17 Oct, 2019 1 commit
    • Rasmus Villemoes's avatar
      printf: add support for printing symbolic error names · 57f5677e
      Rasmus Villemoes authored
      It has been suggested several times to extend vsnprintf() to be able
      to convert the numeric value of ENOSPC to print "ENOSPC". This
      implements that as a %p extension: With %pe, one can do
      
        if (IS_ERR(foo)) {
          pr_err("Sorry, can't do that: %pe\n", foo);
          return PTR_ERR(foo);
        }
      
      instead of what is seen in quite a few places in the kernel:
      
        if (IS_ERR(foo)) {
          pr_err("Sorry, can't do that: %ld\n", PTR_ERR(foo));
          return PTR_ERR(foo);
        }
      
      If the value passed to %pe is an ERR_PTR, but the library function
      errname() added here doesn't know about the value, the value is simply
      printed in decimal. If the value passed to %pe is not an ERR_PTR, we
      treat it as an ordinary %p and thus print the hashed value (passing
      non-ERR_PTR values to %pe indicates a bug in the caller, but we can't
      do much about that).
      
      With my embedded hat on, and because it's not very invasive to do,
      I've made it possible to remove this. The errname() function and
      associated lookup tables take up about 3K. For most, that's probably
      quite acceptable and a price worth paying for more readable
      dmesg (once this starts getting used), while for those that disable
      printk() it's of very little use - I don't see a
      procfs/sysfs/seq_printf() file reasonably making use of this - and
      they clearly want to squeeze vmlinux as much as possible. Hence the
      default y if PRINTK.
      
      The symbols to include have been found by massaging the output of
      
        find arch include -iname 'errno*.h' | xargs grep -E 'define\s*E'
      
      In the cases where some common aliasing exists
      (e.g. EAGAIN=EWOULDBLOCK on all platforms, EDEADLOCK=EDEADLK on most),
      I've moved the more popular one (in terms of 'git grep -w Efoo | wc)
      to the bottom so that one takes precedence.
      
      Link: http://lkml.kernel.org/r/20191015190706.15989-1-linux@rasmusvillemoes.dk
      To: "Jonathan Corbet" <corbet@lwn.net>
      To: linux-kernel@vger.kernel.org
      Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>
      Cc: "Andrew Morton" <akpm@linux-foundation.org>
      Cc: "Joe Perches" <joe@perches.com>
      Cc: linux-doc@vger.kernel.org
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Acked-by: default avatarUwe Kleine-König <uwe@kleine-koenig.org>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      [andy.shevchenko@gmail.com: use abs()]
      Acked-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      57f5677e
  10. 30 Sep, 2019 2 commits
  11. 26 Sep, 2019 1 commit
  12. 24 Sep, 2019 3 commits
  13. 11 Sep, 2019 1 commit
  14. 17 Jul, 2019 2 commits
    • Masahiro Yamada's avatar
      kbuild: create *.mod with full directory path and remove MODVERDIR · b7dca6dd
      Masahiro Yamada authored
      While descending directories, Kbuild produces objects for modules,
      but do not link final *.ko files; it is done in the modpost.
      
      To keep track of modules, Kbuild creates a *.mod file in $(MODVERDIR)
      for every module it is building. Some post-processing steps read the
      necessary information from *.mod files. This avoids descending into
      directories again. This mechanism was introduced in 2003 or so.
      
      Later, commit 551559e1 ("kbuild: implement modules.order") added
      modules.order. So, we can simply read it out to know all the modules
      with directory paths. This is easier than parsing the first line of
      *.mod files.
      
      $(MODVERDIR) has a flat directory structure, that is, *.mod files
      are named only with base names. This is based on the assumption that
      the module name is unique across the tree. This assumption is really
      fragile.
      
      Stephen Rothwell reported a race condition caused by a module name
      conflict:
      
        https://lkml.org/lkml/2019/5/13/991
      
      In parallel building, two different threads could write to the same
      $(MODVERDIR)/*.mod simultaneously.
      
      Non-unique module names are the source of all kind of troubles, hence
      commit 3a48a919 ("kbuild: check uniqueness of module names")
      introduced a new checker script.
      
      However, it is still fragile in the build system point of view because
      this race happens before scripts/modules-check.sh is invoked. If it
      happens again, the modpost will emit unclear error messages.
      
      To fix this issue completely, create *.mod with full directory path
      so that two threads never attempt to write to the same file.
      
      $(MODVERDIR) is no longer needed.
      
      Since modules with directory paths are listed in modules.order, Kbuild
      is still able to find *.mod files without additional descending.
      
      I also killed cmd_secanalysis; scripts/mod/sumversion.c computes MD4 hash
      for modules with MODULE_VERSION(). When CONFIG_DEBUG_SECTION_MISMATCH=y,
      it occurs not only in the modpost stage, but also during directory
      descending, where sumversion.c may parse stale *.mod files. It would emit
      'No such file or directory' warning when an object consisting a module is
      renamed, or when a single-obj module is turned into a multi-obj module or
      vice versa.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarNicolas Pitre <nico@fluxnic.net>
      b7dca6dd
    • Alexander Potapenko's avatar
      lib: introduce test_meminit module · 5015a300
      Alexander Potapenko authored
      Add tests for heap and pagealloc initialization.  These can be used to
      check init_on_alloc and init_on_free implementations as well as other
      approaches to initialization.
      
      Expected test output in the case the kernel provides heap initialization
      (e.g.  when running with either init_on_alloc=1 or init_on_free=1):
      
        test_meminit: all 10 tests in test_pages passed
        test_meminit: all 40 tests in test_kvmalloc passed
        test_meminit: all 60 tests in test_kmemcache passed
        test_meminit: all 10 tests in test_rcu_persistent passed
        test_meminit: all 120 tests passed!
      
      Link: http://lkml.kernel.org/r/20190529123812.43089-4-glider@google.comSigned-off-by: default avatarAlexander Potapenko <glider@google.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Kostya Serebryany <kcc@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Sandeep Patil <sspatil@android.com>
      Cc: Laura Abbott <labbott@redhat.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Marco Elver <elver@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5015a300
  15. 15 Jul, 2019 1 commit
    • Mauro Carvalho Chehab's avatar
      docs: locking: convert docs to ReST and rename to *.rst · 387b1468
      Mauro Carvalho Chehab authored
      Convert the locking documents to ReST and add them to the
      kernel development book where it belongs.
      
      Most of the stuff here is just to make Sphinx to properly
      parse the text file, as they're already in good shape,
      not requiring massive changes in order to be parsed.
      
      The conversion is actually:
        - add blank lines and identation in order to identify paragraphs;
        - fix tables markups;
        - add some lists markups;
        - mark literal blocks;
        - adjust title markups.
      
      At its new index.rst, let's add a :orphan: while this is not linked to
      the main index.rst file, in order to avoid build warnings.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Acked-by: default avatarFederico Vaga <federico.vaga@vaga.pv.it>
      387b1468
  16. 02 Jul, 2019 1 commit
  17. 26 Jun, 2019 1 commit
    • Ferdinand Blomqvist's avatar
      rslib: Add tests for the encoder and decoder · 4b4f3acc
      Ferdinand Blomqvist authored
      A Reed-Solomon code with minimum distance d can correct any error and
      erasure pattern that satisfies 2 * #error + #erasures < d. If the
      error correction capacity is exceeded, then correct decoding cannot be
      guaranteed. The decoder must, however, return a valid codeword or report
      failure.
      
      There are two main tests:
      
      - Check for correct behaviour up to the error correction capacity
      - Check for correct behaviour beyond error corrupted capacity
      
      Both tests are simple:
      
      1. Generate random data
      2. Encode data with the chosen code
      3. Add errors and erasures to data
      4. Decode the corrupted word
      5. Check for correct behaviour
      
      When testing up to capacity we test for:
      
      - Correct decoding
      - Correct return value (i.e. the number of corrected symbols)
      - That the returned error positions are correct
      
      There are two kinds of erasures; the erased symbol can be corrupted or
      not. When counting the number of corrected symbols, erasures without
      symbol corruption should not be counted. Similarly, the returned error
      positions should only include positions where a correction is necessary.
      
      We run the up to capacity tests for three different interfaces of
      decode_rs:
      
      - Use the correction buffers
      - Use the correction buffers with syndromes provided by the caller
      - Error correction in place (does not check the error positions)
      
      When testing beyond capacity test for silent failures. A silent failure is
      when the decoder returns success but the returned word is not a valid
      codeword.
      
      There are a couple of options for the tests:
      
      - Verbosity.
      
      - Whether to test for correct behaviour beyond capacity. Default is to
        test beyond capacity.
      
      - Whether to allow erasures without symbol corruption. Defaults to yes.
      
      Note that the tests take a couple of minutes to complete.
      Signed-off-by: default avatarFerdinand Blomqvist <ferdinand.blomqvist@gmail.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20190620141039.9874-2-ferdinand.blomqvist@gmail.com
      4b4f3acc
  18. 17 Jun, 2019 1 commit
  19. 15 Jun, 2019 3 commits
    • Masahiro Yamada's avatar
      kbuild: add 'headers' target to build up uapi headers in usr/include · 59b2bd05
      Masahiro Yamada authored
      In Linux build system, build targets and installation targets are
      separated.
      
      Examples are:
      
       - 'make vmlinux' -> 'make install'
       - 'make modules' -> 'make modules_install'
       - 'make dtbs'    -> 'make dtbs_install'
       - 'make vdso'    -> 'make vdso_install'
      
      The intention is to run the build targets under the normal privilege,
      then the installation targets under the root privilege since we need
      the write permission to the system directories.
      
      We have 'make headers_install' but the corresponding 'make headers'
      stage does not exist. The purpose of headers_install is to provide
      the kernel interface to C library. So, nobody would try to install
      headers to /usr/include directly.
      
      If 'sudo make INSTALL_HDR_PATH=/usr/include headers_install' were run,
      some build artifacts in the kernel tree would be owned by root because
      some of uapi headers are generated by 'uapi-asm-generic', 'archheaders'
      targets.
      
      Anyway, I believe it makes sense to split the header installation into
      two stages.
      
       [1] 'make headers'
          Process headers in uapi directories by scripts/headers_install.sh
          and copy them to usr/include
      
       [2] 'make headers_install'
          Copy '*.h' verbatim from usr/include to $(INSTALL_HDR_PATH)/include
      
      For the backward compatibility, 'headers_install' depends on 'headers'.
      
      Some samples expect uapi headers in usr/include. So, the 'headers'
      target is useful to build up them in the fixed location usr/include
      irrespective of INSTALL_HDR_PATH.
      
      Another benefit is to stop polluting the final destination with the
      time-stamp files '.install' and '.check'. Maybe you can see them in
      your toolchains.
      
      Lastly, my main motivation is to prepare for compile-testing uapi
      headers. To build something, we have to save an object and .*.cmd
      somewhere. The usr/include/ will be the work directory for that.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      59b2bd05
    • Masahiro Yamada's avatar
      kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of samples · e949f4c2
      Masahiro Yamada authored
      Commit 5318321d ("samples: disable CONFIG_SAMPLES for UML") used
      a big hammer to fix the build errors under the samples/ directory.
      Only some samples actually include uapi headers from usr/include.
      
      Introduce CONFIG_HEADERS_INSTALL since 'depends on HEADERS_INSTALL' is
      clearer than 'depends on !UML'. If this option is enabled, uapi headers
      are installed before starting directory descending.
      
      I added 'depends on HEADERS_INSTALL' to per-sample CONFIG options.
      This allows UML to compile some samples.
      
      $ make ARCH=um allmodconfig samples/
        [ snip ]
        CC [M]  samples/configfs/configfs_sample.o
        CC [M]  samples/kfifo/bytestream-example.o
        CC [M]  samples/kfifo/dma-example.o
        CC [M]  samples/kfifo/inttype-example.o
        CC [M]  samples/kfifo/record-example.o
        CC [M]  samples/kobject/kobject-example.o
        CC [M]  samples/kobject/kset-example.o
        CC [M]  samples/trace_events/trace-events-sample.o
        CC [M]  samples/trace_printk/trace-printk.o
        AR      samples/vfio-mdev/built-in.a
        AR      samples/built-in.a
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e949f4c2
    • Masahiro Yamada's avatar
      kbuild: fix Kconfig prompt of CONFIG_HEADERS_CHECK · c6509a24
      Masahiro Yamada authored
      Prior to commit 257edce6 ("kbuild: exploit parallel building for
      CONFIG_HEADERS_CHECK"), the sanity check of exported headers was done
      as a side-effect of build rule of vmlinux.
      
      That commit is good, but I missed to update the prompt of the Kconfig
      entry. For the sake of preciseness, lets' say "when building 'all'".
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      c6509a24
  20. 14 Jun, 2019 1 commit
  21. 12 Jun, 2019 1 commit
  22. 21 May, 2019 1 commit
  23. 16 May, 2019 1 commit
    • Qian Cai's avatar
      slab: remove /proc/slab_allocators · 7878c231
      Qian Cai authored
      It turned out that DEBUG_SLAB_LEAK is still broken even after recent
      recue efforts that when there is a large number of objects like
      kmemleak_object which is normal on a debug kernel,
      
        # grep kmemleak /proc/slabinfo
        kmemleak_object   2243606 3436210 ...
      
      reading /proc/slab_allocators could easily loop forever while processing
      the kmemleak_object cache and any additional freeing or allocating
      objects will trigger a reprocessing. To make a situation worse,
      soft-lockups could easily happen in this sitatuion which will call
      printk() to allocate more kmemleak objects to guarantee an infinite
      loop.
      
      Also, since it seems no one had noticed when it was totally broken
      more than 2-year ago - see the commit fcf88917 ("slab: fix a crash
      by reading /proc/slab_allocators"), probably nobody cares about it
      anymore due to the decline of the SLAB. Just remove it entirely.
      Suggested-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7878c231
  24. 15 May, 2019 2 commits