incoming
Subsystems (85)
Andrew Morton
maintainerThis is the post-linux-next queue. Material which was based on or dependent upon material which was in -next.
69 patches, based on 9b57f458985742bd1c585f4c7f36d04634ce1143.
Subsystems affected by this patch series:
mm/migration
sysctl
mm/zsmalloc
proc
lib
Subsystem: mm/migration
Alistair Popple <[email protected]>:
mm/migrate.c: rework migration_entry_wait() to not take a pageref
Subsystem: sysctl
Xiaoming Ni <[email protected]>:
Patch series "sysctl: first set of kernel/sysctl cleanups", v2:
sysctl: add a new register_sysctl_init() interface
sysctl: move some boundary constants from sysctl.c to sysctl_vals
hung_task: move hung_task sysctl interface to hung_task.c
watchdog: move watchdog sysctl interface to watchdog.c
Stephen Kitt <[email protected]>:
sysctl: make ngroups_max const
Xiaoming Ni <[email protected]>:
sysctl: use const for typically used max/min proc sysctls
sysctl: use SYSCTL_ZERO to replace some static int zero uses
aio: move aio sysctl to aio.c
dnotify: move dnotify sysctl to dnotify.c
Luis Chamberlain <[email protected]>:
Patch series "sysctl: second set of kernel/sysctl cleanups", v2:
hpet: simplify subdirectory registration with register_sysctl()
i915: simplify subdirectory registration with register_sysctl() macintosh/mac_hid.c: simplify subdirectory registration with register_sysctl()
ocfs2: simplify subdirectory registration with register_sysctl()
test_sysctl: simplify subdirectory registration with register_sysctl()
Xiaoming Ni <[email protected]>:
inotify: simplify subdirectory registration with register_sysctl()
Luis Chamberlain <[email protected]>:
cdrom: simplify subdirectory registration with register_sysctl()
Xiaoming Ni <[email protected]>:
eventpoll: simplify sysctl declaration with register_sysctl()
Patch series "sysctl: 3rd set of kernel/sysctl cleanups", v2:
firmware_loader: move firmware sysctl to its own files
random: move the random sysctl declarations to its own file
Luis Chamberlain <[email protected]>:
sysctl: add helper to register a sysctl mount point
fs: move binfmt_misc sysctl to its own file
Xiaoming Ni <[email protected]>:
printk: move printk sysctl to printk/sysctl.c scsi/sg: move sg-big-buff sysctl to scsi/sg.c
stackleak: move stack_erasing sysctl to stackleak.c
Luis Chamberlain <[email protected]>:
sysctl: share unsigned long const values
Patch series "sysctl: 4th set of kernel/sysctl cleanups":
fs: move inode sysctls to its own file
fs: move fs stat sysctls to file_table.c
fs: move dcache sysctls to its own file
sysctl: move maxolduid as a sysctl specific const
fs: move shared sysctls to fs/sysctls.c
fs: move locking sysctls where they are used
fs: move namei sysctls to its own file
fs: move fs/exec.c sysctls into its own file
fs: move pipe sysctls to is own file
Patch series "sysctl: add and use base directory declarer and registration helper":
sysctl: add and use base directory declarer and registration helper
fs: move namespace sysctls and declare fs base directory kernel/sysctl.c: rename sysctl_init() to sysctl_init_bases()
Xiaoming Ni <[email protected]>:
printk: fix build warning when CONFIG_PRINTK=n fs/coredump: move coredump sysctls into its own file
kprobe: move sysctl_kprobes_optimization to kprobes.c
Colin Ian King <[email protected]>:
kernel/sysctl.c: remove unused variable ten_thousand
Baokun Li <[email protected]>:
sysctl: returns -EINVAL when a negative value is passed to proc_doulongvec_minmax
Subsystem: mm/zsmalloc
Minchan Kim <[email protected]>:
Patch series "zsmalloc: remove bit_spin_lock", v2:
zsmalloc: introduce some helper functions
zsmalloc: rename zs_stat_type to class_stat_type
zsmalloc: decouple class actions from zspage works
zsmalloc: introduce obj_allocated
zsmalloc: move huge compressed obj from page to zspage
zsmalloc: remove zspage isolation for migration locking/rwlocks: introduce write_lock_nested
zsmalloc: replace per zpage lock with pool->migrate_lock
Mike Galbraith <[email protected]>:
zsmalloc: replace get_cpu_var with local_lock
Subsystem: proc
Muchun Song <[email protected]>:
fs: proc: store PDE()->data into inode->i_private
proc: remove PDE_DATA() completely
Subsystem: lib
Vlastimil Babka <[email protected]>:
lib/stackdepot: allow optional init and stack_table allocation by kvmalloc()
lib/stackdepot: fix spelling mistake and grammar in pr_err message lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup3 lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup4
Marco Elver <[email protected]>:
lib/stackdepot: always do filter_irq_stacks() in stack_depot_save()
Christoph Hellwig <[email protected]>:
Patch series "remove Xen tmem leftovers":
mm: remove cleancache
frontswap: remove frontswap_writethrough
frontswap: remove frontswap_tmem_exclusive_gets
frontswap: remove frontswap_shrink
frontswap: remove frontswap_curr_pages
frontswap: simplify frontswap_init
frontswap: remove the frontswap exports
mm: simplify try_to_unuse
frontswap: remove frontswap_test
frontswap: simplify frontswap_register_ops
mm: mark swap_lock and swap_active_head static
frontswap: remove support for multiple ops
mm: hide the FRONTSWAP Kconfig symbol
Documentation/vm/cleancache.rst | 296 ------ Documentation/vm/frontswap.rst | 31 Documentation/vm/index.rst | 1 MAINTAINERS | 7 arch/alpha/kernel/srm_env.c | 4 arch/arm/configs/bcm2835_defconfig | 1 arch/arm/configs/qcom_defconfig | 1 arch/arm/kernel/atags_proc.c | 2 arch/arm/mm/alignment.c | 2 arch/ia64/kernel/salinfo.c | 10 arch/m68k/configs/amiga_defconfig | 1 arch/m68k/configs/apollo_defconfig | 1 arch/m68k/configs/atari_defconfig | 1 arch/m68k/configs/bvme6000_defconfig | 1 arch/m68k/configs/hp300_defconfig | 1 arch/m68k/configs/mac_defconfig | 1 arch/m68k/configs/multi_defconfig | 1 arch/m68k/configs/mvme147_defconfig | 1 arch/m68k/configs/mvme16x_defconfig | 1 arch/m68k/configs/q40_defconfig | 1 arch/m68k/configs/sun3_defconfig | 1 arch/m68k/configs/sun3x_defconfig | 1 arch/powerpc/kernel/proc_powerpc.c | 4 arch/s390/configs/debug_defconfig | 1 arch/s390/configs/defconfig | 1 arch/sh/mm/alignment.c | 4 arch/xtensa/platforms/iss/simdisk.c | 4 block/bdev.c | 5 drivers/acpi/proc.c | 2 drivers/base/firmware_loader/fallback.c | 7 drivers/base/firmware_loader/fallback.h | 11 drivers/base/firmware_loader/fallback_table.c | 25 drivers/cdrom/cdrom.c | 23 drivers/char/hpet.c | 22 drivers/char/random.c | 14 drivers/gpu/drm/drm_dp_mst_topology.c | 1 drivers/gpu/drm/drm_mm.c | 4 drivers/gpu/drm/drm_modeset_lock.c | 9 drivers/gpu/drm/i915/i915_perf.c | 22 drivers/gpu/drm/i915/intel_runtime_pm.c | 3 drivers/hwmon/dell-smm-hwmon.c | 4 drivers/macintosh/mac_hid.c | 24 drivers/net/bonding/bond_procfs.c | 8 drivers/net/wireless/cisco/airo.c | 22 drivers/net/wireless/intersil/hostap/hostap_ap.c | 16 drivers/net/wireless/intersil/hostap/hostap_download.c | 2 drivers/net/wireless/intersil/hostap/hostap_proc.c | 24 drivers/net/wireless/ray_cs.c | 2 drivers/nubus/proc.c | 36 drivers/parisc/led.c | 4 drivers/pci/proc.c | 10 drivers/platform/x86/thinkpad_acpi.c | 4 drivers/platform/x86/toshiba_acpi.c | 16 drivers/pnp/isapnp/proc.c | 2 drivers/pnp/pnpbios/proc.c | 4 drivers/scsi/scsi_proc.c | 4 drivers/scsi/sg.c | 35 drivers/usb/gadget/function/rndis.c | 4 drivers/zorro/proc.c | 2 fs/Makefile | 4 fs/afs/proc.c | 6 fs/aio.c | 31 fs/binfmt_misc.c | 6 fs/btrfs/extent_io.c | 10 fs/btrfs/super.c | 2 fs/coredump.c | 66 + fs/dcache.c | 37 fs/eventpoll.c | 10 fs/exec.c | 145 +-- fs/ext4/mballoc.c | 14 fs/ext4/readpage.c | 6 fs/ext4/super.c | 3 fs/f2fs/data.c | 13 fs/file_table.c | 47 - fs/inode.c | 39 fs/jbd2/journal.c | 2 fs/locks.c | 34 fs/mpage.c | 7 fs/namei.c | 58 + fs/namespace.c | 24 fs/notify/dnotify/dnotify.c | 21 fs/notify/fanotify/fanotify_user.c | 10 fs/notify/inotify/inotify_user.c | 11 fs/ntfs3/ntfs_fs.h | 1 fs/ocfs2/stackglue.c | 25 fs/ocfs2/super.c | 2 fs/pipe.c | 64 + fs/proc/generic.c | 6 fs/proc/inode.c | 1 fs/proc/internal.h | 5 fs/proc/proc_net.c | 8 fs/proc/proc_sysctl.c | 67 + fs/super.c | 3 fs/sysctls.c | 47 - include/linux/aio.h | 4 include/linux/cleancache.h | 124 -- include/linux/coredump.h | 10 include/linux/dcache.h | 10 include/linux/dnotify.h | 1 include/linux/fanotify.h | 2 include/linux/frontswap.h | 35 include/linux/fs.h | 18 include/linux/inotify.h | 3 include/linux/kprobes.h | 6 include/linux/migrate.h | 2 include/linux/mount.h | 3 include/linux/pipe_fs_i.h | 4 include/linux/poll.h | 2 include/linux/printk.h | 4 include/linux/proc_fs.h | 17 include/linux/ref_tracker.h | 2 include/linux/rwlock.h | 6 include/linux/rwlock_api_smp.h | 8 include/linux/rwlock_rt.h | 10 include/linux/sched/sysctl.h | 14 include/linux/seq_file.h | 2 include/linux/shmem_fs.h | 3 include/linux/spinlock_api_up.h | 1 include/linux/stackdepot.h | 25 include/linux/stackleak.h | 5 include/linux/swapfile.h | 3 include/linux/sysctl.h | 67 + include/scsi/sg.h | 4 init/main.c | 9 ipc/util.c | 2 kernel/hung_task.c | 81 + kernel/irq/proc.c | 8 kernel/kprobes.c | 30 kernel/locking/spinlock.c | 10 kernel/locking/spinlock_rt.c | 12 kernel/printk/Makefile | 5 kernel/printk/internal.h | 8 kernel/printk/printk.c | 4 kernel/printk/sysctl.c | 85 + kernel/resource.c | 4 kernel/stackleak.c | 26 kernel/sysctl.c | 790 +---------------- kernel/watchdog.c | 101 ++ lib/Kconfig | 4 lib/Kconfig.kasan | 2 lib/stackdepot.c | 46 lib/test_sysctl.c | 22 mm/Kconfig | 40 mm/Makefile | 1 mm/cleancache.c | 315 ------ mm/filemap.c | 102 +- mm/frontswap.c | 259 ----- mm/kasan/common.c | 1 mm/migrate.c | 38 mm/page_owner.c | 2 mm/shmem.c | 33 mm/swapfile.c | 90 - mm/truncate.c | 15 mm/zsmalloc.c | 557 ++++------- mm/zswap.c | 8 net/atm/proc.c | 4 net/bluetooth/af_bluetooth.c | 8 net/can/bcm.c | 2 net/can/proc.c | 2 net/core/neighbour.c | 6 net/core/pktgen.c | 6 net/ipv4/netfilter/ipt_CLUSTERIP.c | 6 net/ipv4/raw.c | 8 net/ipv4/tcp_ipv4.c | 2 net/ipv4/udp.c | 6 net/netfilter/x_tables.c | 10 net/netfilter/xt_hashlimit.c | 18 net/netfilter/xt_recent.c | 4 net/sunrpc/auth_gss/svcauth_gss.c | 4 net/sunrpc/cache.c | 24 net/sunrpc/stats.c | 2 sound/core/info.c | 4 172 files changed, 1877 insertions(+), 2931 deletions(-)
Andrew Morton
maintainerPATCH 1/69 mm/migrate.c: rework migration_entry_wait() to not take a pageref
From: Alistair Popple <[email protected]>
Subject: mm/migrate.c: rework migration_entry_wait() to not take a pageref
This fixes the FIXME in migrate_vma_check_page().
Before migrating a page migration code will take a reference and check there are no unexpected page references, failing the migration if there are. When a thread faults on a migration entry it will take a temporary reference to the page to wait for the page to become unlocked signifying the migration entry has been removed.
This reference is dropped just prior to waiting on the page lock, however the extra reference can cause migration failures so it is desirable to avoid taking it.
As migration code already has a reference to the migrating page an extra reference to wait on PG_locked is unnecessary so long as the reference can't be dropped whilst setting up the wait.
When faulting on a migration entry the ptl is taken to check the migration entry. Removing a migration entry also requires the ptl, and migration code won't drop its page reference until after the migration entry has been removed. Therefore retaining the ptl of a migration entry is sufficient to ensure the page has a reference. Reworking migration_entry_wait() to hold the ptl until the wait setup is complete means the extra page reference is no longer needed.
---
include/linux/migrate.h | 2 mm/filemap.c | 91 ++++++++++++++++++++++++++++++++++++++ mm/migrate.c | 38 +-------------- 3 files changed, 97 insertions(+), 34 deletions(-)
include/linux/migrate.h renamed from include/linux/migrate.h~mm-migratec-rework-migration_entry_wait-to-not-take-a-pageref +2 -0
@@ -40,6 +40,8 @@ extern int migrate_huge_page_move_mappin struct page *newpage, struct page *page);extern int migrate_page_move_mapping (struct address_space *mapping,struct page *newpage,struct page *page,int extra_count); +void migration_entry_wait_on_locked (swp_entry_t entry,pte_t *ptep, +spinlock_t *ptl);void folio_migrate_flags (struct folio *newfolio,struct folio *folio);void folio_migrate_copy (struct folio *newfolio,struct folio *folio); int folio_migrate_mapping(struct address_space *mapping,
mm/filemap.c renamed from mm/filemap.c~mm-migratec-rework-migration_entry_wait-to-not-take-a-pageref +91 -0
109 lines not on this page · raw message
mm/migrate.c renamed from mm/migrate.c~mm-migratec-rework-migration_entry_wait-to-not-take-a-pageref +4 -34
@@ -291,7 +291,6 @@ void __migration_entry_wait(struct mm_st {pte_t pte;swp_entry_t entry; -struct folio *folio;spin_lock (ptl); pte = *ptep;
@@ -302,17 +301,7 @@ void __migration_entry_wait(struct mm_stif (!is_migration_entry (entry)) goto out; - folio =page_folio (pfn_swap_entry_to_page (entry)); - -/* -* Once page cache replacement of page migration started, page_count -* is zero; but we must not call folio_put_wait_locked() without -* a ref. Use folio_try_get(), and just fault again if it fails. -*/ -if (!folio_try_get (folio)) - goto out; -pte_unmap_unlock (ptep, ptl); -folio_put_wait_locked (folio,TASK_UNINTERRUPTIBLE ); +migration_entry_wait_on_locked (entry, ptep, ptl);return ; out:pte_unmap_unlock (ptep, ptl);
@@ -337,16 +326,11 @@ void migration_entry_wait_huge(struct vmvoid pmd_migration_entry_wait (struct mm_struct *mm,pmd_t *pmd) {spinlock_t *ptl; -struct folio *folio; ptl =pmd_lock (mm, pmd);if (!is_pmd_migration_entry (*pmd)) goto unlock; - folio =page_folio (pfn_swap_entry_to_page (pmd_to_swp_entry (*pmd))); -if (!folio_try_get (folio)) - goto unlock; -spin_unlock (ptl); -folio_put_wait_locked (folio,TASK_UNINTERRUPTIBLE ); +migration_entry_wait_on_locked (pmd_to_swp_entry (*pmd),NULL , ptl);return ; unlock:spin_unlock (ptl);
@@ -2431,22 +2415,8 @@ static bool migrate_vma_check_page(strucreturn false;/* Page from ZONE_DEVICE have one extra reference */ -if (is_zone_device_page (page)) { -/* -* Private page can never be pin as they have no valid pte and -* GUP will fail for those. Yet if there is a pending migration -* a thread might try to wait on the pte migration entry and -* will bump the page reference count. Sadly there is no way to -* differentiate a regular pin from migration wait. Hence to -* avoid 2 racing thread trying to migrate back to CPU to enter -* infinite loop (one stopping migration because the other is -* waiting on pte migration entry). We always return true here. -* -* FIXME proper solution is to rework migration_entry_wait() so -* it does not need to take a reference on page. -*/ -return is_device_private_page (page); - } +if (is_zone_device_page (page)) + extra++;/* For file back page */ if (page_mapping (page))
_
Andrew Morton
maintainerPATCH 2/69 sysctl: add a new register_sysctl_init() interface
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: sysctl: add a new register_sysctl_init() interface
Patch series "sysctl: first set of kernel/sysctl cleanups", v2.
Finally had time to respin the series of the work we had started last year on cleaning up the kernel/sysct.c kitchen sink. People keeps stuffing their sysctls in that file and this creates a maintenance burden. So this effort is aimed at placing sysctls where they actually belong.
I'm going to split patches up into series as there is quite a bit of work.
This first set adds register_sysctl_init() for uses of registerting a sysctl on the init path, adds const where missing to a few places, generalizes common values so to be more easy to share, and starts the move of a few kernel/sysctl.c out where they belong.
The majority of rework on v2 in this first patch set is 0-day fixes. Eric W. Biederman's feedback is later addressed in subsequent patch sets.
I'll only post the first two patch sets for now. We can address the rest once the first two patch sets get completely reviewed / Acked.
This patch (of 9):
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.
Today though folks heavily rely on tables on kernel/sysctl.c so they can easily just extend this table with their needed sysctls. In order to help users move their sysctls out we need to provide a helper which can be used during code initialization.
We special-case the initialization use of register_sysctl() since it *is* safe to fail, given all that sysctls do is provide a dynamic interface to query or modify at runtime an existing variable. So the use case of register_sysctl() on init should *not* stop if the sysctls don't end up getting registered. It would be counter productive to stop boot if a simple sysctl registration failed.
Provide a helper for init then, and document the recommended init levels to use for callers of this routine. We will later use this in subsequent patches to start slimming down kernel/sysctl.c tables and moving sysctl registration to the code which actually needs these sysctls.
---
fs/proc/proc_sysctl.c | 33 +++++++++++++++++++++++++++++++++ include/linux/sysctl.h | 3 +++ 2 files changed, 36 insertions(+)
fs/proc/proc_sysctl.c renamed from fs/proc/proc_sysctl.c~sysctl-add-a-new-register_sysctl_init-interface +33 -0
@@ -16,6 +16,7 @@#include <linux/module.h> #include <linux/bpf-cgroup.h> #include <linux/mount.h> +#include <linux/kmemleak.h> #include "internal.h" static const struct dentry_operations proc_sys_dentry_operations;
@@ -1383,6 +1384,38 @@ struct ctl_table_header *register_sysctl }EXPORT_SYMBOL (register_sysctl); +/** +* __register_sysctl_init() - register sysctl table to path +* @path: path name for sysctl base +* @table: This is the sysctl table that needs to be registered to the path +* @table_name: The name of sysctl table, only used for log printing when +* registration fails +* +* The sysctl interface is used by userspace to query or modify at runtime +* a predefined value set on a variable. These variables however have default +* values pre-set. Code which depends on these variables will always work even +* if register_sysctl() fails. If register_sysctl() fails you'd just loose the +* ability to query or modify the sysctls dynamically at run time. Chances of +* register_sysctl() failing on init are extremely low, and so for both reasons +* this function does not return any error as it is used by initialization code. +* +* Context: Can only be called after your respective sysctl base path has been +* registered. So for instance, most base directories are registered early on +* init before init levels are processed through proc_sys_init() and +* sysctl_init(). +*/ +void __init __register_sysctl_init (const char *path,struct ctl_table *table, +const char *table_name) +{ +struct ctl_table_header *hdr =register_sysctl (path, table); + +if (unlikely (!hdr)) { +pr_err ("failed when register_sysctl %s to %s\n" , table_name, path); +return ; + } +kmemleak_not_leak (hdr); +} +static char *append_path (const char *path,char *pos,const char *name) {int namelen;
include/linux/sysctl.h renamed from include/linux/sysctl.h~sysctl-add-a-new-register_sysctl_init-interface +3 -0
@@ -199,6 +199,9 @@ struct ctl_table_header *register_sysctlvoid unregister_sysctl_table (struct ctl_table_header * table);extern int sysctl_init (void ); +extern void __register_sysctl_init (const char *path,struct ctl_table *table, +const char *table_name); +#define register_sysctl_init (path, table) __register_sysctl_init(path, table, #table)void do_sysctl_args (void );extern int pwrsw_enabled;
_
Andrew Morton
maintainerPATCH 3/69 sysctl: move some boundary constants from sysctl.c to sysctl_vals
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: sysctl: move some boundary constants from sysctl.c to sysctl_vals
sysctl has helpers which let us specify boundary values for a min or max int value. Since these are used for a boundary check only they don't change, so move these variables to sysctl_vals to avoid adding duplicate variables. This will help with our cleanup of kernel/sysctl.c.
---
fs/proc/proc_sysctl.c | 2 - include/linux/sysctl.h | 13 ++++++++--- kernel/sysctl.c | 45 ++++++++++++++++----------------------- 3 files changed, 30 insertions(+), 30 deletions(-)
fs/proc/proc_sysctl.c renamed from fs/proc/proc_sysctl.c~sysctl-move-some-boundary-constants-from-sysctlc-to-sysctl_vals +1 -1
@@ -26,7 +26,7 @@ static const struct file_operations procstatic const struct inode_operations proc_sys_dir_operations;/* shared constants to be used in various sysctls */ -const int sysctl_vals[] = {0 ,1 ,INT_MAX }; +const int sysctl_vals[] = {-1 ,0 ,1 ,2 ,4 ,100 ,200 ,1000 ,3000 ,INT_MAX };EXPORT_SYMBOL (sysctl_vals);/* Support for permanently empty directories */
include/linux/sysctl.h renamed from include/linux/sysctl.h~sysctl-move-some-boundary-constants-from-sysctlc-to-sysctl_vals +10 -3
@@ -38,9 +38,16 @@ struct ctl_table_header;struct ctl_dir ;/* Keep the same order as in fs/proc/proc_sysctl.c */ -#define SYSCTL_ZERO ((void *)&sysctl_vals[0]) -#define SYSCTL_ONE ((void *)&sysctl_vals[1]) -#define SYSCTL_INT_MAX ((void *)&sysctl_vals[2]) +#define SYSCTL_NEG_ONE ((void *)&sysctl_vals[0]) +#define SYSCTL_ZERO ((void *)&sysctl_vals[1]) +#define SYSCTL_ONE ((void *)&sysctl_vals[2]) +#define SYSCTL_TWO ((void *)&sysctl_vals[3]) +#define SYSCTL_FOUR ((void *)&sysctl_vals[4]) +#define SYSCTL_ONE_HUNDRED ((void *)&sysctl_vals[5]) +#define SYSCTL_TWO_HUNDRED ((void *)&sysctl_vals[6]) +#define SYSCTL_ONE_THOUSAND ((void *)&sysctl_vals[7]) +#define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[8]) +#define SYSCTL_INT_MAX ((void *)&sysctl_vals[9])extern const int sysctl_vals[];
kernel/sysctl.c renamed from kernel/sysctl.c~sysctl-move-some-boundary-constants-from-sysctlc-to-sysctl_vals +19 -26
168 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 4/69 hung_task: move hung_task sysctl interface to hung_task.c
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: hung_task: move hung_task sysctl interface to hung_task.c
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 hung_task sysctl interface to hung_task.c and use register_sysctl() to register the sysctl interface.
---
include/linux/sched/sysctl.h | 14 ----- kernel/hung_task.c | 81 +++++++++++++++++++++++++++++++-- kernel/sysctl.c | 61 ------------------------ 3 files changed, 79 insertions(+), 77 deletions(-)
include/linux/sched/sysctl.h renamed from include/linux/sched/sysctl.h~hung_task-move-hung_task-sysctl-interface-to-hung_taskc +1 -13
@@ -7,20 +7,8 @@struct ctl_table ;#ifdef CONFIG_DETECT_HUNG_TASK - -#ifdef CONFIG_SMP -extern unsigned int sysctl_hung_task_all_cpu_backtrace; -#else -#define sysctl_hung_task_all_cpu_backtrace 0 -#endif /* CONFIG_SMP */ - -extern int sysctl_hung_task_check_count; -extern unsigned int sysctl_hung_task_panic; +/* used for hung_task and block/ */ extern unsigned long sysctl_hung_task_timeout_secs; -extern unsigned long sysctl_hung_task_check_interval_secs; -extern int sysctl_hung_task_warnings; -int proc_dohung_task_timeout_secs (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos);#else /* Avoid need for ifdefs elsewhere in the code */ enum { sysctl_hung_task_timeout_secs =0 };
kernel/hung_task.c renamed from kernel/hung_task.c~hung_task-move-hung_task-sysctl-interface-to-hung_taskc +78 -3
108 lines not on this page · raw message
kernel/sysctl.c renamed from kernel/sysctl.c~hung_task-move-hung_task-sysctl-interface-to-hung_taskc +0 -61
73 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 5/69 watchdog: move watchdog sysctl interface to watchdog.c
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: watchdog: move watchdog sysctl interface to watchdog.c
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 of proc sysctl.
So, move the watchdog syscl interface to watchdog.c. Use register_sysctl() to register the sysctl interface to avoid merge conflicts when different features modify sysctl.c at the same time.
---
kernel/sysctl.c | 96 ----------------------------------------- kernel/watchdog.c | 101 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 96 deletions(-)
kernel/sysctl.c renamed from kernel/sysctl.c~watchdog-move-watchdog-sysctl-interface-to-watchdogc +0 -96
@@ -103,16 +103,10 @@#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE #include <linux/stackleak.h> #endif -#ifdef CONFIG_LOCKUP_DETECTOR -#include <linux/nmi.h> -#endif #if defined(CONFIG_SYSCTL )/* Constants used for minimum and maximum */ -#ifdef CONFIG_LOCKUP_DETECTOR -static int sixty =60 ; -#endif static unsigned long zero_ul;static unsigned long one_ul =1 ;
@@ -2309,96 +2303,6 @@ static struct ctl_table kern_table[] = { .mode = 0444, .proc_handler = proc_dointvec, }, -#if defined(CONFIG_LOCKUP_DETECTOR) - { - .procname = "watchdog", - .data = &watchdog_user_enabled, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_watchdog, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, - { - .procname = "watchdog_thresh", - .data = &watchdog_thresh, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_watchdog_thresh, - .extra1 = SYSCTL_ZERO, - .extra2 = &sixty, - }, - { - .procname = "nmi_watchdog", - .data = &nmi_watchdog_user_enabled, - .maxlen = sizeof(int), - .mode = NMI_WATCHDOG_SYSCTL_PERM, - .proc_handler = proc_nmi_watchdog, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, - { - .procname = "watchdog_cpumask", - .data = &watchdog_cpumask_bits, - .maxlen = NR_CPUS, - .mode = 0644, - .proc_handler = proc_watchdog_cpumask, - }, -#ifdef CONFIG_SOFTLOCKUP_DETECTOR - { - .procname = "soft_watchdog", - .data = &soft_watchdog_user_enabled, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_soft_watchdog, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, - { - .procname = "softlockup_panic", - .data = &softlockup_panic, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#ifdef CONFIG_SMP - { - .procname = "softlockup_all_cpu_backtrace", - .data = &sysctl_softlockup_all_cpu_backtrace, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif /* CONFIG_SMP */ -#endif -#ifdef CONFIG_HARDLOCKUP_DETECTOR - { - .procname = "hardlockup_panic", - .data = &hardlockup_panic, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#ifdef CONFIG_SMP - { - .procname = "hardlockup_all_cpu_backtrace", - .data = &sysctl_hardlockup_all_cpu_backtrace, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif /* CONFIG_SMP */ -#endif -#endif -#if defined(CONFIG_X86_LOCAL_APIC ) && defined(CONFIG_X86 ) { .procname = "unknown_nmi_panic",
kernel/watchdog.c renamed from kernel/watchdog.c~watchdog-move-watchdog-sysctl-interface-to-watchdogc +101 -0
111 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 6/69 sysctl: make ngroups_max const
In reply to Andrew MortonFrom: Stephen Kitt <[email protected]>
Subject: sysctl: make ngroups_max const
ngroups_max is a read-only sysctl entry, reflecting NGROUPS_MAX. Make it const, in the same way as cap_last_cap.
---
kernel/sysctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sysctl.c renamed from kernel/sysctl.c~sysctl-make-ngroups_max-const +2 -2
@@ -125,7 +125,7 @@ static unsigned long dirty_bytes_min = 2static int maxolduid =65535 ;static int minolduid; -static int ngroups_max =NGROUPS_MAX ; +static const int ngroups_max =NGROUPS_MAX ;static const int cap_last_cap =CAP_LAST_CAP ;
@@ -2291,7 +2291,7 @@ static struct ctl_table kern_table[] = {#endif { .procname = "ngroups_max", - .data = &ngroups_max, + .data = (void *)&ngroups_max, .maxlen = sizeof (int), .mode = 0444, .proc_handler = proc_dointvec,
_
Andrew Morton
maintainerPATCH 7/69 sysctl: use const for typically used max/min proc sysctls
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: sysctl: use const for typically used max/min proc sysctls
When proc_dointvec_minmax() or proc_doulongvec_minmax() are used we are using the extra1 and extra2 parameters on the sysctl table only for a min and max boundary, these extra1 and extra2 arguments are then used for read-only operations. So make them const to reflect this.
---
kernel/sysctl.c | 53 ++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 27 deletions(-)
kernel/sysctl.c renamed from kernel/sysctl.c~sysctl-use-const-for-typically-used-max-min-proc-sysctls +26 -27
@@ -108,27 +108,26 @@/* Constants used for minimum and maximum */ -static unsigned long zero_ul; -static unsigned long one_ul =1 ; -static unsigned long long_max =LONG_MAX ; +static const unsigned long zero_ul; +static const unsigned long one_ul =1 ; +static const unsigned long long_max =LONG_MAX ;#ifdef CONFIG_PRINTK -static int ten_thousand =10000 ; +static const int ten_thousand =10000 ;#endif #ifdef CONFIG_PERF_EVENTS -static int six_hundred_forty_kb =640 *1024 ; +static const int six_hundred_forty_kb =640 *1024 ;#endif /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ -static unsigned long dirty_bytes_min =2 *PAGE_SIZE ; +static const unsigned long dirty_bytes_min =2 *PAGE_SIZE ;/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ -static int maxolduid =65535 ; -static int minolduid; +static const int maxolduid =65535 ; +static const int minolduid;static const int ngroups_max =NGROUPS_MAX ;static const int cap_last_cap =CAP_LAST_CAP ; -#ifdef CONFIG_INOTIFY_USER #include <linux/inotify.h> #endif
@@ -172,8 +171,8 @@ int sysctl_legacy_va_layout;#endif #ifdef CONFIG_COMPACTION -static int min_extfrag_threshold; -static int max_extfrag_threshold =1000 ; +static const int min_extfrag_threshold; +static const int max_extfrag_threshold =1000 ;#endif #endif /* CONFIG_SYSCTL */
@@ -2177,8 +2176,8 @@ static struct ctl_table kern_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = &minolduid, - .extra2 = &maxolduid, + .extra1 = (void *)&minolduid, + .extra2 = (void *)&maxolduid, }, { .procname = "overflowgid",
@@ -2186,8 +2185,8 @@ static struct ctl_table kern_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = &minolduid, - .extra2 = &maxolduid, + .extra1 = (void *)&minolduid, + .extra2 = (void *)&maxolduid, },#ifdef CONFIG_S390 {
@@ -2261,7 +2260,7 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, - .extra2 = &ten_thousand, + .extra2 = (void *)&ten_thousand, }, { .procname = "printk_devkmsg",
@@ -2473,7 +2472,7 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = perf_event_max_stack_handler, .extra1 = SYSCTL_ZERO, - .extra2 = &six_hundred_forty_kb, + .extra2 = (void *)&six_hundred_forty_kb, }, { .procname = "perf_event_max_contexts_per_stack",
@@ -2629,7 +2628,7 @@ static struct ctl_table vm_table[] = { .maxlen = sizeof(dirty_background_bytes), .mode = 0644, .proc_handler = dirty_background_bytes_handler, - .extra1 = &one_ul, + .extra1 = (void *)&one_ul, }, { .procname = "dirty_ratio",
@@ -2646,7 +2645,7 @@ static struct ctl_table vm_table[] = { .maxlen = sizeof(vm_dirty_bytes), .mode = 0644, .proc_handler = dirty_bytes_handler, - .extra1 = &dirty_bytes_min, + .extra1 = (void *)&dirty_bytes_min, }, { .procname = "dirty_writeback_centisecs",
@@ -2760,8 +2759,8 @@ static struct ctl_table vm_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = &min_extfrag_threshold, - .extra2 = &max_extfrag_threshold, + .extra1 = (void *)&min_extfrag_threshold, + .extra2 = (void *)&max_extfrag_threshold, }, { .procname = "compact_unevictable_allowed",
@@ -3047,8 +3046,8 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(files_stat.max_files), .mode = 0644, .proc_handler = proc_doulongvec_minmax, - .extra1 = &zero_ul, - .extra2 = &long_max, + .extra1 = (void *)&zero_ul, + .extra2 = (void *)&long_max, }, { .procname = "nr_open",
@@ -3072,8 +3071,8 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = &minolduid, - .extra2 = &maxolduid, + .extra1 = (void *)&minolduid, + .extra2 = (void *)&maxolduid, }, { .procname = "overflowgid",
@@ -3081,8 +3080,8 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = &minolduid, - .extra2 = &maxolduid, + .extra1 = (void *)&minolduid, + .extra2 = (void *)&maxolduid, },#ifdef CONFIG_FILE_LOCKING {
_
Andrew Morton
maintainerPATCH 8/69 sysctl: use SYSCTL_ZERO to replace some static int zero uses
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: sysctl: use SYSCTL_ZERO to replace some static int zero uses
Use the variable SYSCTL_ZERO to replace some static int boundary variables with a value of 0 (minolduid, min_extfrag_threshold, min_wakeup_granularity_ns).
---
kernel/sysctl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
kernel/sysctl.c renamed from kernel/sysctl.c~sysctl-use-sysctl_zero-to-replace-some-static-int-zero-uses +7 -7
@@ -123,7 +123,7 @@ static const unsigned long dirty_bytes_m/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ static const int maxolduid =65535 ; -static const int minolduid; +/* minolduid is SYSCTL_ZERO */ static const int ngroups_max =NGROUPS_MAX ;static const int cap_last_cap =CAP_LAST_CAP ;
@@ -171,7 +171,7 @@ int sysctl_legacy_va_layout;#endif #ifdef CONFIG_COMPACTION -static const int min_extfrag_threshold; +/* min_extfrag_threshold is SYSCTL_ZERO */ ;static const int max_extfrag_threshold =1000 ;#endif
@@ -2176,7 +2176,7 @@ static struct ctl_table kern_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&minolduid, + .extra1 = SYSCTL_ZERO, .extra2 = (void *)&maxolduid, }, {
@@ -2185,7 +2185,7 @@ static struct ctl_table kern_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&minolduid, + .extra1 = SYSCTL_ZERO, .extra2 = (void *)&maxolduid, },#ifdef CONFIG_S390
@@ -2759,7 +2759,7 @@ static struct ctl_table vm_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&min_extfrag_threshold, + .extra1 = SYSCTL_ZERO, .extra2 = (void *)&max_extfrag_threshold, }, {
@@ -3071,7 +3071,7 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&minolduid, + .extra1 = SYSCTL_ZERO, .extra2 = (void *)&maxolduid, }, {
@@ -3080,7 +3080,7 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = (void *)&minolduid, + .extra1 = SYSCTL_ZERO, .extra2 = (void *)&maxolduid, },#ifdef CONFIG_FILE_LOCKING
_
Andrew Morton
maintainerPATCH 9/69 aio: move aio sysctl to aio.c
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: aio: move aio sysctl to aio.c
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.
Move aio sysctl to aio.c and use the new register_sysctl_init() to register the sysctl interface for aio.
---
fs/aio.c | 31 +++++++++++++++++++++++++++++-- include/linux/aio.h | 4 ---- kernel/sysctl.c | 17 ----------------- 3 files changed, 29 insertions(+), 23 deletions(-)
fs/aio.c renamed from fs/aio.c~aio-move-aio-sysctl-to-aioc +29 -2
@@ -220,9 +220,35 @@ struct aio_kiocb {/*------ sysctl variables----*/ static DEFINE_SPINLOCK (aio_nr_lock); -unsigned long aio_nr;/* current system wide number of aio requests */ -unsigned long aio_max_nr =0x10000 ;/* system wide maximum number of aio requests */ +static unsigned long aio_nr;/* current system wide number of aio requests */ +static unsigned long aio_max_nr =0x10000 ;/* system wide maximum number of aio requests */ /*----end sysctl variables---*/ +#ifdef CONFIG_SYSCTL +static struct ctl_table aio_sysctls[] = { + { + .procname ="aio-nr" , + .data = &aio_nr, + .maxlen =sizeof (aio_nr), + .mode =0444 , + .proc_handler = proc_doulongvec_minmax, + }, + { + .procname ="aio-max-nr" , + .data = &aio_max_nr, + .maxlen =sizeof (aio_max_nr), + .mode =0644 , + .proc_handler = proc_doulongvec_minmax, + }, + {} +}; + +static void __init aio_sysctl_init (void ) +{ +register_sysctl_init ("fs" , aio_sysctls); +} +#else +#define aio_sysctl_init () do { } while (0) +#endif static struct kmem_cache *kiocb_cachep;static struct kmem_cache *kioctx_cachep;
@@ -275,6 +301,7 @@ static int __init aio_setup(void) kiocb_cachep =KMEM_CACHE (aio_kiocb,SLAB_HWCACHE_ALIGN |SLAB_PANIC ); kioctx_cachep =KMEM_CACHE (kioctx,SLAB_HWCACHE_ALIGN |SLAB_PANIC ); +aio_sysctl_init ();return 0 ; }__initcall (aio_setup);
include/linux/aio.h renamed from include/linux/aio.h~aio-move-aio-sysctl-to-aioc +0 -4
@@ -20,8 +20,4 @@ static inline void kiocb_set_cancel_fn(s kiocb_cancel_fn *cancel) { }#endif /* CONFIG_AIO */ -/* for sysctl: */ -extern unsigned long aio_nr; -extern unsigned long aio_max_nr; -#endif /* __LINUX__AIO_H */
kernel/sysctl.c renamed from kernel/sysctl.c~aio-move-aio-sysctl-to-aioc +0 -17
@@ -20,7 +20,6 @@*/ #include <linux/module.h> -#include <linux/aio.h> #include <linux/mm.h> #include <linux/swap.h> #include <linux/slab.h>
@@ -3111,22 +3110,6 @@ static struct ctl_table fs_table[] = { .proc_handler = proc_dointvec, },#endif -#ifdef CONFIG_AIO - { - .procname = "aio-nr", - .data = &aio_nr, - .maxlen = sizeof(aio_nr), - .mode = 0444, - .proc_handler = proc_doulongvec_minmax, - }, - { - .procname = "aio-max-nr", - .data = &aio_max_nr, - .maxlen = sizeof(aio_max_nr), - .mode = 0644, - .proc_handler = proc_doulongvec_minmax, - }, -#endif /* CONFIG_AIO */#ifdef CONFIG_INOTIFY_USER { .procname = "inotify",
_
Andrew Morton
maintainerPATCH 10/69 dnotify: move dnotify sysctl to dnotify.c
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: dnotify: move dnotify sysctl to dnotify.c
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 dnotify sysctls to dnotify.c and use the new register_sysctl_init() to register the sysctl interface.
---
fs/notify/dnotify/dnotify.c | 21 ++++++++++++++++++++- include/linux/dnotify.h | 1 - kernel/sysctl.c | 10 ---------- 3 files changed, 20 insertions(+), 12 deletions(-)
fs/notify/dnotify/dnotify.c renamed from fs/notify/dnotify/dnotify.c~dnotify-move-dnotify-sysctl-to-dnotifyc +20 -1
@@ -19,7 +19,25 @@#include <linux/fdtable.h> #include <linux/fsnotify_backend.h> -int dir_notify_enable__read_mostly =1 ; +static int dir_notify_enable__read_mostly =1 ; +#ifdef CONFIG_SYSCTL +static struct ctl_table dnotify_sysctls[] = { + { + .procname ="dir-notify-enable" , + .data = &dir_notify_enable, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec, + }, + {} +}; +static void __init dnotify_sysctl_init (void ) +{ +register_sysctl_init ("fs" , dnotify_sysctls); +} +#else +#define dnotify_sysctl_init () do { } while (0) +#endif static struct kmem_cache *dnotify_struct_cache__read_mostly ;static struct kmem_cache *dnotify_mark_cache__read_mostly ;
@@ -386,6 +404,7 @@ static int __init dnotify_init(void) dnotify_group =fsnotify_alloc_group (&dnotify_fsnotify_ops);if (IS_ERR (dnotify_group))panic ("unable to allocate fsnotify group for dnotify\n" ); +dnotify_sysctl_init ();return 0 ; }
include/linux/dnotify.h renamed from include/linux/dnotify.h~dnotify-move-dnotify-sysctl-to-dnotifyc +0 -1
@@ -29,7 +29,6 @@ struct dnotify_struct { FS_CREATE | FS_RENAME |\ FS_MOVED_FROM | FS_MOVED_TO) -extern int dir_notify_enable;extern void dnotify_flush (struct file *,fl_owner_t );extern int fcntl_dirnotify (int ,struct file *,unsigned long );
kernel/sysctl.c renamed from kernel/sysctl.c~dnotify-move-dnotify-sysctl-to-dnotifyc +0 -10
@@ -49,7 +49,6 @@#include <linux/times.h> #include <linux/limits.h> #include <linux/dcache.h> -#include <linux/dnotify.h> #include <linux/syscalls.h> #include <linux/vmstat.h> #include <linux/nfs_fs.h>
@@ -3089,15 +3088,6 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, -#endif -#ifdef CONFIG_DNOTIFY - { - .procname = "dir-notify-enable", - .data = &dir_notify_enable, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec, },#endif #ifdef CONFIG_MMU
_
Andrew Morton
maintainerPATCH 11/69 hpet: simplify subdirectory registration with register_sysctl()
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: hpet: simplify subdirectory registration with register_sysctl()
Patch series "sysctl: second set of kernel/sysctl cleanups", v2.
This is the 2nd set of kernel/sysctl.c cleanups. The diff stat should reflect how this is a much better way to deal with theses. Fortunately coccinelle can be used to ensure correctness for most of these and/or future merge conflicts.
Note that since this is part of a larger effort to cleanup kernel/sysctl.c I think we have no other option but to go with merging these patches in either Andrew's tree or keep them staged in a separate tree and send a merge request later. Otherwise kernel/sysctl.c will end up becoming a sore spot for the next merge window.
This patch (of 8):
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 drivers/char/hpet.c
@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
---
drivers/char/hpet.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
drivers/char/hpet.c renamed from drivers/char/hpet.c~hpet-simplify-subdirectory-registration-with-register_sysctl +1 -21
@@ -746,26 +746,6 @@ static struct ctl_table hpet_table[] = { {} }; -static struct ctl_table hpet_root[] = { - { - .procname ="hpet" , - .maxlen =0 , - .mode =0555 , - .child = hpet_table, - }, - {} -}; - -static struct ctl_table dev_root[] = { - { - .procname ="dev" , - .maxlen =0 , - .mode =0555 , - .child = hpet_root, - }, - {} -}; -static struct ctl_table_header *sysctl_header;/*
@@ -1061,7 +1041,7 @@ static int __init hpet_init(void)if (result <0 )return -ENODEV ; - sysctl_header =register_sysctl_table (dev_root); + sysctl_header =register_sysctl ("dev/hpet" , hpet_table); result =acpi_bus_register_driver (&hpet_acpi_driver);if (result <0 ) {
_
Andrew Morton
maintainerPATCH 12/69 i915: simplify subdirectory registration with register_sysctl()
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: i915: simplify subdirectory registration with register_sysctl()
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);
---
drivers/gpu/drm/i915/i915_perf.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_perf.c renamed from drivers/gpu/drm/i915/i915_perf.c~i915-simplify-subdirectory-registration-with-register_sysctl +1 -21
@@ -4273,26 +4273,6 @@ static struct ctl_table oa_table[] = { {} }; -static struct ctl_table i915_root[] = { - { - .procname ="i915" , - .maxlen =0 , - .mode =0555 , - .child = oa_table, - }, - {} -}; - -static struct ctl_table dev_root[] = { - { - .procname ="dev" , - .maxlen =0 , - .mode =0555 , - .child = i915_root, - }, - {} -}; -static void oa_init_supported_formats (struct i915_perf *perf) {struct drm_i915_private *i915 = perf->i915;
@@ -4488,7 +4468,7 @@ static int destroy_config(int id, void *int i915_perf_sysctl_register (void ) { - sysctl_header =register_sysctl_table (dev_root); + sysctl_header =register_sysctl ("dev/i915" , oa_table);return 0 ; }
_
Andrew Morton
maintainerPATCH 13/69 macintosh/mac_hid.c: simplify subdirectory registration with register_sysctl()
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: macintosh/mac_hid.c: simplify subdirectory registration with register_sysctl()
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);
---
drivers/macintosh/mac_hid.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-)
drivers/macintosh/mac_hid.c renamed from drivers/macintosh/mac_hid.c~macintosh-mac_hidc-simplify-subdirectory-registration-with-register_sysctl +1 -23
@@ -239,33 +239,11 @@ static struct ctl_table mac_hid_files[] { } }; -/* dir in /proc/sys/dev */ -static struct ctl_table mac_hid_dir[] = { - { - .procname ="mac_hid" , - .maxlen =0 , - .mode =0555 , - .child = mac_hid_files, - }, - { } -}; - -/* /proc/sys/dev itself, in case that is not there yet */ -static struct ctl_table mac_hid_root_dir[] = { - { - .procname ="dev" , - .maxlen =0 , - .mode =0555 , - .child = mac_hid_dir, - }, - { } -}; -static struct ctl_table_header *mac_hid_sysctl_header;static int __init mac_hid_init (void ) { - mac_hid_sysctl_header =register_sysctl_table (mac_hid_root_dir); + mac_hid_sysctl_header =register_sysctl ("dev/mac_hid" , mac_hid_files);if (!mac_hid_sysctl_header)return -ENOMEM ;
_
Andrew Morton
maintainerPATCH 14/69 ocfs2: simplify subdirectory registration with register_sysctl()
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: ocfs2: simplify subdirectory registration with register_sysctl()
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);
---
fs/ocfs2/stackglue.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-)
fs/ocfs2/stackglue.c renamed from fs/ocfs2/stackglue.c~ocfs2-simplify-subdirectory-registration-with-register_sysctl +1 -24
@@ -672,31 +672,8 @@ static struct ctl_table ocfs2_mod_table[ { } }; -static struct ctl_table ocfs2_kern_table[] = { - { - .procname ="ocfs2" , - .data =NULL , - .maxlen =0 , - .mode =0555 , - .child = ocfs2_mod_table - }, - { } -}; - -static struct ctl_table ocfs2_root_table[] = { - { - .procname ="fs" , - .data =NULL , - .maxlen =0 , - .mode =0555 , - .child = ocfs2_kern_table - }, - { } -}; -static struct ctl_table_header *ocfs2_table_header; -/* * Initialization */
@@ -705,7 +682,7 @@ static int __init ocfs2_stack_glue_init( {strcpy (cluster_stack_name,OCFS2_STACK_PLUGIN_O2CB ); - ocfs2_table_header =register_sysctl_table (ocfs2_root_table); + ocfs2_table_header =register_sysctl ("fs/ocfs2" , ocfs2_mod_table);if (!ocfs2_table_header) {printk (KERN_ERR "ocfs2 stack glue: unable to register sysctl\n" );
_
Andrew Morton
maintainerPATCH 15/69 test_sysctl: simplify subdirectory registration with register_sysctl()
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: test_sysctl: simplify subdirectory registration with register_sysctl()
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 lib/test_sysctl.c
@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);
---
lib/test_sysctl.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
lib/test_sysctl.c renamed from lib/test_sysctl.c~test_sysctl-simplify-subdirectory-registration-with-register_sysctl +1 -21
@@ -128,26 +128,6 @@ static struct ctl_table test_table[] = { { } }; -static struct ctl_table test_sysctl_table[] = { - { - .procname ="test_sysctl" , - .maxlen =0 , - .mode =0555 , - .child = test_table, - }, - { } -}; - -static struct ctl_table test_sysctl_root_table[] = { - { - .procname ="debug" , - .maxlen =0 , - .mode =0555 , - .child = test_sysctl_table, - }, - { } -}; -static struct ctl_table_header *test_sysctl_header;static int __init test_sysctl_init (void )
@@ -155,7 +135,7 @@ static int __init test_sysctl_init(void) test_data.bitmap_0001 =kzalloc (SYSCTL_TEST_BITMAP_SIZE /8 ,GFP_KERNEL );if (!test_data.bitmap_0001)return -ENOMEM ; - test_sysctl_header =register_sysctl_table (test_sysctl_root_table); + test_sysctl_header =register_sysctl ("debug/test_sysctl" , test_table);if (!test_sysctl_header) {kfree (test_data.bitmap_0001);return -ENOMEM ;
_
Andrew Morton
maintainerPATCH 16/69 inotify: simplify subdirectory registration with register_sysctl()
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: inotify: simplify subdirectory registration with register_sysctl()
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.
---
fs/notify/fanotify/fanotify_user.c | 10 +++++++++- fs/notify/inotify/inotify_user.c | 11 ++++++++++- include/linux/fanotify.h | 2 -- include/linux/inotify.h | 3 --- kernel/sysctl.c | 21 --------------------- 5 files changed, 19 insertions(+), 28 deletions(-)
fs/notify/fanotify/fanotify_user.c renamed from fs/notify/fanotify/fanotify_user.c~inotify-simplify-subdirectory-registration-with-register_sysctl +9 -1
@@ -59,7 +59,7 @@ static int fanotify_max_queued_events __static long ft_zero =0 ;static long ft_int_max =INT_MAX ; -struct ctl_table fanotify_table[] = { +static struct ctl_table fanotify_table[] = { { .procname ="max_user_groups" , .data = &init_user_ns.ucount_max[UCOUNT_FANOTIFY_GROUPS ],
@@ -88,6 +88,13 @@ struct ctl_table fanotify_table[] = { }, { } }; + +static void __init fanotify_sysctls_init (void ) +{ +register_sysctl ("fs/fanotify" , fanotify_table); +} +#else +#define fanotify_sysctls_init () do { } while (0)#endif /* CONFIG_SYSCTL */ /*
@@ -1743,6 +1750,7 @@ static int __init fanotify_user_setup(vo init_user_ns.ucount_max[UCOUNT_FANOTIFY_GROUPS ] =FANOTIFY_DEFAULT_MAX_GROUPS ; init_user_ns.ucount_max[UCOUNT_FANOTIFY_MARKS ] = max_marks; +fanotify_sysctls_init ();return 0 ; }
fs/notify/inotify/inotify_user.c renamed from fs/notify/inotify/inotify_user.c~inotify-simplify-subdirectory-registration-with-register_sysctl +10 -1
@@ -58,7 +58,7 @@ struct kmem_cache *inotify_inode_mark_castatic long it_zero =0 ;static long it_int_max =INT_MAX ; -struct ctl_table inotify_table[] = { +static struct ctl_table inotify_table[] = { { .procname ="max_user_instances" , .data = &init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES ],
@@ -87,6 +87,14 @@ struct ctl_table inotify_table[] = { }, { } }; + +static void __init inotify_sysctls_init (void ) +{ +register_sysctl ("fs/inotify" , inotify_table); +} + +#else +#define inotify_sysctls_init () do { } while (0)#endif /* CONFIG_SYSCTL */ static inline __u32 inotify_arg_to_mask (struct inode *inode,u32 arg)
@@ -849,6 +857,7 @@ static int __init inotify_user_setup(voi inotify_max_queued_events =16384 ; init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES ] =128 ; init_user_ns.ucount_max[UCOUNT_INOTIFY_WATCHES ] = watches_max; +inotify_sysctls_init ();return 0 ; }
include/linux/fanotify.h renamed from include/linux/fanotify.h~inotify-simplify-subdirectory-registration-with-register_sysctl +0 -2
@@ -5,8 +5,6 @@#include <linux/sysctl.h> #include <uapi/linux/fanotify.h> -extern struct ctl_table fanotify_table[];/* for sysctl */ -#define FAN_GROUP_FLAG (group, flag) \ ((group)->fanotify_data.flags & (flag))
include/linux/inotify.h renamed from include/linux/inotify.h~inotify-simplify-subdirectory-registration-with-register_sysctl +0 -3
@@ -7,11 +7,8 @@#ifndef _LINUX_INOTIFY_H#define _LINUX_INOTIFY_H -#include <linux/sysctl.h> #include <uapi/linux/inotify.h> -extern struct ctl_table inotify_table[];/* for sysctl */ -#define ALL_INOTIFY_BITS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ IN_MOVED_TO | IN_CREATE | IN_DELETE | \
kernel/sysctl.c renamed from kernel/sysctl.c~inotify-simplify-subdirectory-registration-with-register_sysctl +0 -21
@@ -126,13 +126,6 @@ static const int maxolduid = 65535;static const int ngroups_max =NGROUPS_MAX ;static const int cap_last_cap =CAP_LAST_CAP ; -#ifdef CONFIG_INOTIFY_USER -#include <linux/inotify.h> -#endif -#ifdef CONFIG_FANOTIFY -#include <linux/fanotify.h> -#endif -#ifdef CONFIG_PROC_SYSCTL /**
@@ -3100,20 +3093,6 @@ static struct ctl_table fs_table[] = { .proc_handler = proc_dointvec, },#endif -#ifdef CONFIG_INOTIFY_USER - { - .procname = "inotify", - .mode = 0555, - .child = inotify_table, - }, -#endif -#ifdef CONFIG_FANOTIFY - { - .procname = "fanotify", - .mode = 0555, - .child = fanotify_table, - }, -#endif#ifdef CONFIG_EPOLL { .procname = "epoll",
_
Andrew Morton
maintainerPATCH 17/69 cdrom: simplify subdirectory registration with register_sysctl()
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: cdrom: simplify subdirectory registration with register_sysctl()
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);
---
drivers/cdrom/cdrom.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/cdrom/cdrom.c renamed from drivers/cdrom/cdrom.c~cdrom-simplify-subdirectory-registration-with-register_sysctl +1 -22
@@ -3691,27 +3691,6 @@ static struct ctl_table cdrom_table[] = }, { } }; - -static struct ctl_table cdrom_cdrom_table[] = { - { - .procname ="cdrom" , - .maxlen =0 , - .mode =0555 , - .child = cdrom_table, - }, - { } -}; - -/* Make sure that /proc/sys/dev is there */ -static struct ctl_table cdrom_root_table[] = { - { - .procname ="dev" , - .maxlen =0 , - .mode =0555 , - .child = cdrom_cdrom_table, - }, - { } -};static struct ctl_table_header *cdrom_sysctl_header;static void cdrom_sysctl_register (void )
@@ -3721,7 +3700,7 @@ static void cdrom_sysctl_register(void)if (!atomic_add_unless (&initialized,1 ,1 ))return ; - cdrom_sysctl_header =register_sysctl_table (cdrom_root_table); + cdrom_sysctl_header =register_sysctl ("dev/cdrom" , cdrom_table);/* set the defaults */ cdrom_sysctl_settings.autoclose = autoclose;
_
Andrew Morton
maintainerPATCH 18/69 eventpoll: simplify sysctl declaration with register_sysctl()
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: eventpoll: simplify sysctl declaration with register_sysctl()
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().
---
fs/eventpoll.c | 10 +++++++++- include/linux/poll.h | 2 -- include/linux/sysctl.h | 1 - kernel/sysctl.c | 7 ------- 4 files changed, 9 insertions(+), 11 deletions(-)
fs/eventpoll.c renamed from fs/eventpoll.c~eventpoll-simplify-sysctl-declaration-with-register_sysctl +9 -1
@@ -307,7 +307,7 @@ static void unlist_file(struct epitems_hstatic long long_zero;static long long_max =LONG_MAX ; -struct ctl_table epoll_table[] = { +static struct ctl_table epoll_table[] = { { .procname ="max_user_watches" , .data = &max_user_watches,
@@ -319,6 +319,13 @@ struct ctl_table epoll_table[] = { }, { } }; + +static void __init epoll_sysctls_init (void ) +{ +register_sysctl ("fs/epoll" , epoll_table); +} +#else +#define epoll_sysctls_init () do { } while (0)#endif /* CONFIG_SYSCTL */ static const struct file_operations eventpoll_fops;
@@ -2378,6 +2385,7 @@ static int __init eventpoll_init(void)/* Allocates slab cache used to allocate "struct eppoll_entry" */ pwq_cache =kmem_cache_create ("eventpoll_pwq" ,sizeof (struct eppoll_entry ),0 ,SLAB_PANIC |SLAB_ACCOUNT ,NULL ); +epoll_sysctls_init (); ephead_cache =kmem_cache_create ("ep_head" ,sizeof (struct epitems_head ),0 ,SLAB_PANIC |SLAB_ACCOUNT ,NULL );
include/linux/poll.h renamed from include/linux/poll.h~eventpoll-simplify-sysctl-declaration-with-register_sysctl +0 -2
@@ -8,12 +8,10 @@#include <linux/wait.h> #include <linux/string.h> #include <linux/fs.h> -#include <linux/sysctl.h> #include <linux/uaccess.h> #include <uapi/linux/poll.h> #include <uapi/linux/eventpoll.h> -extern struct ctl_table epoll_table[];/* for sysctl */ /* ~832 bytes of stack space used max in sys_select/sys_poll before allocating additional memory. */ #ifdef __clang__
include/linux/sysctl.h renamed from include/linux/sysctl.h~eventpoll-simplify-sysctl-declaration-with-register_sysctl +0 -1
@@ -219,7 +219,6 @@ extern int no_unaligned_warning;extern struct ctl_table sysctl_mount_point[];extern struct ctl_table random_table[];extern struct ctl_table firmware_config_table[]; -extern struct ctl_table epoll_table[];#else /* CONFIG_SYSCTL */ static inline struct ctl_table_header *register_sysctl_table (struct ctl_table * table)
kernel/sysctl.c renamed from kernel/sysctl.c~eventpoll-simplify-sysctl-declaration-with-register_sysctl +0 -7
@@ -3093,13 +3093,6 @@ static struct ctl_table fs_table[] = { .proc_handler = proc_dointvec, },#endif -#ifdef CONFIG_EPOLL - { - .procname = "epoll", - .mode = 0555, - .child = epoll_table, - }, -#endif#endif { .procname = "protected_symlinks",
_
Andrew Morton
maintainerPATCH 19/69 firmware_loader: move firmware sysctl to its own files
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: firmware_loader: move firmware sysctl to its own files
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.
---
drivers/base/firmware_loader/fallback.c | 7 +++- drivers/base/firmware_loader/fallback.h | 11 +++++++ drivers/base/firmware_loader/fallback_table.c | 25 ++++++++++++++-- include/linux/sysctl.h | 1 kernel/sysctl.c | 7 ---- 5 files changed, 40 insertions(+), 11 deletions(-)
drivers/base/firmware_loader/fallback.c renamed from drivers/base/firmware_loader/fallback.c~firmware_loader-move-firmware-sysctl-to-its-own-files +6 -1
@@ -199,11 +199,16 @@ static struct class firmware_class = {int register_sysfs_loader (void ) { -return class_register (&firmware_class); +int ret =class_register (&firmware_class); + +if (ret !=0 ) +return ret; +return register_firmware_config_sysctl (); }void unregister_sysfs_loader (void ) { +unregister_firmware_config_sysctl ();class_unregister (&firmware_class); }
drivers/base/firmware_loader/fallback.h renamed from drivers/base/firmware_loader/fallback.h~firmware_loader-move-firmware-sysctl-to-its-own-files +11 -0
@@ -42,6 +42,17 @@ void fw_fallback_set_default_timeout(voiint register_sysfs_loader (void );void unregister_sysfs_loader (void ); +#ifdef CONFIG_SYSCTL +extern int register_firmware_config_sysctl (void ); +extern void unregister_firmware_config_sysctl (void ); +#else +static inline int register_firmware_config_sysctl (void ) +{ +return 0 ; +} +static inline void unregister_firmware_config_sysctl (void ) { } +#endif /* CONFIG_SYSCTL */ +#else /* CONFIG_FW_LOADER_USER_HELPER */ static inline int firmware_fallback_sysfs(struct firmware *fw, const char *name, struct device *device,
drivers/base/firmware_loader/fallback_table.c renamed from drivers/base/firmware_loader/fallback_table.c~firmware_loader-move-firmware-sysctl-to-its-own-files +23 -2
@@ -4,6 +4,7 @@#include <linux/kconfig.h> #include <linux/list.h> #include <linux/slab.h> +#include <linux/export.h> #include <linux/security.h> #include <linux/highmem.h> #include <linux/umh.h>
@@ -24,7 +25,7 @@ struct firmware_fallback_config fw_fallbEXPORT_SYMBOL_NS_GPL (fw_fallback_config,FIRMWARE_LOADER_PRIVATE ); #ifdef CONFIG_SYSCTL -struct ctl_table firmware_config_table[] = { +static struct ctl_table firmware_config_table[] = { { .procname = "force_sysfs_fallback", .data = &fw_fallback_config.force_sysfs_fallback,
@@ -45,4 +46,24 @@ struct ctl_table firmware_config_table[] }, { } }; -#endif + +static struct ctl_table_header *firmware_config_sysct_table_header; +int register_firmware_config_sysctl (void ) +{ + firmware_config_sysct_table_header = +register_sysctl ("kernel/firmware_config" , + firmware_config_table); +if (!firmware_config_sysct_table_header) +return -ENOMEM ; +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (register_firmware_config_sysctl,FIRMWARE_LOADER_PRIVATE ); + +void unregister_firmware_config_sysctl (void ) +{ +unregister_sysctl_table (firmware_config_sysct_table_header); + firmware_config_sysct_table_header =NULL ; +} +EXPORT_SYMBOL_NS_GPL (unregister_firmware_config_sysctl,FIRMWARE_LOADER_PRIVATE ); + +#endif /* CONFIG_SYSCTL */
include/linux/sysctl.h renamed from include/linux/sysctl.h~firmware_loader-move-firmware-sysctl-to-its-own-files +0 -1
@@ -218,7 +218,6 @@ extern int no_unaligned_warning;extern struct ctl_table sysctl_mount_point[];extern struct ctl_table random_table[]; -extern struct ctl_table firmware_config_table[];#else /* CONFIG_SYSCTL */ static inline struct ctl_table_header *register_sysctl_table (struct ctl_table * table)
kernel/sysctl.c renamed from kernel/sysctl.c~firmware_loader-move-firmware-sysctl-to-its-own-files +0 -7
@@ -2154,13 +2154,6 @@ static struct ctl_table kern_table[] = { .mode = 0555, .child = usermodehelper_table, }, -#ifdef CONFIG_FW_LOADER_USER_HELPER - { - .procname = "firmware_config", - .mode = 0555, - .child = firmware_config_table, - }, -#endif { .procname = "overflowuid", .data = &overflowuid,
_
Andrew Morton
maintainerPATCH 20/69 random: move the random sysctl declarations to its own file
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: random: move the random sysctl declarations to its own file
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().
---
drivers/char/random.c | 14 ++++++++++++-- include/linux/sysctl.h | 1 - kernel/sysctl.c | 5 ----- 3 files changed, 12 insertions(+), 8 deletions(-)
drivers/char/random.c renamed from drivers/char/random.c~random-move-the-random-sysctl-declarations-to-its-own-file +12 -2
@@ -1992,8 +1992,7 @@ static int proc_do_entropy(struct ctl_ta }static int sysctl_poolsize =POOL_BITS ; -extern struct ctl_table random_table[]; -struct ctl_table random_table[] = { +static struct ctl_table random_table[] = { { .procname ="poolsize" , .data = &sysctl_poolsize,
@@ -2055,6 +2054,17 @@ struct ctl_table random_table[] = {#endif { } }; + +/* +* rand_initialize() is called before sysctl_init(), +* so we cannot call register_sysctl_init() in rand_initialize() +*/ +static int __init random_sysctls_init (void ) +{ +register_sysctl_init ("kernel/random" , random_table); +return 0 ; +} +device_initcall (random_sysctls_init);#endif /* CONFIG_SYSCTL */ struct batched_entropy {
include/linux/sysctl.h renamed from include/linux/sysctl.h~random-move-the-random-sysctl-declarations-to-its-own-file +0 -1
@@ -217,7 +217,6 @@ extern int unaligned_dump_stack;extern int no_unaligned_warning;extern struct ctl_table sysctl_mount_point[]; -extern struct ctl_table random_table[];#else /* CONFIG_SYSCTL */ static inline struct ctl_table_header *register_sysctl_table (struct ctl_table * table)
kernel/sysctl.c renamed from kernel/sysctl.c~random-move-the-random-sysctl-declarations-to-its-own-file +0 -5
@@ -2145,11 +2145,6 @@ static struct ctl_table kern_table[] = { .proc_handler = sysctl_max_threads, }, { - .procname = "random", - .mode = 0555, - .child = random_table, - }, - { .procname = "usermodehelper", .mode = 0555, .child = usermodehelper_table,
_
Andrew Morton
maintainerPATCH 21/69 sysctl: add helper to register a sysctl mount point
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: sysctl: add helper to register a sysctl mount point
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.
---
fs/proc/proc_sysctl.c | 14 ++++++++++++++ include/linux/sysctl.h | 7 +++++++ 2 files changed, 21 insertions(+)
fs/proc/proc_sysctl.c renamed from fs/proc/proc_sysctl.c~sysctl-add-helper-to-register-a-sysctl-mount-point +14 -0
@@ -35,6 +35,20 @@ struct ctl_table sysctl_mount_point[] = { } }; +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +return register_sysctl (path, sysctl_mount_point); +} +EXPORT_SYMBOL (register_sysctl_mount_point); +static bool is_empty_dir (struct ctl_table_header *head) {return head->ctl_table[0 ].child == sysctl_mount_point;
include/linux/sysctl.h renamed from include/linux/sysctl.h~sysctl-add-helper-to-register-a-sysctl-mount-point +7 -0
@@ -209,6 +209,8 @@ extern int sysctl_init(void);extern void __register_sysctl_init (const char *path,struct ctl_table *table,const char *table_name);#define register_sysctl_init (path, table) __register_sysctl_init(path, table, #table) +extern struct ctl_table_header *register_sysctl_mount_point (const char *path); +void do_sysctl_args (void );extern int pwrsw_enabled;
@@ -223,6 +225,11 @@ static inline struct ctl_table_header *r {return NULL ; } + +static inline struct sysctl_header *register_sysctl_mount_point (const char *path) +{ +return NULL ; +}static inline struct ctl_table_header *register_sysctl_paths (const struct ctl_path *path,struct ctl_table *table)
_
Andrew Morton
maintainerPATCH 22/69 fs: move binfmt_misc sysctl to its own file
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move binfmt_misc sysctl to its own file
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.
---
fs/binfmt_misc.c | 6 +++++- kernel/sysctl.c | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-)
fs/binfmt_misc.c renamed from fs/binfmt_misc.c~fs-move-binfmt_misc-sysctl-to-its-own-file +5 -1
@@ -822,7 +822,11 @@ static int __init init_misc_binfmt(void)int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); -return err; +if (!register_sysctl_mount_point ("fs/binfmt_misc" )) { +pr_warn ("Failed to create fs/binfmt_misc sysctl mount point" ); +return -ENOMEM ; + } +return 0 ; } static void __exit exit_misc_binfmt(void)
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-binfmt_misc-sysctl-to-its-own-file +0 -7
@@ -3127,13 +3127,6 @@ static struct ctl_table fs_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, }, -#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) - { - .procname = "binfmt_misc", - .mode = 0555, - .child = sysctl_mount_point, - }, -#endif { .procname = "pipe-max-size", .data = &pipe_max_size,
_
PATCH 1/1 Fix regression due to "fs: move binfmt_misc sysctl to its own file"
Commit 3ba442d5331f did not go unnoticed, binfmt-support stopped to work on my Debian system since v5.17-rc2 (did not check with -rc1).
The existance of /proc/sys/fs/binfmt_misc is a precondition for attempting to mount the binfmt_misc fs, which in turn triggers the autoload of the binfmt_misc module. Without it, no module is loaded and no binfmt is available at boot.
Building as built-in or manually loading the module and mounting the fs works fine, it's therefore only a matter of interaction with user-space.
I could try to improve the Debian systemd configuration but I can't say anything about the other distributions.
In the meanwhile this patch restores a working system right after boot.
--- fs/binfmt_misc.c | 6 +----- kernel/sysctl.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-)
fs/binfmt_misc.c +1 -5
@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" ); -return 0 ; +return err; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }
kernel/sysctl.c +13 -0
@@ -2806,6 +2806,17 @@ static struct ctl_table vm_table[] = { { } }; +static struct ctl_table fs_table[] = { +#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) + { + .procname = "binfmt_misc", + .mode = 0555, + .child = sysctl_mount_point, + }, +#endif + { } +}; + static struct ctl_table debug_table[] = { #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE {
@@ -2825,6 +2836,7 @@ static struct ctl_table dev_table[] = {DECLARE_SYSCTL_BASE (kernel, kern_table);DECLARE_SYSCTL_BASE (vm, vm_table); +DECLARE_SYSCTL_BASE (fs, fs_table);DECLARE_SYSCTL_BASE (debug, debug_table);DECLARE_SYSCTL_BASE (dev, dev_table);
@@ -2832,6 +2844,7 @@ int __init sysctl_init_bases(void) {register_sysctl_base (kernel);register_sysctl_base (vm); +register_sysctl_base (fs);register_sysctl_base (debug);register_sysctl_base (dev);
Luis Chamberlain
maintainerRe: [PATCH] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
Quoted 76 lines · Domenico Andreoli
Commit
3ba442d5331fdid not go unnoticed, binfmt-support stopped to work on my Debian system since v5.17-rc2 (did not check with -rc1).The existance of
/proc/sys/fs/binfmt_miscis a precondition for attempting to mount thebinfmt_miscfs, which in turn triggers the autoload of thebinfmt_miscmodule. Without it, no module is loaded and no binfmt is available at boot.Building as built-in or manually loading the module and mounting the fs works fine, it's therefore only a matter of interaction with user-space.
I could try to improve the Debian systemd configuration but I can't say anything about the other distributions.
In the meanwhile this patch restores a working system right after boot.
Fixes 3ba442d5331f ("fs: move binfmt_misc sysctl to its own file")Signed-off-by Domenico Andreoli <[email protected]>Cc Al Viro <[email protected]>Cc Amir Goldstein <[email protected]>Cc Andrew Morton <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Antti Palosaari <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Benjamin LaHaise <[email protected]>Cc Clemens Ladisch <[email protected]>Cc David Airlie <[email protected]>Cc Douglas Gilbert <[email protected]>Cc Eric Biederman <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Iurii Zaikin <[email protected]>Cc James E.J. Bottomley <[email protected]>Cc Jan Kara <[email protected]>Cc Jani Nikula <[email protected]>Cc Jani Nikula <[email protected]>Cc Joel Becker <[email protected]>Cc John Ogness <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Joseph Qi <[email protected]>Cc Julia Lawall <[email protected]>Cc Kees Cook <[email protected]>Cc Lukas Middendorf <[email protected]>Cc Luis Chamberlain <[email protected]>Cc Mark Fasheh <[email protected]>Cc Martin K. Petersen <[email protected]>Cc Paul Turner <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Petr Mladek <[email protected]>Cc Phillip Potter <[email protected]>Cc Qing Wang <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Sebastian Reichel <[email protected]>Cc Sergey Senozhatsky <[email protected]>Cc Stephen Kitt <[email protected]>Cc Steven Rostedt (VMware) <[email protected]>Cc Suren Baghdasaryan <[email protected]>Cc Tetsuo Handa <[email protected]>Cc "Theodore Ts'o" <[email protected]>Cc Xiaoming Ni <[email protected]>--- fs/binfmt_misc.c | 6 +----- kernel/sysctl.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-)Index:
b/fs/binfmt_misc.c
===================================================================fs/binfmt_misc.c +0
-1@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header;
fs/binfmt_misc.c static struct file_system_type bm_fs_typ · line 826
Quoted 10 lines
fs/binfmt_misc.c +1
-3-static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" ); -return 0 ; +return err; }
OK I think the issue here should have been that declaring this on fs/binfmt_misc.c creates the chicken and the egg issue, and so we need to do this on built-in code. Instead of your patch can you try this instead, it just always creates the sysctl mount always now so long as proc sysctl is enabled. It does not do the unregistration as we always want the path present as it used to be before as well.
fs/binfmt_misc.c +0 -4
@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_type = { };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }
fs/file_table.c +1 -0
@@ -119,6 +119,7 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);
Re: [PATCH] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
Quoted 13 lines · Luis Chamberlain
OK I think the issue here should have been that declaring this on
fs/binfmt_misc.ccreates the chicken and the egg issue, and so we need to do this on built-in code. Instead of your patch can you try this instead, it just always creates the sysctl mount always now so long as proc sysctl is enabled. It does not do the unregistration as we always want the path present as it used to be before as well.fs/file_table.c +0
-0
fs/file_table.c static struct ctl_table fs_stat_sysctls[] = { · line 125
Quoted 7 lines
fs/file_table.c +1
-0@@ -119,6 +119,7 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);
I'm looking at the original code, and it seems that if we don't select CONFIG_BINFMT_MISC at all,
this file won't be created. This would suggest an IF MACRO around
Quoted 1 line
+
register_sysctl_mount_point("fs/binfmt_misc");
and it should looks like
+#if IS_ENABLED(CONFIG_BINFMT_MISC)
+ register_sysctl_mount_point("fs/binfmt_misc");
+#endif
or if you prefer original style:
#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
- Tong
Luis Chamberlain
maintainerRe: [PATCH] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
Quoted 30 lines · Tong Zhang
Quoted 13 lines · Luis Chamberlain
OK I think the issue here should have been that declaring this on
fs/binfmt_misc.ccreates the chicken and the egg issue, and so we need to do this on built-in code. Instead of your patch can you try this instead, it just always creates the sysctl mount always now so long as proc sysctl is enabled. It does not do the unregistration as we always want the path present as it used to be before as well.fs/file_table.c +0
-0fs/file_table.c static struct ctl_table fs_stat_sysctls[] = { · line 125
Quoted 7 lines
fs/file_table.c +1
-0@@ -119,6 +119,7 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);I'm looking at the original code, and it seems that if we don't select
CONFIG_BINFMT_MISCat all,
this file won't be created. This would suggest an IF MACRO aroundQuoted 1 line
+
register_sysctl_mount_point("fs/binfmt_misc");and it should looks like
(quoted diff) +3
-0+#if IS_ENABLED(CONFIG_BINFMT_MISC) + register_sysctl_mount_point("fs/binfmt_misc"); +#endif
Quoted 2 lines
or if you prefer original style:
#ifdefined(CONFIG_BINFMT_MISC)||defined(CONFIG_BINFMT_MISC_MODULE)
Or better yet using IS_ENABLED() to avoid the ifdef cruft:
fs/binfmt_misc.c +0 -4
@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_type = { };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }
fs/file_table.c +2 -0
@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);
Re: [PATCH] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
Quoted 66 lines · Luis Chamberlain
Quoted 30 lines · Tong Zhang
Quoted 13 lines · Luis Chamberlain
OK I think the issue here should have been that declaring this on
fs/binfmt_misc.ccreates the chicken and the egg issue, and so we need to do this on built-in code. Instead of your patch can you try this instead, it just always creates the sysctl mount always now so long as proc sysctl is enabled. It does not do the unregistration as we always want the path present as it used to be before as well.fs/file_table.c +0
-0fs/file_table.c static struct ctl_table fs_stat_sysctls[] = { · line 125
Quoted 7 lines
fs/file_table.c +1
-0@@ -119,6 +119,7 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);I'm looking at the original code, and it seems that if we don't select
CONFIG_BINFMT_MISCat all,
this file won't be created. This would suggest an IF MACRO aroundQuoted 1 line
+
register_sysctl_mount_point("fs/binfmt_misc");and it should looks like
(quoted diff) +3
-0+#if IS_ENABLED(CONFIG_BINFMT_MISC) + register_sysctl_mount_point("fs/binfmt_misc"); +#endifQuoted 2 lines
or if you prefer original style:
#ifdefined(CONFIG_BINFMT_MISC)||defined(CONFIG_BINFMT_MISC_MODULE)Or better yet using
IS_ENABLED()to avoid the ifdef cruft:fs/binfmt_misc.c +0
-4@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_type = { };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }fs/file_table.c +0
-0
fs/file_table.c static struct ctl_table fs_stat_sysctls[] = { · line 126
Quoted 8 lines
fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);
Apologies for the late reply, I was notified the patch is added to the mm patchset and thought to be late for any update but now I'm not seeing it anywhere. Maybe it's been dropped?
Forgot of IS_ENABLED(), I would surely use it in the v2.
Not clear what's the benefit in registering the mount point in fs/file_table.c vs. kernel/sysctl.c. I'd keep it close to where people was used to find it, unless there is a good reason otherwise.
Could you please elaborate?
Thanks for your review!
Dom
Signature · 2 lines
rsa4096: 3B10 0CA1 8674 ACBA B4FE FCD2 CE5B CF17 9960 DE13 ed25519: FFB4 0CC3 7F2E 091D F7DA 356E CC79 2832 ED38 CB05
PATCH v2 1/1 Fix regression due to "fs: move binfmt_misc sysctl to its own file"
In reply to Luis ChamberlainCommit 3ba442d5331f did not go unnoticed, binfmt-support stopped to work on my Debian system since v5.17-rc2 (did not check with -rc1).
The existance of the /proc/sys/fs/binfmt_misc is a precondition for attempting to mount the binfmt_misc fs, which in turn triggers the autoload of the binfmt_misc module. Without it, no module is loaded and no binfmt is available at boot.
Building as built-in or manually loading the module and mounting the fs works fine, it's therefore only a matter of interaction with user-space. I could try to improve the Debian systemd configuration but I can't say anything about the other distributions.
This patch restores a working system right after boot.
v2:
- move creation of fs/binfmt_misc to fs/file_table.c
- use IS_ENABLED() to conditionally create it
--- fs/binfmt_misc.c | 6 +----- fs/file_table.c | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-)
fs/binfmt_misc.c +1 -5
@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" ); -return 0 ; +return err; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }
fs/file_table.c +2 -0
@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);
Re: [PATCH v2] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
Quoted 101 lines · Domenico Andreoli
Commit
3ba442d5331fdid not go unnoticed, binfmt-support stopped to work on my Debian system since v5.17-rc2 (did not check with -rc1).The existance of the
/proc/sys/fs/binfmt_miscis a precondition for attempting to mount thebinfmt_miscfs, which in turn triggers the autoload of thebinfmt_miscmodule. Without it, no module is loaded and no binfmt is available at boot.Building as built-in or manually loading the module and mounting the fs works fine, it's therefore only a matter of interaction with user-space. I could try to improve the Debian systemd configuration but I can't say anything about the other distributions.
This patch restores a working system right after boot.
v2:
- move creation offs/binfmt_misctofs/file_table.c
- useIS_ENABLED()to conditionally create itFixes 3ba442d5331f ("fs: move binfmt_misc sysctl to its own file")Signed-off-by Domenico Andreoli <[email protected]>Cc Al Viro <[email protected]>Cc Amir Goldstein <[email protected]>Cc Andrew Morton <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Antti Palosaari <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Benjamin LaHaise <[email protected]>Cc Clemens Ladisch <[email protected]>Cc David Airlie <[email protected]>Cc Douglas Gilbert <[email protected]>Cc Eric Biederman <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Iurii Zaikin <[email protected]>Cc James E.J. Bottomley <[email protected]>Cc Jan Kara <[email protected]>Cc Jani Nikula <[email protected]>Cc Jani Nikula <[email protected]>Cc Joel Becker <[email protected]>Cc John Ogness <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Joseph Qi <[email protected]>Cc Julia Lawall <[email protected]>Cc Kees Cook <[email protected]>Cc Lukas Middendorf <[email protected]>Cc Mark Fasheh <[email protected]>Cc Martin K. Petersen <[email protected]>Cc Paul Turner <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Petr Mladek <[email protected]>Cc Phillip Potter <[email protected]>Cc Qing Wang <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Sebastian Reichel <[email protected]>Cc Sergey Senozhatsky <[email protected]>Cc Stephen Kitt <[email protected]>Cc Steven Rostedt (VMware) <[email protected]>Cc Suren Baghdasaryan <[email protected]>Cc Tetsuo Handa <[email protected]>Cc "Theodore Ts'o" <[email protected]>Cc Xiaoming Ni <[email protected]>--- fs/binfmt_misc.c | 6 +----- fs/file_table.c | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-)Index:
b/fs/binfmt_misc.c
===================================================================fs/binfmt_misc.c +1
-5@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" ); -return 0 ; +return err; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }Index:
b/fs/file_table.c
===================================================================
fs/file_table.c static struct ctl_table fs_stat_sysctls[ · line 126
Quoted 8 lines
fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);
Looks good
Thanks!
Re: [PATCH v2] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
In reply to Domenico AndreoliQuoted 35 lines · Domenico Andreoli
fs/binfmt_misc.c | 6 +----- fs/file_table.c | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-)Index:
b/fs/binfmt_misc.c
===================================================================fs/binfmt_misc.c +1
-5@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" ); -return 0 ; +return err; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }Index:
b/fs/file_table.c
===================================================================
fs/file_table.c static struct ctl_table fs_stat_sysctls[ · line 123
Quoted 5 lines
fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );
Hi,
kmemleak complains about this:
# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff8881045fea88 (size 96):
comm "swapper/0", pid 1, jiffies 4294669355 (age 167.804s)
hex dump (first 32 bytes):
e0 c8 07 88 ff ff ff ff 00 00 00 00 01 00 00 00 ................
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff81d11637>] __register_sysctl_table+0x117/0x1150
[<ffffffff86c3600f>] init_fs_stat_sysctls+0x30/0x33
[<ffffffff81002558>] do_one_initcall+0x108/0x690
[<ffffffff86bca8bd>] kernel_init_freeable+0x45a/0x4de
[<ffffffff83e0757f>] kernel_init+0x1f/0x220
[<ffffffff810048cf>] ret_from_fork+0x1f/0x30Quoted 4 lines
fs/file_table.c +0
-0return 0 ; }fs_initcall (init_fs_stat_sysctls);
Re: [PATCH v2] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
Quoted 50 lines · Ido Schimmel
Quoted 35 lines · Domenico Andreoli
fs/binfmt_misc.c | 6 +----- fs/file_table.c | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-)Index:
b/fs/binfmt_misc.c
===================================================================fs/binfmt_misc.c +1
-5@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" ); -return 0 ; +return err; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }Index:
b/fs/file_table.c
===================================================================fs/file_table.c static struct ctl_table fs_stat_sysctls[ · line 123
Quoted 5 lines
fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );Hi,
kmemleak complains about this:
Quoted 17 lines
# cat /sys/kernel/debug/kmemleak unreferenced object 0xffff8881045fea88 (size 96): comm "swapper/0", pid 1, jiffies 4294669355 (age 167.804s) hex dump (first 32 bytes): e0 c8 07 88 ff ff ff ff 00 00 00 00 01 00 00 00 ................ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<ffffffff81d11637>] __register_sysctl_table+0x117/0x1150 [<ffffffff86c3600f>] init_fs_stat_sysctls+0x30/0x33 [<ffffffff81002558>] do_one_initcall+0x108/0x690 [<ffffffff86bca8bd>] kernel_init_freeable+0x45a/0x4de [<ffffffff83e0757f>] kernel_init+0x1f/0x220 [<ffffffff810048cf>] ret_from_fork+0x1f/0x30Quoted 3 lines
fs/file_table.c +0
-0return 0 ; }fs_initcall (init_fs_stat_sysctls);
Hi Ido,
Thanks for the report. This is a known issue. The fix is proposed here.
https://lore.kernel.org/all/[email protected]/ <https://lore.kernel.org/all/[email protected]/>
Thanks,
- Tong
Re: [PATCH v2] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
In reply to Ido SchimmelQuoted 47 lines · Ido Schimmel
Quoted 35 lines · Domenico Andreoli
fs/binfmt_misc.c | 6 +----- fs/file_table.c | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-)Index:
b/fs/binfmt_misc.c
===================================================================fs/binfmt_misc.c +1
-5@@ -817,20 +817,16 @@ static struct file_system_type bm_fs_typ };MODULE_ALIAS_FS ("binfmt_misc" ); -static struct ctl_table_header *binfmt_misc_header; -static int __init init_misc_binfmt (void ) {int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); - binfmt_misc_header =register_sysctl_mount_point ("fs/binfmt_misc" ); -return 0 ; +return err; } static void __exit exit_misc_binfmt(void) { -unregister_sysctl_table (binfmt_misc_header);unregister_binfmt (&misc_format);unregister_filesystem (&bm_fs_type); }Index:
b/fs/file_table.c
===================================================================fs/file_table.c static struct ctl_table fs_stat_sysctls[ · line 123
Quoted 5 lines
fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );Hi,
kmemleak complains about this:
Quoted 18 lines
# cat /sys/kernel/debug/kmemleak unreferenced object 0xffff8881045fea88 (size 96): comm "swapper/0", pid 1, jiffies 4294669355 (age 167.804s) hex dump (first 32 bytes): e0 c8 07 88 ff ff ff ff 00 00 00 00 01 00 00 00 ................ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<ffffffff81d11637>] __register_sysctl_table+0x117/0x1150 [<ffffffff86c3600f>] init_fs_stat_sysctls+0x30/0x33 [<ffffffff81002558>] do_one_initcall+0x108/0x690 [<ffffffff86bca8bd>] kernel_init_freeable+0x45a/0x4de [<ffffffff83e0757f>] kernel_init+0x1f/0x220 [<ffffffff810048cf>] ret_from_fork+0x1f/0x30Quoted 4 lines
fs/file_table.c +0
-0return 0 ; }fs_initcall (init_fs_stat_sysctls);
Hi Ido,
Thanks for the report. This is a known issue. The fix is proposed here.
https://lore.kernel.org/all/[email protected]/
Thanks,
- Tong
Re: [PATCH v2] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
Quoted 3 lines · Tong Zhang
Hi Ido,
Thanks for the report. This is a known issue. The fix is proposed here.
https://lore.kernel.org/all/[email protected]/
Great, thanks for letting me know
Re: [PATCH] Fix regression due to "fs: move binfmt_misc sysctl to its own file"
In reply to Domenico Andreoli[TLDR: I'm adding the regression report below to regzbot, the Linux kernel regression tracking bot; all text you find below is compiled from a few templates paragraphs you might have encountered already already from similar mails.]
Hi, this is your Linux kernel regression tracker speaking.
CCing the regression mailing list, as it should be in the loop for all regressions, as explained here:
https://www.kernel.org/doc/html/latest/admin-guide/reporting-issues.html
Quoted 8 lines · Domenico Andreoli
Commit
3ba442d5331fdid not go unnoticed, binfmt-support stopped to work on my Debian system since v5.17-rc2 (did not check with -rc1).The existance of
/proc/sys/fs/binfmt_miscis a precondition for attempting to mount thebinfmt_miscfs, which in turn triggers the autoload of thebinfmt_miscmodule. Without it, no module is loaded and no binfmt is available at boot.
Quoted 8 lines
Building as built-in or manually loading the module and mounting the fs works fine, it's therefore only a matter of interaction with user-space.
I could try to improve the Debian systemd configuration but I can't say anything about the other distributions.
In the meanwhile this patch restores a working system right after boot. [...]
To be sure this issue doesn't fall through the cracks unnoticed, I'm adding it to regzbot, my Linux kernel regression tracking bot:
#regzbot ^introduced 3ba442d5331f
#regzbot title binfmt-support stopped to work
#regzbot ignore-activity
Reminder for developers: when fixing the issue, please add a 'Link:' tags pointing to the report (the mail quoted above) using lore.kernel.org/r/, as explained in 'Documentation/process/submitting-patches.rst' and 'Documentation/process/5.Posting.rst'. This allows the bot to connect the report with any patches posted or committed to fix the issue; this again allows the bot to show the current status of regressions and automatically resolve the issue when the fix hits the right tree.
I'm sending this to everyone that got the initial report, to make them aware of the tracking. I also hope that messages like this motivate people to directly get at least the regression mailing list and ideally even regzbot involved when dealing with regressions, as messages like this wouldn't be needed then.
Don't worry, I'll send further messages wrt to this regression just to the lists (with a tag in the subject so people can filter them away), if they are relevant just for regzbot. With a bit of luck no such messages will be needed anyway.
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
P.S.: As the Linux kernel's regression tracker I'm getting a lot of reports on my table. I can only look briefly into most of them and lack knowledge about most of the areas they concern. I thus unfortunately will sometimes get things wrong or miss something important. I hope that's not the case here; if you think it is, don't hesitate to tell me in a public reply, it's in everyone's interest to set the public record straight.
Signature · 25 lines
Additional information about regzbot: If you want to know more about regzbot, check out its web-interface, the getting start guide, and the references documentation: https://linux-regtracking.leemhuis.info/regzbot/ https://gitlab.com/knurd42/regzbot/-/blob/main/docs/getting_started.md https://gitlab.com/knurd42/regzbot/-/blob/main/docs/reference.md The last two documents will explain how you can interact with regzbot yourself if your want to. Hint for reporters: when reporting a regression it's in your interest to CC the regression list and tell regzbot about the issue, as that ensures the regression makes it onto the radar of the Linux kernel's regression tracker -- that's in your interest, as it ensures your report won't fall through the cracks unnoticed. Hint for developers: you normally don't need to care about regzbot once it's involved. Fix the issue as you normally would, just remember to include 'Link:' tag in the patch descriptions pointing to all reports about the issue. This has been expected from developers even before regzbot showed up for reasons explained in 'Documentation/process/submitting-patches.rst' and 'Documentation/process/5.Posting.rst'.
Re: [PATCH] Fix regression due to "fs: move binfmt_misc sysctl to its own file" #forregzbot
For the record:
Sadly the fix for below regression didn't link to the report, as explained by 'Documentation/process/submitting-patches.rst' and 'Documentation/process/5.Posting.rst'. So I have to tell regzbot about the fix manually:
#regzbot fixed-by: b42bc9a3c5115c
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
P.S.: As the Linux kernel's regression tracker I'm getting a lot of reports on my table. I can only look briefly into most of them and lack knowledge about most of the areas they concern. I thus unfortunately will sometimes get things wrong or miss something important. I hope that's not the case here; if you think it is, don't hesitate to tell me in a public reply, it's in everyone's interest to set the public record straight.
TWIMC: this mail is primarily send for documentation purposes and for regzbot, my Linux kernel regression tracking bot. These mails usually contain '#forregzbot' in the subject, to make them easy to spot and filter.
Quoted 67 lines · Thorsten Leemhuis
[TLDR: I'm adding the regression report below to regzbot, the Linux kernel regression tracking bot; all text you find below is compiled from a few templates paragraphs you might have encountered already already from similar mails.]
Hi, this is your Linux kernel regression tracker speaking.
CCing the regression mailing list, as it should be in the loop for all regressions, as explained here:
https://www.kernel.org/doc/html/latest/admin-guide/reporting-issues.htmlQuoted 8 lines · Domenico Andreoli
Commit
3ba442d5331fdid not go unnoticed, binfmt-support stopped to work on my Debian system since v5.17-rc2 (did not check with -rc1).The existance of
/proc/sys/fs/binfmt_miscis a precondition for attempting to mount thebinfmt_miscfs, which in turn triggers the autoload of thebinfmt_miscmodule. Without it, no module is loaded and no binfmt is available at boot.Quoted 8 lines
Building as built-in or manually loading the module and mounting the fs works fine, it's therefore only a matter of interaction with user-space.
I could try to improve the Debian systemd configuration but I can't say anything about the other distributions.
In the meanwhile this patch restores a working system right after boot. [...]
To be sure this issue doesn't fall through the cracks unnoticed, I'm adding it to regzbot, my Linux kernel regression tracking bot:
#regzbot ^introduced
3ba442d5331f
#regzbot title binfmt-support stopped to work
#regzbot ignore-activityReminder for developers: when fixing the issue, please add a 'Link:' tags pointing to the report (the mail quoted above) using lore.kernel.org/r/, as explained in '
Documentation/process/submitting-patches.rst' and 'Documentation/process/5.Posting.rst'. This allows the bot to connect the report with any patches posted or committed to fix the issue; this again allows the bot to show the current status of regressions and automatically resolve the issue when the fix hits the right tree.I'm sending this to everyone that got the initial report, to make them aware of the tracking. I also hope that messages like this motivate people to directly get at least the regression mailing list and ideally even regzbot involved when dealing with regressions, as messages like this wouldn't be needed then.
Don't worry, I'll send further messages wrt to this regression just to the lists (with a tag in the subject so people can filter them away), if they are relevant just for regzbot. With a bit of luck no such messages will be needed anyway.
Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
P.S.: As the Linux kernel's regression tracker I'm getting a lot of reports on my table. I can only look briefly into most of them and lack knowledge about most of the areas they concern. I thus unfortunately will sometimes get things wrong or miss something important. I hope that's not the case here; if you think it is, don't hesitate to tell me in a public reply, it's in everyone's interest to set the public record straight.
Andrew Morton
maintainerPATCH 23/69 printk: move printk sysctl to printk/sysctl.c
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: printk: move printk sysctl to printk/sysctl.c
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.
---
kernel/printk/Makefile | 5 +- kernel/printk/internal.h | 6 ++ kernel/printk/printk.c | 1 kernel/printk/sysctl.c | 85 +++++++++++++++++++++++++++++++++++++ kernel/sysctl.c | 68 ----------------------------- 5 files changed, 96 insertions(+), 69 deletions(-)
kernel/printk/internal.h renamed from kernel/printk/internal.h~printk-move-printk-sysctl-to-printk-sysctlc +6 -0
@@ -4,6 +4,12 @@*/ #include <linux/percpu.h> +#if defined(CONFIG_PRINTK ) && defined(CONFIG_SYSCTL ) +void __init printk_sysctl_init (void ); +#else +#define printk_sysctl_init () do { } while (0) +#endif +#ifdef CONFIG_PRINTK /* Flags for a single printk record. */
kernel/printk/Makefile renamed from kernel/printk/Makefile~printk-move-printk-sysctl-to-printk-sysctlc +4 -1
@@ -2,5 +2,8 @@ obj-y = printk.o obj-$(CONFIG_PRINTK) += printk_safe.o obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o -obj-$(CONFIG_PRINTK) += printk_ringbuffer.o obj-$(CONFIG_PRINTK_INDEX) += index.o + +obj-$(CONFIG_PRINTK) += printk_support.o +printk_support-y := printk_ringbuffer.o +printk_support-$(CONFIG_SYSCTL) += sysctl.o
kernel/printk/printk.c renamed from kernel/printk/printk.c~printk-move-printk-sysctl-to-printk-sysctlc +1 -0
@@ -3211,6 +3211,7 @@ static int __init printk_late_init(void) ret =cpuhp_setup_state_nocalls (CPUHP_AP_ONLINE_DYN ,"printk:online" , console_cpu_notify,NULL );WARN_ON (ret <0 ); +printk_sysctl_init ();return 0 ; }late_initcall (printk_late_init);
kernel/printk/sysctl.c new file +85 -0
85 lines not on this page · raw message
kernel/sysctl.c renamed from kernel/sysctl.c~printk-move-printk-sysctl-to-printk-sysctlc +0 -68
80 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 24/69 scsi/sg: move sg-big-buff sysctl to scsi/sg.c
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: scsi/sg: move sg-big-buff sysctl to scsi/sg.c
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.
---
drivers/scsi/sg.c | 35 ++++++++++++++++++++++++++++++++++- include/scsi/sg.h | 4 ---- kernel/sysctl.c | 12 ------------ 3 files changed, 34 insertions(+), 17 deletions(-)
drivers/scsi/sg.c renamed from drivers/scsi/sg.c~scsi-sg-move-sg-big-buff-sysctl-to-scsi-sgc +34 -1
@@ -77,7 +77,7 @@ static int sg_proc_init(void);#define SG_DEFAULT_TIMEOUT mult_frac(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ) -int sg_big_buff =SG_DEF_RESERVED_SIZE ; +static int sg_big_buff =SG_DEF_RESERVED_SIZE ;/* N.B. This variable is readable and writeable via /proc/scsi/sg/def_reserved_size . Each time sg_open() is called a buffer of this size (or less if there is not enough memory) will be reserved
@@ -1634,6 +1634,37 @@ MODULE_PARM_DESC(scatter_elem_sz, "scattMODULE_PARM_DESC (def_reserved_size,"size of buffer reserved for each fd" );MODULE_PARM_DESC (allow_dio,"allow direct I/O (default: 0 (disallow))" ); +#ifdef CONFIG_SYSCTL +#include <linux/sysctl.h> + +static struct ctl_table sg_sysctls[] = { + { + .procname ="sg-big-buff" , + .data = &sg_big_buff, + .maxlen =sizeof (int ), + .mode =0444 , + .proc_handler = proc_dointvec, + }, + {} +}; + +static struct ctl_table_header *hdr; +static void register_sg_sysctls (void ) +{ +if (!hdr) + hdr =register_sysctl ("kernel" , sg_sysctls); +} + +static void unregister_sg_sysctls (void ) +{ +if (hdr) +unregister_sysctl_table (hdr); +} +#else +#define register_sg_sysctls () do { } while (0) +#define unregister_sg_sysctls () do { } while (0) +#endif /* CONFIG_SYSCTL */ +static int __init init_sg (void ) {
@@ -1666,6 +1697,7 @@ init_sg(void)return 0 ; }class_destroy (sg_sysfs_class); +register_sg_sysctls (); err_out:unregister_chrdev_region (MKDEV (SCSI_GENERIC_MAJOR ,0 ),SG_MAX_DEVS );return rc;
@@ -1674,6 +1706,7 @@ err_out: static void __exitexit_sg (void ) { +unregister_sg_sysctls ();#ifdef CONFIG_SCSI_PROC_FS remove_proc_subtree ("scsi/sg" ,NULL );#endif /* CONFIG_SCSI_PROC_FS */
include/scsi/sg.h renamed from include/scsi/sg.h~scsi-sg-move-sg-big-buff-sysctl-to-scsi-sgc +0 -4
@@ -29,10 +29,6 @@* For utility and test programs see: http://sg.danny.cz/sg/sg3_utils.html */ -#ifdef __KERNEL__ -extern int sg_big_buff;/* for sysctl */ -#endif - typedef struct sg_iovec /* same structure as used by readv() Linux system */ { /* call. It defines one scatter-gather element. */
kernel/sysctl.c renamed from kernel/sysctl.c~scsi-sg-move-sg-big-buff-sysctl-to-scsi-sgc +0 -12
@@ -95,9 +95,6 @@#if defined(CONFIG_PROVE_LOCKING ) || defined(CONFIG_LOCK_STAT )#include <linux/lockdep.h> #endif -#ifdef CONFIG_CHR_DEV_SG -#include <scsi/sg.h> -#endif #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE #include <linux/stackleak.h> #endif
@@ -2090,15 +2087,6 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dostring, },#endif -#ifdef CONFIG_CHR_DEV_SG - { - .procname = "sg-big-buff", - .data = &sg_big_buff, - .maxlen = sizeof (int), - .mode = 0444, - .proc_handler = proc_dointvec, - }, -#endif#ifdef CONFIG_BSD_PROCESS_ACCT { .procname = "acct",
_
Andrew Morton
maintainerPATCH 25/69 stackleak: move stack_erasing sysctl to stackleak.c
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: stackleak: move stack_erasing sysctl to stackleak.c
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.
---
include/linux/stackleak.h | 5 ----- kernel/stackleak.c | 26 ++++++++++++++++++++++++-- kernel/sysctl.c | 14 -------------- 3 files changed, 24 insertions(+), 21 deletions(-)
include/linux/stackleak.h renamed from include/linux/stackleak.h~stackleak-move-stack_erasing-sysctl-to-stackleakc +0 -5
@@ -23,11 +23,6 @@ static inline void stackleak_task_init(s # endif } -#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE -int stack_erasing_sysctl (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos); -#endif -#else /* !CONFIG_GCC_PLUGIN_STACKLEAK */ static inline void stackleak_task_init (struct task_struct *t) { }#endif
kernel/stackleak.c renamed from kernel/stackleak.c~stackleak-move-stack_erasing-sysctl-to-stackleakc +24 -2
@@ -16,11 +16,13 @@ #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE #include <linux/jump_label.h> #include <linux/sysctl.h> +#include <linux/init.h> static DEFINE_STATIC_KEY_FALSE(stack_erasing_bypass); -int stack_erasing_sysctl (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +#ifdef CONFIG_SYSCTL +static int stack_erasing_sysctl(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int ret = 0; int state = !static_branch_unlikely(&stack_erasing_bypass);
@@ -42,6 +44,26 @@ int stack_erasing_sysctl(struct ctl_tabl state ? "enabled" : "disabled"); return ret; } +static struct ctl_table stackleak_sysctls[] = { + { + .procname ="stack_erasing" , + .data =NULL , + .maxlen =sizeof (int ), + .mode =0600 , + .proc_handler = stack_erasing_sysctl, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_ONE , + }, + {} +}; + +static int __init stackleak_sysctls_init (void ) +{ +register_sysctl_init ("kernel" , stackleak_sysctls); +return 0 ; +} +late_initcall (stackleak_sysctls_init); +#endif /* CONFIG_SYSCTL */ #define skip_erasing () static_branch_unlikely(&stack_erasing_bypass)#else
kernel/sysctl.c renamed from kernel/sysctl.c~stackleak-move-stack_erasing-sysctl-to-stackleakc +0 -14
@@ -95,9 +95,6 @@#if defined(CONFIG_PROVE_LOCKING ) || defined(CONFIG_LOCK_STAT )#include <linux/lockdep.h> #endif -#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE -#include <linux/stackleak.h> -#endif #if defined(CONFIG_SYSCTL )
@@ -2443,17 +2440,6 @@ static struct ctl_table kern_table[] = { .extra2 = SYSCTL_INT_MAX, },#endif -#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE - { - .procname = "stack_erasing", - .data = NULL, - .maxlen = sizeof(int), - .mode = 0600, - .proc_handler = stack_erasing_sysctl, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif { } };
_
Andrew Morton
maintainerPATCH 26/69 sysctl: share unsigned long const values
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: sysctl: share unsigned long const values
Provide a way to share unsigned long values. This will allow others to not have to re-invent these values.
---
fs/proc/proc_sysctl.c | 3 +++ include/linux/sysctl.h | 6 ++++++ kernel/sysctl.c | 9 +++------ 3 files changed, 12 insertions(+), 6 deletions(-)
fs/proc/proc_sysctl.c renamed from fs/proc/proc_sysctl.c~sysctl-share-unsigned-long-const-values +3 -0
@@ -29,6 +29,9 @@ static const struct inode_operations proconst int sysctl_vals[] = {-1 ,0 ,1 ,2 ,4 ,100 ,200 ,1000 ,3000 ,INT_MAX };EXPORT_SYMBOL (sysctl_vals); +const unsigned long sysctl_long_vals[] = {0 ,1 ,LONG_MAX }; +EXPORT_SYMBOL_GPL (sysctl_long_vals); +/* Support for permanently empty directories */ struct ctl_table sysctl_mount_point[] = {
include/linux/sysctl.h renamed from include/linux/sysctl.h~sysctl-share-unsigned-long-const-values +6 -0
@@ -51,6 +51,12 @@ struct ctl_dir;extern const int sysctl_vals[]; +#define SYSCTL_LONG_ZERO ((void *)&sysctl_long_vals[0]) +#define SYSCTL_LONG_ONE ((void *)&sysctl_long_vals[1]) +#define SYSCTL_LONG_MAX ((void *)&sysctl_long_vals[2]) + +extern const unsigned long sysctl_long_vals[]; +typedef int proc_handler (struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos);
kernel/sysctl.c renamed from kernel/sysctl.c~sysctl-share-unsigned-long-const-values +3 -6
@@ -100,9 +100,6 @@/* Constants used for minimum and maximum */ -static const unsigned long zero_ul; -static const unsigned long one_ul =1 ; -static const unsigned long long_max =LONG_MAX ;#ifdef CONFIG_PRINTK static const int ten_thousand =10000 ;#endif
@@ -2513,7 +2510,7 @@ static struct ctl_table vm_table[] = { .maxlen = sizeof(dirty_background_bytes), .mode = 0644, .proc_handler = dirty_background_bytes_handler, - .extra1 = (void *)&one_ul, + .extra1 = SYSCTL_LONG_ONE, }, { .procname = "dirty_ratio",
@@ -2931,8 +2928,8 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(files_stat.max_files), .mode = 0644, .proc_handler = proc_doulongvec_minmax, - .extra1 = (void *)&zero_ul, - .extra2 = (void *)&long_max, + .extra1 = SYSCTL_LONG_ZERO, + .extra2 = SYSCTL_LONG_MAX, }, { .procname = "nr_open",
_
Andrew Morton
maintainerPATCH 27/69 fs: move inode sysctls to its own file
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move inode sysctls to its own file
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.
---
fs/inode.c | 39 ++++++++++++++++++++++++++++++++------- include/linux/fs.h | 3 --- kernel/sysctl.c | 14 -------------- 3 files changed, 32 insertions(+), 24 deletions(-)
fs/inode.c renamed from fs/inode.c~fs-move-inode-sysctls-to-its-own-file +32 -7
@@ -67,11 +67,6 @@ const struct address_space_operations em };EXPORT_SYMBOL (empty_aops); -/* -* Statistics gathering.. -*/ -struct inodes_stat_t inodes_stat; - static DEFINE_PER_CPU(unsigned long, nr_inodes); static DEFINE_PER_CPU(unsigned long, nr_unused);
@@ -106,13 +101,43 @@ long get_nr_dirty_inodes(void)* Handle nr_inode sysctl */ #ifdef CONFIG_SYSCTL -int proc_nr_inodes (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +/* +* Statistics gathering.. +*/ +static struct inodes_stat_t inodes_stat; + +static int proc_nr_inodes (struct ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos) { inodes_stat.nr_inodes =get_nr_inodes (); inodes_stat.nr_unused =get_nr_inodes_unused ();return proc_doulongvec_minmax (table, write, buffer, lenp, ppos); } + +static struct ctl_table inodes_sysctls[] = { + { + .procname ="inode-nr" , + .data = &inodes_stat, + .maxlen =2 *sizeof (long ), + .mode =0444 , + .proc_handler = proc_nr_inodes, + }, + { + .procname ="inode-state" , + .data = &inodes_stat, + .maxlen =7 *sizeof (long ), + .mode =0444 , + .proc_handler = proc_nr_inodes, + }, + { } +}; + +static int __init init_fs_inode_sysctls (void ) +{ +register_sysctl_init ("fs" , inodes_sysctls); +return 0 ; +} +early_initcall (init_fs_inode_sysctls);#endif static int no_open (struct inode *inode,struct file *file)
include/linux/fs.h renamed from include/linux/fs.h~fs-move-inode-sysctls-to-its-own-file +0 -3
@@ -82,7 +82,6 @@ extern void __init files_maxfiles_init(vextern struct files_stat_struct files_stat;extern unsigned long get_max_files (void );extern unsigned int sysctl_nr_open; -extern struct inodes_stat_t inodes_stat;extern int leases_enable, lease_break_time;extern int sysctl_protected_symlinks;extern int sysctl_protected_hardlinks;
@@ -3537,8 +3536,6 @@ int proc_nr_files(struct ctl_table *tabl void *buffer, size_t *lenp, loff_t *ppos);int proc_nr_dentry (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos); -int proc_nr_inodes (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos);int __init list_bdev_fs_names (char *buf,size_t size);#define __FMODE_EXEC ((__force int) FMODE_EXEC)
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-inode-sysctls-to-its-own-file +0 -14
@@ -2902,20 +2902,6 @@ static struct ctl_table vm_table[] = {static struct ctl_table fs_table[] = { { - .procname ="inode-nr" , - .data = &inodes_stat, - .maxlen =2 *sizeof (long ), - .mode =0444 , - .proc_handler = proc_nr_inodes, - }, - { - .procname ="inode-state" , - .data = &inodes_stat, - .maxlen =7 *sizeof (long ), - .mode =0444 , - .proc_handler = proc_nr_inodes, - }, - { .procname ="file-nr" , .data = &files_stat, .maxlen =sizeof (files_stat),
_
Andrew Morton
maintainerPATCH 28/69 fs: move fs stat sysctls to file_table.c
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move fs stat sysctls to file_table.c
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.
---
fs/file_table.c | 47 +++++++++++++++++++++++++++++++++++-------- include/linux/fs.h | 3 -- kernel/sysctl.c | 25 ---------------------- 3 files changed, 39 insertions(+), 36 deletions(-)
fs/file_table.c renamed from fs/file_table.c~fs-move-fs-stat-sysctls-to-file_tablec +39 -8
@@ -33,7 +33,7 @@#include "internal.h" /* sysctl tunables... */ -struct files_stat_struct files_stat = { +static struct files_stat_struct files_stat = { .max_files =NR_FILE };
@@ -75,22 +75,53 @@ unsigned long get_max_files(void) }EXPORT_SYMBOL_GPL (get_max_files); +#if defined(CONFIG_SYSCTL ) && defined(CONFIG_PROC_FS ) +/* * Handle nr_files sysctl */ -#if defined(CONFIG_SYSCTL ) && defined(CONFIG_PROC_FS ) -int proc_nr_files (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +static int proc_nr_files (struct ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos) { files_stat.nr_files =get_nr_files ();return proc_doulongvec_minmax (table, write, buffer, lenp, ppos); } -#else -int proc_nr_files (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) + +static struct ctl_table fs_stat_sysctls[] = { + { + .procname ="file-nr" , + .data = &files_stat, + .maxlen =sizeof (files_stat), + .mode =0444 , + .proc_handler = proc_nr_files, + }, + { + .procname ="file-max" , + .data = &files_stat.max_files, + .maxlen =sizeof (files_stat.max_files), + .mode =0644 , + .proc_handler = proc_doulongvec_minmax, + .extra1 =SYSCTL_LONG_ZERO , + .extra2 =SYSCTL_LONG_MAX , + }, + { + .procname ="nr_open" , + .data = &sysctl_nr_open, + .maxlen =sizeof (unsigned int ), + .mode =0644 , + .proc_handler = proc_dointvec_minmax, + .extra1 = &sysctl_nr_open_min, + .extra2 = &sysctl_nr_open_max, + }, + { } +}; + +static int __init init_fs_stat_sysctls (void ) { -return -ENOSYS ; +register_sysctl_init ("fs" , fs_stat_sysctls); +return 0 ; } +fs_initcall (init_fs_stat_sysctls);#endif static struct file *__alloc_file (int flags,const struct cred *cred)
include/linux/fs.h renamed from include/linux/fs.h~fs-move-fs-stat-sysctls-to-file_tablec +0 -3
@@ -79,7 +79,6 @@ extern void __init inode_init_early(voidextern void __init files_init (void );extern void __init files_maxfiles_init (void ); -extern struct files_stat_struct files_stat;extern unsigned long get_max_files (void );extern unsigned int sysctl_nr_open;extern int leases_enable, lease_break_time;
@@ -3532,8 +3531,6 @@ ssize_t simple_attr_write(struct file *f size_t len, loff_t *ppos);struct ctl_table ; -int proc_nr_files (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos);int proc_nr_dentry (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos);int __init list_bdev_fs_names (char *buf,size_t size);
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-fs-stat-sysctls-to-file_tablec +0 -25
@@ -2902,31 +2902,6 @@ static struct ctl_table vm_table[] = {static struct ctl_table fs_table[] = { { - .procname ="file-nr" , - .data = &files_stat, - .maxlen =sizeof (files_stat), - .mode =0444 , - .proc_handler = proc_nr_files, - }, - { - .procname ="file-max" , - .data = &files_stat.max_files, - .maxlen =sizeof (files_stat.max_files), - .mode =0644 , - .proc_handler = proc_doulongvec_minmax, - .extra1 =SYSCTL_LONG_ZERO , - .extra2 =SYSCTL_LONG_MAX , - }, - { - .procname ="nr_open" , - .data = &sysctl_nr_open, - .maxlen =sizeof (unsigned int ), - .mode =0644 , - .proc_handler = proc_dointvec_minmax, - .extra1 = &sysctl_nr_open_min, - .extra2 = &sysctl_nr_open_max, - }, - { .procname ="dentry-state" , .data = &dentry_stat, .maxlen =6 *sizeof (long ),
_
Andrew Morton
maintainerPATCH 29/69 fs: move dcache sysctls to its own file
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move dcache sysctls to its own file
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.
---
fs/dcache.c | 37 +++++++++++++++++++++++++++++++------ include/linux/dcache.h | 10 ---------- include/linux/fs.h | 2 -- kernel/sysctl.c | 7 ------- 4 files changed, 31 insertions(+), 25 deletions(-)
fs/dcache.c renamed from fs/dcache.c~fs-move-dcache-sysctls-to-its-own-file +31 -6
@@ -115,10 +115,13 @@ static inline struct hlist_bl_head *in_lreturn in_lookup_hashtable +hash_32 (hash,IN_LOOKUP_SHIFT ); } - -/* Statistics gathering. */ -struct dentry_stat_t dentry_stat = { - .age_limit =45 , +struct dentry_stat_t { +long nr_dentry; +long nr_unused; +long age_limit;/* age in seconds */ +long want_pages;/* pages requested by system */ +long nr_negative;/* # of unused negative dentries */ +long dummy;/* Reserved for future use */ }; static DEFINE_PER_CPU(long, nr_dentry);
@@ -126,6 +129,10 @@ static DEFINE_PER_CPU(long, nr_dentry_un static DEFINE_PER_CPU(long, nr_dentry_negative);#if defined(CONFIG_SYSCTL ) && defined(CONFIG_PROC_FS ) +/* Statistics gathering. */ +static struct dentry_stat_t dentry_stat = { + .age_limit =45 , +};/* * Here we resort to our own counters instead of using generic per-cpu counters
@@ -167,14 +174,32 @@ static long get_nr_dentry_negative(void)return sum <0 ?0 : sum; } -int proc_nr_dentry (struct ctl_table *table,int write,void *buffer, -size_t *lenp,loff_t *ppos) +static int proc_nr_dentry (struct ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos) { dentry_stat.nr_dentry =get_nr_dentry (); dentry_stat.nr_unused =get_nr_dentry_unused (); dentry_stat.nr_negative =get_nr_dentry_negative ();return proc_doulongvec_minmax (table, write, buffer, lenp, ppos); } + +static struct ctl_table fs_dcache_sysctls[] = { + { + .procname ="dentry-state" , + .data = &dentry_stat, + .maxlen =6 *sizeof (long ), + .mode =0444 , + .proc_handler = proc_nr_dentry, + }, + { } +}; + +static int __init init_fs_dcache_sysctls (void ) +{ +register_sysctl_init ("fs" , fs_dcache_sysctls); +return 0 ; +} +fs_initcall (init_fs_dcache_sysctls);#endif /*
include/linux/dcache.h renamed from include/linux/dcache.h~fs-move-dcache-sysctls-to-its-own-file +0 -10
@@ -61,16 +61,6 @@ extern const struct qstr empty_name;extern const struct qstr slash_name;extern const struct qstr dotdot_name; -struct dentry_stat_t { -long nr_dentry; -long nr_unused; -long age_limit;/* age in seconds */ -long want_pages;/* pages requested by system */ -long nr_negative;/* # of unused negative dentries */ -long dummy;/* Reserved for future use */ -}; -extern struct dentry_stat_t dentry_stat; -/* * Try to keep struct dentry aligned on 64 byte cachelines (this will * give reasonable cacheline footprint with larger lines without the
include/linux/fs.h renamed from include/linux/fs.h~fs-move-dcache-sysctls-to-its-own-file +0 -2
@@ -3531,8 +3531,6 @@ ssize_t simple_attr_write(struct file *f size_t len, loff_t *ppos);struct ctl_table ; -int proc_nr_dentry (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos);int __init list_bdev_fs_names (char *buf,size_t size);#define __FMODE_EXEC ((__force int) FMODE_EXEC)
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-dcache-sysctls-to-its-own-file +0 -7
@@ -2902,13 +2902,6 @@ static struct ctl_table vm_table[] = {static struct ctl_table fs_table[] = { { - .procname ="dentry-state" , - .data = &dentry_stat, - .maxlen =6 *sizeof (long ), - .mode =0444 , - .proc_handler = proc_nr_dentry, - }, - { .procname ="overflowuid" , .data = &fs_overflowuid, .maxlen =sizeof (int ),
_
Andrew Morton
maintainerPATCH 30/69 sysctl: move maxolduid as a sysctl specific const
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: sysctl: move maxolduid as a sysctl specific const
The maxolduid value is only shared for sysctl purposes for use on a max range. Just stuff this into our shared const array.
---
fs/proc/proc_sysctl.c | 2 +- include/linux/sysctl.h | 3 +++ kernel/sysctl.c | 12 ++++-------- 3 files changed, 8 insertions(+), 9 deletions(-)
fs/proc/proc_sysctl.c renamed from fs/proc/proc_sysctl.c~sysctl-move-maxolduid-as-a-sysctl-specific-const +1 -1
@@ -26,7 +26,7 @@ static const struct file_operations procstatic const struct inode_operations proc_sys_dir_operations;/* shared constants to be used in various sysctls */ -const int sysctl_vals[] = {-1 ,0 ,1 ,2 ,4 ,100 ,200 ,1000 ,3000 ,INT_MAX }; +const int sysctl_vals[] = {-1 ,0 ,1 ,2 ,4 ,100 ,200 ,1000 ,3000 ,INT_MAX ,65535 };EXPORT_SYMBOL (sysctl_vals);const unsigned long sysctl_long_vals[] = {0 ,1 ,LONG_MAX };
include/linux/sysctl.h renamed from include/linux/sysctl.h~sysctl-move-maxolduid-as-a-sysctl-specific-const +3 -0
@@ -49,6 +49,9 @@ struct ctl_dir;#define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[8])#define SYSCTL_INT_MAX ((void *)&sysctl_vals[9]) +/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ +#define SYSCTL_MAXOLDUID ((void *)&sysctl_vals[10]) +extern const int sysctl_vals[];#define SYSCTL_LONG_ZERO ((void *)&sysctl_long_vals[0])
kernel/sysctl.c renamed from kernel/sysctl.c~sysctl-move-maxolduid-as-a-sysctl-specific-const +4 -8
@@ -110,10 +110,6 @@ static const int six_hundred_forty_kb =/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ static const unsigned long dirty_bytes_min =2 *PAGE_SIZE ; -/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ -static const int maxolduid =65535 ; -/* minolduid is SYSCTL_ZERO */ -static const int ngroups_max =NGROUPS_MAX ;static const int cap_last_cap =CAP_LAST_CAP ;
@@ -2127,7 +2123,7 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, - .extra2 = (void *)&maxolduid, + .extra2 = SYSCTL_MAXOLDUID, }, { .procname = "overflowgid",
@@ -2136,7 +2132,7 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, - .extra2 = (void *)&maxolduid, + .extra2 = SYSCTL_MAXOLDUID, },#ifdef CONFIG_S390 {
@@ -2908,7 +2904,7 @@ static struct ctl_table fs_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, - .extra2 = (void *)&maxolduid, + .extra2 = SYSCTL_MAXOLDUID, }, { .procname = "overflowgid",
@@ -2917,7 +2913,7 @@ static struct ctl_table fs_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, - .extra2 = (void *)&maxolduid, + .extra2 = SYSCTL_MAXOLDUID, },#ifdef CONFIG_FILE_LOCKING {
_
Andrew Morton
maintainerPATCH 31/69 fs: move shared sysctls to fs/sysctls.c
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move shared sysctls to fs/sysctls.c
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.
---
fs/Makefile | 1 + fs/sysctls.c | 38 ++++++++++++++++++++++++++++++++++++++ kernel/sysctl.c | 18 ------------------ 3 files changed, 39 insertions(+), 18 deletions(-)
fs/Makefile renamed from fs/Makefile~fs-move-shared-sysctls-to-fs-sysctlsc +1 -0
@@ -28,6 +28,7 @@ obj-y += notify/ obj-$(CONFIG_EPOLL) += eventpoll.o obj-y += anon_inodes.o obj-$(CONFIG_SIGNALFD) += signalfd.o +obj-$(CONFIG_SYSCTL) += sysctls.o obj-$(CONFIG_TIMERFD) += timerfd.o obj-$(CONFIG_EVENTFD) += eventfd.o obj-$(CONFIG_USERFAULTFD) += userfaultfd.o
fs/sysctls.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* /proc/sys/fs shared sysctls +* +* These sysctls are shared between different filesystems. +*/ +#include <linux/init.h> +#include <linux/sysctl.h> + +static struct ctl_table fs_shared_sysctls[] = { + { + .procname ="overflowuid" , + .data = &fs_overflowuid, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_MAXOLDUID , + }, + { + .procname ="overflowgid" , + .data = &fs_overflowgid, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_MAXOLDUID , + }, + { } +}; + +static int __init init_fs_shared_sysctls (void ) +{ +register_sysctl_init ("fs" , fs_shared_sysctls); +return 0 ; +} + +early_initcall (init_fs_shared_sysctls);
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-shared-sysctls-to-fs-sysctlsc +0 -18
@@ -2897,24 +2897,6 @@ static struct ctl_table vm_table[] = { }; static struct ctl_table fs_table[] = { - { - .procname ="overflowuid" , - .data = &fs_overflowuid, - .maxlen =sizeof (int ), - .mode =0644 , - .proc_handler = proc_dointvec_minmax, - .extra1 =SYSCTL_ZERO , - .extra2 =SYSCTL_MAXOLDUID , - }, - { - .procname ="overflowgid" , - .data = &fs_overflowgid, - .maxlen =sizeof (int ), - .mode =0644 , - .proc_handler = proc_dointvec_minmax, - .extra1 =SYSCTL_ZERO , - .extra2 =SYSCTL_MAXOLDUID , - }, #ifdef CONFIG_FILE_LOCKING { .procname = "leases-enable",
_
Andrew Morton
maintainerPATCH 32/69 fs: move locking sysctls where they are used
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move locking sysctls where they are used
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.
---
fs/locks.c | 34 ++++++++++++++++++++++++++++++++-- include/linux/fs.h | 4 ---- kernel/sysctl.c | 20 -------------------- 3 files changed, 32 insertions(+), 26 deletions(-)
fs/locks.c renamed from fs/locks.c~fs-move-locking-sysctls-where-they-are-used +32 -2
@@ -62,6 +62,7 @@#include <linux/pid_namespace.h> #include <linux/hashtable.h> #include <linux/percpu.h> +#include <linux/sysctl.h> #define CREATE_TRACE_POINTS #include <trace/events/filelock.h>
@@ -88,8 +89,37 @@ static int target_leasetype(struct file_return fl->fl_type; } -int leases_enable =1 ; -int lease_break_time =45 ; +static int leases_enable =1 ; +static int lease_break_time =45 ; + +#ifdef CONFIG_SYSCTL +static struct ctl_table locks_sysctls[] = { + { + .procname ="leases-enable" , + .data = &leases_enable, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec, + }, +#ifdef CONFIG_MMU + { + .procname ="lease-break-time" , + .data = &lease_break_time, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec, + }, +#endif /* CONFIG_MMU */ + {} +}; + +static int __init init_fs_locks_sysctls (void ) +{ +register_sysctl_init ("fs" , locks_sysctls); +return 0 ; +} +early_initcall (init_fs_locks_sysctls); +#endif /* CONFIG_SYSCTL */ /* * The global file_lock_list is only used for displaying /proc/locks, so we
include/linux/fs.h renamed from include/linux/fs.h~fs-move-locking-sysctls-where-they-are-used +0 -4
@@ -82,10 +82,6 @@ extern void __init files_maxfiles_init(vextern unsigned long get_max_files (void );extern unsigned int sysctl_nr_open;extern int leases_enable, lease_break_time; -extern int sysctl_protected_symlinks; -extern int sysctl_protected_hardlinks; -extern int sysctl_protected_fifos; -extern int sysctl_protected_regular;typedef __kernel_rwf_t rwf_t ;
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-locking-sysctls-where-they-are-used +0 -20
@@ -2897,26 +2897,6 @@ static struct ctl_table vm_table[] = { };static struct ctl_table fs_table[] = { -#ifdef CONFIG_FILE_LOCKING - { - .procname = "leases-enable", - .data = &leases_enable, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec, - }, -#endif -#ifdef CONFIG_MMU -#ifdef CONFIG_FILE_LOCKING - { - .procname = "lease-break-time", - .data = &lease_break_time, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec, - }, -#endif -#endif { .procname ="protected_symlinks" , .data = &sysctl_protected_symlinks,
_
Andrew Morton
maintainerPATCH 33/69 fs: move namei sysctls to its own file
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move namei sysctls to its own file
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
---
fs/namei.c | 58 ++++++++++++++++++++++++++++++++++++++++--- include/linux/fs.h | 1 kernel/sysctl.c | 36 -------------------------- 3 files changed, 54 insertions(+), 41 deletions(-)
fs/namei.c renamed from fs/namei.c~fs-move-namei-sysctls-to-its-own-file +54 -4
@@ -1020,10 +1020,60 @@ static inline void put_link(struct nameipath_put (&last->link); } -int sysctl_protected_symlinks__read_mostly =0 ; -int sysctl_protected_hardlinks__read_mostly =0 ; -int sysctl_protected_fifos__read_mostly ; -int sysctl_protected_regular__read_mostly ; +static int sysctl_protected_symlinks__read_mostly ; +static int sysctl_protected_hardlinks__read_mostly ; +static int sysctl_protected_fifos__read_mostly ; +static int sysctl_protected_regular__read_mostly ; + +#ifdef CONFIG_SYSCTL +static struct ctl_table namei_sysctls[] = { + { + .procname ="protected_symlinks" , + .data = &sysctl_protected_symlinks, + .maxlen =sizeof (int ), + .mode =0600 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_ONE , + }, + { + .procname ="protected_hardlinks" , + .data = &sysctl_protected_hardlinks, + .maxlen =sizeof (int ), + .mode =0600 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_ONE , + }, + { + .procname ="protected_fifos" , + .data = &sysctl_protected_fifos, + .maxlen =sizeof (int ), + .mode =0600 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_TWO , + }, + { + .procname ="protected_regular" , + .data = &sysctl_protected_regular, + .maxlen =sizeof (int ), + .mode =0600 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_TWO , + }, + { } +}; + +static int __init init_fs_namei_sysctls (void ) +{ +register_sysctl_init ("fs" , namei_sysctls); +return 0 ; +} +fs_initcall (init_fs_namei_sysctls); + +#endif /* CONFIG_SYSCTL */ /** * may_follow_link - Check symlink following for unsafe situations
include/linux/fs.h renamed from include/linux/fs.h~fs-move-namei-sysctls-to-its-own-file +0 -1
@@ -81,7 +81,6 @@ extern void __init files_maxfiles_init(vextern unsigned long get_max_files (void );extern unsigned int sysctl_nr_open; -extern int leases_enable, lease_break_time;typedef __kernel_rwf_t rwf_t ;
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-namei-sysctls-to-its-own-file +0 -36
@@ -2898,42 +2898,6 @@ static struct ctl_table vm_table[] = {static struct ctl_table fs_table[] = { { - .procname ="protected_symlinks" , - .data = &sysctl_protected_symlinks, - .maxlen =sizeof (int ), - .mode =0600 , - .proc_handler = proc_dointvec_minmax, - .extra1 =SYSCTL_ZERO , - .extra2 =SYSCTL_ONE , - }, - { - .procname ="protected_hardlinks" , - .data = &sysctl_protected_hardlinks, - .maxlen =sizeof (int ), - .mode =0600 , - .proc_handler = proc_dointvec_minmax, - .extra1 =SYSCTL_ZERO , - .extra2 =SYSCTL_ONE , - }, - { - .procname ="protected_fifos" , - .data = &sysctl_protected_fifos, - .maxlen =sizeof (int ), - .mode =0600 , - .proc_handler = proc_dointvec_minmax, - .extra1 =SYSCTL_ZERO , - .extra2 =SYSCTL_TWO , - }, - { - .procname ="protected_regular" , - .data = &sysctl_protected_regular, - .maxlen =sizeof (int ), - .mode =0600 , - .proc_handler = proc_dointvec_minmax, - .extra1 =SYSCTL_ZERO , - .extra2 =SYSCTL_TWO , - }, - { .procname ="suid_dumpable" , .data = &suid_dumpable, .maxlen =sizeof (int ),
_
Andrew Morton
maintainerPATCH 34/69 fs: move fs/exec.c sysctls into its own file
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move fs/exec.c sysctls into its own file
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
---
fs/exec.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++ kernel/sysctl.c | 66 --------------------------------- 2 files changed, 90 insertions(+), 66 deletions(-)
fs/exec.c renamed from fs/exec.c~fs-move-fs-execc-sysctls-into-its-own-file +90 -0
@@ -65,6 +65,7 @@#include <linux/vmalloc.h> #include <linux/io_uring.h> #include <linux/syscall_user_dispatch.h> +#include <linux/coredump.h> #include <linux/uaccess.h> #include <asm/mmu_context.h>
@@ -2099,3 +2100,92 @@ COMPAT_SYSCALL_DEFINE5(execveat, int, fd argv, envp, flags); }#endif + +#ifdef CONFIG_SYSCTL + +static void validate_coredump_safety (void ) +{ +#ifdef CONFIG_COREDUMP +if (suid_dumpable ==SUID_DUMP_ROOT && + core_pattern[0 ] !='/' && core_pattern[0 ] !='|' ) { +pr_warn ( +"Unsafe core_pattern used with fs.suid_dumpable=2.\n" +"Pipe handler or fully qualified core dump path required.\n" +"Set kernel.core_pattern before fs.suid_dumpable.\n" + ); + } +#endif +} + +static int proc_dointvec_minmax_coredump (struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) +{ +int error =proc_dointvec_minmax (table, write, buffer, lenp, ppos); + +if (!error) +validate_coredump_safety (); +return error; +} + +static struct ctl_table fs_exec_sysctls[] = { + { + .procname ="suid_dumpable" , + .data = &suid_dumpable, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec_minmax_coredump, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_TWO , + }, + { } +}; + +#ifdef CONFIG_COREDUMP + +static int proc_dostring_coredump (struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) +{ +int error =proc_dostring (table, write, buffer, lenp, ppos); + +if (!error) +validate_coredump_safety (); +return error; +} + +static struct ctl_table kernel_exec_sysctls[] = { + { + .procname ="core_uses_pid" , + .data = &core_uses_pid, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec, + }, + { + .procname ="core_pattern" , + .data = core_pattern, + .maxlen =CORENAME_MAX_SIZE , + .mode =0644 , + .proc_handler = proc_dostring_coredump, + }, + { + .procname ="core_pipe_limit" , + .data = &core_pipe_limit, + .maxlen =sizeof (unsigned int ), + .mode =0644 , + .proc_handler = proc_dointvec, + }, + { } +}; +#endif + +static int __init init_fs_exec_sysctls (void ) +{ +register_sysctl_init ("fs" , fs_exec_sysctls); +#ifdef CONFIG_COREDUMP +register_sysctl_init ("kernel" , kernel_exec_sysctls); +#endif +return 0 ; +} + +fs_initcall (init_fs_exec_sysctls); +#endif /* CONFIG_SYSCTL */
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-fs-execc-sysctls-into-its-own-file +0 -66
84 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 35/69 fs: move pipe sysctls to is own file
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move pipe sysctls to is own file
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.
---
fs/pipe.c | 64 ++++++++++++++++++++++++++++++++++-- include/linux/pipe_fs_i.h | 4 -- include/linux/sysctl.h | 6 +++ kernel/sysctl.c | 61 +++------------------------------- 4 files changed, 73 insertions(+), 62 deletions(-)
fs/pipe.c renamed from fs/pipe.c~fs-move-pipe-sysctls-to-is-own-file +61 -3
@@ -25,6 +25,7 @@#include <linux/fcntl.h> #include <linux/memcontrol.h> #include <linux/watch_queue.h> +#include <linux/sysctl.h> #include <linux/uaccess.h> #include <asm/ioctls.h>
@@ -50,13 +51,13 @@* The max size that a non-root user is allowed to grow the pipe. Can * be set by root in /proc/sys/fs/pipe-max-size */ -unsigned int pipe_max_size =1048576 ; +static unsigned int pipe_max_size =1048576 ;/* Maximum allocatable pages per user. Hard limit is unset by default, soft * matches default values. */ -unsigned long pipe_user_pages_hard; -unsigned long pipe_user_pages_soft =PIPE_DEF_BUFFERS *INR_OPEN_CUR ; +static unsigned long pipe_user_pages_hard; +static unsigned long pipe_user_pages_soft =PIPE_DEF_BUFFERS *INR_OPEN_CUR ;/* * We use head and tail indices that aren't masked off, except at the point of
@@ -1428,6 +1429,60 @@ static struct file_system_type pipe_fs_t .kill_sb = kill_anon_super, }; +#ifdef CONFIG_SYSCTL +static int do_proc_dopipe_max_size_conv (unsigned long *lvalp, +unsigned int *valp, +int write,void *data) +{ +if (write) { +unsigned int val; + + val =round_pipe_size (*lvalp); +if (val ==0 ) +return -EINVAL ; + + *valp = val; + }else { +unsigned int val = *valp; + *lvalp = (unsigned long ) val; + } + +return 0 ; +} + +static int proc_dopipe_max_size (struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) +{ +return do_proc_douintvec (table, write, buffer, lenp, ppos, + do_proc_dopipe_max_size_conv,NULL ); +} + +static struct ctl_table fs_pipe_sysctls[] = { + { + .procname ="pipe-max-size" , + .data = &pipe_max_size, + .maxlen =sizeof (pipe_max_size), + .mode =0644 , + .proc_handler = proc_dopipe_max_size, + }, + { + .procname ="pipe-user-pages-hard" , + .data = &pipe_user_pages_hard, + .maxlen =sizeof (pipe_user_pages_hard), + .mode =0644 , + .proc_handler = proc_doulongvec_minmax, + }, + { + .procname ="pipe-user-pages-soft" , + .data = &pipe_user_pages_soft, + .maxlen =sizeof (pipe_user_pages_soft), + .mode =0644 , + .proc_handler = proc_doulongvec_minmax, + }, + { } +}; +#endif +static int __init init_pipe_fs (void ) {int err =register_filesystem (&pipe_fs_type);
@@ -1439,6 +1494,9 @@ static int __init init_pipe_fs(void)unregister_filesystem (&pipe_fs_type); } } +#ifdef CONFIG_SYSCTL +register_sysctl_init ("fs" , fs_pipe_sysctls); +#endif return err; }
include/linux/pipe_fs_i.h renamed from include/linux/pipe_fs_i.h~fs-move-pipe-sysctls-to-is-own-file +0 -4
@@ -238,10 +238,6 @@ void pipe_lock(struct pipe_inode_info *)void pipe_unlock (struct pipe_inode_info *);void pipe_double_lock (struct pipe_inode_info *,struct pipe_inode_info *); -extern unsigned int pipe_max_size; -extern unsigned long pipe_user_pages_hard; -extern unsigned long pipe_user_pages_soft; -/* Wait for a pipe to be readable/writable while dropping the pipe lock */ void pipe_wait_readable (struct pipe_inode_info *);void pipe_wait_writable (struct pipe_inode_info *);
include/linux/sysctl.h renamed from include/linux/sysctl.h~fs-move-pipe-sysctls-to-is-own-file +6 -0
@@ -221,6 +221,12 @@ extern void __register_sysctl_init(constextern struct ctl_table_header *register_sysctl_mount_point (const char *path);void do_sysctl_args (void ); +int do_proc_douintvec (struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos, +int (*conv)(unsigned long *lvalp, +unsigned int *valp, +int write,void *data), +void *data);extern int pwrsw_enabled;extern int unaligned_enabled;
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-pipe-sysctls-to-is-own-file +6 -55
85 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 36/69 sysctl: add and use base directory declarer and registration helper
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: sysctl: add and use base directory declarer and registration helper
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.
---
fs/proc/proc_sysctl.c | 9 ++++++++ include/linux/sysctl.h | 24 ++++++++++++++++++++++ kernel/sysctl.c | 41 +++++++++------------------------------ 3 files changed, 43 insertions(+), 31 deletions(-)
fs/proc/proc_sysctl.c renamed from fs/proc/proc_sysctl.c~sysctl-add-and-use-base-directory-declarer-and-registration-helper +9 -0
@@ -1646,6 +1646,15 @@ struct ctl_table_header *register_sysctl }EXPORT_SYMBOL (register_sysctl_table); +int __register_sysctl_base (struct ctl_table *base_table) +{ +struct ctl_table_header *hdr; + + hdr =register_sysctl_table (base_table); +kmemleak_not_leak (hdr); +return 0 ; +} +static void put_links (struct ctl_table_header *header) {struct ctl_table_set *root_set = &sysctl_table_root.default_set;
include/linux/sysctl.h renamed from include/linux/sysctl.h~sysctl-add-and-use-base-directory-declarer-and-registration-helper +24 -0
@@ -194,6 +194,20 @@ struct ctl_path {#ifdef CONFIG_SYSCTL +#define DECLARE_SYSCTL_BASE (_name, _table) \ +static struct ctl_table _name##_base_table[] = { \ + { \ + .procname = #_name, \ + .mode = 0555, \ + .child = _table, \ + }, \ + { }, \ +} + +extern int __register_sysctl_base (struct ctl_table *base_table); + +#define register_sysctl_base (_name) __register_sysctl_base(_name##_base_table) +void proc_sys_poll_notify (struct ctl_table_poll *poll); extern void setup_sysctl_set(struct ctl_table_set *p,
@@ -236,6 +250,16 @@ extern int no_unaligned_warning;extern struct ctl_table sysctl_mount_point[];#else /* CONFIG_SYSCTL */ + +#define DECLARE_SYSCTL_BASE (_name, _table) + +static inline int __register_sysctl_base (struct ctl_table *base_table) +{ +return 0 ; +} + +#define register_sysctl_base (table) __register_sysctl_base(table) +static inline struct ctl_table_header *register_sysctl_table (struct ctl_table * table) {return NULL ;
kernel/sysctl.c renamed from kernel/sysctl.c~sysctl-add-and-use-base-directory-declarer-and-registration-helper +10 -31
51 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 37/69 fs: move namespace sysctls and declare fs base directory
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: fs: move namespace sysctls and declare fs base directory
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()
---
fs/Makefile | 3 ++- fs/namespace.c | 24 +++++++++++++++++++++++- fs/sysctls.c | 9 +++++---- include/linux/mount.h | 3 --- kernel/sysctl.c | 14 -------------- 5 files changed, 30 insertions(+), 23 deletions(-)
fs/Makefile renamed from fs/Makefile~fs-move-namespace-sysctls-and-declare-fs-base-directory +2 -1
@@ -6,6 +6,8 @@ # Rewritten to use lists instead of if-statements. # +obj-$(CONFIG_SYSCTL) += sysctls.o + obj-y := open.o read_write.o file_table.o super.o \ char_dev.o stat.o exec.o pipe.o namei.o fcntl.o \ ioctl.o readdir.o select.o dcache.o inode.o \
@@ -28,7 +30,6 @@ obj-y += notify/ obj-$(CONFIG_EPOLL) += eventpoll.o obj-y += anon_inodes.o obj-$(CONFIG_SIGNALFD) += signalfd.o -obj-$(CONFIG_SYSCTL) += sysctls.o obj-$(CONFIG_TIMERFD) += timerfd.o obj-$(CONFIG_EVENTFD) += eventfd.o obj-$(CONFIG_USERFAULTFD) += userfaultfd.o
fs/namespace.c renamed from fs/namespace.c~fs-move-namespace-sysctls-and-declare-fs-base-directory +23 -1
@@ -37,7 +37,7 @@#include "internal.h" /* Maximum number of mounts in a mount namespace */ -unsigned int sysctl_mount_max__read_mostly =100000 ; +static unsigned int sysctl_mount_max__read_mostly =100000 ;static unsigned int m_hash_mask__read_mostly ;static unsigned int m_hash_shift__read_mostly ;
@@ -4620,3 +4620,25 @@ const struct proc_ns_operations mntns_op .install = mntns_install, .owner = mntns_owner, }; + +#ifdef CONFIG_SYSCTL +static struct ctl_table fs_namespace_sysctls[] = { + { + .procname ="mount-max" , + .data = &sysctl_mount_max, + .maxlen =sizeof (unsigned int ), + .mode =0644 , + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ONE , + }, + { } +}; + +static int __init init_fs_namespace_sysctls (void ) +{ +register_sysctl_init ("fs" , fs_namespace_sysctls); +return 0 ; +} +fs_initcall (init_fs_namespace_sysctls); + +#endif /* CONFIG_SYSCTL */
fs/sysctls.c renamed from fs/sysctls.c~fs-move-namespace-sysctls-and-declare-fs-base-directory +5 -4
@@ -29,10 +29,11 @@ static struct ctl_table fs_shared_sysctl { } }; -static int __init init_fs_shared_sysctls (void ) +DECLARE_SYSCTL_BASE (fs, fs_shared_sysctls); + +static int __init init_fs_sysctls (void ) { -register_sysctl_init ("fs" , fs_shared_sysctls); -return 0 ; +return register_sysctl_base (fs); } -early_initcall (init_fs_shared_sysctls); +early_initcall (init_fs_sysctls);
include/linux/mount.h renamed from include/linux/mount.h~fs-move-namespace-sysctls-and-declare-fs-base-directory +0 -3
@@ -113,9 +113,6 @@ extern void mnt_set_expiry(struct vfsmouextern void mark_mounts_for_expiry (struct list_head *mounts);extern dev_t name_to_dev_t (const char *name); - -extern unsigned int sysctl_mount_max; -extern bool path_is_mountpoint (const struct path *path);extern void kern_unmount_array (struct vfsmount *mnt[],unsigned int num);
kernel/sysctl.c renamed from kernel/sysctl.c~fs-move-namespace-sysctls-and-declare-fs-base-directory +0 -14
@@ -2811,18 +2811,6 @@ static struct ctl_table vm_table[] = { { } }; -static struct ctl_table fs_table[] = { - { - .procname ="mount-max" , - .data = &sysctl_mount_max, - .maxlen =sizeof (unsigned int ), - .mode =0644 , - .proc_handler = proc_dointvec_minmax, - .extra1 =SYSCTL_ONE , - }, - { } -}; - static struct ctl_table debug_table[] = { #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE {
@@ -2853,7 +2841,6 @@ static struct ctl_table dev_table[] = {DECLARE_SYSCTL_BASE (kernel, kern_table);DECLARE_SYSCTL_BASE (vm, vm_table); -DECLARE_SYSCTL_BASE (fs, fs_table);DECLARE_SYSCTL_BASE (debug, debug_table);DECLARE_SYSCTL_BASE (dev, dev_table);
@@ -2861,7 +2848,6 @@ int __init sysctl_init(void) {register_sysctl_base (kernel);register_sysctl_base (vm); -register_sysctl_base (fs);register_sysctl_base (debug);register_sysctl_base (dev);
_
Andrew Morton
maintainerPATCH 38/69 kernel/sysctl.c: rename sysctl_init() to sysctl_init_bases()
In reply to Andrew MortonFrom: Luis Chamberlain <[email protected]>
Subject: kernel/sysctl.c: rename sysctl_init() to sysctl_init_bases()
Rename sysctl_init() to sysctl_init_bases() so to reflect exactly what this is doing.
---
arch/arm/mm/alignment.c | 2 +- arch/sh/mm/alignment.c | 2 +- fs/proc/proc_sysctl.c | 4 ++-- include/linux/sysctl.h | 2 +- kernel/sysctl.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/mm/alignment.c renamed from arch/arm/mm/alignment.c~kernel-sysctlc-rename-sysctl_init-to-sysctl_init_bases +1 -1
@@ -1005,7 +1005,7 @@ static int __init noalign_setup(char *____setup ("noalign" , noalign_setup);/* -* This needs to be done after sysctl_init, otherwise sys/ will be +* This needs to be done after sysctl_init_bases(), otherwise sys/ will be * overwritten. Actually, this shouldn't be in sys/ at all since * it isn't a sysctl, and it doesn't contain sysctl information. * We now locate it in /proc/cpu/alignment instead.
arch/sh/mm/alignment.c renamed from arch/sh/mm/alignment.c~kernel-sysctlc-rename-sysctl_init-to-sysctl_init_bases +1 -1
@@ -161,7 +161,7 @@ static const struct proc_ops alignment_p };/* -* This needs to be done after sysctl_init, otherwise sys/ will be +* This needs to be done after sysctl_init_bases(), otherwise sys/ will be * overwritten. Actually, this shouldn't be in sys/ at all since * it isn't a sysctl, and it doesn't contain sysctl information. * We now locate it in /proc/cpu/alignment instead.
fs/proc/proc_sysctl.c renamed from fs/proc/proc_sysctl.c~kernel-sysctlc-rename-sysctl_init-to-sysctl_init_bases +2 -2
@@ -1419,7 +1419,7 @@ EXPORT_SYMBOL(register_sysctl);* Context: Can only be called after your respective sysctl base path has been * registered. So for instance, most base directories are registered early on * init before init levels are processed through proc_sys_init() and -* sysctl_init(). +* sysctl_init_bases(). */ void __init __register_sysctl_init (const char *path,struct ctl_table *table,const char *table_name)
@@ -1768,7 +1768,7 @@ int __init proc_sys_init(void) proc_sys_root->proc_dir_ops = &proc_sys_dir_file_operations; proc_sys_root->nlink =0 ; -return sysctl_init (); +return sysctl_init_bases (); }struct sysctl_alias {
include/linux/sysctl.h renamed from include/linux/sysctl.h~kernel-sysctlc-rename-sysctl_init-to-sysctl_init_bases +1 -1
@@ -228,7 +228,7 @@ struct ctl_table_header *register_sysctlvoid unregister_sysctl_table (struct ctl_table_header * table); -extern int sysctl_init (void ); +extern int sysctl_init_bases (void );extern void __register_sysctl_init (const char *path,struct ctl_table *table,const char *table_name);#define register_sysctl_init (path, table) __register_sysctl_init(path, table, #table)
kernel/sysctl.c renamed from kernel/sysctl.c~kernel-sysctlc-rename-sysctl_init-to-sysctl_init_bases +1 -1
@@ -2844,7 +2844,7 @@ DECLARE_SYSCTL_BASE(vm, vm_table);DECLARE_SYSCTL_BASE (debug, debug_table);DECLARE_SYSCTL_BASE (dev, dev_table); -int __init sysctl_init (void ) +int __init sysctl_init_bases (void ) {register_sysctl_base (kernel);register_sysctl_base (vm);
_
Andrew Morton
maintainerPATCH 39/69 printk: fix build warning when CONFIG_PRINTK=n
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: printk: fix build warning when CONFIG_PRINTK=n
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.
---
include/linux/printk.h | 4 ---- kernel/printk/internal.h | 2 ++ kernel/printk/printk.c | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-)
include/linux/printk.h renamed from include/linux/printk.h~printk-fix-build-warning-when-config_printk=n +0 -4
@@ -183,10 +183,6 @@ extern bool printk_timed_ratelimit(unsigextern int printk_delay_msec;extern int dmesg_restrict; -extern int -devkmsg_sysctl_set_loglvl (struct ctl_table *table,int write,void *buf, -size_t *lenp,loff_t *ppos); -extern void wake_up_klogd (void );char *log_buf_addr_get (void );
kernel/printk/internal.h renamed from kernel/printk/internal.h~printk-fix-build-warning-when-config_printk=n +2 -0
@@ -6,6 +6,8 @@#if defined(CONFIG_PRINTK ) && defined(CONFIG_SYSCTL )void __init printk_sysctl_init (void ); +int devkmsg_sysctl_set_loglvl (struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos);#else #define printk_sysctl_init () do { } while (0)#endif
kernel/printk/printk.c renamed from kernel/printk/printk.c~printk-fix-build-warning-when-config_printk=n +2 -1
@@ -171,7 +171,7 @@ static int __init control_devkmsg(char *__setup ("printk.devkmsg=" , control_devkmsg);char devkmsg_log_str[DEVKMSG_STR_MAX_SIZE ] ="ratelimit" ; - +#if defined(CONFIG_PRINTK ) && defined(CONFIG_SYSCTL )int devkmsg_sysctl_set_loglvl (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos) {
@@ -210,6 +210,7 @@ int devkmsg_sysctl_set_loglvl(struct ctl return 0; } +#endif /* CONFIG_PRINTK && CONFIG_SYSCTL */ /* Number of registered extended console drivers. */ static int nr_ext_console_drivers;
_
Andrew Morton
maintainerPATCH 40/69 fs/coredump: move coredump sysctls into its own file
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: fs/coredump: move coredump sysctls into its own file
This moves the fs/coredump.c respective sysctls to its own file.
---
fs/coredump.c | 66 ++++++++++++++++++++++++++++++++++--- fs/exec.c | 55 ------------------------------ include/linux/coredump.h | 10 +++-- kernel/sysctl.c | 2 - 4 files changed, 67 insertions(+), 66 deletions(-)
fs/coredump.c renamed from fs/coredump.c~fs-coredump-move-coredump-sysctls-into-its-own-file +61 -5
@@ -41,6 +41,7 @@#include <linux/fs.h> #include <linux/path.h> #include <linux/timekeeping.h> +#include <linux/sysctl.h> #include <linux/uaccess.h> #include <asm/mmu_context.h>
@@ -52,9 +53,9 @@#include <trace/events/sched.h> -int core_uses_pid; -unsigned int core_pipe_limit; -char core_pattern[CORENAME_MAX_SIZE ] ="core" ; +static int core_uses_pid; +static unsigned int core_pipe_limit; +static char core_pattern[CORENAME_MAX_SIZE ] ="core" ;static int core_name_size =CORENAME_MAX_SIZE ;struct core_name {
@@ -62,8 +63,6 @@ struct core_name {int used, size; }; -/* The maximal length of core_pattern is also specified in sysctl.c */ -static int expand_corename (struct core_name *cn,int size) {char *corename =krealloc (cn->corename, size,GFP_KERNEL );
@@ -893,6 +892,63 @@ int dump_align(struct coredump_params *c }EXPORT_SYMBOL (dump_align); +#ifdef CONFIG_SYSCTL + +void validate_coredump_safety (void ) +{ +if (suid_dumpable ==SUID_DUMP_ROOT && + core_pattern[0 ] !='/' && core_pattern[0 ] !='|' ) { +pr_warn ( +"Unsafe core_pattern used with fs.suid_dumpable=2.\n" +"Pipe handler or fully qualified core dump path required.\n" +"Set kernel.core_pattern before fs.suid_dumpable.\n" + ); + } +} + +static int proc_dostring_coredump (struct ctl_table *table,int write, +void *buffer,size_t *lenp,loff_t *ppos) +{ +int error =proc_dostring (table, write, buffer, lenp, ppos); + +if (!error) +validate_coredump_safety (); +return error; +} + +static struct ctl_table coredump_sysctls[] = { + { + .procname ="core_uses_pid" , + .data = &core_uses_pid, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_dointvec, + }, + { + .procname ="core_pattern" , + .data = core_pattern, + .maxlen =CORENAME_MAX_SIZE , + .mode =0644 , + .proc_handler = proc_dostring_coredump, + }, + { + .procname ="core_pipe_limit" , + .data = &core_pipe_limit, + .maxlen =sizeof (unsigned int ), + .mode =0644 , + .proc_handler = proc_dointvec, + }, + { } +}; + +static int __init init_fs_coredump_sysctls (void ) +{ +register_sysctl_init ("kernel" , coredump_sysctls); +return 0 ; +} +fs_initcall (init_fs_coredump_sysctls); +#endif /* CONFIG_SYSCTL */ +/* * The purpose of always_dump_vma() is to make sure that special kernel mappings * that are useful for post-mortem analysis are included in every core dump.
fs/exec.c renamed from fs/exec.c~fs-coredump-move-coredump-sysctls-into-its-own-file +0 -55
70 lines not on this page · raw message
include/linux/coredump.h renamed from include/linux/coredump.h~fs-coredump-move-coredump-sysctls-into-its-own-file +6 -4
@@ -14,10 +14,6 @@ struct core_vma_metadata {unsigned long dump_size; }; -extern int core_uses_pid; -extern char core_pattern[]; -extern unsigned int core_pipe_limit; -/* * These are the only things you should do on a core-file: use only these * functions to write out all the necessary info.
@@ -37,4 +33,10 @@ extern void do_coredump(const kernel_sigstatic inline void do_coredump (const kernel_siginfo_t *siginfo) {}#endif +#if defined(CONFIG_COREDUMP ) && defined(CONFIG_SYSCTL ) +extern void validate_coredump_safety (void ); +#else +static inline void validate_coredump_safety (void ) {} +#endif +#endif /* _LINUX_COREDUMP_H */
kernel/sysctl.c renamed from kernel/sysctl.c~fs-coredump-move-coredump-sysctls-into-its-own-file +0 -2
@@ -62,12 +62,10 @@#include <linux/capability.h> #include <linux/binfmts.h> #include <linux/sched/sysctl.h> -#include <linux/sched/coredump.h> #include <linux/kexec.h> #include <linux/bpf.h> #include <linux/mount.h> #include <linux/userfaultfd_k.h> -#include <linux/coredump.h> #include <linux/latencytop.h> #include <linux/pid.h> #include <linux/delayacct.h>
_
Andrew Morton
maintainerPATCH 41/69 kprobe: move sysctl_kprobes_optimization to kprobes.c
In reply to Andrew MortonFrom: Xiaoming Ni <[email protected]>
Subject: kprobe: move sysctl_kprobes_optimization to kprobes.c
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.
---
include/linux/kprobes.h | 6 ------ kernel/kprobes.c | 30 ++++++++++++++++++++++++++---- kernel/sysctl.c | 12 ------------ 3 files changed, 26 insertions(+), 22 deletions(-)
include/linux/kprobes.h renamed from include/linux/kprobes.h~kprobe-move-sysctl_kprobes_optimization-to-kprobesc +0 -6
@@ -348,12 +348,6 @@ extern void opt_pre_handler(struct kprobDEFINE_INSN_CACHE_OPS (optinsn); -#ifdef CONFIG_SYSCTL -extern int sysctl_kprobes_optimization; -extern int proc_kprobes_optimization_handler (struct ctl_table *table, -int write,void *buffer, -size_t *length,loff_t *ppos); -#endif /* CONFIG_SYSCTL */ extern void wait_for_kprobe_optimizer (void );#else /* !CONFIG_OPTPROBES */ static inline void wait_for_kprobe_optimizer (void ) { }
kernel/kprobes.c renamed from kernel/kprobes.c~kprobe-move-sysctl_kprobes_optimization-to-kprobesc +26 -4
@@ -48,6 +48,9 @@#define KPROBE_HASH_BITS 6#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) +#if !defined(CONFIG_OPTPROBES ) || !defined(CONFIG_SYSCTL ) +#define kprobe_sysctls_init () do { } while (0) +#endif static int kprobes_initialized;/* kprobe_table can be accessed by
@@ -938,10 +941,10 @@ static void unoptimize_all_kprobes(void) }static DEFINE_MUTEX (kprobe_sysctl_mutex); -int sysctl_kprobes_optimization; -int proc_kprobes_optimization_handler (struct ctl_table *table,int write, -void *buffer,size_t *length, -loff_t *ppos) +static int sysctl_kprobes_optimization; +static int proc_kprobes_optimization_handler (struct ctl_table *table, +int write,void *buffer, +size_t *length,loff_t *ppos) {int ret;
@@ -957,6 +960,24 @@ int proc_kprobes_optimization_handler(st return ret; } + +static struct ctl_table kprobe_sysctls[] = { + { + .procname ="kprobes-optimization" , + .data = &sysctl_kprobes_optimization, + .maxlen =sizeof (int ), + .mode =0644 , + .proc_handler = proc_kprobes_optimization_handler, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_ONE , + }, + {} +}; + +static void __init kprobe_sysctls_init (void ) +{ +register_sysctl_init ("debug" , kprobe_sysctls); +}#endif /* CONFIG_SYSCTL */ /* Put a breakpoint for a probe. */
@@ -2584,6 +2605,7 @@ static int __init init_kprobes(void) err =register_module_notifier (&kprobe_module_nb); kprobes_initialized = (err ==0 ); +kprobe_sysctls_init ();return err; }early_initcall (init_kprobes);
kernel/sysctl.c renamed from kernel/sysctl.c~kprobe-move-sysctl_kprobes_optimization-to-kprobesc +0 -12
@@ -56,7 +56,6 @@#include <linux/reboot.h> #include <linux/ftrace.h> #include <linux/perf_event.h> -#include <linux/kprobes.h> #include <linux/oom.h> #include <linux/kmod.h> #include <linux/capability.h>
@@ -2819,17 +2818,6 @@ static struct ctl_table debug_table[] = .proc_handler = proc_dointvec },#endif -#if defined(CONFIG_OPTPROBES ) - { - .procname = "kprobes-optimization", - .data = &sysctl_kprobes_optimization, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_kprobes_optimization_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif { } };
_
Andrew Morton
maintainerPATCH 42/69 kernel/sysctl.c: remove unused variable ten_thousand
In reply to Andrew MortonFrom: Colin Ian King <[email protected]>
Subject: kernel/sysctl.c: remove unused variable ten_thousand
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;
---
kernel/sysctl.c | 3 --- 1 file changed, 3 deletions(-)
kernel/sysctl.c renamed from kernel/sysctl.c~kernel-sysctlc-remove-unused-variable-ten_thousand +0 -3
@@ -96,9 +96,6 @@/* Constants used for minimum and maximum */ -#ifdef CONFIG_PRINTK -static const int ten_thousand =10000 ; -#endif #ifdef CONFIG_PERF_EVENTS static const int six_hundred_forty_kb =640 *1024 ;#endif
_
Andrew Morton
maintainerPATCH 43/69 sysctl: returns -EINVAL when a negative value is passed to proc_doulongvec_minmax
In reply to Andrew MortonFrom: Baokun Li <[email protected]>
Subject: sysctl: returns -EINVAL when a negative value is passed to proc_doulongvec_minmax
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.
---
kernel/sysctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/sysctl.c renamed from kernel/sysctl.c~sysctl-returns-einval-when-a-negative-value-is-passed-to-proc_doulongvec_minmax +4 -3
@@ -1145,10 +1145,11 @@ static int __do_proc_doulongvec_minmax(v err =proc_get_long (&p, &left, &val, &neg, proc_wspace_sep,sizeof (proc_wspace_sep),NULL ); -if (err) +if (err || neg) { + err = -EINVAL ;break ; -if (neg) -continue ; + } + val = convmul * val / convdiv;if ((min && val < *min) || (max && val > *max)) { err = -EINVAL ;
_
Andrew Morton
maintainerPATCH 44/69 zsmalloc: introduce some helper functions
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: zsmalloc: introduce some helper functions
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.
---
mm/zsmalloc.c | 54 ++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 31 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-introduce-some-helper-functions +23 -31
@@ -517,6 +517,12 @@ static void get_zspage_mapping(struct zs *class_idx = zspage->class; } +static struct size_class *zspage_class (struct zs_pool *pool, +struct zspage *zspage) +{ +return pool->size_class[zspage->class]; +} +static void set_zspage_mapping (struct zspage *zspage,unsigned int class_idx,enum fullness_group fullness)
@@ -844,6 +850,12 @@ static void obj_to_location(unsigned lon *obj_idx = (obj &OBJ_INDEX_MASK ); } +static void obj_to_page (unsigned long obj,struct page **page) +{ + obj >>=OBJ_TAG_BITS ; + *page =pfn_to_page (obj >>OBJ_INDEX_BITS ); +} +/** * location_to_obj - get obj value encoded from (<page>, <obj_idx>) * @page: page object resides in zspage
@@ -1246,8 +1258,6 @@ void *zs_map_object(struct zs_pool *poolunsigned long obj, off;unsigned int obj_idx; -unsigned int class_idx; -enum fullness_group fg;struct size_class *class;struct mapping_area *area;struct page *pages[2 ];
@@ -1270,8 +1280,7 @@ void *zs_map_object(struct zs_pool *pool/* migration cannot move any subpage in this zspage */ migrate_read_lock (zspage); -get_zspage_mapping (zspage, &class_idx, &fg); - class = pool->size_class[class_idx]; + class =zspage_class (pool, zspage); off = (class->size * obj_idx) & ~PAGE_MASK ; area = &get_cpu_var (zs_map_area);
@@ -1304,16 +1313,13 @@ void zs_unmap_object(struct zs_pool *poounsigned long obj, off;unsigned int obj_idx; -unsigned int class_idx; -enum fullness_group fg;struct size_class *class;struct mapping_area *area; obj =handle_to_obj (handle);obj_to_location (obj, &page, &obj_idx); zspage =get_zspage (page); -get_zspage_mapping (zspage, &class_idx, &fg); - class = pool->size_class[class_idx]; + class =zspage_class (pool, zspage); off = (class->size * obj_idx) & ~PAGE_MASK ; area =this_cpu_ptr (&zs_map_area);
@@ -1491,8 +1497,6 @@ void zs_free(struct zs_pool *pool, unsigstruct zspage *zspage;struct page *f_page;unsigned long obj; -unsigned int f_objidx; -int class_idx;struct size_class *class;enum fullness_group fullness;bool isolated;
@@ -1502,13 +1506,11 @@ void zs_free(struct zs_pool *pool, unsigpin_tag (handle); obj =handle_to_obj (handle); -obj_to_location (obj, &f_page, &f_objidx); +obj_to_page (obj, &f_page); zspage =get_zspage (f_page);migrate_read_lock (zspage); - -get_zspage_mapping (zspage, &class_idx, &fullness); - class = pool->size_class[class_idx]; + class =zspage_class (pool, zspage);spin_lock (&class->lock);obj_free (class, obj);
@@ -1866,8 +1868,6 @@ static bool zs_page_isolate(struct page {struct zs_pool *pool;struct size_class *class; -int class_idx; -enum fullness_group fullness;struct zspage *zspage;struct address_space *mapping;
@@ -1880,15 +1880,10 @@ static bool zs_page_isolate(struct page zspage =get_zspage (page); -/* -* Without class lock, fullness could be stale while class_idx is okay -* because class_idx is constant unless page is freed so we should get -* fullness again under class lock. -*/ -get_zspage_mapping (zspage, &class_idx, &fullness); mapping =page_mapping (page); pool = mapping->private_data; - class = pool->size_class[class_idx]; + + class =zspage_class (pool, zspage);spin_lock (&class->lock);if (get_zspage_inuse (zspage) ==0 ) {
@@ -1907,6 +1902,9 @@ static bool zs_page_isolate(struct page* size_class to prevent further object allocation from the zspage. */ if (!list_empty (&zspage->list) && !is_zspage_isolated (zspage)) { +enum fullness_group fullness; +unsigned int class_idx; +get_zspage_mapping (zspage, &class_idx, &fullness);atomic_long_inc (&pool->isolated_pages);remove_zspage (class, zspage, fullness);
@@ -1923,8 +1921,6 @@ static int zs_page_migrate(struct addres {struct zs_pool *pool;struct size_class *class; -int class_idx; -enum fullness_group fullness;struct zspage *zspage;struct page *dummy;void *s_addr, *d_addr, *addr;
@@ -1949,9 +1945,8 @@ static int zs_page_migrate(struct addres/* Concurrent compactor cannot migrate any subpage in zspage */ migrate_write_lock (zspage); -get_zspage_mapping (zspage, &class_idx, &fullness); pool = mapping->private_data; - class = pool->size_class[class_idx]; + class =zspage_class (pool, zspage); offset =get_first_obj_offset (page);spin_lock (&class->lock);
@@ -2049,8 +2044,6 @@ static void zs_page_putback(struct page {struct zs_pool *pool;struct size_class *class; -int class_idx; -enum fullness_group fg;struct address_space *mapping;struct zspage *zspage;
@@ -2058,10 +2051,9 @@ static void zs_page_putback(struct pageVM_BUG_ON_PAGE (!PageIsolated (page), page); zspage =get_zspage (page); -get_zspage_mapping (zspage, &class_idx, &fg); mapping =page_mapping (page); pool = mapping->private_data; - class = pool->size_class[class_idx]; + class =zspage_class (pool, zspage);spin_lock (&class->lock);dec_zspage_isolation (zspage);
_
Andrew Morton
maintainerPATCH 45/69 zsmalloc: rename zs_stat_type to class_stat_type
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: zsmalloc: rename zs_stat_type to class_stat_type
The stat aims for class stat, not zspage so rename it.
---
mm/zsmalloc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-rename-zs_stat_type-to-class_stat_type +12 -12
@@ -158,7 +158,7 @@ enum fullness_group { NR_ZS_FULLNESS, }; -enum zs_stat_type { +enum class_stat_type {CLASS_EMPTY ,CLASS_ALMOST_EMPTY ,CLASS_ALMOST_FULL ,
@@ -549,21 +549,21 @@ static int get_size_class_index(int sizereturn min_t (int,ZS_SIZE_CLASSES -1 , idx); } -/* type can be of enum type zs_stat_type or fullness_group */ -static inline void zs_stat_inc (struct size_class *class, +/* type can be of enum type class_stat_type or fullness_group */ +static inline void class_stat_inc (struct size_class *class,int type,unsigned long cnt) { class->stats.objs[type] += cnt; } -/* type can be of enum type zs_stat_type or fullness_group */ -static inline void zs_stat_dec (struct size_class *class, +/* type can be of enum type class_stat_type or fullness_group */ +static inline void class_stat_dec (struct size_class *class,int type,unsigned long cnt) { class->stats.objs[type] -= cnt; } -/* type can be of enum type zs_stat_type or fullness_group */ +/* type can be of enum type class_stat_type or fullness_group */ static inline unsigned long zs_stat_get (struct size_class *class,int type) {
@@ -725,7 +725,7 @@ static void insert_zspage(struct size_cl {struct zspage *head; -zs_stat_inc (class, fullness,1 ); +class_stat_inc (class, fullness,1 ); head =list_first_entry_or_null (&class->fullness_list[fullness], struct zspage, list);/*
@@ -750,7 +750,7 @@ static void remove_zspage(struct size_clVM_BUG_ON (is_zspage_isolated (zspage));list_del_init (&zspage->list); -zs_stat_dec (class, fullness,1 ); +class_stat_dec (class, fullness,1 ); }/*
@@ -964,7 +964,7 @@ static void __free_zspage(struct zs_poolcache_free_zspage (pool, zspage); -zs_stat_dec (class,OBJ_ALLOCATED , class->objs_per_zspage); +class_stat_dec (class,OBJ_ALLOCATED , class->objs_per_zspage);atomic_long_sub (class->pages_per_zspage, &pool->pages_allocated); }
@@ -1394,7 +1394,7 @@ static unsigned long obj_malloc(struct skunmap_atomic (vaddr);mod_zspage_inuse (zspage,1 ); -zs_stat_inc (class,OBJ_USED ,1 ); +class_stat_inc (class,OBJ_USED ,1 ); obj =location_to_obj (m_page, obj);
@@ -1458,7 +1458,7 @@ unsigned long zs_malloc(struct zs_pool *record_obj (handle, obj);atomic_long_add (class->pages_per_zspage, &pool->pages_allocated); -zs_stat_inc (class,OBJ_ALLOCATED , class->objs_per_zspage); +class_stat_inc (class,OBJ_ALLOCATED , class->objs_per_zspage);/* We completely set up zspage so mark them as movable */ SetZsPageMovable (pool, zspage);
@@ -1489,7 +1489,7 @@ static void obj_free(struct size_class *kunmap_atomic (vaddr);set_freeobj (zspage, f_objidx);mod_zspage_inuse (zspage,-1 ); -zs_stat_dec (class,OBJ_USED ,1 ); +class_stat_dec (class,OBJ_USED ,1 ); }void zs_free (struct zs_pool *pool,unsigned long handle)
_
Andrew Morton
maintainerPATCH 46/69 zsmalloc: decouple class actions from zspage works
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: zsmalloc: decouple class actions from zspage works
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.
---
mm/zsmalloc.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-decouple-class-actions-from-zspage-works +13 -10
@@ -1360,17 +1360,19 @@ size_t zs_huge_class_size(struct zs_pool }EXPORT_SYMBOL_GPL (zs_huge_class_size); -static unsigned long obj_malloc (struct size_class *class, +static unsigned long obj_malloc (struct zs_pool *pool,struct zspage *zspage,unsigned long handle) {int i, nr_page, offset;unsigned long obj;struct link_free *link; +struct size_class *class;struct page *m_page;unsigned long m_offset;void *vaddr; + class = pool->size_class[zspage->class]; handle |=OBJ_ALLOCATED_TAG ; obj =get_freeobj (zspage);
@@ -1394,7 +1396,6 @@ static unsigned long obj_malloc(struct skunmap_atomic (vaddr);mod_zspage_inuse (zspage,1 ); -class_stat_inc (class,OBJ_USED ,1 ); obj =location_to_obj (m_page, obj);
@@ -1433,10 +1434,11 @@ unsigned long zs_malloc(struct zs_pool *spin_lock (&class->lock); zspage =find_get_zspage (class);if (likely (zspage)) { - obj =obj_malloc (class, zspage, handle); + obj =obj_malloc (pool, zspage, handle);/* Now move the zspage to another fullness group, if required */ fix_fullness_group (class, zspage);record_obj (handle, obj); +class_stat_inc (class,OBJ_USED ,1 );spin_unlock (&class->lock);return handle;
@@ -1451,7 +1453,7 @@ unsigned long zs_malloc(struct zs_pool * }spin_lock (&class->lock); - obj =obj_malloc (class, zspage, handle); + obj =obj_malloc (pool, zspage, handle); newfg =get_fullness_group (class, zspage);insert_zspage (class, zspage, newfg);set_zspage_mapping (zspage, class->index, newfg);
@@ -1459,6 +1461,7 @@ unsigned long zs_malloc(struct zs_pool *atomic_long_add (class->pages_per_zspage, &pool->pages_allocated);class_stat_inc (class,OBJ_ALLOCATED , class->objs_per_zspage); +class_stat_inc (class,OBJ_USED ,1 );/* We completely set up zspage so mark them as movable */ SetZsPageMovable (pool, zspage);
@@ -1468,7 +1471,7 @@ unsigned long zs_malloc(struct zs_pool * }EXPORT_SYMBOL_GPL (zs_malloc); -static void obj_free (struct size_class *class,unsigned long obj) +static void obj_free (int class_size,unsigned long obj) {struct link_free *link;struct zspage *zspage;
@@ -1478,7 +1481,7 @@ static void obj_free(struct size_class *void *vaddr;obj_to_location (obj, &f_page, &f_objidx); - f_offset = (class->size * f_objidx) & ~PAGE_MASK ; + f_offset = (class_size * f_objidx) & ~PAGE_MASK ; zspage =get_zspage (f_page); vaddr =kmap_atomic (f_page);
@@ -1489,7 +1492,6 @@ static void obj_free(struct size_class *kunmap_atomic (vaddr);set_freeobj (zspage, f_objidx);mod_zspage_inuse (zspage,-1 ); -class_stat_dec (class,OBJ_USED ,1 ); }void zs_free (struct zs_pool *pool,unsigned long handle)
@@ -1513,7 +1515,8 @@ void zs_free(struct zs_pool *pool, unsig class =zspage_class (pool, zspage);spin_lock (&class->lock); -obj_free (class, obj); +obj_free (class->size, obj); +class_stat_dec (class,OBJ_USED ,1 ); fullness =fix_fullness_group (class, zspage);if (fullness !=ZS_EMPTY ) {migrate_read_unlock (zspage);
@@ -1671,7 +1674,7 @@ static int migrate_zspage(struct zs_pool } used_obj =handle_to_obj (handle); - free_obj =obj_malloc (class,get_zspage (d_page), handle); + free_obj =obj_malloc (pool,get_zspage (d_page), handle);zs_object_copy (class, free_obj, used_obj); obj_idx++;/*
@@ -1683,7 +1686,7 @@ static int migrate_zspage(struct zs_pool free_obj |=BIT (HANDLE_PIN_BIT );record_obj (handle, free_obj);unpin_tag (handle); -obj_free (class, used_obj); +obj_free (class->size, used_obj); }/* Remember last position in this iteration */
_
Andrew Morton
maintainerPATCH 47/69 zsmalloc: introduce obj_allocated
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: zsmalloc: introduce obj_allocated
The usage pattern for obj_to_head is to check whether the zpage is allocated or not. Thus, introduce obj_allocated.
---
mm/zsmalloc.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-introduce-obj_allocated +16 -17
@@ -877,13 +877,21 @@ static unsigned long handle_to_obj(unsigreturn *(unsigned long *)handle; } -static unsigned long obj_to_head (struct page *page,void *obj) +static bool obj_allocated (struct page *page,void *obj,unsigned long *phandle) { +unsigned long handle; +if (unlikely (PageHugeObject (page))) {VM_BUG_ON_PAGE (!is_first_page (page), page); -return page->index; + handle = page->index; }else -return *(unsigned long *)obj; + handle = *(unsigned long *)obj; + +if (!(handle &OBJ_ALLOCATED_TAG )) +return false; + + *phandle = handle & ~OBJ_ALLOCATED_TAG ; +return true; }static inline int testpin_tag (unsigned long handle)
@@ -1606,7 +1614,6 @@ static void zs_object_copy(struct size_cstatic unsigned long find_alloced_obj (struct size_class *class,struct page *page,int *obj_idx) { -unsigned long head;int offset =0 ;int index = *obj_idx;unsigned long handle =0 ;
@@ -1616,9 +1623,7 @@ static unsigned long find_alloced_obj(st offset += class->size * index;while (offset <PAGE_SIZE ) { - head =obj_to_head (page, addr + offset); -if (head &OBJ_ALLOCATED_TAG ) { - handle = head & ~OBJ_ALLOCATED_TAG ; +if (obj_allocated (page, addr + offset, &handle)) {if (trypin_tag (handle))break ; handle =0 ;
@@ -1928,7 +1933,7 @@ static int zs_page_migrate(struct addresstruct page *dummy;void *s_addr, *d_addr, *addr;int offset, pos; -unsigned long handle, head; +unsigned long handle;unsigned long old_obj, new_obj;unsigned int obj_idx;int ret = -EAGAIN ;
@@ -1964,9 +1969,7 @@ static int zs_page_migrate(struct addres pos = offset; s_addr =kmap_atomic (page);while (pos <PAGE_SIZE ) { - head =obj_to_head (page, s_addr + pos); -if (head &OBJ_ALLOCATED_TAG ) { - handle = head & ~OBJ_ALLOCATED_TAG ; +if (obj_allocated (page, s_addr + pos, &handle)) {if (!trypin_tag (handle)) goto unpin_objects; }
@@ -1982,9 +1985,7 @@ static int zs_page_migrate(struct addresfor (addr = s_addr + offset; addr < s_addr + pos; addr += class->size) { - head =obj_to_head (page, addr); -if (head &OBJ_ALLOCATED_TAG ) { - handle = head & ~OBJ_ALLOCATED_TAG ; +if (obj_allocated (page, addr, &handle)) {BUG_ON (!testpin_tag (handle)); old_obj =handle_to_obj (handle);
@@ -2029,9 +2030,7 @@ static int zs_page_migrate(struct addres unpin_objects:for (addr = s_addr + offset; addr < s_addr + pos; addr += class->size) { - head =obj_to_head (page, addr); -if (head &OBJ_ALLOCATED_TAG ) { - handle = head & ~OBJ_ALLOCATED_TAG ; +if (obj_allocated (page, addr, &handle)) {BUG_ON (!testpin_tag (handle));unpin_tag (handle); }
_
Andrew Morton
maintainerPATCH 48/69 zsmalloc: move huge compressed obj from page to zspage
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: zsmalloc: move huge compressed obj from page to zspage
The flag aims for zspage, not per page. Let's move it to zspage.
---
mm/zsmalloc.c | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-move-huge-compressed-obj-from-page-to-zspage +26 -24
@@ -121,6 +121,7 @@#define OBJ_INDEX_BITS (BITS_PER_LONG - _PFN_BITS - OBJ_TAG_BITS)#define OBJ_INDEX_MASK ((_AC(1, UL) << OBJ_INDEX_BITS) - 1) +#define HUGE_BITS 1#define FULLNESS_BITS 2#define CLASS_BITS 8#define ISOLATED_BITS 3
@@ -213,22 +214,6 @@ struct size_class {struct zs_size_stat stats; }; -/* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ -static void SetPageHugeObject (struct page *page) -{ -SetPageOwnerPriv1 (page); -} - -static void ClearPageHugeObject (struct page *page) -{ -ClearPageOwnerPriv1 (page); -} - -static int PageHugeObject (struct page *page) -{ -return PageOwnerPriv1 (page); -} -/* * Placed within free objects to form a singly linked list. * For every zspage, zspage->freeobj gives head of this list.
@@ -278,6 +263,7 @@ struct zs_pool {struct zspage {struct { +unsigned int huge:HUGE_BITS ;unsigned int fullness:FULLNESS_BITS ;unsigned int class:CLASS_BITS +1 ;unsigned int isolated:ISOLATED_BITS ;
@@ -298,6 +284,17 @@ struct mapping_area {enum zs_mapmode vm_mm;/* mapping mode */ }; +/* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ +static void SetZsHugePage (struct zspage *zspage) +{ + zspage->huge =1 ; +} + +static bool ZsHugePage (struct zspage *zspage) +{ +return zspage->huge; +} +#ifdef CONFIG_COMPACTION static int zs_register_migration (struct zs_pool *pool);static void zs_unregister_migration (struct zs_pool *pool);
@@ -830,7 +827,9 @@ static struct zspage *get_zspage(structstatic struct page *get_next_page (struct page *page) { -if (unlikely (PageHugeObject (page))) +struct zspage *zspage =get_zspage (page); + +if (unlikely (ZsHugePage (zspage)))return NULL ;return (struct page *)page->index;
@@ -880,8 +879,9 @@ static unsigned long handle_to_obj(unsigstatic bool obj_allocated (struct page *page,void *obj,unsigned long *phandle) {unsigned long handle; +struct zspage *zspage =get_zspage (page); -if (unlikely (PageHugeObject (page))) { +if (unlikely (ZsHugePage (zspage))) {VM_BUG_ON_PAGE (!is_first_page (page), page); handle = page->index; }else
@@ -920,7 +920,6 @@ static void reset_page(struct page *pageClearPagePrivate (page);set_page_private (page,0 );page_mapcount_reset (page); -ClearPageHugeObject (page); page->index =0 ; }
@@ -1062,7 +1061,7 @@ static void create_page_chain(struct sizSetPagePrivate (page);if (unlikely (class->objs_per_zspage ==1 && class->pages_per_zspage ==1 )) -SetPageHugeObject (page); +SetZsHugePage (zspage); }else { prev_page->index = (unsigned long )page; }
@@ -1307,7 +1306,7 @@ void *zs_map_object(struct zs_pool *pool ret =__zs_map_object (area, pages, off, class->size); out: -if (likely (!PageHugeObject (page))) +if (likely (!ZsHugePage (zspage))) ret +=ZS_HANDLE_SIZE ;return ret;
@@ -1395,7 +1394,7 @@ static unsigned long obj_malloc(struct z vaddr =kmap_atomic (m_page); link = (struct link_free *)vaddr + m_offset /sizeof (*link);set_freeobj (zspage, link->next >>OBJ_TAG_BITS ); -if (likely (!PageHugeObject (m_page))) +if (likely (!ZsHugePage (zspage)))/* record handle in the header of allocated chunk */ link->handle = handle;else
@@ -1496,7 +1495,10 @@ static void obj_free(int class_size, uns/* Insert this object in containing zspage's freelist */ link = (struct link_free *)(vaddr + f_offset); - link->next =get_freeobj (zspage) <<OBJ_TAG_BITS ; +if (likely (!ZsHugePage (zspage))) + link->next =get_freeobj (zspage) <<OBJ_TAG_BITS ; +else + f_page->index =0 ;kunmap_atomic (vaddr);set_freeobj (zspage, f_objidx);mod_zspage_inuse (zspage,-1 );
@@ -1867,7 +1869,7 @@ static void replace_sub_page(struct sizecreate_page_chain (class, zspage, pages);set_first_obj_offset (newpage,get_first_obj_offset (oldpage)); -if (unlikely (PageHugeObject (oldpage))) +if (unlikely (ZsHugePage (zspage))) newpage->index = oldpage->index;__SetPageMovable (newpage,page_mapping (oldpage)); }
_
Andrew Morton
maintainerPATCH 49/69 zsmalloc: remove zspage isolation for migration
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: zsmalloc: remove zspage isolation for migration
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.
---
mm/zsmalloc.c | 157 ++---------------------------------------------- 1 file changed, 8 insertions(+), 149 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-remove-zspage-isolation-for-migration +8 -149
@@ -254,10 +254,6 @@ struct zs_pool {#ifdef CONFIG_COMPACTION struct inode *inode;struct work_struct free_work; -/* A wait queue for when migration races with async_free_zspage() */ -struct wait_queue_head migration_wait; -atomic_long_t isolated_pages; -bool destroying;#endif };
@@ -454,11 +450,6 @@ MODULE_ALIAS("zpool-zsmalloc");/* per-cpu VM mapping areas for zspage accesses that cross page boundaries */ static DEFINE_PER_CPU(struct mapping_area, zs_map_area); -static bool is_zspage_isolated (struct zspage *zspage) -{ -return zspage->isolated; -} -static __maybe_unused int is_first_page (struct page *page) {return PagePrivate (page);
@@ -744,7 +735,6 @@ static void remove_zspage(struct size_cl enum fullness_group fullness) {VM_BUG_ON (list_empty (&class->fullness_list[fullness])); -VM_BUG_ON (is_zspage_isolated (zspage));list_del_init (&zspage->list);class_stat_dec (class, fullness,1 );
@@ -770,13 +760,9 @@ static enum fullness_group fix_fullness_if (newfg == currfg) goto out; -if (!is_zspage_isolated (zspage)) { -remove_zspage (class, zspage, currfg); -insert_zspage (class, zspage, newfg); - } - +remove_zspage (class, zspage, currfg); +insert_zspage (class, zspage, newfg);set_zspage_mapping (zspage, class_idx, newfg); - out:return newfg; }
@@ -1511,7 +1497,6 @@ void zs_free(struct zs_pool *pool, unsigunsigned long obj;struct size_class *class;enum fullness_group fullness; -bool isolated;if (unlikely (!handle))return ;
@@ -1533,11 +1518,9 @@ void zs_free(struct zs_pool *pool, unsig goto out; } - isolated =is_zspage_isolated (zspage);migrate_read_unlock (zspage);/* If zspage is isolated, zs_page_putback will free the zspage */ -if (likely (!isolated)) -free_zspage (pool, class, zspage); +free_zspage (pool, class, zspage); out:spin_unlock (&class->lock);
@@ -1718,7 +1701,6 @@ static struct zspage *isolate_zspage(str zspage =list_first_entry_or_null (&class->fullness_list[fg[i]], struct zspage, list);if (zspage) { -VM_BUG_ON (is_zspage_isolated (zspage));remove_zspage (class, zspage, fg[i]);return zspage; }
@@ -1739,8 +1721,6 @@ static enum fullness_group putback_zspag {enum fullness_group fullness; -VM_BUG_ON (is_zspage_isolated (zspage)); - fullness =get_fullness_group (class, zspage);insert_zspage (class, zspage, fullness);set_zspage_mapping (zspage, class->index, fullness);
@@ -1822,35 +1802,10 @@ static void inc_zspage_isolation(structstatic void dec_zspage_isolation (struct zspage *zspage) { +VM_BUG_ON (zspage->isolated ==0 ); zspage->isolated--; } -static void putback_zspage_deferred (struct zs_pool *pool, -struct size_class *class, -struct zspage *zspage) -{ -enum fullness_group fg; - - fg =putback_zspage (class, zspage); -if (fg ==ZS_EMPTY ) -schedule_work (&pool->free_work); - -} - -static inline void zs_pool_dec_isolated (struct zs_pool *pool) -{ -VM_BUG_ON (atomic_long_read (&pool->isolated_pages) <=0 ); -atomic_long_dec (&pool->isolated_pages); -/* -* Checking pool->destroying must happen after atomic_long_dec() -* for pool->isolated_pages above. Paired with the smp_mb() in -* zs_unregister_migration(). -*/ -smp_mb__after_atomic (); -if (atomic_long_read (&pool->isolated_pages) ==0 && pool->destroying) -wake_up_all (&pool->migration_wait); -} -static void replace_sub_page (struct size_class *class,struct zspage *zspage,struct page *newpage,struct page *oldpage) {
@@ -1876,10 +1831,7 @@ static void replace_sub_page(struct sizestatic bool zs_page_isolate (struct page *page,isolate_mode_t mode) { -struct zs_pool *pool; -struct size_class *class;struct zspage *zspage; -struct address_space *mapping;/* * Page is locked so zspage couldn't be destroyed. For detail, look at
@@ -1889,39 +1841,9 @@ static bool zs_page_isolate(struct pageVM_BUG_ON_PAGE (PageIsolated (page), page); zspage =get_zspage (page); - - mapping =page_mapping (page); - pool = mapping->private_data; - - class =zspage_class (pool, zspage); - -spin_lock (&class->lock); -if (get_zspage_inuse (zspage) ==0 ) { -spin_unlock (&class->lock); -return false; - } - -/* zspage is isolated for object migration */ -if (list_empty (&zspage->list) && !is_zspage_isolated (zspage)) { -spin_unlock (&class->lock); -return false; - } - -/* -* If this is first time isolation for the zspage, isolate zspage from -* size_class to prevent further object allocation from the zspage. -*/ -if (!list_empty (&zspage->list) && !is_zspage_isolated (zspage)) { -enum fullness_group fullness; -unsigned int class_idx; - -get_zspage_mapping (zspage, &class_idx, &fullness); -atomic_long_inc (&pool->isolated_pages); -remove_zspage (class, zspage, fullness); - } - +migrate_write_lock (zspage);inc_zspage_isolation (zspage); -spin_unlock (&class->lock); +migrate_write_unlock (zspage);return true; }
@@ -2004,21 +1926,6 @@ static int zs_page_migrate(struct addresdec_zspage_isolation (zspage); -/* -* Page migration is done so let's putback isolated zspage to -* the list if @page is final isolated subpage in the zspage. -*/ -if (!is_zspage_isolated (zspage)) { -/* -* We cannot race with zs_destroy_pool() here because we wait -* for isolation to hit zero before we start destroying. -* Also, we ensure that everyone can see pool->destroying before -* we start waiting. -*/ -putback_zspage_deferred (pool, class, zspage); -zs_pool_dec_isolated (pool); - } -if (page_zone (newpage) !=page_zone (page)) {dec_zone_page_state (page,NR_ZSPAGES );inc_zone_page_state (newpage,NR_ZSPAGES );
@@ -2046,30 +1953,15 @@ unpin_objects:static void zs_page_putback (struct page *page) { -struct zs_pool *pool; -struct size_class *class; -struct address_space *mapping;struct zspage *zspage;VM_BUG_ON_PAGE (!PageMovable (page), page);VM_BUG_ON_PAGE (!PageIsolated (page), page); zspage =get_zspage (page); - mapping =page_mapping (page); - pool = mapping->private_data; - class =zspage_class (pool, zspage); - -spin_lock (&class->lock); +migrate_write_lock (zspage);dec_zspage_isolation (zspage); -if (!is_zspage_isolated (zspage)) { -/* -* Due to page_lock, we cannot free zspage immediately -* so let's defer. -*/ -putback_zspage_deferred (pool, class, zspage); -zs_pool_dec_isolated (pool); - } -spin_unlock (&class->lock); +migrate_write_unlock (zspage); }static const struct address_space_operations zsmalloc_aops = {
@@ -2091,36 +1983,8 @@ static int zs_register_migration(structreturn 0 ; } -static bool pool_isolated_are_drained (struct zs_pool *pool) -{ -return atomic_long_read (&pool->isolated_pages) ==0 ; -} - -/* Function for resolving migration */ -static void wait_for_isolated_drain (struct zs_pool *pool) -{ - -/* -* We're in the process of destroying the pool, so there are no -* active allocations. zs_page_isolate() fails for completely free -* zspages, so we need only wait for the zs_pool's isolated -* count to hit zero. -*/ -wait_event (pool->migration_wait, -pool_isolated_are_drained (pool)); -} -static void zs_unregister_migration (struct zs_pool *pool) { - pool->destroying = true; -/* -* We need a memory barrier here to ensure global visibility of -* pool->destroying. Thus pool->isolated pages will either be 0 in which -* case we don't care, or it will be > 0 and pool->destroying will -* ensure that we wake up once isolation hits 0. -*/ -smp_mb (); -wait_for_isolated_drain (pool);/* This can block */ flush_work (&pool->free_work);iput (pool->inode); }
@@ -2150,7 +2014,6 @@ static void async_free_zspage(struct worspin_unlock (&class->lock); } -list_for_each_entry_safe (zspage, tmp, &free_pages, list) {list_del (&zspage->list);lock_zspage (zspage);
@@ -2363,10 +2226,6 @@ struct zs_pool *zs_create_pool(const chaif (!pool->name) goto err; -#ifdef CONFIG_COMPACTION -init_waitqueue_head (&pool->migration_wait); -#endif -if (create_cache (pool)) goto err;
_
Andrew Morton
maintainerPATCH 50/69 locking/rwlocks: introduce write_lock_nested
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: locking/rwlocks: introduce write_lock_nested
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.
---
include/linux/rwlock.h | 6 ++++++ include/linux/rwlock_api_smp.h | 8 ++++++++ include/linux/rwlock_rt.h | 10 ++++++++++ include/linux/spinlock_api_up.h | 1 + kernel/locking/spinlock.c | 10 ++++++++++ kernel/locking/spinlock_rt.c | 12 ++++++++++++ 6 files changed, 47 insertions(+)
include/linux/rwlock_api_smp.h renamed from include/linux/rwlock_api_smp.h~locking-rwlocks-introduce-write_lock_nested +8 -0
@@ -17,6 +17,7 @@ void __lockfunc _raw_read_lock(rwlock_t *lock) __acquires(lock); void __lockfunc _raw_write_lock(rwlock_t *lock) __acquires(lock); +void __lockfunc _raw_write_lock_nested(rwlock_t *lock, int subclass) __acquires(lock); void __lockfunc _raw_read_lock_bh(rwlock_t *lock) __acquires(lock); void __lockfunc _raw_write_lock_bh(rwlock_t *lock) __acquires(lock); void __lockfunc _raw_read_lock_irq(rwlock_t *lock) __acquires(lock);
@@ -209,6 +210,13 @@ static inline void __raw_write_lock(rwlo LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock); } +static inline void __raw_write_lock_nested (rwlock_t *lock,int subclass) +{ +preempt_disable (); +rwlock_acquire (&lock->dep_map, subclass,0 , _RET_IP_); +LOCK_CONTENDED (lock, do_raw_write_trylock, do_raw_write_lock); +} +#endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_DEBUG_LOCK_ALLOC */ static inline void __raw_write_unlock (rwlock_t *lock)
include/linux/rwlock.h renamed from include/linux/rwlock.h~locking-rwlocks-introduce-write_lock_nested +6 -0
@@ -55,6 +55,12 @@ do { \#define write_lock (lock) _raw_write_lock(lock)#define read_lock (lock) _raw_read_lock(lock) +#ifdef CONFIG_DEBUG_LOCK_ALLOC +#define write_lock_nested (lock, subclass) _raw_write_lock_nested(lock, subclass) +#else +#define write_lock_nested (lock, subclass) _raw_write_lock(lock) +#endif +#if defined(CONFIG_SMP ) || defined(CONFIG_DEBUG_SPINLOCK )#define read_lock_irqsave (lock, flags) \
include/linux/rwlock_rt.h renamed from include/linux/rwlock_rt.h~locking-rwlocks-introduce-write_lock_nested +10 -0
@@ -28,6 +28,7 @@ extern void rt_read_lock(rwlock_t *rwlocextern int rt_read_trylock (rwlock_t *rwlock);extern void rt_read_unlock (rwlock_t *rwlock);extern void rt_write_lock (rwlock_t *rwlock); +extern void rt_write_lock_nested (rwlock_t *rwlock,int subclass);extern int rt_write_trylock (rwlock_t *rwlock);extern void rt_write_unlock (rwlock_t *rwlock);
@@ -83,6 +84,15 @@ static __always_inline void write_lock(rrt_write_lock (rwlock); } +#ifdef CONFIG_DEBUG_LOCK_ALLOC +static __always_inline void write_lock_nested(rwlock_t *rwlock, int subclass) +{ +rt_write_lock_nested (rwlock, subclass); +} +#else +#define write_lock_nested (lock, subclass) rt_write_lock(((void)(subclass), (lock))) +#endif + static __always_inline void write_lock_bh(rwlock_t *rwlock) {local_bh_disable ();
include/linux/spinlock_api_up.h renamed from include/linux/spinlock_api_up.h~locking-rwlocks-introduce-write_lock_nested +1 -0
@@ -59,6 +59,7 @@#define _raw_spin_lock_nested (lock, subclass) __LOCK(lock)#define _raw_read_lock (lock) __LOCK(lock)#define _raw_write_lock (lock) __LOCK(lock) +#define _raw_write_lock_nested (lock, subclass) __LOCK(lock)#define _raw_spin_lock_bh (lock) __LOCK_BH(lock)#define _raw_read_lock_bh (lock) __LOCK_BH(lock)#define _raw_write_lock_bh (lock) __LOCK_BH(lock)
kernel/locking/spinlock.c renamed from kernel/locking/spinlock.c~locking-rwlocks-introduce-write_lock_nested +10 -0
@@ -300,6 +300,16 @@ void __lockfunc _raw_write_lock(rwlock_t__raw_write_lock (lock); }EXPORT_SYMBOL (_raw_write_lock); + +#ifndef CONFIG_DEBUG_LOCK_ALLOC +#define __raw_write_lock_nested (lock, subclass) __raw_write_lock(((void)(subclass), (lock))) +#endif + +void __lockfunc _raw_write_lock_nested(rwlock_t *lock, int subclass) +{ +__raw_write_lock_nested (lock, subclass); +} +EXPORT_SYMBOL (_raw_write_lock_nested);#endif #ifndef CONFIG_INLINE_WRITE_LOCK_IRQSAVE
kernel/locking/spinlock_rt.c renamed from kernel/locking/spinlock_rt.c~locking-rwlocks-introduce-write_lock_nested +12 -0
@@ -239,6 +239,18 @@ void __sched rt_write_lock(rwlock_t *rwl }EXPORT_SYMBOL (rt_write_lock); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass) +{ +rtlock_might_resched (); +rwlock_acquire (&rwlock->dep_map, subclass,0 , _RET_IP_); +rwbase_write_lock (&rwlock->rwbase,TASK_RTLOCK_WAIT ); +rcu_read_lock (); +migrate_disable (); +} +EXPORT_SYMBOL (rt_write_lock_nested); +#endif + void __sched rt_read_unlock(rwlock_t *rwlock) {rwlock_release (&rwlock->dep_map, _RET_IP_);
_
Andrew Morton
maintainerPATCH 51/69 zsmalloc: replace per zpage lock with pool->migrate_lock
In reply to Andrew MortonFrom: Minchan Kim <[email protected]>
Subject: zsmalloc: replace per zpage lock with pool->migrate_lock
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.
---
mm/zsmalloc.c | 205 ++++++++++++++++++++++-------------------------- 1 file changed, 96 insertions(+), 109 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-replace-per-zpage-lock-with-pool-migrate_lock +96 -109
@@ -30,6 +30,14 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +/* +* lock ordering: +* page_lock +* pool->migrate_lock +* class->lock +* zspage->lock +*/ +#include <linux/module.h> #include <linux/kernel.h> #include <linux/sched.h>
@@ -101,15 +109,6 @@#define _PFN_BITS (MAX_POSSIBLE_PHYSMEM_BITS - PAGE_SHIFT)/* -* Memory for allocating for handle keeps object position by -* encoding <page, obj_idx> and the encoded value has a room -* in least bit(ie, look at obj_to_location). -* We use the bit to synchronize between object access by -* user and migration. -*/ -#define HANDLE_PIN_BIT 0 - -/* * Head in allocated object should have OBJ_ALLOCATED_TAG * to identify the object was allocated or not. * It's okay to add the status bit in the least bit because
@@ -255,6 +254,8 @@ struct zs_pool {struct inode *inode;struct work_struct free_work;#endif +/* protect page/zspage migration */ +rwlock_t migrate_lock; };struct zspage {
@@ -297,6 +298,9 @@ static void zs_unregister_migration(strustatic void migrate_lock_init (struct zspage *zspage);static void migrate_read_lock (struct zspage *zspage);static void migrate_read_unlock (struct zspage *zspage); +static void migrate_write_lock (struct zspage *zspage); +static void migrate_write_lock_nested (struct zspage *zspage); +static void migrate_write_unlock (struct zspage *zspage);static void kick_deferred_free (struct zs_pool *pool);static void init_deferred_free (struct zs_pool *pool);static void SetZsPageMovable (struct zs_pool *pool,struct zspage *zspage);
@@ -308,6 +312,9 @@ static void zs_unregister_migration(strustatic void migrate_lock_init (struct zspage *zspage) {}static void migrate_read_lock (struct zspage *zspage) {}static void migrate_read_unlock (struct zspage *zspage) {} +static void migrate_write_lock (struct zspage *zspage) {} +static void migrate_write_lock_nested (struct zspage *zspage) {} +static void migrate_write_unlock (struct zspage *zspage) {}static void kick_deferred_free (struct zs_pool *pool) {}static void init_deferred_free (struct zs_pool *pool) {}static void SetZsPageMovable (struct zs_pool *pool,struct zspage *zspage) {}
@@ -359,14 +366,10 @@ static void cache_free_zspage(struct zs_kmem_cache_free (pool->zspage_cachep, zspage); } +/* class->lock(which owns the handle) synchronizes races */ static void record_obj (unsigned long handle,unsigned long obj) { -/* -* lsb of @obj represents handle lock while other bits -* represent object value the handle is pointing so -* updating shouldn't do store tearing. -*/ -WRITE_ONCE (*(unsigned long *)handle, obj); + *(unsigned long *)handle = obj; }/* zpool driver */
@@ -880,26 +883,6 @@ static bool obj_allocated(struct page *preturn true; } -static inline int testpin_tag (unsigned long handle) -{ -return bit_spin_is_locked (HANDLE_PIN_BIT , (unsigned long *)handle); -} - -static inline int trypin_tag (unsigned long handle) -{ -return bit_spin_trylock (HANDLE_PIN_BIT , (unsigned long *)handle); -} - -static void pin_tag (unsigned long handle)__acquires (bitlock) -{ -bit_spin_lock (HANDLE_PIN_BIT , (unsigned long *)handle); -} - -static void unpin_tag (unsigned long handle)__releases (bitlock) -{ -bit_spin_unlock (HANDLE_PIN_BIT , (unsigned long *)handle); -} -static void reset_page (struct page *page) {__ClearPageMovable (page);
@@ -968,6 +951,11 @@ static void free_zspage(struct zs_pool *VM_BUG_ON (get_zspage_inuse (zspage));VM_BUG_ON (list_empty (&zspage->list)); +/* +* Since zs_free couldn't be sleepable, this function cannot call +* lock_page. The page locks trylock_zspage got will be released +* by __free_zspage. +*/ if (!trylock_zspage (zspage)) {kick_deferred_free (pool);return ;
@@ -1263,15 +1251,20 @@ void *zs_map_object(struct zs_pool *pool*/ BUG_ON (in_interrupt ()); -/* From now on, migration cannot move the object */ -pin_tag (handle); - +/* It guarantees it can get zspage from handle safely */ +read_lock (&pool->migrate_lock); obj =handle_to_obj (handle);obj_to_location (obj, &page, &obj_idx); zspage =get_zspage (page); -/* migration cannot move any subpage in this zspage */ +/* +* migration cannot move any zpages in this zspage. Here, class->lock +* is too heavy since callers would take some time until they calls +* zs_unmap_object API so delegate the locking from class to zspage +* which is smaller granularity. +*/ migrate_read_lock (zspage); +read_unlock (&pool->migrate_lock); class =zspage_class (pool, zspage); off = (class->size * obj_idx) & ~PAGE_MASK ;
@@ -1330,7 +1323,6 @@ void zs_unmap_object(struct zs_pool *pooput_cpu_var (zs_map_area);migrate_read_unlock (zspage); -unpin_tag (handle); }EXPORT_SYMBOL_GPL (zs_unmap_object);
@@ -1424,6 +1416,7 @@ unsigned long zs_malloc(struct zs_pool * size +=ZS_HANDLE_SIZE ; class = pool->size_class[get_size_class_index (size)]; +/* class->lock effectively protects the zpage migration */ spin_lock (&class->lock); zspage =find_get_zspage (class);if (likely (zspage)) {
@@ -1501,30 +1494,27 @@ void zs_free(struct zs_pool *pool, unsigif (unlikely (!handle))return ; -pin_tag (handle); +/* +* The pool->migrate_lock protects the race with zpage's migration +* so it's safe to get the page from handle. +*/ +read_lock (&pool->migrate_lock); obj =handle_to_obj (handle);obj_to_page (obj, &f_page); zspage =get_zspage (f_page); - -migrate_read_lock (zspage); class =zspage_class (pool, zspage); -spin_lock (&class->lock); +read_unlock (&pool->migrate_lock); +obj_free (class->size, obj);class_stat_dec (class,OBJ_USED ,1 ); fullness =fix_fullness_group (class, zspage); -if (fullness !=ZS_EMPTY ) { -migrate_read_unlock (zspage); +if (fullness !=ZS_EMPTY ) goto out; - } -migrate_read_unlock (zspage); -/* If zspage is isolated, zs_page_putback will free the zspage */ free_zspage (pool, class, zspage); out: -spin_unlock (&class->lock); -unpin_tag (handle);cache_free_handle (pool, handle); }EXPORT_SYMBOL_GPL (zs_free);
@@ -1608,11 +1598,8 @@ static unsigned long find_alloced_obj(st offset += class->size * index;while (offset <PAGE_SIZE ) { -if (obj_allocated (page, addr + offset, &handle)) { -if (trypin_tag (handle)) -break ; - handle =0 ; - } +if (obj_allocated (page, addr + offset, &handle)) +break ; offset += class->size; index++;
@@ -1658,7 +1645,6 @@ static int migrate_zspage(struct zs_pool/* Stop if there is no more space */ if (zspage_full (class,get_zspage (d_page))) { -unpin_tag (handle); ret = -ENOMEM ;break ; }
@@ -1667,15 +1653,7 @@ static int migrate_zspage(struct zs_pool free_obj =obj_malloc (pool,get_zspage (d_page), handle);zs_object_copy (class, free_obj, used_obj); obj_idx++; -/* -* record_obj updates handle's value to free_obj and it will -* invalidate lock bit(ie, HANDLE_PIN_BIT) of handle, which -* breaks synchronization using pin_tag(e,g, zs_free) so -* let's keep the lock bit. -*/ - free_obj |=BIT (HANDLE_PIN_BIT );record_obj (handle, free_obj); -unpin_tag (handle);obj_free (class->size, used_obj); }
@@ -1789,6 +1767,11 @@ static void migrate_write_lock(struct zswrite_lock (&zspage->lock); } +static void migrate_write_lock_nested (struct zspage *zspage) +{ +write_lock_nested (&zspage->lock,SINGLE_DEPTH_NESTING ); +} +static void migrate_write_unlock (struct zspage *zspage) {write_unlock (&zspage->lock);
@@ -1856,11 +1839,10 @@ static int zs_page_migrate(struct addresstruct zspage *zspage;struct page *dummy;void *s_addr, *d_addr, *addr; -int offset, pos; +int offset;unsigned long handle;unsigned long old_obj, new_obj;unsigned int obj_idx; -int ret = -EAGAIN ;/* * We cannot support the _NO_COPY case here, because copy needs to
@@ -1873,32 +1855,25 @@ static int zs_page_migrate(struct addresVM_BUG_ON_PAGE (!PageMovable (page), page);VM_BUG_ON_PAGE (!PageIsolated (page), page); - zspage =get_zspage (page); - -/* Concurrent compactor cannot migrate any subpage in zspage */ -migrate_write_lock (zspage); pool = mapping->private_data; + +/* +* The pool migrate_lock protects the race between zpage migration +* and zs_free. +*/ +write_lock (&pool->migrate_lock); + zspage =get_zspage (page); class =zspage_class (pool, zspage); - offset =get_first_obj_offset (page); +/* +* the class lock protects zpage alloc/free in the zspage. +*/ spin_lock (&class->lock); -if (!get_zspage_inuse (zspage)) { -/* -* Set "offset" to end of the page so that every loops -* skips unnecessary object scanning. -*/ - offset =PAGE_SIZE ; - } +/* the migrate_write_lock protects zpage access via zs_map_object */ +migrate_write_lock (zspage); - pos = offset; + offset =get_first_obj_offset (page); s_addr =kmap_atomic (page); -while (pos <PAGE_SIZE ) { -if (obj_allocated (page, s_addr + pos, &handle)) { -if (!trypin_tag (handle)) - goto unpin_objects; - } - pos += class->size; - }/* * Here, any user cannot access all objects in the zspage so let's move.
@@ -1907,25 +1882,30 @@ static int zs_page_migrate(struct addresmemcpy (d_addr, s_addr,PAGE_SIZE );kunmap_atomic (d_addr); -for (addr = s_addr + offset; addr < s_addr + pos; +for (addr = s_addr + offset; addr < s_addr +PAGE_SIZE ; addr += class->size) {if (obj_allocated (page, addr, &handle)) { -BUG_ON (!testpin_tag (handle)); old_obj =handle_to_obj (handle);obj_to_location (old_obj, &dummy, &obj_idx); new_obj = (unsigned long )location_to_obj (newpage, obj_idx); - new_obj |=BIT (HANDLE_PIN_BIT );record_obj (handle, new_obj); } } +kunmap_atomic (s_addr);replace_sub_page (class, zspage, newpage, page); -get_page (newpage); - +/* +* Since we complete the data copy and set up new zspage structure, +* it's okay to release migration_lock. +*/ +write_unlock (&pool->migrate_lock); +spin_unlock (&class->lock);dec_zspage_isolation (zspage); +migrate_write_unlock (zspage); +get_page (newpage);if (page_zone (newpage) !=page_zone (page)) {dec_zone_page_state (page,NR_ZSPAGES );inc_zone_page_state (newpage,NR_ZSPAGES );
@@ -1933,22 +1913,8 @@ static int zs_page_migrate(struct addresreset_page (page);put_page (page); - page = newpage; - - ret =MIGRATEPAGE_SUCCESS ; -unpin_objects: -for (addr = s_addr + offset; addr < s_addr + pos; - addr += class->size) { -if (obj_allocated (page, addr, &handle)) { -BUG_ON (!testpin_tag (handle)); -unpin_tag (handle); - } - } -kunmap_atomic (s_addr); -spin_unlock (&class->lock); -migrate_write_unlock (zspage); -return ret; +return MIGRATEPAGE_SUCCESS ; }static void zs_page_putback (struct page *page)
@@ -2077,8 +2043,13 @@ static unsigned long __zs_compact(structstruct zspage *dst_zspage =NULL ;unsigned long pages_freed =0 ; +/* protect the race between zpage migration and zs_free */ +write_lock (&pool->migrate_lock); +/* protect zpage allocation/free */ spin_lock (&class->lock);while ((src_zspage =isolate_zspage (class, true))) { +/* protect someone accessing the zspage(i.e., zs_map_object) */ +migrate_write_lock (src_zspage);if (!zs_can_compact (class))break ;
@@ -2087,6 +2058,8 @@ static unsigned long __zs_compact(struct cc.s_page =get_first_page (src_zspage);while ((dst_zspage =isolate_zspage (class, false))) { +migrate_write_lock_nested (dst_zspage); + cc.d_page =get_first_page (dst_zspage);/* * If there is no more space in dst_page, resched
@@ -2096,6 +2069,10 @@ static unsigned long __zs_compact(structbreak ;putback_zspage (class, dst_zspage); +migrate_write_unlock (dst_zspage); + dst_zspage =NULL ; +if (rwlock_is_contended (&pool->migrate_lock)) +break ; }/* Stop if we couldn't find slot */
@@ -2103,19 +2080,28 @@ static unsigned long __zs_compact(structbreak ;putback_zspage (class, dst_zspage); +migrate_write_unlock (dst_zspage); +if (putback_zspage (class, src_zspage) ==ZS_EMPTY ) { +migrate_write_unlock (src_zspage);free_zspage (pool, class, src_zspage); pages_freed += class->pages_per_zspage; - } + }else +migrate_write_unlock (src_zspage);spin_unlock (&class->lock); +write_unlock (&pool->migrate_lock);cond_resched (); +write_lock (&pool->migrate_lock);spin_lock (&class->lock); } -if (src_zspage) +if (src_zspage) {putback_zspage (class, src_zspage); +migrate_write_unlock (src_zspage); + }spin_unlock (&class->lock); +write_unlock (&pool->migrate_lock);return pages_freed; }
@@ -2221,6 +2207,7 @@ struct zs_pool *zs_create_pool(const chareturn NULL ;init_deferred_free (pool); +rwlock_init (&pool->migrate_lock); pool->name =kstrdup (name,GFP_KERNEL );if (!pool->name)
_
Andrew Morton
maintainerPATCH 52/69 zsmalloc: replace get_cpu_var with local_lock
In reply to Andrew MortonFrom: Mike Galbraith <[email protected]>
Subject: zsmalloc: replace get_cpu_var with local_lock
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.
---
mm/zsmalloc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-replace-get_cpu_var-with-local_lock +8 -3
@@ -65,6 +65,7 @@#include <linux/wait.h> #include <linux/pagemap.h> #include <linux/fs.h> +#include <linux/local_lock.h> #define ZSPAGE_MAGIC 0x58
@@ -276,6 +277,7 @@ struct zspage { };struct mapping_area { +local_lock_t lock;char *vm_buf;/* copy buffer for objects that span pages */ char *vm_addr;/* address of kmap_atomic()'ed pages */ enum zs_mapmode vm_mm;/* mapping mode */
@@ -451,7 +453,9 @@ MODULE_ALIAS("zpool-zsmalloc");#endif /* CONFIG_ZPOOL */ /* per-cpu VM mapping areas for zspage accesses that cross page boundaries */ -static DEFINE_PER_CPU(struct mapping_area, zs_map_area); +static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { + .lock =INIT_LOCAL_LOCK (lock), +};static __maybe_unused int is_first_page (struct page *page) {
@@ -1269,7 +1273,8 @@ void *zs_map_object(struct zs_pool *pool class =zspage_class (pool, zspage); off = (class->size * obj_idx) & ~PAGE_MASK ; - area = &get_cpu_var (zs_map_area); +local_lock (&zs_map_area.lock); + area =this_cpu_ptr (&zs_map_area); area->vm_mm = mm;if (off + class->size <=PAGE_SIZE ) {/* this object is contained entirely within a page */
@@ -1320,7 +1325,7 @@ void zs_unmap_object(struct zs_pool *poo__zs_unmap_object (area, pages, off, class->size); } -put_cpu_var (zs_map_area); +local_unlock (&zs_map_area.lock);migrate_read_unlock (zspage); }
_
Andrew Morton
maintainerPATCH 53/69 fs: proc: store PDE()->data into inode->i_private
In reply to Andrew MortonFrom: Muchun Song <[email protected]>
Subject: fs: proc: store PDE()->data into inode->i_private
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.
---
fs/proc/generic.c | 6 ------ fs/proc/inode.c | 1 + fs/proc/internal.h | 5 ----- include/linux/proc_fs.h | 13 ++++++++++++- 4 files changed, 13 insertions(+), 12 deletions(-)
fs/proc/generic.c renamed from fs/proc/generic.c~fs-proc-store-pde-data-into-inode-i_private +0 -6
@@ -791,12 +791,6 @@ void proc_remove(struct proc_dir_entry * }EXPORT_SYMBOL (proc_remove); -void *PDE_DATA (const struct inode *inode) -{ -return __PDE_DATA (inode); -} -EXPORT_SYMBOL (PDE_DATA ); -/* * Pull a user buffer into memory and pass it to the file's write handler if * one is supplied. The ->write() method is permitted to modify the
fs/proc/inode.c renamed from fs/proc/inode.c~fs-proc-store-pde-data-into-inode-i_private +1 -0
@@ -650,6 +650,7 @@ struct inode *proc_get_inode(struct supereturn NULL ; } + inode->i_private = de->data; inode->i_ino = de->low_ino; inode->i_mtime = inode->i_atime = inode->i_ctime =current_time (inode);PROC_I (inode)->pde = de;
fs/proc/internal.h renamed from fs/proc/internal.h~fs-proc-store-pde-data-into-inode-i_private +0 -5
@@ -115,11 +115,6 @@ static inline struct proc_dir_entry *PDEreturn PROC_I (inode)->pde; } -static inline void *__PDE_DATA (const struct inode *inode) -{ -return PDE (inode)->data; -} -static inline struct pid *proc_pid (const struct inode *inode) {return PROC_I (inode)->pid;
include/linux/proc_fs.h renamed from include/linux/proc_fs.h~fs-proc-store-pde-data-into-inode-i_private +12 -1
@@ -110,7 +110,18 @@ extern struct proc_dir_entry *proc_creatstruct proc_dir_entry *proc_create (const char *name,umode_t mode,struct proc_dir_entry *parent,const struct proc_ops *proc_ops);extern void proc_set_size (struct proc_dir_entry *,loff_t );extern void proc_set_user (struct proc_dir_entry *,kuid_t ,kgid_t ); -extern void *PDE_DATA (const struct inode *); + +/* +* Obtain the private data passed by user through proc_create_data() or +* related. +*/ +static inline void *pde_data (const struct inode *inode) +{ +return inode->i_private; +} + +#define PDE_DATA (i) pde_data(i) +extern void *proc_get_parent_data (const struct inode *);extern void proc_remove (struct proc_dir_entry *);extern void remove_proc_entry (const char *,struct proc_dir_entry *);
_
Andrew Morton
maintainerPATCH 54/69 proc: remove PDE_DATA() completely
In reply to Andrew MortonFrom: Muchun Song <[email protected]>
Subject: proc: remove PDE_DATA() completely
Remove PDE_DATA() completely and replace it with pde_data().
---
arch/alpha/kernel/srm_env.c | 4 - arch/arm/kernel/atags_proc.c | 2 arch/ia64/kernel/salinfo.c | 10 +- arch/powerpc/kernel/proc_powerpc.c | 4 - arch/sh/mm/alignment.c | 2 arch/xtensa/platforms/iss/simdisk.c | 4 - drivers/acpi/proc.c | 2 drivers/hwmon/dell-smm-hwmon.c | 4 - drivers/net/bonding/bond_procfs.c | 8 +- drivers/net/wireless/cisco/airo.c | 22 +++--- drivers/net/wireless/intersil/hostap/hostap_ap.c | 16 ++-- drivers/net/wireless/intersil/hostap/hostap_download.c | 2 drivers/net/wireless/intersil/hostap/hostap_proc.c | 24 +++--- drivers/net/wireless/ray_cs.c | 2 drivers/nubus/proc.c | 36 +++++----- drivers/parisc/led.c | 4 - drivers/pci/proc.c | 10 +- drivers/platform/x86/thinkpad_acpi.c | 4 - drivers/platform/x86/toshiba_acpi.c | 16 ++-- drivers/pnp/isapnp/proc.c | 2 drivers/pnp/pnpbios/proc.c | 4 - drivers/scsi/scsi_proc.c | 4 - drivers/usb/gadget/function/rndis.c | 4 - drivers/zorro/proc.c | 2 fs/afs/proc.c | 6 - fs/ext4/mballoc.c | 14 +-- fs/jbd2/journal.c | 2 fs/proc/proc_net.c | 8 +- include/linux/proc_fs.h | 4 - include/linux/seq_file.h | 2 ipc/util.c | 2 kernel/irq/proc.c | 8 +- kernel/resource.c | 4 - net/atm/proc.c | 4 - net/bluetooth/af_bluetooth.c | 8 +- net/can/bcm.c | 2 net/can/proc.c | 2 net/core/neighbour.c | 6 - net/core/pktgen.c | 6 - net/ipv4/netfilter/ipt_CLUSTERIP.c | 6 - net/ipv4/raw.c | 8 +- net/ipv4/tcp_ipv4.c | 2 net/ipv4/udp.c | 6 - net/netfilter/x_tables.c | 10 +- net/netfilter/xt_hashlimit.c | 18 ++--- net/netfilter/xt_recent.c | 4 - net/sunrpc/auth_gss/svcauth_gss.c | 4 - net/sunrpc/cache.c | 24 +++--- net/sunrpc/stats.c | 2 sound/core/info.c | 4 - 50 files changed, 178 insertions(+), 180 deletions(-)
arch/alpha/kernel/srm_env.c renamed from arch/alpha/kernel/srm_env.c~proc-remove-pde_data-completely +2 -2
@@ -83,14 +83,14 @@ static int srm_env_proc_show(struct seq_static int srm_env_proc_open (struct inode *inode,struct file *file) { -return single_open (file, srm_env_proc_show,PDE_DATA (inode)); +return single_open (file, srm_env_proc_show,pde_data (inode)); }static ssize_t srm_env_proc_write (struct file *file,const char __user *buffer,size_t count,loff_t *pos) {int res; -unsigned long id = (unsigned long )PDE_DATA (file_inode (file)); +unsigned long id = (unsigned long )pde_data (file_inode (file));char *buf = (char *)__get_free_page (GFP_USER );unsigned long ret1, ret2;
arch/arm/kernel/atags_proc.c renamed from arch/arm/kernel/atags_proc.c~proc-remove-pde_data-completely +1 -1
@@ -13,7 +13,7 @@ struct buffer {static ssize_t atags_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -struct buffer *b =PDE_DATA (file_inode (file)); +struct buffer *b =pde_data (file_inode (file));return simple_read_from_buffer (buf, count, ppos, b->data, b->size); }
arch/ia64/kernel/salinfo.c renamed from arch/ia64/kernel/salinfo.c~proc-remove-pde_data-completely +5 -5
@@ -282,7 +282,7 @@ salinfo_event_open(struct inode *inode,static ssize_t salinfo_event_read (struct file *file,char __user *buffer,size_t count,loff_t *ppos) { -struct salinfo_data *data =PDE_DATA (file_inode (file)); +struct salinfo_data *data =pde_data (file_inode (file));char cmd[32 ];size_t size;int i, n, cpu =-1 ;
@@ -340,7 +340,7 @@ static const struct proc_ops salinfo_evestatic int salinfo_log_open (struct inode *inode,struct file *file) { -struct salinfo_data *data =PDE_DATA (inode); +struct salinfo_data *data =pde_data (inode);if (!capable (CAP_SYS_ADMIN ))return -EPERM ;
@@ -365,7 +365,7 @@ salinfo_log_open(struct inode *inode, ststatic int salinfo_log_release (struct inode *inode,struct file *file) { -struct salinfo_data *data =PDE_DATA (inode); +struct salinfo_data *data =pde_data (inode);if (data->state ==STATE_NO_DATA ) {vfree (data->log_buffer);
@@ -433,7 +433,7 @@ retry:static ssize_t salinfo_log_read (struct file *file,char __user *buffer,size_t count,loff_t *ppos) { -struct salinfo_data *data =PDE_DATA (file_inode (file)); +struct salinfo_data *data =pde_data (file_inode (file));u8 *buf;u64 bufsize;
@@ -494,7 +494,7 @@ salinfo_log_clear(struct salinfo_data *dstatic ssize_t salinfo_log_write (struct file *file,const char __user *buffer,size_t count,loff_t *ppos) { -struct salinfo_data *data =PDE_DATA (file_inode (file)); +struct salinfo_data *data =pde_data (file_inode (file));char cmd[32 ];size_t size;u32 offset;
arch/powerpc/kernel/proc_powerpc.c renamed from arch/powerpc/kernel/proc_powerpc.c~proc-remove-pde_data-completely +2 -2
@@ -25,7 +25,7 @@ static ssize_t page_map_read( struct fil loff_t *ppos) {return simple_read_from_buffer (buf, nbytes, ppos, -PDE_DATA (file_inode (file)),PAGE_SIZE ); +pde_data (file_inode (file)),PAGE_SIZE ); }static int page_map_mmap (struct file *file,struct vm_area_struct *vma )
@@ -34,7 +34,7 @@ static int page_map_mmap( struct file *freturn -EINVAL ;remap_pfn_range (vma, vma->vm_start, -__pa (PDE_DATA (file_inode (file))) >>PAGE_SHIFT , +__pa (pde_data (file_inode (file))) >>PAGE_SHIFT ,PAGE_SIZE , vma->vm_page_prot);return 0 ; }
arch/sh/mm/alignment.c renamed from arch/sh/mm/alignment.c~proc-remove-pde_data-completely +1 -1
@@ -140,7 +140,7 @@ static int alignment_proc_open(struct instatic ssize_t alignment_proc_write (struct file *file,const char __user *buffer,size_t count,loff_t *pos) { -int *data =PDE_DATA (file_inode (file)); +int *data =pde_data (file_inode (file));char mode;if (count >0 ) {
arch/xtensa/platforms/iss/simdisk.c renamed from arch/xtensa/platforms/iss/simdisk.c~proc-remove-pde_data-completely +2 -2
@@ -208,7 +208,7 @@ static int simdisk_detach(struct simdiskstatic ssize_t proc_read_simdisk (struct file *file,char __user *buf,size_t size,loff_t *ppos) { -struct simdisk *dev =PDE_DATA (file_inode (file)); +struct simdisk *dev =pde_data (file_inode (file));const char *s = dev->filename;if (s) { ssize_t n = simple_read_from_buffer(buf, size, ppos,
@@ -225,7 +225,7 @@ static ssize_t proc_write_simdisk(struct size_t count, loff_t *ppos) { char *tmp = memdup_user_nul(buf, count); -struct simdisk *dev =PDE_DATA (file_inode (file)); +struct simdisk *dev =pde_data (file_inode (file));int err;if (IS_ERR (tmp))
drivers/acpi/proc.c renamed from drivers/acpi/proc.c~proc-remove-pde_data-completely +1 -1
@@ -127,7 +127,7 @@ static int acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) { return single_open(file, acpi_system_wakeup_device_seq_show, - PDE_DATA(inode )); + pde_data(inode )); } static const struct proc_ops acpi_system_wakeup_device_proc_ops = {
drivers/hwmon/dell-smm-hwmon.c renamed from drivers/hwmon/dell-smm-hwmon.c~proc-remove-pde_data-completely +2 -2
@@ -451,7 +451,7 @@ static int i8k_get_power_status(void)static long i8k_ioctl (struct file *fp,unsigned int cmd,unsigned long arg) { -struct dell_smm_data *data =PDE_DATA (file_inode (fp)); +struct dell_smm_data *data =pde_data (file_inode (fp));int __user *argp = (int __user *)arg;int speed, err;int val =0 ;
@@ -585,7 +585,7 @@ static int i8k_proc_show(struct seq_filestatic int i8k_open_fs (struct inode *inode,struct file *file) { -return single_open (file, i8k_proc_show,PDE_DATA (inode)); +return single_open (file, i8k_proc_show,pde_data (inode)); }static const struct proc_ops i8k_proc_ops = {
drivers/net/bonding/bond_procfs.c renamed from drivers/net/bonding/bond_procfs.c~proc-remove-pde_data-completely +4 -4
@@ -11,7 +11,7 @@static void *bond_info_seq_start (struct seq_file *seq,loff_t *pos)__acquires (RCU ) { -struct bonding *bond =PDE_DATA (file_inode (seq->file)); +struct bonding *bond =pde_data (file_inode (seq->file));struct list_head *iter;struct slave *slave;loff_t off =0 ;
@@ -30,7 +30,7 @@ static void *bond_info_seq_start(structstatic void *bond_info_seq_next (struct seq_file *seq,void *v,loff_t *pos) { -struct bonding *bond =PDE_DATA (file_inode (seq->file)); +struct bonding *bond =pde_data (file_inode (seq->file));struct list_head *iter;struct slave *slave;bool found = false;
@@ -57,7 +57,7 @@ static void bond_info_seq_stop(struct sestatic void bond_info_show_master (struct seq_file *seq) { -struct bonding *bond =PDE_DATA (file_inode (seq->file)); +struct bonding *bond =pde_data (file_inode (seq->file));const struct bond_opt_value *optval;struct slave *curr, *primary;int i;
@@ -175,7 +175,7 @@ static void bond_info_show_master(structstatic void bond_info_show_slave (struct seq_file *seq,const struct slave *slave) { -struct bonding *bond =PDE_DATA (file_inode (seq->file)); +struct bonding *bond =pde_data (file_inode (seq->file));seq_printf (seq,"\nSlave Interface: %s\n" , slave->dev->name);seq_printf (seq,"MII Status: %s\n" ,bond_slave_link_status (slave->link));
drivers/net/wireless/cisco/airo.c renamed from drivers/net/wireless/cisco/airo.c~proc-remove-pde_data-completely +11 -11
@@ -4672,7 +4672,7 @@ static ssize_t proc_write(struct file *fstatic int proc_status_open (struct inode *inode,struct file *file) {struct proc_data *data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *apriv = dev->ml_priv;CapabilityRid cap_rid;StatusRid status_rid;
@@ -4756,7 +4756,7 @@ static int proc_stats_rid_open(struct in u16 rid) {struct proc_data *data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *apriv = dev->ml_priv;StatsRid stats;int i, j;
@@ -4819,7 +4819,7 @@ static inline int sniffing_mode(struct astatic void proc_config_on_close (struct inode *inode,struct file *file) {struct proc_data *data = file->private_data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;char *line;
@@ -5030,7 +5030,7 @@ static const char *get_rmode(__le16 modestatic int proc_config_open (struct inode *inode,struct file *file) {struct proc_data *data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;int i;__le16 mode;
@@ -5120,7 +5120,7 @@ static int proc_config_open(struct inodestatic void proc_SSID_on_close (struct inode *inode,struct file *file) {struct proc_data *data = file->private_data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;SsidRid SSID_rid;int i;
@@ -5156,7 +5156,7 @@ static void proc_SSID_on_close(struct instatic void proc_APList_on_close (struct inode *inode,struct file *file) {struct proc_data *data = file->private_data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;APListRid *APList_rid = &ai->APList;int i;
@@ -5280,7 +5280,7 @@ static int set_wep_tx_idx(struct airo_instatic void proc_wepkey_on_close (struct inode *inode,struct file *file) {struct proc_data *data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;int i, rc;char key[16 ];
@@ -5331,7 +5331,7 @@ static void proc_wepkey_on_close(structstatic int proc_wepkey_open (struct inode *inode,struct file *file) {struct proc_data *data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;char *ptr;WepKeyRid wkr;
@@ -5379,7 +5379,7 @@ static int proc_wepkey_open(struct inodestatic int proc_SSID_open (struct inode *inode,struct file *file) {struct proc_data *data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;int i;char *ptr;
@@ -5423,7 +5423,7 @@ static int proc_SSID_open(struct inode *static int proc_APList_open (struct inode *inode,struct file *file) {struct proc_data *data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;int i;char *ptr;
@@ -5462,7 +5462,7 @@ static int proc_APList_open(struct inodestatic int proc_BSSList_open (struct inode *inode,struct file *file) {struct proc_data *data; -struct net_device *dev =PDE_DATA (inode); +struct net_device *dev =pde_data (inode);struct airo_info *ai = dev->ml_priv;char *ptr;BSSListRid BSSList_rid;
drivers/net/wireless/intersil/hostap/hostap_ap.c renamed from drivers/net/wireless/intersil/hostap/hostap_ap.c~proc-remove-pde_data-completely +8 -8
@@ -69,7 +69,7 @@ static void prism2_send_mgmt(struct net_#if !defined(PRISM2_NO_PROCFS_DEBUG ) && defined(CONFIG_PROC_FS )static int ap_debug_proc_show (struct seq_file *m,void *v) { -struct ap_data *ap =PDE_DATA (file_inode (m->file)); +struct ap_data *ap =pde_data (file_inode (m->file));seq_printf (m,"BridgedUnicastFrames=%u\n" , ap->bridged_unicast);seq_printf (m,"BridgedMulticastFrames=%u\n" , ap->bridged_multicast);
@@ -320,7 +320,7 @@ void hostap_deauth_all_stas(struct net_dstatic int ap_control_proc_show (struct seq_file *m,void *v) { -struct ap_data *ap =PDE_DATA (file_inode (m->file)); +struct ap_data *ap =pde_data (file_inode (m->file));char *policy_txt;struct mac_entry *entry;
@@ -352,20 +352,20 @@ static int ap_control_proc_show(struct sstatic void *ap_control_proc_start (struct seq_file *m,loff_t *_pos) { -struct ap_data *ap =PDE_DATA (file_inode (m->file)); +struct ap_data *ap =pde_data (file_inode (m->file));spin_lock_bh (&ap->mac_restrictions.lock);return seq_list_start_head (&ap->mac_restrictions.mac_list, *_pos); }static void *ap_control_proc_next (struct seq_file *m,void *v,loff_t *_pos) { -struct ap_data *ap =PDE_DATA (file_inode (m->file)); +struct ap_data *ap =pde_data (file_inode (m->file));return seq_list_next (v, &ap->mac_restrictions.mac_list, _pos); }static void ap_control_proc_stop (struct seq_file *m,void *v) { -struct ap_data *ap =PDE_DATA (file_inode (m->file)); +struct ap_data *ap =pde_data (file_inode (m->file));spin_unlock_bh (&ap->mac_restrictions.lock); }
@@ -554,20 +554,20 @@ static int prism2_ap_proc_show(struct sestatic void *prism2_ap_proc_start (struct seq_file *m,loff_t *_pos) { -struct ap_data *ap =PDE_DATA (file_inode (m->file)); +struct ap_data *ap =pde_data (file_inode (m->file));spin_lock_bh (&ap->sta_table_lock);return seq_list_start_head (&ap->sta_list, *_pos); }static void *prism2_ap_proc_next (struct seq_file *m,void *v,loff_t *_pos) { -struct ap_data *ap =PDE_DATA (file_inode (m->file)); +struct ap_data *ap =pde_data (file_inode (m->file));return seq_list_next (v, &ap->sta_list, _pos); }static void prism2_ap_proc_stop (struct seq_file *m,void *v) { -struct ap_data *ap =PDE_DATA (file_inode (m->file)); +struct ap_data *ap =pde_data (file_inode (m->file));spin_unlock_bh (&ap->sta_table_lock); }
drivers/net/wireless/intersil/hostap/hostap_download.c renamed from drivers/net/wireless/intersil/hostap/hostap_download.c~proc-remove-pde_data-completely +1 -1
@@ -227,7 +227,7 @@ static int prism2_download_aux_dump_proc sizeof(struct prism2_download_aux_dump));if (ret ==0 ) {struct seq_file *m = file->private_data; - m->private =PDE_DATA (inode); + m->private =pde_data (inode); }return ret; }
drivers/net/wireless/intersil/hostap/hostap_proc.c renamed from drivers/net/wireless/intersil/hostap/hostap_proc.c~proc-remove-pde_data-completely +12 -12
@@ -97,20 +97,20 @@ static int prism2_wds_proc_show(struct sstatic void *prism2_wds_proc_start (struct seq_file *m,loff_t *_pos) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));read_lock_bh (&local->iface_lock);return seq_list_start (&local->hostap_interfaces, *_pos); }static void *prism2_wds_proc_next (struct seq_file *m,void *v,loff_t *_pos) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));return seq_list_next (v, &local->hostap_interfaces, _pos); }static void prism2_wds_proc_stop (struct seq_file *m,void *v) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));read_unlock_bh (&local->iface_lock); }
@@ -123,7 +123,7 @@ static const struct seq_operations prismstatic int prism2_bss_list_proc_show (struct seq_file *m,void *v) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));struct list_head *ptr = v;struct hostap_bss_info *bss;
@@ -151,21 +151,21 @@ static int prism2_bss_list_proc_show(strstatic void *prism2_bss_list_proc_start (struct seq_file *m,loff_t *_pos) __acquires(&local->lock) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));spin_lock_bh (&local->lock);return seq_list_start_head (&local->bss_list, *_pos); }static void *prism2_bss_list_proc_next (struct seq_file *m,void *v,loff_t *_pos) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));return seq_list_next (v, &local->bss_list, _pos); }static void prism2_bss_list_proc_stop (struct seq_file *m,void *v) __releases(&local->lock) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));spin_unlock_bh (&local->lock); }
@@ -198,7 +198,7 @@ static int prism2_crypt_proc_show(structstatic ssize_t prism2_pda_proc_read (struct file *file,char __user *buf,size_t count,loff_t *_pos) { -local_info_t *local =PDE_DATA (file_inode (file)); +local_info_t *local =pde_data (file_inode (file));size_t off;if (local->pda ==NULL || *_pos >=PRISM2_PDA_SIZE )
@@ -272,7 +272,7 @@ static int prism2_io_debug_proc_read(cha#ifndef PRISM2_NO_STATION_MODES static int prism2_scan_results_proc_show (struct seq_file *m,void *v) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));unsigned long entry;int i, len;struct hfa384x_hostscan_result *scanres;
@@ -322,7 +322,7 @@ static int prism2_scan_results_proc_showstatic void *prism2_scan_results_proc_start (struct seq_file *m,loff_t *_pos) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));spin_lock_bh (&local->lock);/* We have a header (pos 0) + N results to show (pos 1...N) */
@@ -333,7 +333,7 @@ static void *prism2_scan_results_proc_ststatic void *prism2_scan_results_proc_next (struct seq_file *m,void *v,loff_t *_pos) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file)); ++*_pos;if (*_pos > local->last_scan_results_count)
@@ -343,7 +343,7 @@ static void *prism2_scan_results_proc_nestatic void prism2_scan_results_proc_stop (struct seq_file *m,void *v) { -local_info_t *local =PDE_DATA (file_inode (m->file)); +local_info_t *local =pde_data (file_inode (m->file));spin_unlock_bh (&local->lock); }
drivers/net/wireless/ray_cs.c renamed from drivers/net/wireless/ray_cs.c~proc-remove-pde_data-completely +1 -1
@@ -2746,7 +2746,7 @@ static ssize_t int_proc_write(struct fil nr = nr *10 + c; p++; }while (--len); - *(int *)PDE_DATA (file_inode (file)) = nr; + *(int *)pde_data (file_inode (file)) = nr;return count; }
drivers/nubus/proc.c renamed from drivers/nubus/proc.c~proc-remove-pde_data-completely +18 -18
@@ -93,30 +93,30 @@ struct nubus_proc_pde_data {static struct nubus_proc_pde_data *nubus_proc_alloc_pde_data (unsigned char *ptr,unsigned int size) { -struct nubus_proc_pde_data *pde_data; +struct nubus_proc_pde_data *pded; - pde_data =kmalloc (sizeof (*pde_data),GFP_KERNEL ); -if (!pde_data) + pded =kmalloc (sizeof (*pded),GFP_KERNEL ); +if (!pded)return NULL ; - pde_data->res_ptr = ptr; - pde_data->res_size = size; -return pde_data; + pded->res_ptr = ptr; + pded->res_size = size; +return pded; }static int nubus_proc_rsrc_show (struct seq_file *m,void *v) {struct inode *inode = m->private; -struct nubus_proc_pde_data *pde_data; +struct nubus_proc_pde_data *pded; - pde_data =PDE_DATA (inode); -if (!pde_data) + pded =pde_data (inode); +if (!pded)return 0 ; -if (pde_data->res_size > m->size) +if (pded->res_size > m->size)return -EFBIG ; -if (pde_data->res_size) { +if (pded->res_size) {int lanes = (int )proc_get_parent_data (inode);struct nubus_dirent ent;
@@ -124,11 +124,11 @@ static int nubus_proc_rsrc_show(struct sreturn 0 ; ent.mask = lanes; - ent.base = pde_data->res_ptr; + ent.base = pded->res_ptr; ent.data =0 ; -nubus_seq_write_rsrc_mem (m, &ent, pde_data->res_size); +nubus_seq_write_rsrc_mem (m, &ent, pded->res_size); }else { -unsigned int data = (unsigned int )pde_data->res_ptr; +unsigned int data = (unsigned int )pded->res_ptr;seq_putc (m, data >>16 );seq_putc (m, data >>8 );
@@ -142,18 +142,18 @@ void nubus_proc_add_rsrc_mem(struct proc unsigned int size) {char name[9 ]; -struct nubus_proc_pde_data *pde_data; +struct nubus_proc_pde_data *pded;if (!procdir)return ;snprintf (name,sizeof (name),"%x" , ent->type);if (size) - pde_data =nubus_proc_alloc_pde_data (nubus_dirptr (ent), size); + pded =nubus_proc_alloc_pde_data (nubus_dirptr (ent), size);else - pde_data =NULL ; + pded =NULL ;proc_create_single_data (name,S_IFREG |0444 , procdir, - nubus_proc_rsrc_show, pde_data); + nubus_proc_rsrc_show, pded); } void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,
drivers/parisc/led.c renamed from drivers/parisc/led.c~proc-remove-pde_data-completely +2 -2
@@ -168,14 +168,14 @@ static int led_proc_show(struct seq_filestatic int led_proc_open (struct inode *inode,struct file *file) { -return single_open (file, led_proc_show,PDE_DATA (inode)); +return single_open (file, led_proc_show,pde_data (inode)); }static ssize_t led_proc_write (struct file *file,const char __user *buf,size_t count,loff_t *pos) { -void *data =PDE_DATA (file_inode (file)); +void *data =pde_data (file_inode (file));char *cur, lbuf[32 ];int d;
drivers/pci/proc.c renamed from drivers/pci/proc.c~proc-remove-pde_data-completely +5 -5
@@ -21,14 +21,14 @@ static int proc_initialized; /* = 0 */static loff_t proc_bus_pci_lseek (struct file *file,loff_t off,int whence) { -struct pci_dev *dev =PDE_DATA (file_inode (file)); +struct pci_dev *dev =pde_data (file_inode (file));return fixed_size_llseek (file, off, whence, dev->cfg_size); }static ssize_t proc_bus_pci_read (struct file *file,char __user *buf,size_t nbytes,loff_t *ppos) { -struct pci_dev *dev =PDE_DATA (file_inode (file)); +struct pci_dev *dev =pde_data (file_inode (file));unsigned int pos = *ppos;unsigned int cnt, size;
@@ -114,7 +114,7 @@ static ssize_t proc_bus_pci_write(struct size_t nbytes, loff_t *ppos) { struct inode *ino = file_inode(file); -struct pci_dev *dev =PDE_DATA (ino); +struct pci_dev *dev =pde_data (ino);int pos = *ppos;int size = dev->cfg_size;int cnt, ret;
@@ -196,7 +196,7 @@ struct pci_filp_private {static long proc_bus_pci_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct pci_dev *dev =PDE_DATA (file_inode (file)); +struct pci_dev *dev =pde_data (file_inode (file));#ifdef HAVE_PCI_MMAP struct pci_filp_private *fpriv = file->private_data;#endif /* HAVE_PCI_MMAP */
@@ -244,7 +244,7 @@ static long proc_bus_pci_ioctl(struct fi#ifdef HAVE_PCI_MMAP static int proc_bus_pci_mmap (struct file *file,struct vm_area_struct *vma) { -struct pci_dev *dev =PDE_DATA (file_inode (file)); +struct pci_dev *dev =pde_data (file_inode (file));struct pci_filp_private *fpriv = file->private_data;int i, ret, write_combine =0 , res_bit =IORESOURCE_MEM ;
drivers/platform/x86/thinkpad_acpi.c renamed from drivers/platform/x86/thinkpad_acpi.c~proc-remove-pde_data-completely +2 -2
@@ -880,14 +880,14 @@ static int dispatch_proc_show(struct seqstatic int dispatch_proc_open (struct inode *inode,struct file *file) { -return single_open (file, dispatch_proc_show,PDE_DATA (inode)); +return single_open (file, dispatch_proc_show,pde_data (inode)); }static ssize_t dispatch_proc_write (struct file *file,const char __user *userbuf,size_t count,loff_t *pos) { -struct ibm_struct *ibm =PDE_DATA (file_inode (file)); +struct ibm_struct *ibm =pde_data (file_inode (file));char *kernbuf;int ret;
drivers/platform/x86/toshiba_acpi.c renamed from drivers/platform/x86/toshiba_acpi.c~proc-remove-pde_data-completely +8 -8
@@ -1368,7 +1368,7 @@ static int lcd_proc_show(struct seq_filestatic int lcd_proc_open (struct inode *inode,struct file *file) { -return single_open (file, lcd_proc_show,PDE_DATA (inode)); +return single_open (file, lcd_proc_show,pde_data (inode)); }static int set_lcd_brightness (struct toshiba_acpi_dev *dev,int value)
@@ -1404,7 +1404,7 @@ static int set_lcd_status(struct backligstatic ssize_t lcd_proc_write (struct file *file,const char __user *buf,size_t count,loff_t *pos) { -struct toshiba_acpi_dev *dev =PDE_DATA (file_inode (file)); +struct toshiba_acpi_dev *dev =pde_data (file_inode (file));char cmd[42 ];size_t len;int levels;
@@ -1469,13 +1469,13 @@ static int video_proc_show(struct seq_fistatic int video_proc_open (struct inode *inode,struct file *file) { -return single_open (file, video_proc_show,PDE_DATA (inode)); +return single_open (file, video_proc_show,pde_data (inode)); }static ssize_t video_proc_write (struct file *file,const char __user *buf,size_t count,loff_t *pos) { -struct toshiba_acpi_dev *dev =PDE_DATA (file_inode (file)); +struct toshiba_acpi_dev *dev =pde_data (file_inode (file));char *buffer;char *cmd;int lcd_out =-1 , crt_out =-1 , tv_out =-1 ;
@@ -1580,13 +1580,13 @@ static int fan_proc_show(struct seq_filestatic int fan_proc_open (struct inode *inode,struct file *file) { -return single_open (file, fan_proc_show,PDE_DATA (inode)); +return single_open (file, fan_proc_show,pde_data (inode)); }static ssize_t fan_proc_write (struct file *file,const char __user *buf,size_t count,loff_t *pos) { -struct toshiba_acpi_dev *dev =PDE_DATA (file_inode (file)); +struct toshiba_acpi_dev *dev =pde_data (file_inode (file));char cmd[42 ];size_t len;int value;
@@ -1628,13 +1628,13 @@ static int keys_proc_show(struct seq_filstatic int keys_proc_open (struct inode *inode,struct file *file) { -return single_open (file, keys_proc_show,PDE_DATA (inode)); +return single_open (file, keys_proc_show,pde_data (inode)); }static ssize_t keys_proc_write (struct file *file,const char __user *buf,size_t count,loff_t *pos) { -struct toshiba_acpi_dev *dev =PDE_DATA (file_inode (file)); +struct toshiba_acpi_dev *dev =pde_data (file_inode (file));char cmd[42 ];size_t len;int value;
drivers/pnp/isapnp/proc.c renamed from drivers/pnp/isapnp/proc.c~proc-remove-pde_data-completely +1 -1
@@ -22,7 +22,7 @@ static loff_t isapnp_proc_bus_lseek(strustatic ssize_t isapnp_proc_bus_read (struct file *file,char __user * buf,size_t nbytes,loff_t * ppos) { -struct pnp_dev *dev =PDE_DATA (file_inode (file)); +struct pnp_dev *dev =pde_data (file_inode (file));int pos = *ppos;int cnt, size =256 ;
drivers/pnp/pnpbios/proc.c renamed from drivers/pnp/pnpbios/proc.c~proc-remove-pde_data-completely +2 -2
@@ -173,13 +173,13 @@ static int pnpbios_proc_show(struct seq_static int pnpbios_proc_open (struct inode *inode,struct file *file) { -return single_open (file, pnpbios_proc_show,PDE_DATA (inode)); +return single_open (file, pnpbios_proc_show,pde_data (inode)); }static ssize_t pnpbios_proc_write (struct file *file,const char __user *buf,size_t count,loff_t *pos) { -void *data =PDE_DATA (file_inode (file)); +void *data =pde_data (file_inode (file));struct pnp_bios_node *node;int boot = (long )data >>8 ;u8 nodenum = (long )data;
drivers/scsi/scsi_proc.c renamed from drivers/scsi/scsi_proc.c~proc-remove-pde_data-completely +2 -2
@@ -49,7 +49,7 @@ static DEFINE_MUTEX(global_host_templatestatic ssize_t proc_scsi_host_write (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -struct Scsi_Host *shost =PDE_DATA (file_inode (file)); +struct Scsi_Host *shost =pde_data (file_inode (file));ssize_t ret = -ENOMEM ;char *page;
@@ -79,7 +79,7 @@ static int proc_scsi_show(struct seq_filstatic int proc_scsi_host_open (struct inode *inode,struct file *file) { -return single_open_size (file, proc_scsi_show,PDE_DATA (inode), +return single_open_size (file, proc_scsi_show,pde_data (inode),4 *PAGE_SIZE ); }
drivers/usb/gadget/function/rndis.c renamed from drivers/usb/gadget/function/rndis.c~proc-remove-pde_data-completely +2 -2
@@ -1117,7 +1117,7 @@ static int rndis_proc_show(struct seq_fistatic ssize_t rndis_proc_write (struct file *file,const char __user *buffer,size_t count,loff_t *ppos) { -rndis_params *p =PDE_DATA (file_inode (file)); +rndis_params *p =pde_data (file_inode (file));u32 speed =0 ;int i, fl_speed =0 ;
@@ -1161,7 +1161,7 @@ static ssize_t rndis_proc_write(struct fstatic int rndis_proc_open (struct inode *inode,struct file *file) { -return single_open (file, rndis_proc_show,PDE_DATA (inode)); +return single_open (file, rndis_proc_show,pde_data (inode)); }static const struct proc_ops rndis_proc_ops = {
drivers/zorro/proc.c renamed from drivers/zorro/proc.c~proc-remove-pde_data-completely +1 -1
@@ -30,7 +30,7 @@ proc_bus_zorro_lseek(struct file *file,static ssize_t proc_bus_zorro_read (struct file *file,char __user *buf,size_t nbytes,loff_t *ppos) { -struct zorro_dev *z =PDE_DATA (file_inode (file)); +struct zorro_dev *z =pde_data (file_inode (file));struct ConfigDev cd;loff_t pos = *ppos;
fs/afs/proc.c renamed from fs/afs/proc.c~proc-remove-pde_data-completely +3 -3
@@ -227,7 +227,7 @@ static int afs_proc_cell_volumes_show(ststatic void *afs_proc_cell_volumes_start (struct seq_file *m,loff_t *_pos) __acquires(cell->proc_lock) { -struct afs_cell *cell =PDE_DATA (file_inode (m->file)); +struct afs_cell *cell =pde_data (file_inode (m->file));rcu_read_lock ();return seq_hlist_start_head_rcu (&cell->proc_volumes, *_pos);
@@ -236,7 +236,7 @@ static void *afs_proc_cell_volumes_startstatic void *afs_proc_cell_volumes_next (struct seq_file *m,void *v,loff_t *_pos) { -struct afs_cell *cell =PDE_DATA (file_inode (m->file)); +struct afs_cell *cell =pde_data (file_inode (m->file));return seq_hlist_next_rcu (v, &cell->proc_volumes, _pos); }
@@ -322,7 +322,7 @@ static void *afs_proc_cell_vlservers_sta {struct afs_vl_seq_net_private *priv = m->private;struct afs_vlserver_list *vllist; -struct afs_cell *cell =PDE_DATA (file_inode (m->file)); +struct afs_cell *cell =pde_data (file_inode (m->file));loff_t pos = *_pos;rcu_read_lock ();
fs/ext4/mballoc.c renamed from fs/ext4/mballoc.c~proc-remove-pde_data-completely +7 -7
@@ -2834,7 +2834,7 @@ out:static void *ext4_mb_seq_groups_start (struct seq_file *seq,loff_t *pos) { -struct super_block *sb =PDE_DATA (file_inode (seq->file)); +struct super_block *sb =pde_data (file_inode (seq->file));ext4_group_t group;if (*pos <0 || *pos >=ext4_get_groups_count (sb))
@@ -2845,7 +2845,7 @@ static void *ext4_mb_seq_groups_start(ststatic void *ext4_mb_seq_groups_next (struct seq_file *seq,void *v,loff_t *pos) { -struct super_block *sb =PDE_DATA (file_inode (seq->file)); +struct super_block *sb =pde_data (file_inode (seq->file));ext4_group_t group; ++*pos;
@@ -2857,7 +2857,7 @@ static void *ext4_mb_seq_groups_next(strstatic int ext4_mb_seq_groups_show (struct seq_file *seq,void *v) { -struct super_block *sb =PDE_DATA (file_inode (seq->file)); +struct super_block *sb =pde_data (file_inode (seq->file));ext4_group_t group = (ext4_group_t) ((unsigned long ) v);int i;int err, buddy_loaded =0 ;
@@ -2985,7 +2985,7 @@ int ext4_seq_mb_stats_show(struct seq_fistatic void *ext4_mb_seq_structs_summary_start (struct seq_file *seq,loff_t *pos) __acquires(&EXT4_SB(sb)->s_mb_rb_lock) { -struct super_block *sb =PDE_DATA (file_inode (seq->file)); +struct super_block *sb =pde_data (file_inode (seq->file));unsigned long position;read_lock (&EXT4_SB (sb)->s_mb_rb_lock);
@@ -2998,7 +2998,7 @@ __acquires(&EXT4_SB(sb)->s_mb_rb_lock)static void *ext4_mb_seq_structs_summary_next (struct seq_file *seq,void *v,loff_t *pos) { -struct super_block *sb =PDE_DATA (file_inode (seq->file)); +struct super_block *sb =pde_data (file_inode (seq->file));unsigned long position; ++*pos;
@@ -3010,7 +3010,7 @@ static void *ext4_mb_seq_structs_summarystatic int ext4_mb_seq_structs_summary_show (struct seq_file *seq,void *v) { -struct super_block *sb =PDE_DATA (file_inode (seq->file)); +struct super_block *sb =pde_data (file_inode (seq->file));struct ext4_sb_info *sbi =EXT4_SB (sb);unsigned long position = ((unsigned long ) v);struct ext4_group_info *grp;
@@ -3058,7 +3058,7 @@ static int ext4_mb_seq_structs_summary_sstatic void ext4_mb_seq_structs_summary_stop (struct seq_file *seq,void *v) __releases(&EXT4_SB(sb)->s_mb_rb_lock) { -struct super_block *sb =PDE_DATA (file_inode (seq->file)); +struct super_block *sb =pde_data (file_inode (seq->file));read_unlock (&EXT4_SB (sb)->s_mb_rb_lock); }
fs/jbd2/journal.c renamed from fs/jbd2/journal.c~proc-remove-pde_data-completely +1 -1
@@ -1212,7 +1212,7 @@ static const struct seq_operations jbd2_static int jbd2_seq_info_open (struct inode *inode,struct file *file) { -journal_t *journal =PDE_DATA (inode); +journal_t *journal =pde_data (inode);struct jbd2_stats_proc_session *s;int rc, size;
fs/proc/proc_net.c renamed from fs/proc/proc_net.c~proc-remove-pde_data-completely +4 -4
@@ -138,7 +138,7 @@ EXPORT_SYMBOL_GPL(proc_create_net_data);* @parent: The parent directory in which to create. * @ops: The seq_file ops with which to read the file. * @write: The write method with which to 'modify' the file. -* @data: Data for retrieval by PDE_DATA(). +* @data: Data for retrieval by pde_data(). * * Create a network namespaced proc file in the @parent directory with the * specified @name and @mode that allows reading of a file that displays a
@@ -153,7 +153,7 @@ EXPORT_SYMBOL_GPL(proc_create_net_data);* modified by the @write function. @write should return 0 on success. * * The @data value is accessible from the @show and @write functions by calling -* PDE_DATA() on the file inode. The network namespace must be accessed by +* pde_data() on the file inode. The network namespace must be accessed by * calling seq_file_net() on the seq_file struct. */ struct proc_dir_entry *proc_create_net_data_write(const char *name, umode_t mode,
@@ -230,7 +230,7 @@ EXPORT_SYMBOL_GPL(proc_create_net_single* @parent: The parent directory in which to create. * @show: The seqfile show method with which to read the file. * @write: The write method with which to 'modify' the file. -* @data: Data for retrieval by PDE_DATA(). +* @data: Data for retrieval by pde_data(). * * Create a network-namespaced proc file in the @parent directory with the * specified @name and @mode that allows reading of a file that displays a
@@ -245,7 +245,7 @@ EXPORT_SYMBOL_GPL(proc_create_net_single* modified by the @write function. @write should return 0 on success. * * The @data value is accessible from the @show and @write functions by calling -* PDE_DATA() on the file inode. The network namespace must be accessed by +* pde_data() on the file inode. The network namespace must be accessed by * calling seq_file_single_net() on the seq_file struct. */ struct proc_dir_entry *proc_create_net_single_write(const char *name, umode_t mode,
include/linux/proc_fs.h renamed from include/linux/proc_fs.h~proc-remove-pde_data-completely +1 -3
@@ -120,8 +120,6 @@ static inline void *pde_data(const strucreturn inode->i_private; } -#define PDE_DATA (i) pde_data(i) -extern void *proc_get_parent_data (const struct inode *);extern void proc_remove (struct proc_dir_entry *);extern void remove_proc_entry (const char *,struct proc_dir_entry *);
@@ -202,7 +200,7 @@ proc_create_data(const char *name, umodestatic inline void proc_set_size (struct proc_dir_entry *de,loff_t size) {}static inline void proc_set_user (struct proc_dir_entry *de,kuid_t uid,kgid_t gid) {} -static inline void *PDE_DATA (const struct inode *inode) {BUG ();return NULL ;} +static inline void *pde_data (const struct inode *inode) {BUG ();return NULL ;}static inline void *proc_get_parent_data (const struct inode *inode) {BUG ();return NULL ; }static inline void proc_remove (struct proc_dir_entry *de) {}
include/linux/seq_file.h renamed from include/linux/seq_file.h~proc-remove-pde_data-completely +1 -1
@@ -209,7 +209,7 @@ static const struct file_operations __na#define DEFINE_PROC_SHOW_ATTRIBUTE (__name) \ static int __name ## _open(struct inode *inode, struct file *file) \ { \ - return single_open(file, __name ## _show, PDE_DATA(inode)); \ + return single_open(file, __name ## _show, pde_data(inode)); \ } \ \ static const struct proc_ops __name ## _proc_ops = { \
ipc/util.c renamed from ipc/util.c~proc-remove-pde_data-completely +1 -1
@@ -894,7 +894,7 @@ static int sysvipc_proc_open(struct inodif (!iter)return -ENOMEM ; - iter->iface =PDE_DATA (inode); + iter->iface =pde_data (inode); iter->ns =get_ipc_ns (current->nsproxy->ipc_ns); iter->pid_ns =get_pid_ns (task_active_pid_ns (current));
kernel/irq/proc.c renamed from kernel/irq/proc.c~proc-remove-pde_data-completely +4 -4
@@ -137,7 +137,7 @@ static inline int irq_select_affinity_usstatic ssize_t write_irq_affinity (int type,struct file *file,const char __user *buffer,size_t count,loff_t *pos) { -unsigned int irq = (int )(long )PDE_DATA (file_inode (file)); +unsigned int irq = (int )(long )pde_data (file_inode (file));cpumask_var_t new_value;int err;
@@ -190,12 +190,12 @@ static ssize_t irq_affinity_list_proc_wrstatic int irq_affinity_proc_open (struct inode *inode,struct file *file) { -return single_open (file, irq_affinity_proc_show,PDE_DATA (inode)); +return single_open (file, irq_affinity_proc_show,pde_data (inode)); }static int irq_affinity_list_proc_open (struct inode *inode,struct file *file) { -return single_open (file, irq_affinity_list_proc_show,PDE_DATA (inode)); +return single_open (file, irq_affinity_list_proc_show,pde_data (inode)); }static const struct proc_ops irq_affinity_proc_ops = {
@@ -265,7 +265,7 @@ out:static int default_affinity_open (struct inode *inode,struct file *file) { -return single_open (file, default_affinity_show,PDE_DATA (inode)); +return single_open (file, default_affinity_show,pde_data (inode)); }static const struct proc_ops default_affinity_proc_ops = {
kernel/resource.c renamed from kernel/resource.c~proc-remove-pde_data-completely +2 -2
@@ -99,7 +99,7 @@ enum { MAX_IORES_LEVEL = 5 };static void *r_start (struct seq_file *m,loff_t *pos)__acquires (resource_lock) { -struct resource *p =PDE_DATA (file_inode (m->file)); +struct resource *p =pde_data (file_inode (m->file));loff_t l =0 ;read_lock (&resource_lock);for (p = p->child; p && l < *pos; p =r_next (m, p, &l))
@@ -115,7 +115,7 @@ static void r_stop(struct seq_file *m, vstatic int r_show (struct seq_file *m,void *v) { -struct resource *root =PDE_DATA (file_inode (m->file)); +struct resource *root =pde_data (file_inode (m->file));struct resource *r = v, *p;unsigned long long start, end;int width = root->end <0x10000 ?4 :8 ;
net/atm/proc.c renamed from net/atm/proc.c~proc-remove-pde_data-completely +2 -2
@@ -108,7 +108,7 @@ out:static inline void *vcc_walk (struct seq_file *seq,loff_t l) {struct vcc_state *state = seq->private; -int family = (uintptr_t )(PDE_DATA (file_inode (seq->file))); +int family = (uintptr_t )(pde_data (file_inode (seq->file)));return __vcc_walk (&state->sk, family, &state->bucket, l) ? state :NULL ;
@@ -324,7 +324,7 @@ static ssize_t proc_dev_atm_read(struct page =get_zeroed_page (GFP_KERNEL );if (!page)return -ENOMEM ; - dev =PDE_DATA (file_inode (file)); + dev =pde_data (file_inode (file));if (!dev->ops->proc_read) length = -EINVAL ;else {
net/bluetooth/af_bluetooth.c renamed from net/bluetooth/af_bluetooth.c~proc-remove-pde_data-completely +4 -4
@@ -611,7 +611,7 @@ EXPORT_SYMBOL(bt_sock_wait_ready);static void *bt_seq_start (struct seq_file *seq,loff_t *pos) __acquires(seq->private->l->lock) { -struct bt_sock_list *l =PDE_DATA (file_inode (seq->file)); +struct bt_sock_list *l =pde_data (file_inode (seq->file));read_lock (&l->lock);return seq_hlist_start_head (&l->head, *pos);
@@ -619,7 +619,7 @@ static void *bt_seq_start(struct seq_filstatic void *bt_seq_next (struct seq_file *seq,void *v,loff_t *pos) { -struct bt_sock_list *l =PDE_DATA (file_inode (seq->file)); +struct bt_sock_list *l =pde_data (file_inode (seq->file));return seq_hlist_next (v, &l->head, pos); }
@@ -627,14 +627,14 @@ static void *bt_seq_next(struct seq_filestatic void bt_seq_stop (struct seq_file *seq,void *v) __releases(seq->private->l->lock) { -struct bt_sock_list *l =PDE_DATA (file_inode (seq->file)); +struct bt_sock_list *l =pde_data (file_inode (seq->file));read_unlock (&l->lock); }static int bt_seq_show (struct seq_file *seq,void *v) { -struct bt_sock_list *l =PDE_DATA (file_inode (seq->file)); +struct bt_sock_list *l =pde_data (file_inode (seq->file));if (v ==SEQ_START_TOKEN ) {seq_puts (seq,"sk RefCnt Rmem Wmem User Inode Parent" );
net/can/bcm.c renamed from net/can/bcm.c~proc-remove-pde_data-completely +1 -1
@@ -193,7 +193,7 @@ static int bcm_proc_show(struct seq_file {char ifname[IFNAMSIZ ];struct net *net = m->private; -struct sock *sk = (struct sock *)PDE_DATA (m->file->f_inode); +struct sock *sk = (struct sock *)pde_data (m->file->f_inode);struct bcm_sock *bo =bcm_sk (sk);struct bcm_op *op;
net/can/proc.c renamed from net/can/proc.c~proc-remove-pde_data-completely +1 -1
@@ -305,7 +305,7 @@ static inline void can_rcvlist_proc_showstatic int can_rcvlist_proc_show (struct seq_file *m,void *v) {/* double cast to prevent GCC warning */ -int idx = (int )(long )PDE_DATA (m->file->f_inode); +int idx = (int )(long )pde_data (m->file->f_inode);struct net_device *dev;struct can_dev_rcv_lists *dev_rcv_lists;struct net *net = m->private;
net/core/neighbour.c renamed from net/core/neighbour.c~proc-remove-pde_data-completely +3 -3
@@ -3364,7 +3364,7 @@ EXPORT_SYMBOL(neigh_seq_stop);static void *neigh_stat_seq_start (struct seq_file *seq,loff_t *pos) { -struct neigh_table *tbl =PDE_DATA (file_inode (seq->file)); +struct neigh_table *tbl =pde_data (file_inode (seq->file));int cpu;if (*pos ==0 )
@@ -3381,7 +3381,7 @@ static void *neigh_stat_seq_start(structstatic void *neigh_stat_seq_next (struct seq_file *seq,void *v,loff_t *pos) { -struct neigh_table *tbl =PDE_DATA (file_inode (seq->file)); +struct neigh_table *tbl =pde_data (file_inode (seq->file));int cpu;for (cpu = *pos; cpu < nr_cpu_ids; ++cpu) {
@@ -3401,7 +3401,7 @@ static void neigh_stat_seq_stop(struct sstatic int neigh_stat_seq_show (struct seq_file *seq,void *v) { -struct neigh_table *tbl =PDE_DATA (file_inode (seq->file)); +struct neigh_table *tbl =pde_data (file_inode (seq->file));struct neigh_statistics *st = v;if (v ==SEQ_START_TOKEN ) {
net/core/pktgen.c renamed from net/core/pktgen.c~proc-remove-pde_data-completely +3 -3
@@ -546,7 +546,7 @@ static ssize_t pgctrl_write(struct filestatic int pgctrl_open (struct inode *inode,struct file *file) { -return single_open (file, pgctrl_show,PDE_DATA (inode)); +return single_open (file, pgctrl_show,pde_data (inode)); }static const struct proc_ops pktgen_proc_ops = {
@@ -1811,7 +1811,7 @@ static ssize_t pktgen_if_write(struct fistatic int pktgen_if_open (struct inode *inode,struct file *file) { -return single_open (file, pktgen_if_show,PDE_DATA (inode)); +return single_open (file, pktgen_if_show,pde_data (inode)); }static const struct proc_ops pktgen_if_proc_ops = {
@@ -1948,7 +1948,7 @@ out:static int pktgen_thread_open (struct inode *inode,struct file *file) { -return single_open (file, pktgen_thread_show,PDE_DATA (inode)); +return single_open (file, pktgen_thread_show,pde_data (inode)); }static const struct proc_ops pktgen_thread_proc_ops = {
net/ipv4/netfilter/ipt_CLUSTERIP.c renamed from net/ipv4/netfilter/ipt_CLUSTERIP.c~proc-remove-pde_data-completely +3 -3
@@ -776,7 +776,7 @@ static int clusterip_proc_open(struct inif (!ret) {struct seq_file *sf = file->private_data; -struct clusterip_config *c =PDE_DATA (inode); +struct clusterip_config *c =pde_data (inode); sf->private = c;
@@ -788,7 +788,7 @@ static int clusterip_proc_open(struct instatic int clusterip_proc_release (struct inode *inode,struct file *file) { -struct clusterip_config *c =PDE_DATA (inode); +struct clusterip_config *c =pde_data (inode);int ret; ret =seq_release (inode, file);
@@ -802,7 +802,7 @@ static int clusterip_proc_release(structstatic ssize_t clusterip_proc_write (struct file *file,const char __user *input,size_t size,loff_t *ofs) { -struct clusterip_config *c =PDE_DATA (file_inode (file)); +struct clusterip_config *c =pde_data (file_inode (file));#define PROC_WRITELEN 10char buffer[PROC_WRITELEN +1 ];unsigned long nodenum;
net/ipv4/raw.c renamed from net/ipv4/raw.c~proc-remove-pde_data-completely +4 -4
@@ -971,7 +971,7 @@ struct proto raw_prot = {static struct sock *raw_get_first (struct seq_file *seq) {struct sock *sk; -struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file)); +struct raw_hashinfo *h =pde_data (file_inode (seq->file));struct raw_iter_state *state =raw_seq_private (seq); for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE;
@@ -987,7 +987,7 @@ found:static struct sock *raw_get_next (struct seq_file *seq,struct sock *sk) { -struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file)); +struct raw_hashinfo *h =pde_data (file_inode (seq->file));struct raw_iter_state *state =raw_seq_private (seq); do {
@@ -1016,7 +1016,7 @@ static struct sock *raw_get_idx(struct svoid *raw_seq_start (struct seq_file *seq,loff_t *pos) __acquires(&h->lock) { -struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file)); +struct raw_hashinfo *h =pde_data (file_inode (seq->file));read_lock (&h->lock);return *pos ?raw_get_idx (seq, *pos -1 ) :SEQ_START_TOKEN ;
@@ -1039,7 +1039,7 @@ EXPORT_SYMBOL_GPL(raw_seq_next);void raw_seq_stop (struct seq_file *seq,void *v) __releases(&h->lock) { -struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file)); +struct raw_hashinfo *h =pde_data (file_inode (seq->file));read_unlock (&h->lock); }
net/ipv4/tcp_ipv4.c renamed from net/ipv4/tcp_ipv4.c~proc-remove-pde_data-completely +1 -1
@@ -3002,7 +3002,7 @@ static unsigned short seq_file_family(co#endif /* Iterated from proc fs */ - afinfo =PDE_DATA (file_inode (seq->file)); + afinfo =pde_data (file_inode (seq->file));return afinfo->family; }
net/ipv4/udp.c renamed from net/ipv4/udp.c~proc-remove-pde_data-completely +3 -3
@@ -2960,7 +2960,7 @@ static struct sock *udp_get_first(structif (state->bpf_seq_afinfo) afinfo = state->bpf_seq_afinfo;else - afinfo =PDE_DATA (file_inode (seq->file)); + afinfo =pde_data (file_inode (seq->file));for (state->bucket = start; state->bucket <= afinfo->udp_table->mask; ++state->bucket) {
@@ -2993,7 +2993,7 @@ static struct sock *udp_get_next(structif (state->bpf_seq_afinfo) afinfo = state->bpf_seq_afinfo;else - afinfo =PDE_DATA (file_inode (seq->file)); + afinfo =pde_data (file_inode (seq->file)); do { sk = sk_next(sk);
@@ -3050,7 +3050,7 @@ void udp_seq_stop(struct seq_file *seq,if (state->bpf_seq_afinfo) afinfo = state->bpf_seq_afinfo;else - afinfo =PDE_DATA (file_inode (seq->file)); + afinfo =pde_data (file_inode (seq->file));if (state->bucket <= afinfo->udp_table->mask)spin_unlock_bh (&afinfo->udp_table->hash[state->bucket].lock);
net/netfilter/x_tables.c renamed from net/netfilter/x_tables.c~proc-remove-pde_data-completely +5 -5
@@ -1517,7 +1517,7 @@ EXPORT_SYMBOL_GPL(xt_unregister_table);#ifdef CONFIG_PROC_FS static void *xt_table_seq_start (struct seq_file *seq,loff_t *pos) { -u8 af = (unsigned long )PDE_DATA (file_inode (seq->file)); +u8 af = (unsigned long )pde_data (file_inode (seq->file));struct net *net =seq_file_net (seq);struct xt_pernet *xt_net;
@@ -1529,7 +1529,7 @@ static void *xt_table_seq_start(struct sstatic void *xt_table_seq_next (struct seq_file *seq,void *v,loff_t *pos) { -u8 af = (unsigned long )PDE_DATA (file_inode (seq->file)); +u8 af = (unsigned long )pde_data (file_inode (seq->file));struct net *net =seq_file_net (seq);struct xt_pernet *xt_net;
@@ -1540,7 +1540,7 @@ static void *xt_table_seq_next(struct sestatic void xt_table_seq_stop (struct seq_file *seq,void *v) { -u_int8_t af = (unsigned long )PDE_DATA (file_inode (seq->file)); +u_int8_t af = (unsigned long )pde_data (file_inode (seq->file));mutex_unlock (&xt[af].mutex); }
@@ -1584,7 +1584,7 @@ static void *xt_mttg_seq_next(struct seq [MTTG_TRAV_NFP_UNSPEC] = MTTG_TRAV_NFP_SPEC, [MTTG_TRAV_NFP_SPEC] = MTTG_TRAV_DONE, }; -uint8_t nfproto = (unsigned long )PDE_DATA (file_inode (seq->file)); +uint8_t nfproto = (unsigned long )pde_data (file_inode (seq->file));struct nf_mttg_trav *trav = seq->private;if (ppos !=NULL )
@@ -1633,7 +1633,7 @@ static void *xt_mttg_seq_start(struct sestatic void xt_mttg_seq_stop (struct seq_file *seq,void *v) { -uint8_t nfproto = (unsigned long )PDE_DATA (file_inode (seq->file)); +uint8_t nfproto = (unsigned long )pde_data (file_inode (seq->file));struct nf_mttg_trav *trav = seq->private;switch (trav->class) {
net/netfilter/xt_hashlimit.c renamed from net/netfilter/xt_hashlimit.c~proc-remove-pde_data-completely +9 -9
@@ -1052,7 +1052,7 @@ static struct xt_match hashlimit_mt_reg[static void *dl_seq_start (struct seq_file *s,loff_t *pos) __acquires(htable->lock) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *htable =pde_data (file_inode (s->file));unsigned int *bucket;spin_lock_bh (&htable->lock);
@@ -1069,7 +1069,7 @@ static void *dl_seq_start(struct seq_filstatic void *dl_seq_next (struct seq_file *s,void *v,loff_t *pos) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *htable =pde_data (file_inode (s->file));unsigned int *bucket = v; *pos = ++(*bucket);
@@ -1083,7 +1083,7 @@ static void *dl_seq_next(struct seq_filestatic void dl_seq_stop (struct seq_file *s,void *v) __releases(htable->lock) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *htable =pde_data (file_inode (s->file));unsigned int *bucket = v;if (!IS_ERR (bucket))
@@ -1125,7 +1125,7 @@ static void dl_seq_print(struct dsthash_static int dl_seq_real_show_v2 (struct dsthash_ent *ent,u_int8_t family,struct seq_file *s) { -struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *ht =pde_data (file_inode (s->file));spin_lock (&ent->lock);/* recalculate to show accurate numbers */
@@ -1140,7 +1140,7 @@ static int dl_seq_real_show_v2(struct dsstatic int dl_seq_real_show_v1 (struct dsthash_ent *ent,u_int8_t family,struct seq_file *s) { -struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *ht =pde_data (file_inode (s->file));spin_lock (&ent->lock);/* recalculate to show accurate numbers */
@@ -1155,7 +1155,7 @@ static int dl_seq_real_show_v1(struct dsstatic int dl_seq_real_show (struct dsthash_ent *ent,u_int8_t family,struct seq_file *s) { -struct xt_hashlimit_htable *ht =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *ht =pde_data (file_inode (s->file));spin_lock (&ent->lock);/* recalculate to show accurate numbers */
@@ -1169,7 +1169,7 @@ static int dl_seq_real_show(struct dsthastatic int dl_seq_show_v2 (struct seq_file *s,void *v) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *htable =pde_data (file_inode (s->file));unsigned int *bucket = (unsigned int *)v;struct dsthash_ent *ent;
@@ -1183,7 +1183,7 @@ static int dl_seq_show_v2(struct seq_filstatic int dl_seq_show_v1 (struct seq_file *s,void *v) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *htable =pde_data (file_inode (s->file));unsigned int *bucket = v;struct dsthash_ent *ent;
@@ -1197,7 +1197,7 @@ static int dl_seq_show_v1(struct seq_filstatic int dl_seq_show (struct seq_file *s,void *v) { -struct xt_hashlimit_htable *htable =PDE_DATA (file_inode (s->file)); +struct xt_hashlimit_htable *htable =pde_data (file_inode (s->file));unsigned int *bucket = v;struct dsthash_ent *ent;
net/netfilter/xt_recent.c renamed from net/netfilter/xt_recent.c~proc-remove-pde_data-completely +2 -2
@@ -551,7 +551,7 @@ static int recent_seq_open(struct inodeif (st ==NULL )return -ENOMEM ; - st->table =PDE_DATA (inode); + st->table =pde_data (inode);return 0 ; }
@@ -559,7 +559,7 @@ static ssize_t recent_mt_proc_write(struct file *file, const char __user *input, size_t size, loff_t *loff) { - struct recent_table *t = PDE_DATA(file_inode(file)); + struct recent_table *t = pde_data(file_inode(file));struct recent_entry *e;char buf[sizeof ("+b335:1d35:1e55:dead:c0de:1715:5afe:c0de" )];const char *c = buf;
net/sunrpc/auth_gss/svcauth_gss.c renamed from net/sunrpc/auth_gss/svcauth_gss.c~proc-remove-pde_data-completely +2 -2
@@ -1433,7 +1433,7 @@ static bool use_gss_proxy(struct net *nestatic ssize_t write_gssp (struct file *file,const char __user *buf,size_t count,loff_t *ppos) { -struct net *net =PDE_DATA (file_inode (file)); +struct net *net =pde_data (file_inode (file));char tbuf[20 ];unsigned long i;int res;
@@ -1461,7 +1461,7 @@ static ssize_t write_gssp(struct file *fstatic ssize_t read_gssp (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -struct net *net =PDE_DATA (file_inode (file)); +struct net *net =pde_data (file_inode (file));struct sunrpc_net *sn =net_generic (net, sunrpc_net_id);unsigned long p = *ppos;char tbuf[10 ];
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~proc-remove-pde_data-completely +12 -12
@@ -1536,7 +1536,7 @@ static ssize_t write_flush(struct file *static ssize_t cache_read_procfs (struct file *filp,char __user *buf,size_t count,loff_t *ppos) { -struct cache_detail *cd =PDE_DATA (file_inode (filp)); +struct cache_detail *cd =pde_data (file_inode (filp));return cache_read (filp, buf, count, ppos, cd); }
@@ -1544,14 +1544,14 @@ static ssize_t cache_read_procfs(structstatic ssize_t cache_write_procfs (struct file *filp,const char __user *buf,size_t count,loff_t *ppos) { -struct cache_detail *cd =PDE_DATA (file_inode (filp)); +struct cache_detail *cd =pde_data (file_inode (filp));return cache_write (filp, buf, count, ppos, cd); }static __poll_t cache_poll_procfs (struct file *filp,poll_table *wait) { -struct cache_detail *cd =PDE_DATA (file_inode (filp)); +struct cache_detail *cd =pde_data (file_inode (filp));return cache_poll (filp, wait, cd); }
@@ -1560,21 +1560,21 @@ static long cache_ioctl_procfs(struct fi unsigned int cmd, unsigned long arg) {struct inode *inode =file_inode (filp); -struct cache_detail *cd =PDE_DATA (inode); +struct cache_detail *cd =pde_data (inode);return cache_ioctl (inode, filp, cmd, arg, cd); }static int cache_open_procfs (struct inode *inode,struct file *filp) { -struct cache_detail *cd =PDE_DATA (inode); +struct cache_detail *cd =pde_data (inode);return cache_open (inode, filp, cd); }static int cache_release_procfs (struct inode *inode,struct file *filp) { -struct cache_detail *cd =PDE_DATA (inode); +struct cache_detail *cd =pde_data (inode);return cache_release (inode, filp, cd); }
@@ -1591,14 +1591,14 @@ static const struct proc_ops cache_channstatic int content_open_procfs (struct inode *inode,struct file *filp) { -struct cache_detail *cd =PDE_DATA (inode); +struct cache_detail *cd =pde_data (inode);return content_open (inode, filp, cd); }static int content_release_procfs (struct inode *inode,struct file *filp) { -struct cache_detail *cd =PDE_DATA (inode); +struct cache_detail *cd =pde_data (inode);return content_release (inode, filp, cd); }
@@ -1612,14 +1612,14 @@ static const struct proc_ops content_prostatic int open_flush_procfs (struct inode *inode,struct file *filp) { -struct cache_detail *cd =PDE_DATA (inode); +struct cache_detail *cd =pde_data (inode);return open_flush (inode, filp, cd); }static int release_flush_procfs (struct inode *inode,struct file *filp) { -struct cache_detail *cd =PDE_DATA (inode); +struct cache_detail *cd =pde_data (inode);return release_flush (inode, filp, cd); }
@@ -1627,7 +1627,7 @@ static int release_flush_procfs(struct istatic ssize_t read_flush_procfs (struct file *filp,char __user *buf,size_t count,loff_t *ppos) { -struct cache_detail *cd =PDE_DATA (file_inode (filp)); +struct cache_detail *cd =pde_data (file_inode (filp));return read_flush (filp, buf, count, ppos, cd); }
@@ -1636,7 +1636,7 @@ static ssize_t write_flush_procfs(structconst char __user *buf, size_t count, loff_t *ppos) { - struct cache_detail *cd = PDE_DATA(file_inode(filp)); + struct cache_detail *cd = pde_data(file_inode(filp));return write_flush (filp, buf, count, ppos, cd); }
net/sunrpc/stats.c renamed from net/sunrpc/stats.c~proc-remove-pde_data-completely +1 -1
@@ -66,7 +66,7 @@ static int rpc_proc_show(struct seq_filestatic int rpc_proc_open (struct inode *inode,struct file *file) { -return single_open (file, rpc_proc_show,PDE_DATA (inode)); +return single_open (file, rpc_proc_show,pde_data (inode)); }static const struct proc_ops rpc_proc_ops = {
sound/core/info.c renamed from sound/core/info.c~proc-remove-pde_data-completely +2 -2
@@ -234,7 +234,7 @@ static int snd_info_entry_mmap(struct fistatic int snd_info_entry_open (struct inode *inode,struct file *file) { -struct snd_info_entry *entry =PDE_DATA (inode); +struct snd_info_entry *entry =pde_data (inode);struct snd_info_private_data *data;int mode, err;
@@ -365,7 +365,7 @@ static int snd_info_seq_show(struct seq_static int snd_info_text_entry_open (struct inode *inode,struct file *file) { -struct snd_info_entry *entry =PDE_DATA (inode); +struct snd_info_entry *entry =pde_data (inode);struct snd_info_private_data *data;int err;
_
Andrew Morton
maintainerPATCH 55/69 lib/stackdepot: allow optional init and stack_table allocation by kvmalloc()
In reply to Andrew MortonFrom: Vlastimil Babka <[email protected]>
Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc()
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/
From: Colin Ian King <[email protected]>
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.
From: Vlastimil Babka <[email protected]>
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/
From: Vlastimil Babka <[email protected]>
Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup3
Due to cd06ab2fd48f ("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.
From: Vlastimil Babka <[email protected]>
Subject: lib/stackdepot: allow optional init and stack_table allocation by kvmalloc() - fixup4
Due to 4e66934eaadc ("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.
---
drivers/gpu/drm/drm_dp_mst_topology.c | 1 drivers/gpu/drm/drm_mm.c | 4 ++ drivers/gpu/drm/drm_modeset_lock.c | 9 ++++++ drivers/gpu/drm/i915/intel_runtime_pm.c | 3 ++ include/linux/ref_tracker.h | 2 + include/linux/stackdepot.h | 25 ++++++++++------ init/main.c | 9 ++++-- lib/Kconfig | 4 ++ lib/Kconfig.kasan | 2 - lib/stackdepot.c | 33 ++++++++++++++++++---- mm/page_owner.c | 2 + 11 files changed, 76 insertions(+), 18 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c renamed from drivers/gpu/drm/drm_dp_mst_topology.c~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +1 -0
@@ -5511,6 +5511,7 @@ int drm_dp_mst_topology_mgr_init(structmutex_init (&mgr->probe_lock);#if IS_ENABLED (CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS )mutex_init (&mgr->topology_ref_history_lock); +stack_depot_init ();#endif INIT_LIST_HEAD (&mgr->tx_msg_downq);INIT_LIST_HEAD (&mgr->destroy_port_list);
drivers/gpu/drm/drm_mm.c renamed from drivers/gpu/drm/drm_mm.c~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +4 -0
@@ -980,6 +980,10 @@ void drm_mm_init(struct drm_mm *mm, u64add_hole (&mm->head_node); mm->scan_active =0 ; + +#ifdef CONFIG_DRM_DEBUG_MM +stack_depot_init (); +#endif }EXPORT_SYMBOL (drm_mm_init);
drivers/gpu/drm/drm_modeset_lock.c renamed from drivers/gpu/drm/drm_modeset_lock.c~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +9 -0
@@ -107,6 +107,11 @@ static void __drm_stack_depot_print(depo kfree(buf); } + +static void __drm_stack_depot_init (void ) +{ +stack_depot_init (); +}#else /* CONFIG_DRM_DEBUG_MODESET_LOCK */ static depot_stack_handle_t __drm_stack_depot_save (void ) {
@@ -115,6 +120,9 @@ static depot_stack_handle_t __drm_stack_static void __drm_stack_depot_print (depot_stack_handle_t stack_depot) { } +static void __drm_stack_depot_init (void ) +{ +}#endif /* CONFIG_DRM_DEBUG_MODESET_LOCK */ /**
@@ -359,6 +367,7 @@ void drm_modeset_lock_init(struct drm_mo {ww_mutex_init (&lock->mutex, &crtc_ww_class);INIT_LIST_HEAD (&lock->head); +__drm_stack_depot_init (); }EXPORT_SYMBOL (drm_modeset_lock_init);
drivers/gpu/drm/i915/intel_runtime_pm.c renamed from drivers/gpu/drm/i915/intel_runtime_pm.c~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +3 -0
@@ -68,6 +68,9 @@ static noinline depot_stack_handle_t __sstatic void init_intel_runtime_pm_wakeref (struct intel_runtime_pm *rpm) {spin_lock_init (&rpm->debug.lock); + +if (rpm->available) +stack_depot_init (); }static noinline depot_stack_handle_t
include/linux/ref_tracker.h renamed from include/linux/ref_tracker.h~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +2 -0
@@ -4,6 +4,7 @@#include <linux/refcount.h> #include <linux/types.h> #include <linux/spinlock.h> +#include <linux/stackdepot.h> struct ref_tracker ;
@@ -26,6 +27,7 @@ static inline void ref_tracker_dir_init(spin_lock_init (&dir->lock); dir->quarantine_avail = quarantine_count;refcount_set (&dir->untracked,1 ); +stack_depot_init (); }void ref_tracker_dir_exit (struct ref_tracker_dir *dir);
include/linux/stackdepot.h renamed from include/linux/stackdepot.h~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +16 -9
@@ -19,6 +19,22 @@ depot_stack_handle_t __stack_depot_save(unsigned int nr_entries, gfp_t gfp_flags, bool can_alloc); +/* +* Every user of stack depot has to call this during its own init when it's +* decided that it will be calling stack_depot_save() later. +* +* The alternative is to select STACKDEPOT_ALWAYS_INIT to have stack depot +* enabled as part of mm_init(), for subsystems where it's known at compile time +* that stack depot will be used. +*/ +int stack_depot_init (void ); + +#ifdef CONFIG_STACKDEPOT_ALWAYS_INIT +static inline int stack_depot_early_init (void ) {return stack_depot_init (); } +#else +static inline int stack_depot_early_init (void ) {return 0 ; } +#endif +depot_stack_handle_t stack_depot_save (unsigned long *entries,unsigned int nr_entries,gfp_t gfp_flags);
@@ -30,13 +46,4 @@ int stack_depot_snprint(depot_stack_handvoid stack_depot_print (depot_stack_handle_t stack); -#ifdef CONFIG_STACKDEPOT -int stack_depot_init (void ); -#else -static inline int stack_depot_init (void ) -{ -return 0 ; -} -#endif /* CONFIG_STACKDEPOT */ -#endif
init/main.c renamed from init/main.c~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +6 -3
@@ -834,12 +834,15 @@ static void __init mm_init(void)init_mem_debugging_and_hardening ();kfence_alloc_pool ();report_meminit (); -stack_depot_init (); +stack_depot_early_init ();mem_init ();mem_init_print_info (); -/* page_owner must be initialized after buddy is ready */ -page_ext_init_flatmem_late ();kmem_cache_init (); +/* +* page_owner must be initialized after buddy is ready, and also after +* slab is ready so that stack_depot_init() works properly +*/ +page_ext_init_flatmem_late ();kmemleak_init ();pgtable_init ();debug_objects_mem_init ();
lib/Kconfig renamed from lib/Kconfig~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +4 -0
@@ -673,6 +673,10 @@ config STACKDEPOT bool select STACKTRACE +config STACKDEPOT_ALWAYS_INIT + bool + select STACKDEPOT + config STACK_HASH_ORDER int "stack depot hash size (12 => 4KB, 20 => 1024KB)" range 12 20
lib/Kconfig.kasan renamed from lib/Kconfig.kasan~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +1 -1
@@ -38,7 +38,7 @@ menuconfig KASAN CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \ HAVE_ARCH_KASAN_HW_TAGS depends on (SLUB && SYSFS) || (SLAB && !DEBUG_SLAB) - select STACKDEPOT + select STACKDEPOT_ALWAYS_INIT help Enables KASAN (KernelAddressSANitizer) - runtime memory debugger, designed to find out-of-bounds accesses and use-after-free bugs.
lib/stackdepot.c renamed from lib/stackdepot.c~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +28 -5
@@ -23,6 +23,7 @@#include <linux/jhash.h> #include <linux/kernel.h> #include <linux/mm.h> +#include <linux/mutex.h> #include <linux/percpu.h> #include <linux/printk.h> #include <linux/slab.h>
@@ -161,18 +162,40 @@ static int __init is_stack_depot_disable }early_param ("stack_depot_disable" , is_stack_depot_disabled); -int __init stack_depot_init (void ) +/* +* __ref because of memblock_alloc(), which will not be actually called after +* the __init code is gone, because at that point slab_is_available() is true +*/ +__ref int stack_depot_init (void ) { -if (!stack_depot_disable) { +static DEFINE_MUTEX (stack_depot_init_mutex); + +mutex_lock (&stack_depot_init_mutex); +if (!stack_depot_disable && !stack_table) {size_t size = (STACK_HASH_SIZE *sizeof (struct stack_record *));int i; - stack_table =memblock_alloc (size, size); -for (i =0 ; i <STACK_HASH_SIZE ; i++) - stack_table[i] =NULL ; +if (slab_is_available ()) { +pr_info ("Stack Depot allocating hash table with kvmalloc\n" ); + stack_table =kvmalloc (size,GFP_KERNEL ); + }else { +pr_info ("Stack Depot allocating hash table with memblock_alloc\n" ); + stack_table =memblock_alloc (size,SMP_CACHE_BYTES ); + } +if (stack_table) { +for (i =0 ; i <STACK_HASH_SIZE ; i++) + stack_table[i] =NULL ; + }else { +pr_err ("Stack Depot hash table allocation failed, disabling\n" ); + stack_depot_disable = true; +mutex_unlock (&stack_depot_init_mutex); +return -ENOMEM ; + } } +mutex_unlock (&stack_depot_init_mutex);return 0 ; } +EXPORT_SYMBOL_GPL (stack_depot_init);/* Calculate hash for a stack */ static inline u32 hash_stack (unsigned long *entries,unsigned int size)
mm/page_owner.c renamed from mm/page_owner.c~lib-stackdepot-allow-optional-init-and-stack_table-allocation-by-kvmalloc +2 -0
@@ -80,6 +80,8 @@ static __init void init_page_owner(void)if (!page_owner_enabled)return ; +stack_depot_init (); +register_dummy_stack ();register_failure_stack ();register_early_stack ();
_
Andrew Morton
maintainerPATCH 56/69 lib/stackdepot: always do filter_irq_stacks() in stack_depot_save()
In reply to Andrew MortonFrom: Marco Elver <[email protected]>
Subject: lib/stackdepot: always do filter_irq_stacks() in stack_depot_save()
The non-interrupt portion of interrupt stack traces before interrupt entry is usually arbitrary. Therefore, saving stack traces of interrupts (that include entries before interrupt entry) to stack depot leads to unbounded stackdepot growth.
As such, use of filter_irq_stacks() is a requirement to ensure stackdepot can efficiently deduplicate interrupt stacks.
Looking through all current users of stack_depot_save(), none (except KASAN) pass the stack trace through filter_irq_stacks() before passing it on to stack_depot_save().
Rather than adding filter_irq_stacks() to all current users of stack_depot_save(), it became clear that stack_depot_save() should simply do filter_irq_stacks().
---
lib/stackdepot.c | 13 +++++++++++++ mm/kasan/common.c | 1 - 2 files changed, 13 insertions(+), 1 deletion(-)
lib/stackdepot.c renamed from lib/stackdepot.c~lib-stackdepot-always-do-filter_irq_stacks-in-stack_depot_save +13 -0
@@ -328,6 +328,9 @@ EXPORT_SYMBOL_GPL(stack_depot_fetch);* (allocates using GFP flags of @alloc_flags). If @can_alloc is %false, avoids * any allocations and will fail if no space is left to store the stack trace. * +* If the stack trace in @entries is from an interrupt, only the portion up to +* interrupt entry is saved. +* * Context: Any context, but setting @can_alloc to %false is required if * alloc_pages() cannot be used from the current context. Currently * this is the case from contexts where neither %GFP_ATOMIC nor
@@ -346,6 +349,16 @@ depot_stack_handle_t __stack_depot_save(unsigned long flags;u32 hash; +/* +* If this stack trace is from an interrupt, including anything before +* interrupt entry usually leads to unbounded stackdepot growth. +* +* Because use of filter_irq_stacks() is a requirement to ensure +* stackdepot can efficiently deduplicate interrupt stacks, always +* filter_irq_stacks() to simplify all callers' use of stackdepot. +*/ + nr_entries =filter_irq_stacks (entries, nr_entries); +if (unlikely (nr_entries ==0 ) || stack_depot_disable) goto fast_exit;
mm/kasan/common.c renamed from mm/kasan/common.c~lib-stackdepot-always-do-filter_irq_stacks-in-stack_depot_save +0 -1
@@ -36,7 +36,6 @@ depot_stack_handle_t kasan_save_stack(gfunsigned int nr_entries; nr_entries =stack_trace_save (entries,ARRAY_SIZE (entries),0 ); - nr_entries =filter_irq_stacks (entries, nr_entries);return __stack_depot_save (entries, nr_entries, flags, can_alloc); }
_