Skip to content
  1. Jan 20, 2022
    • Andy Shevchenko's avatar
      kunit: replace kernel.h with the necessary inclusions · 60c7801b
      Andy Shevchenko authored
      
      
      When kernel.h is used in the headers it adds a lot into dependency hell,
      especially when there are circular dependencies are involved.
      
      Replace kernel.h inclusion with the list of what is really being used.
      
      Link: https://lkml.kernel.org/r/20211213204441.56204-1-andriy.shevchenko@linux.intel.com
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Tested-by: default avatarBrendan Higgins <brendanhiggins@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      60c7801b
    • Isabella Basso's avatar
      test_hash.c: refactor into kunit · 0acc968f
      Isabella Basso authored
      
      
      Use KUnit framework to make tests more easily integrable with CIs.  Even
      though these tests are not yet properly written as unit tests this
      change should help in debugging.
      
      Also remove kernel messages (i.e.  through pr_info) as KUnit handles all
      debugging output and let it handle module init and exit details.
      
      Link: https://lkml.kernel.org/r/20211208183711.390454-6-isabbasso@riseup.net
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Tested-by: default avatarDavid Gow <davidgow@google.com>
      Co-developed-by: default avatarAugusto Durães Camargo <augusto.duraes33@gmail.com>
      Signed-off-by: default avatarAugusto Durães Camargo <augusto.duraes33@gmail.com>
      Co-developed-by: default avatarEnzo Ferreira <ferreiraenzoa@gmail.com>
      Signed-off-by: default avatarEnzo Ferreira <ferreiraenzoa@gmail.com>
      Signed-off-by: default avatarIsabella Basso <isabbasso@riseup.net>
      Cc: Brendan Higgins <brendanhiggins@google.com>
      Cc: Daniel Latypov <dlatypov@google.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0acc968f
    • Isabella Basso's avatar
      lib/Kconfig.debug: properly split hash test kernel entries · 88168bf3
      Isabella Basso authored
      
      
      Split TEST_HASH so that each entry only has one file.
      
      Note that there's no stringhash test file, but actually
      <linux/stringhash.h> tests are performed in lib/test_hash.c.
      
      Link: https://lkml.kernel.org/r/20211208183711.390454-5-isabbasso@riseup.net
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Tested-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarIsabella Basso <isabbasso@riseup.net>
      Cc: Augusto Durães Camargo <augusto.duraes33@gmail.com>
      Cc: Brendan Higgins <brendanhiggins@google.com>
      Cc: Daniel Latypov <dlatypov@google.com>
      Cc: Enzo Ferreira <ferreiraenzoa@gmail.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: kernel test robot <lkp@intel.com>
      Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      88168bf3
    • Isabella Basso's avatar
      test_hash.c: split test_hash_init · 5427d3d7
      Isabella Basso authored
      
      
      Split up test_hash_init so that it calls each test more explicitly
      insofar it is possible without rewriting the entire file.  This aims at
      improving readability.
      
      Split tests performed on string_or as they don't interfere with those
      performed in hash_or.  Also separate pr_info calls about skipped tests
      as they're not part of the tests themselves, but only warn about
      (un)defined arch-specific hash functions.
      
      Link: https://lkml.kernel.org/r/20211208183711.390454-4-isabbasso@riseup.net
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Tested-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarIsabella Basso <isabbasso@riseup.net>
      Cc: Augusto Durães Camargo <augusto.duraes33@gmail.com>
      Cc: Brendan Higgins <brendanhiggins@google.com>
      Cc: Daniel Latypov <dlatypov@google.com>
      Cc: Enzo Ferreira <ferreiraenzoa@gmail.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: kernel test robot <lkp@intel.com>
      Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5427d3d7
    • Isabella Basso's avatar
      test_hash.c: split test_int_hash into arch-specific functions · ae788067
      Isabella Basso authored
      
      
      Split the test_int_hash function to keep its mainloop separate from
      arch-specific chunks, which are only compiled as needed.  This aims at
      improving readability.
      
      Link: https://lkml.kernel.org/r/20211208183711.390454-3-isabbasso@riseup.net
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Tested-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarIsabella Basso <isabbasso@riseup.net>
      Cc: Augusto Durães Camargo <augusto.duraes33@gmail.com>
      Cc: Brendan Higgins <brendanhiggins@google.com>
      Cc: Daniel Latypov <dlatypov@google.com>
      Cc: Enzo Ferreira <ferreiraenzoa@gmail.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: kernel test robot <lkp@intel.com>
      Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ae788067
    • Isabella Basso's avatar
      hash.h: remove unused define directive · fd0a1462
      Isabella Basso authored
      
      
      Patch series "test_hash.c: refactor into KUnit", v3.
      
      We refactored the lib/test_hash.c file into KUnit as part of the student
      group LKCAMP [1] introductory hackathon for kernel development.
      
      This test was pointed to our group by Daniel Latypov [2], so its full
      conversion into a pure KUnit test was our goal in this patch series, but
      we ran into many problems relating to it not being split as unit tests,
      which complicated matters a bit, as the reasoning behind the original
      tests is quite cryptic for those unfamiliar with hash implementations.
      
      Some interesting developments we'd like to highlight are:
      
       - In patch 1/5 we noticed that there was an unused define directive
         that could be removed.
      
       - In patch 4/5 we noticed how stringhash and hash tests are all under
         the lib/test_hash.c file, which might cause some confusion, and we
         also broke those kernel config entries up.
      
      Overall KUnit developments have been made in the other patches in this
      series:
      
      In patches 2/5, 3/5 and 5/5 we refactored the lib/test_hash.c file so as
      to make it more compatible with the KUnit style, whilst preserving the
      original idea of the maintainer who designed it (i.e.  George Spelvin),
      which might be undesirable for unit tests, but we assume it is enough
      for a first patch.
      
      This patch (of 5):
      
      Currently, there exist hash_32() and __hash_32() functions, which were
      introduced in a patch [1] targeting architecture specific optimizations.
      These functions can be overridden on a per-architecture basis to achieve
      such optimizations.  They must set their corresponding define directive
      (HAVE_ARCH_HASH_32 and HAVE_ARCH__HASH_32, respectively) so that header
      files can deal with these overrides properly.
      
      As the supported 32-bit architectures that have their own hash function
      implementation (i.e.  m68k, Microblaze, H8/300, pa-risc) have only been
      making use of the (more general) __hash_32() function (which only lacks
      a right shift operation when compared to the hash_32() function), remove
      the define directive corresponding to the arch-specific hash_32()
      implementation.
      
      [1] https://lore.kernel.org/lkml/20160525073311.5600.qmail@ns.sciencehorizons.net/
      
      [akpm@linux-foundation.org: hash_32_generic() becomes hash_32()]
      
      Link: https://lkml.kernel.org/r/20211208183711.390454-1-isabbasso@riseup.net
      Link: https://lkml.kernel.org/r/20211208183711.390454-2-isabbasso@riseup.net
      Reviewed-by: default avatarDavid Gow <davidgow@google.com>
      Tested-by: default avatarDavid Gow <davidgow@google.com>
      Co-developed-by: default avatarAugusto Durães Camargo <augusto.duraes33@gmail.com>
      Signed-off-by: default avatarAugusto Durães Camargo <augusto.duraes33@gmail.com>
      Co-developed-by: default avatarEnzo Ferreira <ferreiraenzoa@gmail.com>
      Signed-off-by: default avatarEnzo Ferreira <ferreiraenzoa@gmail.com>
      Signed-off-by: default avatarIsabella Basso <isabbasso@riseup.net>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Brendan Higgins <brendanhiggins@google.com>
      Cc: Daniel Latypov <dlatypov@google.com>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
      Cc: kernel test robot <lkp@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      fd0a1462
    • Zhen Lei's avatar
      lib/list_debug.c: print more list debugging context in __list_del_entry_valid() · a31f9336
      Zhen Lei authored
      
      
      Currently, the entry->prev and entry->next are considered to be valid as
      long as they are not LIST_POISON{1|2}.  However, the memory may be
      corrupted.  The prev->next is invalid probably because 'prev' is
      invalid, not because prev->next's content is illegal.
      
      Unfortunately, the printk and its subfunctions will modify the registers
      that hold the 'prev' and 'next', and we don't see this valuable
      information in the BUG context.
      
      So print the contents of 'entry->prev' and 'entry->next'.
      
      Here's an example:
        list_del corruption. prev->next should be c0ecbf74, but was c08410dc
        kernel BUG at lib/list_debug.c:53!
        ... ...
        PC is at __list_del_entry_valid+0x58/0x98
        LR is at __list_del_entry_valid+0x58/0x98
        psr: 60000093
        sp : c0ecbf30  ip : 00000000  fp : 00000001
        r10: c08410d0  r9 : 00000001  r8 : c0825e0c
        r7 : 20000013  r6 : c08410d0  r5 : c0ecbf74  r4 : c0ecbf74
        r3 : c0825d08  r2 : 00000000  r1 : df7ce6f4  r0 : 00000044
        ... ...
        Stack: (0xc0ecbf30 to 0xc0ecc000)
        bf20:                                     c0ecbf74 c0164fd0 c0ecbf70 c0165170
        bf40: c0eca000 c0840c00 c0840c00 c0824500 c0825e0c c0189bbc c088f404 60000013
        bf60: 60000013 c0e85100 000004ec 00000000 c0ebcdc0 c0ecbf74 c0ecbf74 c0825d08
        bf80: c0e807c0 c018965c 00000000 c013f2a0 c0e807c0 c013f154 00000000 00000000
        bfa0: 00000000 00000000 00000000 c01001b0 00000000 00000000 00000000 00000000
        bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
        bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
        (__list_del_entry_valid) from (__list_del_entry+0xc/0x20)
        (__list_del_entry) from (finish_swait+0x60/0x7c)
        (finish_swait) from (rcu_gp_kthread+0x560/0xa20)
        (rcu_gp_kthread) from (kthread+0x14c/0x15c)
        (kthread) from (ret_from_fork+0x14/0x24)
      
      At first, I thought prev->next was overwritten.  Later, I carefully
      analyzed the RCU code and the disassembly code.  The error occurred when
      deleting a node from the list rcu_state.gp_wq.  The System.map shows
      that the address of rcu_state is c0840c00.  Then I use gdb to obtain the
      offset of rcu_state.gp_wq.task_list.
      
        (gdb) p &((struct rcu_state *)0)->gp_wq.task_list
        $1 = (struct list_head *) 0x4dc
      
      Again:
        list_del corruption. prev->next should be c0ecbf74, but was c08410dc
      
        c08410dc = c0840c00 + 0x4dc = &rcu_state.gp_wq.task_list
      
      Because rcu_state.gp_wq has at most one node, so I can guess that "prev
      = &rcu_state.gp_wq.task_list".  But for other scenes, maybe I wasn't so
      lucky, I cannot figure out the value of 'prev'.
      
      Link: https://lkml.kernel.org/r/20211207025835.1909-1-thunder.leizhen@huawei.com
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a31f9336
    • Andy Shevchenko's avatar
      list: introduce list_is_head() helper and re-use it in list.h · 04254730
      Andy Shevchenko authored
      
      
      Introduce list_is_head() in the similar (*) way as it's done for
      list_entry_is_head().  Make use of it in the list.h.
      
      *) it's done as inliner and not a macro to be aligned with other
         list_is_*() APIs; while at it, make all three to have the same
         style.
      
      Link: https://lkml.kernel.org/r/20211201141824.81400-1-andriy.shevchenko@linux.intel.com
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      04254730
    • Alexey Dobriyan's avatar
      kstrtox: uninline everything · 70ac6992
      Alexey Dobriyan authored
      
      
      I've made a mistake of looking into lib/kstrtox.o code generation.
      
      The only function remotely performance critical is _parse_integer()
      (via /proc/*/map_files/*), everything else is not.
      
      Uninline everything, shrink lib/kstrtox.o by ~20 % !
      
      Space savings on x86_64:
      
      	add/remove: 0/0 grow/shrink: 0/23 up/down: 0/-1269 (-1269 !!!)
      	Function                                     old     new   delta
      	kstrtoull                                     16      13      -3
      	kstrtouint                                    59      48     -11
      	kstrtou8                                      60      49     -11
      	kstrtou16                                     61      50     -11
      	_kstrtoul                                     46      35     -11
      	kstrtoull_from_user                           95      83     -12
      	kstrtoul_from_user                            95      83     -12
      	kstrtoll                                      93      80     -13
      	kstrtouint_from_user                         124      83     -41
      	kstrtou8_from_user                           125      83     -42
      	kstrtou16_from_user                          126      83     -43
      	kstrtos8                                     101      50     -51
      	kstrtos16                                    102      51     -51
      	kstrtoint                                    100      49     -51
      	_kstrtol                                      93      35     -58
      	kstrtobool_from_user                         156      75     -81
      	kstrtoll_from_user                           165      83     -82
      	kstrtol_from_user                            165      83     -82
      	kstrtoint_from_user                          172      83     -89
      	kstrtos8_from_user                           173      83     -90
      	kstrtos16_from_user                          174      83     -91
      	_parse_integer                               136      10    -126
      	_kstrtoull                                   308     101    -207
      	Total: Before=3421236, After=3419967, chg -0.04%
      
      Link: https://lkml.kernel.org/r/YZDsFDhHst4m2Pnt@localhost.localdomain
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      70ac6992
    • Randy Dunlap's avatar
      get_maintainer: don't remind about no git repo when --nogit is used · 26d98e9f
      Randy Dunlap authored
      
      
      When --nogit is used with scripts/get_maintainer.pl, the script spews 4
      lines of unnecessary information (noise).  Do not print those lines when
      --nogit is specified.
      
      This change removes the printing of these 4 lines:
      
        ./scripts/get_maintainer.pl: No supported VCS found.  Add --nogit to options?
        Using a git repository produces better results.
        Try Linus Torvalds' latest git repository using:
        git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
      
      Link: https://lkml.kernel.org/r/20220102031424.3328-1-rdunlap@infradead.org
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Joe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      26d98e9f
    • Davidlohr Bueso's avatar
      kernel/sys.c: only take tasklist_lock for get/setpriority(PRIO_PGRP) · 7f8ca0ed
      Davidlohr Bueso authored
      
      
      PRIO_PGRP needs the tasklist_lock mainly to serialize vs setpgid(2), to
      protect against any concurrent change_pid(PIDTYPE_PGID) that can move
      the task from one hlist to another while iterating.
      
      However, the remaining can only rely only on RCU:
      
      PRIO_PROCESS only does the task lookup and never iterates over tasklist
      and we already have an rcu-aware stable pointer.
      
      PRIO_USER is already racy vs setuid(2) so with creds being rcu
      protected, we can end up seeing stale data.  When removing the
      tasklist_lock there can be a race with (i) fork but this is benign as
      the child's nice is inherited and the new task is not observable by the
      user yet either, hence the return semantics do not differ.  And (ii) a
      race with exit, which is a small window and can cause us to miss a task
      which was removed from the list and it had the highest nice.
      
      Similarly change the buggy do_each_thread/while_each_thread combo in
      PRIO_USER for the rcu-safe for_each_process_thread flavor, which doesn't
      make use of next_thread/p->thread_group.
      
      [akpm@linux-foundation.org: coding style fixes]
      
      Link: https://lkml.kernel.org/r/20211210182250.43734-1-dave@stgolabs.net
      Signed-off-by: default avatarDavidlohr Bueso <dbueso@suse.de>
      Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7f8ca0ed
    • Yafang Shao's avatar
      kthread: dynamically allocate memory to store kthread's full name · d6986ce2
      Yafang Shao authored
      
      
      When I was implementing a new per-cpu kthread cfs_migration, I found the
      comm of it "cfs_migration/%u" is truncated due to the limitation of
      TASK_COMM_LEN.  For example, the comm of the percpu thread on CPU10~19
      all have the same name "cfs_migration/1", which will confuse the user.
      This issue is not critical, because we can get the corresponding CPU
      from the task's Cpus_allowed.  But for kthreads corresponding to other
      hardware devices, it is not easy to get the detailed device info from
      task comm, for example,
      
          jbd2/nvme0n1p2-
          xfs-reclaim/sdf
      
      Currently there are so many truncated kthreads:
      
          rcu_tasks_kthre
          rcu_tasks_rude_
          rcu_tasks_trace
          poll_mpt3sas0_s
          ext4-rsv-conver
          xfs-reclaim/sd{a, b, c, ...}
          xfs-blockgc/sd{a, b, c, ...}
          xfs-inodegc/sd{a, b, c, ...}
          audit_send_repl
          ecryptfs-kthrea
          vfio-irqfd-clea
          jbd2/nvme0n1p2-
          ...
      
      We can shorten these names to work around this problem, but it may be
      not applied to all of the truncated kthreads.  Take 'jbd2/nvme0n1p2-'
      for example, it is a nice name, and it is not a good idea to shorten it.
      
      One possible way to fix this issue is extending the task comm size, but
      as task->comm is used in lots of places, that may cause some potential
      buffer overflows.  Another more conservative approach is introducing a
      new pointer to store kthread's full name if it is truncated, which won't
      introduce too much overhead as it is in the non-critical path.  Finally
      we make a dicision to use the second approach.  See also the discussions
      in this thread:
      https://lore.kernel.org/lkml/20211101060419.4682-1-laoar.shao@gmail.com/
      
      After this change, the full name of these truncated kthreads will be
      displayed via /proc/[pid]/comm:
      
          rcu_tasks_kthread
          rcu_tasks_rude_kthread
          rcu_tasks_trace_kthread
          poll_mpt3sas0_statu
          ext4-rsv-conversion
          xfs-reclaim/sdf1
          xfs-blockgc/sdf1
          xfs-inodegc/sdf1
          audit_send_reply
          ecryptfs-kthread
          vfio-irqfd-cleanup
          jbd2/nvme0n1p2-8
      
      Link: https://lkml.kernel.org/r/20211120112850.46047-1-laoar.shao@gmail.com
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Suggested-by: default avatarPetr Mladek <pmladek@suse.com>
      Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d6986ce2
    • Yafang Shao's avatar
      tools/testing/selftests/bpf: replace open-coded 16 with TASK_COMM_LEN · 3087c61e
      Yafang Shao authored
      
      
      As the sched:sched_switch tracepoint args are derived from the kernel,
      we'd better make it same with the kernel.  So the macro TASK_COMM_LEN is
      converted to type enum, then all the BPF programs can get it through
      BTF.
      
      The BPF program which wants to use TASK_COMM_LEN should include the
      header vmlinux.h.  Regarding the test_stacktrace_map and
      test_tracepoint, as the type defined in linux/bpf.h are also defined in
      vmlinux.h, so we don't need to include linux/bpf.h again.
      
      Link: https://lkml.kernel.org/r/20211120112738.45980-8-laoar.shao@gmail.com
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3087c61e
    • Yafang Shao's avatar
      tools/bpf/bpftool/skeleton: replace bpf_probe_read_kernel with... · 4cfb9435
      Yafang Shao authored
      
      tools/bpf/bpftool/skeleton: replace bpf_probe_read_kernel with bpf_probe_read_kernel_str to get task comm
      
      bpf_probe_read_kernel_str() will add a nul terminator to the dst, then
      we don't care about if the dst size is big enough.
      
      Link: https://lkml.kernel.org/r/20211120112738.45980-7-laoar.shao@gmail.com
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4cfb9435
    • Yafang Shao's avatar
      samples/bpf/test_overhead_kprobe_kern: replace bpf_probe_read_kernel with... · d068144d
      Yafang Shao authored
      
      samples/bpf/test_overhead_kprobe_kern: replace bpf_probe_read_kernel with bpf_probe_read_kernel_str to get task comm
      
      bpf_probe_read_kernel_str() will add a nul terminator to the dst, then
      we don't care about if the dst size is big enough.  This patch also
      replaces the hard-coded 16 with TASK_COMM_LEN to make it grepable.
      
      Link: https://lkml.kernel.org/r/20211120112738.45980-6-laoar.shao@gmail.com
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d068144d
    • Yafang Shao's avatar
      fs/binfmt_elf: replace open-coded string copy with get_task_comm · 95af469c
      Yafang Shao authored
      
      
      It is better to use get_task_comm() instead of the open coded string
      copy as we do in other places.
      
      struct elf_prpsinfo is used to dump the task information in userspace
      coredump or kernel vmcore.  Below is the verification of vmcore,
      
        crash> ps
           PID    PPID  CPU       TASK        ST  %MEM     VSZ    RSS  COMM
              0      0   0  ffffffff9d21a940  RU   0.0       0      0  [swapper/0]
        >     0      0   1  ffffa09e40f85e80  RU   0.0       0      0  [swapper/1]
        >     0      0   2  ffffa09e40f81f80  RU   0.0       0      0  [swapper/2]
        >     0      0   3  ffffa09e40f83f00  RU   0.0       0      0  [swapper/3]
        >     0      0   4  ffffa09e40f80000  RU   0.0       0      0  [swapper/4]
        >     0      0   5  ffffa09e40f89f80  RU   0.0       0      0  [swapper/5]
              0      0   6  ffffa09e40f8bf00  RU   0.0       0      0  [swapper/6]
        >     0      0   7  ffffa09e40f88000  RU   0.0       0      0  [swapper/7]
        >     0      0   8  ffffa09e40f8de80  RU   0.0       0      0  [swapper/8]
        >     0      0   9  ffffa09e40f95e80  RU   0.0       0      0  [swapper/9]
        >     0      0  10  ffffa09e40f91f80  RU   0.0       0      0  [swapper/10]
        >     0      0  11  ffffa09e40f93f00  RU   0.0       0      0  [swapper/11]
        >     0      0  12  ffffa09e40f90000  RU   0.0       0      0  [swapper/12]
        >     0      0  13  ffffa09e40f9bf00  RU   0.0       0      0  [swapper/13]
        >     0      0  14  ffffa09e40f98000  RU   0.0       0      0  [swapper/14]
        >     0      0  15  ffffa09e40f9de80  RU   0.0       0      0  [swapper/15]
      
      It works well as expected.
      
      Some comments are added to explain why we use the hard-coded 16.
      
      Link: https://lkml.kernel.org/r/20211120112738.45980-5-laoar.shao@gmail.com
      Suggested-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      95af469c
    • Yafang Shao's avatar
      drivers/infiniband: replace open-coded string copy with get_task_comm · 7b6397d7
      Yafang Shao authored
      
      
      We'd better use the helper get_task_comm() rather than the open-coded
      strlcpy() to get task comm.  As the comment above the hard-coded 16, we
      can replace it with TASK_COMM_LEN.
      
      Link: https://lkml.kernel.org/r/20211120112738.45980-4-laoar.shao@gmail.com
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Acked-by: default avatarDennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7b6397d7
    • Yafang Shao's avatar
      fs/exec: replace strncpy with strscpy_pad in __get_task_comm · 503471ac
      Yafang Shao authored
      
      
      If the dest buffer size is smaller than sizeof(tsk->comm), the buffer
      will be without null ternimator, that may cause problem.  Using
      strscpy_pad() instead of strncpy() in __get_task_comm() can make the
      string always nul ternimated and zero padded.
      
      Link: https://lkml.kernel.org/r/20211120112738.45980-3-laoar.shao@gmail.com
      Suggested-by: default avatarKees Cook <keescook@chromium.org>
      Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      503471ac
    • Yafang Shao's avatar
      fs/exec: replace strlcpy with strscpy_pad in __set_task_comm · 06c5088a
      Yafang Shao authored
      
      
      Patch series "task comm cleanups", v2.
      
      This patchset is part of the patchset "extend task comm from 16 to
      24"[1].  Now we have different opinion that dynamically allocates memory
      to store kthread's long name into a separate pointer, so I decide to
      take the useful cleanups apart from the original patchset and send it
      separately[2].
      
      These useful cleanups can make the usage around task comm less
      error-prone.  Furthermore, it will be useful if we want to extend task
      comm in the future.
      
      [1]. https://lore.kernel.org/lkml/20211101060419.4682-1-laoar.shao@gmail.com/
      [2]. https://lore.kernel.org/lkml/CALOAHbAx55AUo3bm8ZepZSZnw7A08cvKPdPyNTf=E_tPqmw5hw@mail.gmail.com/
      
      This patch (of 7):
      
      strlcpy() can trigger out-of-bound reads on the source string[1], we'd
      better use strscpy() instead.  To make it be robust against full tsk->comm
      copies that got noticed in other places, we should make sure it's zero
      padded.
      
      [1] https://github.com/KSPP/linux/issues/89
      
      Link: https://lkml.kernel.org/r/20211120112738.45980-1-laoar.shao@gmail.com
      Link: https://lkml.kernel.org/r/20211120112738.45980-2-laoar.shao@gmail.com
      Signed-off-by: default avatarYafang Shao <laoar.shao@gmail.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      06c5088a
    • Andy Shevchenko's avatar
      kernel.h: include a note to discourage people from including it in headers · 40cbf09f
      Andy Shevchenko authored
      
      
      Include a note at the top to discourage people from including it in
      headers.
      
      Link: https://lkml.kernel.org/r/20211209150803.4473-1-andriy.shevchenko@linux.intel.com
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      40cbf09f
    • Andy Shevchenko's avatar
      include/linux/unaligned: replace kernel.h with the necessary inclusions · 22c03398
      Andy Shevchenko authored
      
      
      When kernel.h is used in the headers it adds a lot into dependency hell,
      especially when there are circular dependencies are involved.
      
      Replace kernel.h inclusion with the list of what is really being used.
      
      The rest of the changes are induced by the above and may not be split.
      
      Link: https://lkml.kernel.org/r/20211209123823.20425-1-andriy.shevchenko@linux.intel.com
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>	[brcmfmac]
      Acked-by: default avatarKalle Valo <kvalo@kernel.org>
      Cc: Arend van Spriel <aspriel@gmail.com>
      Cc: Franky Lin <franky.lin@broadcom.com>
      Cc: Hante Meuleman <hante.meuleman@broadcom.com>
      Cc: Chi-hsien Lin <chi-hsien.lin@infineon.com>
      Cc: Wright Feng <wright.feng@infineon.com>
      Cc: Chung-hsien Hsu <chung-hsien.hsu@infineon.com>
      Cc: Kalle Valo <kvalo@codeaurora.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      22c03398
    • luo penghao's avatar
      sysctl: remove redundant ret assignment · 7080cead
      luo penghao authored
      
      
      Subsequent if judgments will assign new values to ret, so the statement
      here should be deleted
      
      The clang_analyzer complains as follows:
      
        fs/proc/proc_sysctl.c:
        Value stored to 'ret' is never read
      
      Link: https://lkml.kernel.org/r/20211230063622.586360-1-luo.penghao@zte.com.cn
      Signed-off-by: default avatarluo penghao <luo.penghao@zte.com.cn>
      Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
      Acked-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7080cead
    • Geert Uytterhoeven's avatar
      sysctl: fix duplicate path separator in printed entries · 153ee1c4
      Geert Uytterhoeven authored
      
      
      sysctl_print_dir() always terminates the printed path name with a slash,
      so printing a slash before the file part causes a duplicate like in
      
          sysctl duplicate entry: /kernel//perf_user_access
      
      Fix this by dropping the extra slash.
      
      Link: https://lkml.kernel.org/r/e3054d605dc56f83971e4b6d2f5fa63a978720ad.1641551872.git.geert+renesas@glider.be
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Acked-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      153ee1c4
    • Qi Zheng's avatar
      proc: convert the return type of proc_fd_access_allowed() to be boolean · 51a18734
      Qi Zheng authored
      
      
      Convert return type of proc_fd_access_allowed() and the 'allowed' in it
      to be boolean since the return type of ptrace_may_access() is boolean.
      
      Link: https://lkml.kernel.org/r/20211219024404.29779-1-zhengqi.arch@bytedance.com
      Signed-off-by: default avatarQi Zheng <zhengqi.arch@bytedance.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      51a18734
    • Hans de Goede's avatar
      proc: make the proc_create[_data]() stubs static inlines · ae62fbe2
      Hans de Goede authored
      
      
      Change the proc_create[_data]() stubs which are used when CONFIG_PROC_FS
      is not set from #defines to a static inline stubs.
      
      This should fix clang -Werror builds failing due to errors like this:
      
        drivers/platform/x86/thinkpad_acpi.c:918:30: error: unused variable
         'dispatch_proc_ops' [-Werror,-Wunused-const-variable]
      
      Fixing this in include/linux/proc_fs.h should ensure that the same issue
      is also fixed in any other drivers hitting the same -Werror issue.
      
      [akpm@linux-foundation.org: fix CONFIG_PROC_FS=n]
      [akpm@linux-foundation.org: fix arch/sparc/kernel/led.c]
      [akpm@linux-foundation.org: fix build]
      
      Link: https://lkml.kernel.org/r/20211116131112.508304-1-hdegoede@redhat.com
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ae62fbe2
    • David Hildenbrand's avatar
      proc/vmcore: don't fake reading zeroes on surprise vmcore_cb unregistration · 25bc5b0d
      David Hildenbrand authored
      In commit cc5f2704
      
       ("proc/vmcore: convert oldmem_pfn_is_ram callback
      to more generic vmcore callbacks"), we added detection of surprise
      vmcore_cb unregistration after the vmcore was already opened.  Once
      detected, we warn the user and simulate reading zeroes from that point
      on when accessing the vmcore.
      
      The basic reason was that unexpected unregistration, for example, by
      manually unbinding a driver from a device after opening the vmcore, is
      not supported and could result in reading oldmem the vmcore_cb would
      have actually prohibited while registered.  However, something like that
      can similarly be trigger by a user that's really looking for trouble
      simply by unbinding the relevant driver before opening the vmcore -- or
      by disallowing loading the driver in the first place.  So it's actually
      of limited help.
      
      Currently, unregistration can only be triggered via virtio-mem when
      manually unbinding the driver from the device inside the VM; there is no
      way to trigger it from the hypervisor, as hypervisors don't allow for
      unplugging virtio-mem devices -- ripping out system RAM from a VM
      without coordination with the guest is usually not a good idea.
      
      The important part is that unbinding the driver and unregistering the
      vmcore_cb while concurrently reading the vmcore won't crash the system,
      and that is handled by the rwsem.
      
      To make the mechanism more future proof, let's remove the "read zero"
      part, but leave the warning in place.  For example, we could have a
      future driver (like virtio-balloon) that will contact the hypervisor to
      figure out if we already populated a page for a given PFN.
      Hotunplugging such a device and consequently unregistering the vmcore_cb
      could be triggered from the hypervisor without harming the system even
      while kdump is running.  In that case, we don't want to silently end up
      with a vmcore that contains wrong data, because the user inside the VM
      might be unaware of the hypervisor action and might easily miss the
      warning in the log.
      
      Link: https://lkml.kernel.org/r/20211111192243.22002-1-david@redhat.com
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Philipp Rudo <prudo@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      25bc5b0d
    • Kefeng Wang's avatar
      mm: percpu: add generic pcpu_populate_pte() function · 20c03576
      Kefeng Wang authored
      
      
      With NEED_PER_CPU_PAGE_FIRST_CHUNK enabled, we need a function to
      populate pte, this patch adds a generic pcpu populate pte function,
      pcpu_populate_pte(), which is marked __weak and used on most
      architectures, but it is overridden on x86, which has its own
      implementation.
      
      Link: https://lkml.kernel.org/r/20211216112359.103822-5-wangkefeng.wang@huawei.com
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      20c03576
    • Kefeng Wang's avatar
      mm: percpu: add generic pcpu_fc_alloc/free funciton · 23f91716
      Kefeng Wang authored
      
      
      With the previous patch, we could add a generic pcpu first chunk
      allocate and free function to cleanup the duplicated definations on each
      architecture.
      
      Link: https://lkml.kernel.org/r/20211216112359.103822-4-wangkefeng.wang@huawei.com
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      23f91716
    • Kefeng Wang's avatar
      mm: percpu: add pcpu_fc_cpu_to_node_fn_t typedef · 1ca3fb3a
      Kefeng Wang authored
      
      
      Add pcpu_fc_cpu_to_node_fn_t and pass it into pcpu_fc_alloc_fn_t, pcpu
      first chunk allocation will call it to alloc memblock on the
      corresponding node by it, this is prepare for the next patch.
      
      Link: https://lkml.kernel.org/r/20211216112359.103822-3-wangkefeng.wang@huawei.com
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1ca3fb3a
    • Kefeng Wang's avatar
      mm: percpu: generalize percpu related config · 7ecd19cf
      Kefeng Wang authored
      
      
      Patch series "mm: percpu: Cleanup percpu first chunk function".
      
      When supporting page mapping percpu first chunk allocator on arm64, we
      found there are lots of duplicated codes in percpu embed/page first chunk
      allocator.  This patchset is aimed to cleanup them and should no function
      change.
      
      The currently supported status about 'embed' and 'page' in Archs shows
      below,
      
      	embed: NEED_PER_CPU_PAGE_FIRST_CHUNK
      	page:  NEED_PER_CPU_EMBED_FIRST_CHUNK
      
      		embed	page
      	------------------------
      	arm64	  Y	 Y
      	mips	  Y	 N
      	powerpc	  Y	 Y
      	riscv	  Y	 N
      	sparc	  Y	 Y
      	x86	  Y	 Y
      	------------------------
      
      There are two interfaces about percpu first chunk allocator,
      
       extern int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
                                      size_t atom_size,
                                      pcpu_fc_cpu_distance_fn_t cpu_distance_fn,
      -                               pcpu_fc_alloc_fn_t alloc_fn,
      -                               pcpu_fc_free_fn_t free_fn);
      +                               pcpu_fc_cpu_to_node_fn_t cpu_to_nd_fn);
      
       extern int __init pcpu_page_first_chunk(size_t reserved_size,
      -                               pcpu_fc_alloc_fn_t alloc_fn,
      -                               pcpu_fc_free_fn_t free_fn,
      -                               pcpu_fc_populate_pte_fn_t populate_pte_fn);
      +                               pcpu_fc_cpu_to_node_fn_t cpu_to_nd_fn);
      
      The pcpu_fc_alloc_fn_t/pcpu_fc_free_fn_t is killed, we provide generic
      pcpu_fc_alloc() and pcpu_fc_free() function, which are called in the
      pcpu_embed/page_first_chunk().
      
      1) For pcpu_embed_first_chunk(), pcpu_fc_cpu_to_node_fn_t is needed to be
         provided when archs supported NUMA.
      
      2) For pcpu_page_first_chunk(), the pcpu_fc_populate_pte_fn_t is killed too,
         a generic pcpu_populate_pte() which marked '__weak' is provided, if you
         need a different function to populate pte on the arch(like x86), please
         provide its own implementation.
      
      [1] https://github.com/kevin78/linux.git percpu-cleanup
      
      This patch (of 4):
      
      The HAVE_SETUP_PER_CPU_AREA/NEED_PER_CPU_EMBED_FIRST_CHUNK/
      NEED_PER_CPU_PAGE_FIRST_CHUNK/USE_PERCPU_NUMA_NODE_ID configs, which have
      duplicate definitions on platforms that subscribe it.
      
      Move them into mm, drop these redundant definitions and instead just
      select it on applicable platforms.
      
      Link: https://lkml.kernel.org/r/20211216112359.103822-1-wangkefeng.wang@huawei.com
      Link: https://lkml.kernel.org/r/20211216112359.103822-2-wangkefeng.wang@huawei.com
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Acked-by: Catalin Marinas <catalin.marinas@arm.com>	[arm64]
      Cc: Will Deacon <will@kernel.org>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Tejun Heo <tj@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7ecd19cf
  2. Jan 10, 2022
    • Linus Torvalds's avatar
      Linux 5.16 · df0cc57e
      Linus Torvalds authored
      v5.16
      df0cc57e
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input · e900deb2
      Linus Torvalds authored
      Pull input fix from Dmitry Torokhov:
       "A small fixup to the Zinitix touchscreen driver to avoid enabling the
        IRQ line before we successfully requested it"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
        Input: zinitix - make sure the IRQ is allocated before it gets enabled
      e900deb2
    • Linus Torvalds's avatar
      Merge tag 'soc-fixes-5.16-5' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc · 95350123
      Linus Torvalds authored
      Pull ARM SoC fix from Olof Johansson:
       "One more fix for 5.16
      
        I had missed one patch when I sent up what I thought was the last
        batch of fixes for this release. This one fixes issues on the
        Raspberry Pi platforms due to gpio init changes this release, so
        hopefully we can get it merged before final release is cut"
      
      * tag 'soc-fixes-5.16-5' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc:
        ARM: dts: gpio-ranges property is now required
      95350123
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.16-2022-01-09' of... · 9a12a5aa
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.16-2022-01-09' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Revert "libtraceevent: Increase libtraceevent logging when verbose",
         breaks the build with libtraceevent-1.3.0, i.e. when building with
         'LIBTRACEEVENT_DYNAMIC=1'.
      
       - Avoid early exit in 'perf trace' due to running SIGCHLD handler
         before it makes sense to. It can happen when using a BPF source code
         event that have to be first built into an object file.
      
      * tag 'perf-tools-fixes-for-v5.16-2022-01-09' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        Revert "libtraceevent: Increase libtraceevent logging when verbose"
        perf trace: Avoid early exit due to running SIGCHLD handler before it makes sense to
      9a12a5aa
    • Len Brown's avatar
      Revert "drm/amdgpu: stop scheduler when calling hw_fini (v2)" · df5bc0aa
      Len Brown authored
      This reverts commit f7d6779d.
      
      This bisected regression has impacted suspend-resume stability
      since 5.15-rc1. It regressed -stable via 5.14.10.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=215315
      Fixes: f7d6779d
      
       ("drm/amdgpu: stop scheduler when calling hw_fini (v2)")
      Cc: Guchun Chen <guchun.chen@amd.com>
      Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
      Cc: Christian Koenig <christian.koenig@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: <stable@vger.kernel.org> # 5.14+
      Signed-off-by: default avatarLen Brown <len.brown@intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      df5bc0aa
  3. Jan 09, 2022