1. 22 Jan, 2022 40 commits
    • Vlastimil Babka's avatar
      lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() · 2dba5eb1
      Vlastimil Babka authored
      Currently, enabling CONFIG_STACKDEPOT means its stack_table will be
      allocated from memblock, even if stack depot ends up not actually used.
      The default size of stack_table is 4MB on 32-bit, 8MB on 64-bit.
      
      This is fine for use-cases such as KASAN which is also a config option
      and has overhead on its own.  But it's an issue for functionality that
      has to be actually enabled on boot (page_owner) or depends on hardware
      (GPU drivers) and thus the memory might be wasted.  This was raised as
      an issue [1] when attempting to add stackdepot support for SLUB's debug
      object tracking functionality.  It's common to build kernels with
      CONFIG_SLUB_DEBUG and enable slub_debug on boot only when needed, or
      create only specific kmem caches with debugging for testing purposes.
      
      It would thus be more efficient if stackdepot's table was allocated only
      when actually going to be used.  This patch thus makes the allocation
      (and whole stack_depot_init() call) optional:
      
       - Add a CONFIG_STACKDEPOT_ALWAYS_INIT flag to keep using the current
         well-defined point of allocation as part of mem_init(). Make
         CONFIG_KASAN select this flag.
      
       - Other users have to call stack_depot_init() as part of their own init
         when it's determined that stack depot will actually be used. This may
         depend on both config and runtime conditions. Convert current users
         which are page_owner and several in the DRM subsystem. Same will be
         done for SLUB later.
      
       - Because the init might now be called after the boot-time memblock
         allocation has given all memory to the buddy allocator, change
         stack_depot_init() to allocate stack_table with kvmalloc() when
         memblock is no longer available. Also handle allocation failure by
         disabling stackdepot (could have theoretically happened even with
         memblock allocation previously), and don't unnecessarily align the
         memblock allocation to its own size anymore.
      
      [1] https://lore.kernel.org/all/CAMuHMdW=eoVzM1Re5FVoEN87nKfiLmM2+Ah7eNu2KXEhCvbZyA@mail.gmail.com/
      
      Link: https://lkml.kernel.org/r/20211013073005.11351-1-vbabka@suse.czSigned-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Reviewed-by: Marco Elver <elver@google.com> # stackdepot
      Cc: Marco Elver <elver@google.com>
      Cc: Vijayanand Jitta <vjitta@codeaurora.org>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Oliver Glitta <glittao@gmail.com>
      Cc: Imran Khan <imran.f.khan@oracle.com>
      From: Colin Ian King <colin.king@canonical.com>
      Subject: lib/stackdepot: fix spelling mistake and grammar in pr_err message
      
      There is a spelling mistake of the work allocation so fix this and
      re-phrase the message to make it easier to read.
      
      Link: https://lkml.kernel.org/r/20211015104159.11282-1-colin.king@canonical.comSigned-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      From: Vlastimil Babka <vbabka@suse.cz>
      Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup
      
      On FLATMEM, we call page_ext_init_flatmem_late() just before
      kmem_cache_init() which means stack_depot_init() (called by page owner
      init) will not recognize properly it should use kvmalloc() and not
      memblock_alloc().  memblock_alloc() will also not issue a warning and
      return a block memory that can be invalid and cause kernel page fault when
      saving stacks, as reported by the kernel test robot [1].
      
      Fix this by moving page_ext_init_flatmem_late() below kmem_cache_init() so
      that slab_is_available() is true during stack_depot_init().  SPARSEMEM
      doesn't have this issue, as it doesn't do page_ext_init_flatmem_late(),
      but a different page_ext_init() even later in the boot process.
      
      Thanks to Mike Rapoport for pointing out the FLATMEM init ordering issue.
      
      While at it, also actually resolve a checkpatch warning in stack_depot_init()
      from DRM CI, which was supposed to be in the original patch already.
      
      [1] https://lore.kernel.org/all/20211014085450.GC18719@xsang-OptiPlex-9020/
      
      Link: https://lkml.kernel.org/r/6abd9213-19a9-6d58-cedc-2414386d2d81@suse.czSigned-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Cc: Mike Rapoport <rppt@kernel.org>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      From: Vlastimil Babka <vbabka@suse.cz>
      Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup3
      
      Due to cd06ab2f ("drm/locking: add backtrace for locking contended
      locks without backoff") landing recently to -next adding a new stack depot
      user in drivers/gpu/drm/drm_modeset_lock.c we need to add an appropriate
      call to stack_depot_init() there as well.
      
      Link: https://lkml.kernel.org/r/2a692365-cfa1-64f2-34e0-8aa5674dce5e@suse.czSigned-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
      Cc: Marco Elver <elver@google.com>
      Cc: Vijayanand Jitta <vjitta@codeaurora.org>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Oliver Glitta <glittao@gmail.com>
      Cc: Imran Khan <imran.f.khan@oracle.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      From: Vlastimil Babka <vbabka@suse.cz>
      Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup4
      
      Due to 4e66934e ("lib: add reference counting tracking
      infrastructure") landing recently to net-next adding a new stack depot
      user in lib/ref_tracker.c we need to add an appropriate call to
      stack_depot_init() there as well.
      
      Link: https://lkml.kernel.org/r/45c1b738-1a2f-5b5f-2f6d-86fab206d01c@suse.czSigned-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Jiri Slab <jirislaby@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2dba5eb1
    • Muchun Song's avatar
      proc: remove PDE_DATA() completely · 359745d7
      Muchun Song authored
      Remove PDE_DATA() completely and replace it with pde_data().
      
      [akpm@linux-foundation.org: fix naming clash in drivers/nubus/proc.c]
      [akpm@linux-foundation.org: now fix it properly]
      
      Link: https://lkml.kernel.org/r/20211124081956.87711-2-songmuchun@bytedance.comSigned-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      359745d7
    • Muchun Song's avatar
      fs: proc: store PDE()->data into inode->i_private · 6dfbbae1
      Muchun Song authored
      PDE_DATA(inode) is introduced to get user private data and hide the
      layout of struct proc_dir_entry.  The inode->i_private is used to do the
      same thing as well.  Save a copy of user private data to inode->
      i_private when proc inode is allocated.  This means the user also can
      get their private data by inode->i_private.
      
      Introduce pde_data() to wrap inode->i_private so that we can remove
      PDE_DATA() from fs/proc/generic.c and make PTE_DATE() as a wrapper of
      pde_data().  It will be easier if we decide to remove PDE_DATE() in the
      future.
      
      Link: https://lkml.kernel.org/r/20211124081956.87711-1-songmuchun@bytedance.comSigned-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6dfbbae1
    • Mike Galbraith's avatar
      zsmalloc: replace get_cpu_var with local_lock · a3726599
      Mike Galbraith authored
      The usage of get_cpu_var() in zs_map_object() is problematic because it
      disables preemption and makes it impossible to acquire any sleeping lock
      on PREEMPT_RT such as a spinlock_t.
      
      Replace the get_cpu_var() usage with a local_lock_t which is embedded
      struct mapping_area.  It ensures that the access the struct is
      synchronized against all users on the same CPU.
      
      [minchan: remove the bit_spin_lock part and change the title]
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-10-minchan@kernel.orgSigned-off-by: default avatarMike Galbraith <umgwanakikbuti@gmail.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a3726599
    • Minchan Kim's avatar
      zsmalloc: replace per zpage lock with pool->migrate_lock · b475d42d
      Minchan Kim authored
      The zsmalloc has used a bit for spin_lock in zpage handle to keep zpage
      object alive during several operations.  However, it causes the problem
      for PREEMPT_RT as well as introducing too complicated.
      
      This patch replaces the bit spin_lock with pool->migrate_lock rwlock.
      It could make the code simple as well as zsmalloc work under PREEMPT_RT.
      
      The drawback is the pool->migrate_lock is bigger granuarity than per
      zpage lock so the contention would be higher than old when both
      IO-related operations(i.e., zsmalloc, zsfree, zs_[map|unmap]) and
      compaction(page/zpage migration) are going in parallel(*, the
      migrate_lock is rwlock and IO related functions are all read side lock
      so there is no contention).  However, the write-side is fast
      enough(dominant overhead is just page copy) so it wouldn't affect much.
      If the lock granurity becomes more problem later, we could introduce
      table locks based on handle as a hash value.
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-9-minchan@kernel.orgSigned-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b475d42d
    • Minchan Kim's avatar
      locking/rwlocks: introduce write_lock_nested · 4a57d6bb
      Minchan Kim authored
      In preparation for converting bit_spin_lock to rwlock in zsmalloc so
      that multiple writers of zspages can run at the same time but those
      zspages are supposed to be different zspage instance.  Thus, it's not
      deadlock.  This patch adds write_lock_nested to support the case for
      LOCKDEP.
      
      [minchan@kernel.org: fix write_lock_nested for RT]
        Link: https://lkml.kernel.org/r/YZfrMTAXV56HFWJY@google.com
      [bigeasy@linutronix.de: fixup write_lock_nested() implementation]
        Link: https://lkml.kernel.org/r/20211123170134.y6xb7pmpgdn4m3bn@linutronix.de
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-8-minchan@kernel.orgSigned-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4a57d6bb
    • Minchan Kim's avatar
      zsmalloc: remove zspage isolation for migration · c4549b87
      Minchan Kim authored
      zspage isolation for migration introduced additional exceptions to be
      dealt with since the zspage was isolated from class list.  The reason
      why I isolated zspage from class list was to prevent race between
      obj_malloc and page migration via allocating zpage from the zspage
      further.  However, it couldn't prevent object freeing from zspage so it
      needed corner case handling.
      
      This patch removes the whole mess.  Now, we are fine since class->lock
      and zspage->lock can prevent the race.
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-7-minchan@kernel.orgSigned-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c4549b87
    • Minchan Kim's avatar
      zsmalloc: move huge compressed obj from page to zspage · a41ec880
      Minchan Kim authored
      The flag aims for zspage, not per page.  Let's move it to zspage.
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-6-minchan@kernel.orgSigned-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a41ec880
    • Minchan Kim's avatar
      zsmalloc: introduce obj_allocated · 3ae92ac2
      Minchan Kim authored
      The usage pattern for obj_to_head is to check whether the zpage is
      allocated or not.  Thus, introduce obj_allocated.
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-5-minchan@kernel.orgSigned-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3ae92ac2
    • Minchan Kim's avatar
      zsmalloc: decouple class actions from zspage works · 0a5f079b
      Minchan Kim authored
      This patch moves class stat update out of obj_malloc since it's not
      related to zspage operation.  This is a preparation to introduce new
      lock scheme in next patch.
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-4-minchan@kernel.orgSigned-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0a5f079b
    • Minchan Kim's avatar
      zsmalloc: rename zs_stat_type to class_stat_type · 3828a764
      Minchan Kim authored
      The stat aims for class stat, not zspage so rename it.
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-3-minchan@kernel.orgSigned-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3828a764
    • Minchan Kim's avatar
      zsmalloc: introduce some helper functions · 67f1c9cd
      Minchan Kim authored
      Patch series "zsmalloc: remove bit_spin_lock", v2.
      
      zsmalloc uses bit_spin_lock to minimize space overhead since it's zpage
      granularity lock.  However, it causes zsmalloc non-working under
      PREEMPT_RT as well as adding too much complication.
      
      This patchset tries to replace the bit_spin_lock with per-pool rwlock.
      It also removes unnecessary zspage isolation logic from class, which was
      the other part too much complication added into zsmalloc.
      
      Last patch changes the get_cpu_var to local_lock to make it work in
      PREEMPT_RT.
      
      This patch (of 9):
      
      get_zspage_mapping returns fullness as well as class_idx.  However, the
      fullness is usually not used since it could be stale in some contexts.
      It causes misleading as well as unnecessary instructions so this patch
      introduces zspage_class.
      
      obj_to_location also produces page and index but we don't need always
      the index, either so this patch introduces obj_to_page.
      
      Link: https://lkml.kernel.org/r/20211115185909.3949505-1-minchan@kernel.org
      Link: https://lkml.kernel.org/r/20211115185909.3949505-2-minchan@kernel.orgSigned-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      67f1c9cd
    • Baokun Li's avatar
      sysctl: returns -EINVAL when a negative value is passed to proc_doulongvec_minmax · 1622ed7d
      Baokun Li authored
      When we pass a negative value to the proc_doulongvec_minmax() function,
      the function returns 0, but the corresponding interface value does not
      change.
      
      we can easily reproduce this problem with the following commands:
      
          cd /proc/sys/fs/epoll
          echo -1 > max_user_watches; echo $?; cat max_user_watches
      
      This function requires a non-negative number to be passed in, so when a
      negative number is passed in, -EINVAL is returned.
      
      Link: https://lkml.kernel.org/r/20211220092627.3744624-1-libaokun1@huawei.comSigned-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      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>
      1622ed7d
    • Colin Ian King's avatar
      kernel/sysctl.c: remove unused variable ten_thousand · e565a8ed
      Colin Ian King authored
      The const variable ten_thousand is not used, it is redundant and can be
      removed.
      
      Cleans up clang warning:
      
        kernel/sysctl.c:99:18: warning: unused variable 'ten_thousand' [-Wunused-const-variable]
        static const int ten_thousand = 10000;
      
      Link: https://lkml.kernel.org/r/20211221184501.574670-1-colin.i.king@gmail.com
      Fixes: c26da54dc8ca ("printk: move printk sysctl to printk/sysctl.c")
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      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>
      e565a8ed
    • Xiaoming Ni's avatar
      kprobe: move sysctl_kprobes_optimization to kprobes.c · a737a3c6
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      Move sysctl_kprobes_optimization from kernel/sysctl.c to
      kernel/kprobes.c.  Use register_sysctl() to register the sysctl
      interface.
      
      [mcgrof@kernel.org: fix compile issue when CONFIG_OPTPROBES is disabled]
      
      Link: https://lkml.kernel.org/r/20211129211943.640266-7-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a737a3c6
    • Xiaoming Ni's avatar
      fs/coredump: move coredump sysctls into its own file · f0bc21b2
      Xiaoming Ni authored
      This moves the fs/coredump.c respective sysctls to its own file.
      
      Link: https://lkml.kernel.org/r/20211129211943.640266-6-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f0bc21b2
    • Xiaoming Ni's avatar
      printk: fix build warning when CONFIG_PRINTK=n · fdcd4073
      Xiaoming Ni authored
      build warning when CONFIG_PRINTK=n
      
      	kernel/printk/printk.c:175:5: warning: no previous prototype for
      	 'devkmsg_sysctl_set_loglvl' [-Wmissing-prototypes]
      
      devkmsg_sysctl_set_loglvl() is only used in sysctl.c when
      CONFIG_PRINTK=y, but it participates in the build when CONFIG_PRINTK=n.
      So add compile dependency CONFIG_PRINTK=y && CONFIG_SYSCTL=y to fix the
      build warning.
      
      Link: https://lkml.kernel.org/r/20211129211943.640266-5-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      fdcd4073
    • Luis Chamberlain's avatar
      kernel/sysctl.c: rename sysctl_init() to sysctl_init_bases() · d8c0418a
      Luis Chamberlain authored
      Rename sysctl_init() to sysctl_init_bases() so to reflect exactly what
      this is doing.
      
      Link: https://lkml.kernel.org/r/20211129211943.640266-4-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d8c0418a
    • Luis Chamberlain's avatar
      fs: move namespace sysctls and declare fs base directory · ab171b95
      Luis Chamberlain authored
      This moves the namespace sysctls to its own file as part of the
      kernel/sysctl.c spring cleaning
      
      Since we have now removed all sysctls for "fs", we now have to declare
      it on the filesystem code, we do that using the new helper, which
      reduces boiler plate code.
      
      We rename init_fs_shared_sysctls() to init_fs_sysctls() to reflect that
      now fs/sysctls.c is taking on the burden of being the first to register
      the base directory as well.
      
      Lastly, since init code will load in the order in which we link it we
      have to move the sysctl code to be linked in early, so that its early
      init routine runs prior to other fs code.  This way, other filesystem
      code can register their own sysctls using the helpers after this:
      
        * register_sysctl_init()
        * register_sysctl()
      
      Link: https://lkml.kernel.org/r/20211129211943.640266-3-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ab171b95
    • Luis Chamberlain's avatar
      sysctl: add and use base directory declarer and registration helper · 51cb8dfc
      Luis Chamberlain authored
      Patch series "sysctl: add and use base directory declarer and
      registration helper".
      
      In this patch series we start addressing base directories, and so we
      start with the "fs" sysctls.  The end goal is we end up completely
      moving all "fs" sysctl knobs out from kernel/sysctl.
      
      This patch (of 6):
      
      Add a set of helpers which can be used to declare and register base
      directory sysctls on their own.  We do this so we can later move each of
      the base sysctl directories like "fs", "kernel", etc, to their own
      respective files instead of shoving the declarations and registrations
      all on kernel/sysctl.c.  The lazy approach has caught up and with this,
      we just end up extending the list of base directories / sysctls on one
      file and this makes maintenance difficult due to merge conflicts from
      many developers.
      
      The declarations are used first by kernel/sysctl.c for registration its
      own base which over time we'll try to clean up.  It will be used in the
      next patch to demonstrate how to cleanly deal with base sysctl
      directories.
      
      [mcgrof@kernel.org: null-terminate the ctl_table arrays]
        Link: https://lkml.kernel.org/r/YafJY3rXDYnjK/gs@bombadil.infradead.org
      
      Link: https://lkml.kernel.org/r/20211129211943.640266-1-mcgrof@kernel.org
      Link: https://lkml.kernel.org/r/20211129211943.640266-2-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      51cb8dfc
    • Luis Chamberlain's avatar
      fs: move pipe sysctls to is own file · 1998f193
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the pipe sysctls to its own file.
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-10-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1998f193
    • Luis Chamberlain's avatar
      fs: move fs/exec.c sysctls into its own file · 66ad3986
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the fs/exec.c respective sysctls to its own file.
      
      Since checkpatch complains about style issues with the old code, this
      move also fixes a few of those minor style issues:
      
        * Use pr_warn() instead of prink(WARNING
        * New empty lines are wanted at the beginning of routines
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-9-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      66ad3986
    • Luis Chamberlain's avatar
      fs: move namei sysctls to its own file · 9c011be1
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move namei's own sysctl knobs to its own file.
      
      Other than the move we also avoid initializing two static variables to 0
      as this is not needed:
      
        * sysctl_protected_symlinks
        * sysctl_protected_hardlinks
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-8-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9c011be1
    • Luis Chamberlain's avatar
      fs: move locking sysctls where they are used · dd81faa8
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      The locking fs sysctls are only used on fs/locks.c, so move them there.
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-7-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dd81faa8
    • Luis Chamberlain's avatar
      fs: move shared sysctls to fs/sysctls.c · d1d8ac9e
      Luis Chamberlain authored
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move sysctls which are shared between filesystems into a common file
      outside of kernel/sysctl.c.
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-6-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d1d8ac9e
    • Luis Chamberlain's avatar
      sysctl: move maxolduid as a sysctl specific const · 54771613
      Luis Chamberlain authored
      The maxolduid value is only shared for sysctl purposes for use on a max
      range.  Just stuff this into our shared const array.
      
      [akpm@linux-foundation.org: fix sysctl_vals[], per Mickaël]
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-5-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      54771613
    • Luis Chamberlain's avatar
      fs: move dcache sysctls to its own file · c8c0c239
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the dcache sysctl clutter out of kernel/sysctl.c.  This is a
      small one-off entry, perhaps later we can simplify this representation,
      but for now we use the helpers we have.  We won't know how we can
      simplify this further untl we're fully done with the cleanup.
      
      [arnd@arndb.de: avoid unused-function warning]
        Link: https://lkml.kernel.org/r/20211203190123.874239-2-arnd@kernel.org
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-4-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c8c0c239
    • Luis Chamberlain's avatar
      fs: move fs stat sysctls to file_table.c · 204d5a24
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      We can create the sysctl dynamically on early init for fs stat to help
      with this clutter.  This dusts off the fs stat syctls knobs and puts
      them into where they are declared.
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-3-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      204d5a24
    • Luis Chamberlain's avatar
      fs: move inode sysctls to its own file · 1d67fe58
      Luis Chamberlain authored
      Patch series "sysctl: 4th set of kernel/sysctl cleanups".
      
      This is slimming down the fs uses of kernel/sysctl.c to the point that
      the next step is to just get rid of the fs base directory for it and
      move that elsehwere, so that next patch series starts dealing with that
      to demo how we can end up cleaning up a full base directory from
      kernel/sysctl.c, one at a time.
      
      This patch (of 9):
      
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the inode sysctls to its own file.  Since we are no longer using
      this outside of fs/ remove the extern declaration of its respective proc
      helper.
      
      We use early_initcall() as it is the earliest we can use.
      
      [arnd@arndb.de: avoid unused-variable warning]
        Link: https://lkml.kernel.org/r/20211203190123.874239-1-arnd@kernel.org
      
      Link: https://lkml.kernel.org/r/20211129205548.605569-1-mcgrof@kernel.org
      Link: https://lkml.kernel.org/r/20211129205548.605569-2-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Jeff Layton <jlayton@kernel.org>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1d67fe58
    • Luis Chamberlain's avatar
      sysctl: share unsigned long const values · b1f2aff8
      Luis Chamberlain authored
      Provide a way to share unsigned long values.  This will allow others to
      not have to re-invent these values.
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-9-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b1f2aff8
    • Xiaoming Ni's avatar
      stackleak: move stack_erasing sysctl to stackleak.c · 0df8bdd5
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the stack_erasing sysctl from kernel/sysctl.c to
      kernel/stackleak.c and use register_sysctl() to register the sysctl
      interface.
      
      [mcgrof@kernel.org: commit log update]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-8-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0df8bdd5
    • Xiaoming Ni's avatar
      scsi/sg: move sg-big-buff sysctl to scsi/sg.c · 26d1c80f
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the sg-big-buff sysctl from kernel/sysctl.c to drivers/scsi/sg.c
      and use register_sysctl() to register the sysctl interface.
      
      [mcgrof@kernel.org: commit log update]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-7-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      26d1c80f
    • Xiaoming Ni's avatar
      printk: move printk sysctl to printk/sysctl.c · faaa357a
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move printk sysctl from kernel/sysctl.c to kernel/printk/sysctl.c.
      Use register_sysctl() to register the sysctl interface.
      
      [mcgrof@kernel.org: fixed compile issues when PRINTK is not set, commit log update]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-6-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      faaa357a
    • Luis Chamberlain's avatar
      fs: move binfmt_misc sysctl to its own file · 3ba442d5
      Luis Chamberlain authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      This moves the binfmt_misc sysctl to its own file to help remove clutter
      from kernel/sysctl.c.
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-5-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3ba442d5
    • Luis Chamberlain's avatar
      sysctl: add helper to register a sysctl mount point · ee9efac4
      Luis Chamberlain authored
      The way to create a subdirectory on top of sysctl_mount_point is a bit
      obscure, and *why* we do that even so more.  Provide a helper which
      makes it clear why we do this.
      
      [akpm@linux-foundation.org: export register_sysctl_mount_point() to
      modules]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-4-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Suggested-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ee9efac4
    • Xiaoming Ni's avatar
      random: move the random sysctl declarations to its own file · 5475e8f0
      Xiaoming Ni authored
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the random sysctls to their own file and use
      register_sysctl_init().
      
      [mcgrof@kernel.org: commit log update to justify the move]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-3-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5475e8f0
    • Xiaoming Ni's avatar
      firmware_loader: move firmware sysctl to its own files · 6aad36d4
      Xiaoming Ni authored
      Patch series "sysctl: 3rd set of kernel/sysctl cleanups", v2.
      
      This is the third set of patches to help address cleaning the kitchen
      seink in kernel/sysctl.c and to move sysctls away to where they are
      actually implemented / used.
      
      This patch (of 8):
      
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the firmware configuration sysctl table to the only place where
      it is used, and make it clear that if sysctls are disabled this is not
      used.
      
      [akpm@linux-foundation.org: export register_firmware_config_sysctl and unregister_firmware_config_sysctl to modules]
      [akpm@linux-foundation.org: use EXPORT_SYMBOL_NS_GPL instead]
      [sfr@canb.auug.org.au: fix that so it compiles]
        Link: https://lkml.kernel.org/r/20211201160626.401d828d@canb.auug.org.au
      [mcgrof@kernel.org: major commit log update to justify the move]
      
      Link: https://lkml.kernel.org/r/20211124231435.1445213-1-mcgrof@kernel.org
      Link: https://lkml.kernel.org/r/20211124231435.1445213-2-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6aad36d4
    • Xiaoming Ni's avatar
      eventpoll: simplify sysctl declaration with register_sysctl() · a8f5de89
      Xiaoming Ni authored
      The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      So move the epoll_table sysctl to fs/eventpoll.c and use
      register_sysctl().
      
      Link: https://lkml.kernel.org/r/20211123202422.819032-9-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a8f5de89
    • Luis Chamberlain's avatar
      cdrom: simplify subdirectory registration with register_sysctl() · ad8f7431
      Luis Chamberlain authored
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      // pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH
      
      @c1@
      expression E1;
      identifier subdir, sysctls;
      @@
      
      static struct ctl_table subdir[] = {
      	{
      		.procname = E1,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = sysctls,
      	},
      	{ }
      };
      
      @c2@
      identifier c1.subdir;
      
      expression E2;
      identifier base;
      @@
      
      static struct ctl_table base[] = {
      	{
      		.procname = E2,
      		.maxlen = 0,
      		.mode = 0555,
      		.child = subdir,
      	},
      	{ }
      };
      
      @c3@
      identifier c2.base;
      identifier header;
      @@
      
      header = register_sysctl_table(base);
      
      @r1 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.subdir, c1.sysctls;
      @@
      
      -static struct ctl_table subdir[] = {
      -	{
      -		.procname = E1,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = sysctls,
      -	},
      -	{ }
      -};
      
      @r2 depends on c1 && c2 && c3@
      identifier c1.subdir;
      
      expression c2.E2;
      identifier c2.base;
      @@
      -static struct ctl_table base[] = {
      -	{
      -		.procname = E2,
      -		.maxlen = 0,
      -		.mode = 0555,
      -		.child = subdir,
      -	},
      -	{ }
      -};
      
      @initialize:python@
      @@
      
      def make_my_fresh_expression(s1, s2):
        return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
      
      @r3 depends on c1 && c2 && c3@
      expression c1.E1;
      identifier c1.sysctls;
      expression c2.E2;
      identifier c2.base;
      identifier c3.header;
      fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
      @@
      
      header =
      -register_sysctl_table(base);
      +register_sysctl(E3, sysctls);
      
      Generated-by: Coccinelle SmPL
      Link: https://lkml.kernel.org/r/20211123202422.819032-8-mcgrof@kernel.orgSigned-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ad8f7431
    • Xiaoming Ni's avatar
      inotify: simplify subdirectory registration with register_sysctl() · 7b9ad122
      Xiaoming Ni authored
      There is no need to user boiler plate code to specify a set of base
      directories we're going to stuff sysctls under.  Simplify this by using
      register_sysctl() and specifying the directory path directly.
      
      Move inotify_user sysctl to inotify_user.c while at it to remove clutter
      from kernel/sysctl.c.
      
      [mcgrof@kernel.org: remember to register fanotify_table]
        Link: https://lkml.kernel.org/r/YZ5A6iWLb0h3N3RC@bombadil.infradead.org
      [mcgrof@kernel.org: update commit log to reflect new path we decided to take]
      
      Link: https://lkml.kernel.org/r/20211123202422.819032-7-mcgrof@kernel.orgSigned-off-by: default avatarXiaoming Ni <nixiaoming@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Antti Palosaari <crope@iki.fi>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Cc: Clemens Ladisch <clemens@ladisch.de>
      Cc: David Airlie <airlied@linux.ie>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Lukas Middendorf <kernel@tuxforce.de>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Phillip Potter <phil@philpotter.co.uk>
      Cc: Qing Wang <wangqing@vivo.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Stephen Kitt <steve@sk2.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Cc: James E.J. Bottomley <jejb@linux.ibm.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7b9ad122