Skip to contentSkip to conversation

incoming

PATCH In review Andrew Morton 8 participants 121 messages May 7, 2021 – May 18, 2021 Page 1 of 2

Subsystems (108)
lore
Share & tools
lore

Andrew Morton

author maintainer
#0 lore raw

This is everything else from -mm for this merge window, with the possible exception of Mike Rapoport's "secretmem" syscall patch series
(https://lkml.kernel.org/r/[email protected]).

I've been wobbly about the secretmem patches due to doubts about whether the feature is sufficiently useful to justify inclusion, but developers are now weighing in with helpful information and I've asked Mike for an extensively updated [0/n] changelog. This will take a few days to play out so it is possible that I will prevail upon you for a post-rc1 merge. If that's a problem, there's always 5.13-rc1.

91 patches, based on 8ca5297e7e38f2dc8c753d33a5092e7be181fff0, plus previously sent patches.

Thanks.

Subsystems affected by this patch series:

alpha
procfs
sysctl
misc
core-kernel
bitmap
lib
compat
checkpatch
epoll
isofs
nilfs2
hpfs
exit
fork
kexec
gcov
panic
delayacct
gdb
resource
selftests
async
initramfs
ipc
mm/cleanups
drivers/char
mm/slub
spelling

Subsystem: alpha

Randy Dunlap <[email protected]>:
alpha: eliminate old-style function definitions
alpha: csum_partial_copy.c: add function prototypes from <net/checksum.h>

Subsystem: procfs

Colin Ian King <[email protected]>:
fs/proc/generic.c: fix incorrect pde_is_permanent check

Alexey Dobriyan <[email protected]>:
proc: save LOC in __xlate_proc_name()
proc: mandate ->proc_lseek in "struct proc_ops"
proc: delete redundant subset=pid check
selftests: proc: test subset=pid

Subsystem: sysctl

zhouchuangao <[email protected]>:
proc/sysctl: fix function name error in comments

Subsystem: misc

"Matthew Wilcox (Oracle)" <[email protected]>:
include: remove pagemap.h from blkdev.h

Andy Shevchenko <[email protected]>:
kernel.h: drop inclusion in bitmap.h

Wan Jiabing <[email protected]>:
linux/profile.h: remove unnecessary declaration

Subsystem: core-kernel

Rasmus Villemoes <[email protected]>:
kernel/async.c: fix pr_debug statement
kernel/cred.c: make init_groups static

Subsystem: bitmap

Yury Norov <[email protected]>:
Patch series "lib/find_bit: fast path for small bitmaps", v6:
tools: disable -Wno-type-limits
tools: bitmap: sync function declarations with the kernel
tools: sync BITMAP_LAST_WORD_MASK() macro with the kernel
arch: rearrange headers inclusion order in asm/bitops for m68k, sh and h8300
lib: extend the scope of small_const_nbits() macro
tools: sync small_const_nbits() macro with the kernel
lib: inline _find_next_bit() wrappers
tools: sync find_next_bit implementation
lib: add fast path for find_next_*_bit()
lib: add fast path for find_first_*_bit() and find_last_bit()
tools: sync lib/find_bit implementation
MAINTAINERS: add entry for the bitmap API

Subsystem: lib

Bhaskar Chowdhury <[email protected]>:
lib/bch.c: fix a typo in the file bch.c

Wang Qing <[email protected]>:
lib: fix inconsistent indenting in process_bit1()

ToastC <[email protected]>:
lib/list_sort.c: fix typo in function description

Bhaskar Chowdhury <[email protected]>:
lib/genalloc.c: Fix a typo

Richard Fitzgerald <[email protected]>:
lib: crc8: pointer to data block should be const

Zqiang <[email protected]>:
lib: stackdepot: turn depot_lock spinlock to raw_spinlock

Alex Shi <[email protected]>:
lib/percpu_counter: tame kernel-doc compile warning lib/genalloc: add parameter description to fix doc compile warning

Randy Dunlap <[email protected]>:
lib: parser: clean up kernel-doc

Subsystem: compat

Masahiro Yamada <[email protected]>:
include/linux/compat.h: remove unneeded declaration from COMPAT_SYSCALL_DEFINEx()

Subsystem: checkpatch

Joe Perches <[email protected]>:
checkpatch: warn when missing newline in return sysfs_emit() formats

Vincent Mailhol <[email protected]>:
checkpatch: exclude four preprocessor sub-expressions from MACRO_ARG_REUSE

Christophe JAILLET <[email protected]>:
checkpatch: improve ALLOC_ARRAY_ARGS test

Subsystem: epoll

Davidlohr Bueso <[email protected]>:
Patch series "fs/epoll: restore user-visible behavior upon event ready":
kselftest: introduce new epoll test case
fs/epoll: restore waking from ep_done_scan()

Subsystem: isofs

"Gustavo A. R. Silva" <[email protected]>:
isofs: fix fall-through warnings for Clang

Subsystem: nilfs2

Liu xuzhi <[email protected]>:
fs/nilfs2: fix misspellings using codespell tool

Lu Jialin <[email protected]>:
nilfs2: fix typos in comments

Subsystem: hpfs

"Gustavo A. R. Silva" <[email protected]>:
hpfs: replace one-element array with flexible-array member

Subsystem: exit

Jim Newsome <[email protected]>:
do_wait: make PIDTYPE_PID case O(1) instead of O(n)

Subsystem: fork

Rolf Eike Beer <[email protected]>:
kernel/fork.c: simplify copy_mm()

Xiaofeng Cao <[email protected]>:
kernel/fork.c: fix typos

Subsystem: kexec

Saeed Mirzamohammadi <[email protected]>:
kernel/crash_core: add crashkernel=auto for vmcore creation

Joe LeVeque <[email protected]>:
kexec: Add kexec reboot string

Jia-Ju Bai <[email protected]>:
kernel: kexec_file: fix error return code of kexec_calculate_store_digests()

Pavel Tatashin <[email protected]>:
kexec: dump kmessage before machine_kexec

Subsystem: gcov

Johannes Berg <[email protected]>:
gcov: combine common code
gcov: simplify buffer allocation
gcov: use kvmalloc()

Nick Desaulniers <[email protected]>:
gcov: clang: drop support for clang-10 and older

Subsystem: panic

He Ying <[email protected]>:
smp: kernel/panic.c - silence warnings

Subsystem: delayacct

Yafang Shao <[email protected]>:
delayacct: clear right task's flag after blkio completes

Subsystem: gdb

Johannes Berg <[email protected]>:
gdb: lx-symbols: store the abspath()

Barry Song <[email protected]>:
Patch series "scripts/gdb: clarify the platforms supporting lx_current and add arm64 support", v2:
scripts/gdb: document lx_current is only supported by x86
scripts/gdb: add lx_current support for arm64

Subsystem: resource

David Hildenbrand <[email protected]>:
Patch series "kernel/resource: make walk_system_ram_res() and walk_mem_res() search the whole tree", v2:
kernel/resource: make walk_system_ram_res() find all busy IORESOURCE_SYSTEM_RAM resources kernel/resource: make walk_mem_res() find all busy IORESOURCE_MEM resources kernel/resource: remove first_lvl / siblings_only logic

Alistair Popple <[email protected]>:
kernel/resource: allow region_intersects users to hold resource_lock kernel/resource: refactor __request_region to allow external locking kernel/resource: fix locking in request_free_mem_region

Subsystem: selftests

Zhang Yunkai <[email protected]>:
selftests: remove duplicate include

Subsystem: async

Rasmus Villemoes <[email protected]>:
kernel/async.c: stop guarding pr_debug() statements kernel/async.c: remove async_unregister_domain()

Subsystem: initramfs

Rasmus Villemoes <[email protected]>:
Patch series "background initramfs unpacking, and CONFIG_MODPROBE_PATH", v3:
init/initramfs.c: do unpacking asynchronously
modules: add CONFIG_MODPROBE_PATH

Subsystem: ipc

Bhaskar Chowdhury <[email protected]>:
ipc/sem.c: mundane typo fixes

Subsystem: mm/cleanups

Shijie Luo <[email protected]>:
mm: fix some typos and code style problems

Subsystem: drivers/char

David Hildenbrand <[email protected]>:
Patch series "drivers/char: remove /dev/kmem for good":
drivers/char: remove /dev/kmem for good
mm: remove xlate_dev_kmem_ptr()
mm/vmalloc: remove vwrite()

Subsystem: mm/slub

Maninder Singh <[email protected]>:
arm: print alloc free paths for address in registers

Subsystem: spelling

Drew Fustini <[email protected]>:
scripts/spelling.txt: add "overlfow"

zuoqilin <[email protected]>:
scripts/spelling.txt: Add "diabled" typo

Drew Fustini <[email protected]>:
scripts/spelling.txt: add "overflw"

Colin Ian King <[email protected]>:
mm/slab.c: fix spelling mistake "disired" -> "desired"

Bhaskar Chowdhury <[email protected]>:
include/linux/pgtable.h: few spelling fixes

zhouchuangao <[email protected]>:
kernel/umh.c: fix some spelling mistakes

Xiaofeng Cao <[email protected]>:
kernel/user_namespace.c: fix typos

Bhaskar Chowdhury <[email protected]>:
kernel/up.c: fix typo

Xiaofeng Cao <[email protected]>:
kernel/sys.c: fix typo

dingsenjie <[email protected]>:
fs: fat: fix spelling typo of values

Bhaskar Chowdhury <[email protected]>:
ipc/sem.c: spelling fix

Masahiro Yamada <[email protected]>:
treewide: remove editor modelines and cruft

Ingo Molnar <[email protected]>:
mm: fix typos in comments

Lu Jialin <[email protected]>:
mm: fix typos in comments

 Documentation/admin-guide/devices.txt                         |    2 
 Documentation/admin-guide/kdump/kdump.rst                     |    3 
 Documentation/admin-guide/kernel-parameters.txt               |   18 
 Documentation/dev-tools/gdb-kernel-debugging.rst              |    4 
 MAINTAINERS                                                   |   16 
 arch/Kconfig                                                  |   20 
 arch/alpha/include/asm/io.h                                   |    5 
 arch/alpha/kernel/pc873xx.c                                   |    4 
 arch/alpha/lib/csum_partial_copy.c                            |    1 
 arch/arm/configs/dove_defconfig                               |    1 
 arch/arm/configs/magician_defconfig                           |    1 
 arch/arm/configs/moxart_defconfig                             |    1 
 arch/arm/configs/mps2_defconfig                               |    1 
 arch/arm/configs/mvebu_v5_defconfig                           |    1 
 arch/arm/configs/xcep_defconfig                               |    1 
 arch/arm/include/asm/bug.h                                    |    1 
 arch/arm/include/asm/io.h                                     |    5 
 arch/arm/kernel/process.c                                     |   11 
 arch/arm/kernel/traps.c                                       |    1 
 arch/h8300/include/asm/bitops.h                               |    8 
 arch/hexagon/configs/comet_defconfig                          |    1 
 arch/hexagon/include/asm/io.h                                 |    1 
 arch/ia64/include/asm/io.h                                    |    1 
 arch/ia64/include/asm/uaccess.h                               |   18 
 arch/m68k/atari/time.c                                        |    7 
 arch/m68k/configs/amcore_defconfig                            |    1 
 arch/m68k/include/asm/bitops.h                                |    6 
 arch/m68k/include/asm/io_mm.h                                 |    5 
 arch/mips/include/asm/io.h                                    |    5 
 arch/openrisc/configs/or1ksim_defconfig                       |    1 
 arch/parisc/include/asm/io.h                                  |    5 
 arch/parisc/include/asm/pdc_chassis.h                         |    1 
 arch/powerpc/include/asm/io.h                                 |    5 
 arch/s390/include/asm/io.h                                    |    5 
 arch/sh/configs/edosk7705_defconfig                           |    1 
 arch/sh/configs/se7206_defconfig                              |    1 
 arch/sh/configs/sh2007_defconfig                              |    1 
 arch/sh/configs/sh7724_generic_defconfig                      |    1 
 arch/sh/configs/sh7770_generic_defconfig                      |    1 
 arch/sh/configs/sh7785lcr_32bit_defconfig                     |    1 
 arch/sh/include/asm/bitops.h                                  |    5 
 arch/sh/include/asm/io.h                                      |    5 
 arch/sparc/configs/sparc64_defconfig                          |    1 
 arch/sparc/include/asm/io_64.h                                |    5 
 arch/um/drivers/cow.h                                         |    7 
 arch/xtensa/configs/xip_kc705_defconfig                       |    1 
 block/blk-settings.c                                          |    1 
 drivers/auxdisplay/panel.c                                    |    7 
 drivers/base/firmware_loader/main.c                           |    2 
 drivers/block/brd.c                                           |    1 
 drivers/block/loop.c                                          |    1 
 drivers/char/Kconfig                                          |   10 
 drivers/char/mem.c                                            |  231 --------
 drivers/gpu/drm/qxl/qxl_drv.c                                 |    1 
 drivers/isdn/capi/kcapi_proc.c                                |    1 
 drivers/md/bcache/super.c                                     |    1 
 drivers/media/usb/pwc/pwc-uncompress.c                        |    3 
 drivers/net/ethernet/adaptec/starfire.c                       |    8 
 drivers/net/ethernet/amd/atarilance.c                         |    8 
 drivers/net/ethernet/amd/pcnet32.c                            |    7 
 drivers/net/wireless/intersil/hostap/hostap_proc.c            |    1 
 drivers/net/wireless/intersil/orinoco/orinoco_nortel.c        |    8 
 drivers/net/wireless/intersil/orinoco/orinoco_pci.c           |    8 
 drivers/net/wireless/intersil/orinoco/orinoco_plx.c           |    8 
 drivers/net/wireless/intersil/orinoco/orinoco_tmd.c           |    8 
 drivers/nvdimm/btt.c                                          |    1 
 drivers/nvdimm/pmem.c                                         |    1 
 drivers/parport/parport_ip32.c                                |   12 
 drivers/platform/x86/dell/dell_rbu.c                          |    3 
 drivers/scsi/53c700.c                                         |    1 
 drivers/scsi/53c700.h                                         |    1 
 drivers/scsi/ch.c                                             |    6 
 drivers/scsi/esas2r/esas2r_main.c                             |    1 
 drivers/scsi/ips.c                                            |   20 
 drivers/scsi/ips.h                                            |   20 
 drivers/scsi/lasi700.c                                        |    1 
 drivers/scsi/megaraid/mbox_defs.h                             |    2 
 drivers/scsi/megaraid/mega_common.h                           |    2 
 drivers/scsi/megaraid/megaraid_mbox.c                         |    2 
 drivers/scsi/megaraid/megaraid_mbox.h                         |    2 
 drivers/scsi/qla1280.c                                        |   12 
 drivers/scsi/scsicam.c                                        |    1 
 drivers/scsi/sni_53c710.c                                     |    1 
 drivers/video/fbdev/matrox/matroxfb_base.c                    |    9 
 drivers/video/fbdev/vga16fb.c                                 |   10 
 fs/configfs/configfs_internal.h                               |    4 
 fs/configfs/dir.c                                             |    4 
 fs/configfs/file.c                                            |    4 
 fs/configfs/inode.c                                           |    4 
 fs/configfs/item.c                                            |    4 
 fs/configfs/mount.c                                           |    4 
 fs/configfs/symlink.c                                         |    4 
 fs/eventpoll.c                                                |    6 
 fs/fat/fatent.c                                               |    2 
 fs/hpfs/hpfs.h                                                |    3 
 fs/isofs/rock.c                                               |    1 
 fs/nfs/dir.c                                                  |    7 
 fs/nfs/nfs4proc.c                                             |    6 
 fs/nfs/nfs4renewd.c                                           |    6 
 fs/nfs/nfs4state.c                                            |    6 
 fs/nfs/nfs4xdr.c                                              |    6 
 fs/nfsd/nfs4proc.c                                            |    6 
 fs/nfsd/nfs4xdr.c                                             |    6 
 fs/nfsd/xdr4.h                                                |    6 
 fs/nilfs2/cpfile.c                                            |    2 
 fs/nilfs2/ioctl.c                                             |    4 
 fs/nilfs2/segment.c                                           |    4 
 fs/nilfs2/the_nilfs.c                                         |    2 
 fs/ocfs2/acl.c                                                |    4 
 fs/ocfs2/acl.h                                                |    4 
 fs/ocfs2/alloc.c                                              |    4 
 fs/ocfs2/alloc.h                                              |    4 
 fs/ocfs2/aops.c                                               |    4 
 fs/ocfs2/aops.h                                               |    4 
 fs/ocfs2/blockcheck.c                                         |    4 
 fs/ocfs2/blockcheck.h                                         |    4 
 fs/ocfs2/buffer_head_io.c                                     |    4 
 fs/ocfs2/buffer_head_io.h                                     |    4 
 fs/ocfs2/cluster/heartbeat.c                                  |    4 
 fs/ocfs2/cluster/heartbeat.h                                  |    4 
 fs/ocfs2/cluster/masklog.c                                    |    4 
 fs/ocfs2/cluster/masklog.h                                    |    4 
 fs/ocfs2/cluster/netdebug.c                                   |    4 
 fs/ocfs2/cluster/nodemanager.c                                |    4 
 fs/ocfs2/cluster/nodemanager.h                                |    4 
 fs/ocfs2/cluster/ocfs2_heartbeat.h                            |    4 
 fs/ocfs2/cluster/ocfs2_nodemanager.h                          |    4 
 fs/ocfs2/cluster/quorum.c                                     |    4 
 fs/ocfs2/cluster/quorum.h                                     |    4 
 fs/ocfs2/cluster/sys.c                                        |    4 
 fs/ocfs2/cluster/sys.h                                        |    4 
 fs/ocfs2/cluster/tcp.c                                        |    4 
 fs/ocfs2/cluster/tcp.h                                        |    4 
 fs/ocfs2/cluster/tcp_internal.h                               |    4 
 fs/ocfs2/dcache.c                                             |    4 
 fs/ocfs2/dcache.h                                             |    4 
 fs/ocfs2/dir.c                                                |    4 
 fs/ocfs2/dir.h                                                |    4 
 fs/ocfs2/dlm/dlmapi.h                                         |    4 
 fs/ocfs2/dlm/dlmast.c                                         |    4 
 fs/ocfs2/dlm/dlmcommon.h                                      |    4 
 fs/ocfs2/dlm/dlmconvert.c                                     |    4 
 fs/ocfs2/dlm/dlmconvert.h                                     |    4 
 fs/ocfs2/dlm/dlmdebug.c                                       |    4 
 fs/ocfs2/dlm/dlmdebug.h                                       |    4 
 fs/ocfs2/dlm/dlmdomain.c                                      |    4 
 fs/ocfs2/dlm/dlmdomain.h                                      |    4 
 fs/ocfs2/dlm/dlmlock.c                                        |    4 
 fs/ocfs2/dlm/dlmmaster.c                                      |    4 
 fs/ocfs2/dlm/dlmrecovery.c                                    |    4 
 fs/ocfs2/dlm/dlmthread.c                                      |    4 
 fs/ocfs2/dlm/dlmunlock.c                                      |    4 
 fs/ocfs2/dlmfs/dlmfs.c                                        |    4 
 fs/ocfs2/dlmfs/userdlm.c                                      |    4 
 fs/ocfs2/dlmfs/userdlm.h                                      |    4 
 fs/ocfs2/dlmglue.c                                            |    4 
 fs/ocfs2/dlmglue.h                                            |    4 
 fs/ocfs2/export.c                                             |    4 
 fs/ocfs2/export.h                                             |    4 
 fs/ocfs2/extent_map.c                                         |    4 
 fs/ocfs2/extent_map.h                                         |    4 
 fs/ocfs2/file.c                                               |    4 
 fs/ocfs2/file.h                                               |    4 
 fs/ocfs2/filecheck.c                                          |    4 
 fs/ocfs2/filecheck.h                                          |    4 
 fs/ocfs2/heartbeat.c                                          |    4 
 fs/ocfs2/heartbeat.h                                          |    4 
 fs/ocfs2/inode.c                                              |    4 
 fs/ocfs2/inode.h                                              |    4 
 fs/ocfs2/journal.c                                            |    4 
 fs/ocfs2/journal.h                                            |    4 
 fs/ocfs2/localalloc.c                                         |    4 
 fs/ocfs2/localalloc.h                                         |    4 
 fs/ocfs2/locks.c                                              |    4 
 fs/ocfs2/locks.h                                              |    4 
 fs/ocfs2/mmap.c                                               |    4 
 fs/ocfs2/move_extents.c                                       |    4 
 fs/ocfs2/move_extents.h                                       |    4 
 fs/ocfs2/namei.c                                              |    4 
 fs/ocfs2/namei.h                                              |    4 
 fs/ocfs2/ocfs1_fs_compat.h                                    |    4 
 fs/ocfs2/ocfs2.h                                              |    4 
 fs/ocfs2/ocfs2_fs.h                                           |    4 
 fs/ocfs2/ocfs2_ioctl.h                                        |    4 
 fs/ocfs2/ocfs2_lockid.h                                       |    4 
 fs/ocfs2/ocfs2_lockingver.h                                   |    4 
 fs/ocfs2/refcounttree.c                                       |    4 
 fs/ocfs2/refcounttree.h                                       |    4 
 fs/ocfs2/reservations.c                                       |    4 
 fs/ocfs2/reservations.h                                       |    4 
 fs/ocfs2/resize.c                                             |    4 
 fs/ocfs2/resize.h                                             |    4 
 fs/ocfs2/slot_map.c                                           |    4 
 fs/ocfs2/slot_map.h                                           |    4 
 fs/ocfs2/stack_o2cb.c                                         |    4 
 fs/ocfs2/stack_user.c                                         |    4 
 fs/ocfs2/stackglue.c                                          |    4 
 fs/ocfs2/stackglue.h                                          |    4 
 fs/ocfs2/suballoc.c                                           |    4 
 fs/ocfs2/suballoc.h                                           |    4 
 fs/ocfs2/super.c                                              |    4 
 fs/ocfs2/super.h                                              |    4 
 fs/ocfs2/symlink.c                                            |    4 
 fs/ocfs2/symlink.h                                            |    4 
 fs/ocfs2/sysfile.c                                            |    4 
 fs/ocfs2/sysfile.h                                            |    4 
 fs/ocfs2/uptodate.c                                           |    4 
 fs/ocfs2/uptodate.h                                           |    4 
 fs/ocfs2/xattr.c                                              |    4 
 fs/ocfs2/xattr.h                                              |    4 
 fs/proc/generic.c                                             |   13 
 fs/proc/inode.c                                               |   18 
 fs/proc/proc_sysctl.c                                         |    2 
 fs/reiserfs/procfs.c                                          |   10 
 include/asm-generic/bitops/find.h                             |  108 +++
 include/asm-generic/bitops/le.h                               |   38 +
 include/asm-generic/bitsperlong.h                             |   12 
 include/asm-generic/io.h                                      |   11 
 include/linux/align.h                                         |   15 
 include/linux/async.h                                         |    1 
 include/linux/bitmap.h                                        |   11 
 include/linux/bitops.h                                        |   12 
 include/linux/blkdev.h                                        |    1 
 include/linux/compat.h                                        |    1 
 include/linux/configfs.h                                      |    4 
 include/linux/crc8.h                                          |    2 
 include/linux/cred.h                                          |    1 
 include/linux/delayacct.h                                     |   20 
 include/linux/fs.h                                            |    2 
 include/linux/genl_magic_func.h                               |    1 
 include/linux/genl_magic_struct.h                             |    1 
 include/linux/gfp.h                                           |    2 
 include/linux/init_task.h                                     |    1 
 include/linux/initrd.h                                        |    2 
 include/linux/kernel.h                                        |    9 
 include/linux/mm.h                                            |    2 
 include/linux/mmzone.h                                        |    2 
 include/linux/pgtable.h                                       |   10 
 include/linux/proc_fs.h                                       |    1 
 include/linux/profile.h                                       |    3 
 include/linux/smp.h                                           |    8 
 include/linux/swap.h                                          |    1 
 include/linux/vmalloc.h                                       |    7 
 include/uapi/linux/if_bonding.h                               |   11 
 include/uapi/linux/nfs4.h                                     |    6 
 include/xen/interface/elfnote.h                               |   10 
 include/xen/interface/hvm/hvm_vcpu.h                          |   10 
 include/xen/interface/io/xenbus.h                             |   10 
 init/Kconfig                                                  |   12 
 init/initramfs.c                                              |   38 +
 init/main.c                                                   |    1 
 ipc/sem.c                                                     |   12 
 kernel/async.c                                                |   68 --
 kernel/configs/android-base.config                            |    1 
 kernel/crash_core.c                                           |    7 
 kernel/cred.c                                                 |    2 
 kernel/exit.c                                                 |   67 ++
 kernel/fork.c                                                 |   23 
 kernel/gcov/Kconfig                                           |    1 
 kernel/gcov/base.c                                            |   49 +
 kernel/gcov/clang.c                                           |  282 ----------
 kernel/gcov/fs.c                                              |  146 ++++-
 kernel/gcov/gcc_4_7.c                                         |  173 ------
 kernel/gcov/gcov.h                                            |   14 
 kernel/kexec_core.c                                           |    4 
 kernel/kexec_file.c                                           |    4 
 kernel/kmod.c                                                 |    2 
 kernel/resource.c                                             |  198 ++++---
 kernel/sys.c                                                  |   14 
 kernel/umh.c                                                  |    8 
 kernel/up.c                                                   |    2 
 kernel/user_namespace.c                                       |    6 
 lib/bch.c                                                     |    2 
 lib/crc8.c                                                    |    2 
 lib/decompress_unlzma.c                                       |    2 
 lib/find_bit.c                                                |   68 --
 lib/genalloc.c                                                |    7 
 lib/list_sort.c                                               |    2 
 lib/parser.c                                                  |   61 +-
 lib/percpu_counter.c                                          |    2 
 lib/stackdepot.c                                              |    6 
 mm/balloon_compaction.c                                       |    4 
 mm/compaction.c                                               |    4 
 mm/filemap.c                                                  |    2 
 mm/gup.c                                                      |    2 
 mm/highmem.c                                                  |    2 
 mm/huge_memory.c                                              |    6 
 mm/hugetlb.c                                                  |    6 
 mm/internal.h                                                 |    2 
 mm/kasan/kasan.h                                              |    8 
 mm/kasan/quarantine.c                                         |    4 
 mm/kasan/shadow.c                                             |    4 
 mm/kfence/report.c                                            |    2 
 mm/khugepaged.c                                               |    2 
 mm/ksm.c                                                      |    6 
 mm/madvise.c                                                  |    4 
 mm/memcontrol.c                                               |   18 
 mm/memory-failure.c                                           |    2 
 mm/memory.c                                                   |   18 
 mm/mempolicy.c                                                |    6 
 mm/migrate.c                                                  |    8 
 mm/mmap.c                                                     |    4 
 mm/mprotect.c                                                 |    2 
 mm/mremap.c                                                   |    2 
 mm/nommu.c                                                    |   10 
 mm/oom_kill.c                                                 |    2 
 mm/page-writeback.c                                           |    4 
 mm/page_alloc.c                                               |   16 
 mm/page_owner.c                                               |    2 
 mm/page_vma_mapped.c                                          |    2 
 mm/percpu-internal.h                                          |    2 
 mm/percpu.c                                                   |    2 
 mm/pgalloc-track.h                                            |    6 
 mm/rmap.c                                                     |    2 
 mm/slab.c                                                     |    8 
 mm/slub.c                                                     |    2 
 mm/swap.c                                                     |    4 
 mm/swap_slots.c                                               |    2 
 mm/swap_state.c                                               |    2 
 mm/vmalloc.c                                                  |  124 ----
 mm/vmstat.c                                                   |    2 
 mm/z3fold.c                                                   |    2 
 mm/zpool.c                                                    |    2 
 mm/zsmalloc.c                                                 |    6 
 samples/configfs/configfs_sample.c                            |    2 
 scripts/checkpatch.pl                                         |   15 
 scripts/gdb/linux/cpus.py                                     |   23 
 scripts/gdb/linux/symbols.py                                  |    3 
 scripts/spelling.txt                                          |    3 
 tools/include/asm-generic/bitops/find.h                       |   85 ++-
 tools/include/asm-generic/bitsperlong.h                       |    3 
 tools/include/linux/bitmap.h                                  |   18 
 tools/lib/bitmap.c                                            |    4 
 tools/lib/find_bit.c                                          |   56 -
 tools/scripts/Makefile.include                                |    1 
 tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c |   44 +
 tools/testing/selftests/kvm/lib/sparsebit.c                   |    1 
 tools/testing/selftests/mincore/mincore_selftest.c            |    1 
 tools/testing/selftests/powerpc/mm/tlbie_test.c               |    1 
 tools/testing/selftests/proc/Makefile                         |    1 
 tools/testing/selftests/proc/proc-subset-pid.c                |  121 ++++
 tools/testing/selftests/proc/read.c                           |    4 
 tools/usb/hcd-tests.sh                                        |    2 
 343 files changed, 1383 insertions(+), 2119 deletions(-)
author maintainer
#1 lore raw

PATCH 1/91 alpha: eliminate old-style function definitions

From: Randy Dunlap <[email protected]>
Subject: alpha: eliminate old-style function definitions

'make ARCH=alpha W=1' reports a couple of old-style function definitions with missing parameter list, so fix those.

../arch/alpha/kernel/pc873xx.c: In function 'pc873xx_get_base':
../arch/alpha/kernel/pc873xx.c:16:21: warning: old-style function definition [-Wold-style-definition]
16 | unsigned int __init pc873xx_get_base()

../arch/alpha/kernel/pc873xx.c: In function 'pc873xx_get_model':
../arch/alpha/kernel/pc873xx.c:21:14: warning: old-style function definition [-Wold-style-definition]
21 | char *__init pc873xx_get_model()

---

 arch/alpha/kernel/pc873xx.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/alpha/kernel/pc873xx.c renamed from arch/alpha/kernel/pc873xx.c~alpha-eliminate-old-style-function-definitions +2 -2
@@ -13,12 +13,12 @@ static char *pc873xx_names[] = {
 static unsigned int base, model;
 
 
-unsigned int __init pc873xx_get_base()
+unsigned int __init pc873xx_get_base(void)
 {
 	return base;
 }
 
-char *__init pc873xx_get_model()
+char *__init pc873xx_get_model(void)
 {
 	return pc873xx_names[model];
 }

_

author maintainer
#2 lore raw

PATCH 2/91 alpha: csum_partial_copy.c: add function prototypes from <net/checksum.h>

In reply to Andrew Morton

From: Randy Dunlap <[email protected]>
Subject: alpha: csum_partial_copy.c: add function prototypes from <net/checksum.h>

Fix "no previous prototype" W=1 warnings from the kernel test robot:

../arch/alpha/lib/csum_partial_copy.c:349:1: error: no previous prototype for 'csum_and_copy_from_user' [-Werror=missing-prototypes]
349 | csum_and_copy_from_user(const void __user *src, void *dst, int len)

      | ^~~~~~~~~~~~~~~~~~~~~~~
../arch/alpha/lib/csum_partial_copy.c:358:1: error: no previous prototype for 'csum_partial_copy_nocheck' [-Werror=missing-prototypes]
  358 | csum_partial_copy_nocheck(const void *src, void *dst, int len)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
Fixes 808b49da54e6 ("alpha: turn csum_partial_copy_from_user() into csum_and_copy_from_user()")
Cc Al Viro <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc Matt Turner <[email protected]>

---

 arch/alpha/lib/csum_partial_copy.c |    1 +
 1 file changed, 1 insertion(+)
arch/alpha/lib/csum_partial_copy.c renamed from arch/alpha/lib/csum_partial_copy.c~alpha-csum_partial_copyc-add-function-prototypes-from-net-checksumh +1 -0
@@ -13,6 +13,7 @@
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/uaccess.h>
+#include <net/checksum.h>
 
 
 #define ldq_u(x,y) \

_

author maintainer
#3 lore raw

PATCH 3/91 fs/proc/generic.c: fix incorrect pde_is_permanent check

In reply to Andrew Morton

From: Colin Ian King <[email protected]>
Subject: fs/proc/generic.c: fix incorrect pde_is_permanent check

Currently the pde_is_permanent() check is being run on root multiple times rather than on the next proc directory entry. This looks like a copy-paste error. Fix this by replacing root with next.

Addresses-Coverity: ("Copy-paste error")

Fixes d919b33dafb3 ("proc: faster open/read/close with "permanent" files")
Cc Greg Kroah-Hartman <[email protected]>

---

 fs/proc/generic.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/generic.c renamed from fs/proc/generic.c~proc-fix-incorrect-pde_is_permanent-check +1 -1
@@ -756,7 +756,7 @@ int remove_proc_subtree(const char *name
 	while (1) {
 		next = pde_subdir_first(de);
 		if (next) {
-			if (unlikely(pde_is_permanent(root))) {
+			if (unlikely(pde_is_permanent(next))) {
 				write_unlock(&proc_subdir_lock);
 				WARN(1, "removing permanent /proc entry '%s/%s'",
 					next->parent->name, next->name);

_

author maintainer
#4 lore raw

PATCH 4/91 proc: save LOC in __xlate_proc_name()

In reply to Andrew Morton

From: Alexey Dobriyan <[email protected]>
Subject: proc: save LOC in __xlate_proc_name()

Can't look at this verbosity anymore.

---

 fs/proc/generic.c |   11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
fs/proc/generic.c renamed from fs/proc/generic.c~proc-save-loc-in-__xlate_proc_name +2 -9
@@ -166,15 +166,8 @@ static int __xlate_proc_name(const char
 	const char     		*cp = name, *next;
 	struct proc_dir_entry	*de;
 
-	de = *ret;
-	if (!de)
-		de = &proc_root;
-
-	while (1) {
-		next = strchr(cp, '/');
-		if (!next)
-			break;
-
+	de = *ret ?: &proc_root;
+	while ((next = strchr(cp, '/'))) {
 		de = pde_subdir_find(de, cp, next - cp);
 		if (!de) {
 			WARN(1, "name '%s'\n", name);

_

#5 lore raw

Re: [patch 04/91] proc: save LOC in __xlate_proc_name()

Quoted 3 lines · Andrew Morton

From: Alexey Dobriyan <[email protected]>
Subject: proc: save LOC in __xlate_proc_name()

..

Quoted 1 line

+ while ((next = strchr(cp, '/'))) {

Please don't do this.

Yes, gcc suggests that double parentheses syntax around an assignment to avoid warnings.

gcc is wrong, and is being completely stupid.

The proper way to avoid the "assignment in conditional" warning is to (surprise, surprise) USE A CONDITIONAL.

So that

          while ((next = strchr(cp, '/'))) {

is the crazy rantings of a misguided compiler. No sane human should ever care about some odd double parenthesis syntax. We're not writing LISP, for chrissake.

The proper way to write this is

          while ((next = strchr(cp, '/')) != NULL) {

which makes sense to not just a machine, but to a human, and avoids the whole "assignment used as a conditional" warning very naturally.

See? Now it uses a conditional as a conditional. Doesn't that make a whole lot more sense than the crazy ramblings of a broken machine mind?

I fixed it up manually, I just wanted to rant against this kind of "mindlessly take advice from the compiler without thinking about it".

Linus

#6 lore raw

Re: [patch 04/91] proc: save LOC in __xlate_proc_name()

Quoted 8 lines · Linus Torvalds
Quoted 3 lines · Andrew Morton

From: Alexey Dobriyan <[email protected]>
Subject: proc: save LOC in __xlate_proc_name()

..

Quoted 1 line

+ while ((next = strchr(cp, '/'))) {

Please don't do this.

It is actually how it should be done.

Kernel has such code in other places

	#define hlist_for_each(pos, head) \
	        for (pos = (head)->first; pos ; pos = pos->next)

And we do check pointers for validness like this

	if (ptr) {
	}

"while" loop is no different.

Quoted 2 lines

Yes, gcc suggests that double parentheses syntax around an assignment to avoid warnings.

I never saw this warning. I just wrote double parenth knowing the warning will be emitted. It's an old warning.

Quoted 9 lines

gcc is wrong, and is being completely stupid.

The proper way to avoid the "assignment in conditional" warning is to (surprise, surprise) USE A CONDITIONAL.

So that

          while ((next = strchr(cp, '/'))) {
Quoted 7 lines

is the crazy rantings of a misguided compiler. No sane human should ever care about some odd double parenthesis syntax. We're not writing LISP, for chrissake.

The proper way to write this is

          while ((next = strchr(cp, '/')) != NULL) {

This NULL is redundant in the same way "if (ptr != NULL)" is redundant. Even more so in C where comparison can't be overloaded.
You don't even save the parenth.

Quoted 9 lines

which makes sense to not just a machine, but to a human, and avoids the whole "assignment used as a conditional" warning very naturally.

See? Now it uses a conditional as a conditional. Doesn't that make a whole lot more sense than the crazy ramblings of a broken machine mind?

I fixed it up manually, I just wanted to rant against this kind of "mindlessly take advice from the compiler without thinking about it".

#7 lore raw

Re: [patch 04/91] proc: save LOC in __xlate_proc_name()

Quoted 8 lines · Alexey Dobriyan
Quoted 4 lines · Linus Torvalds

..

Quoted 1 line

+ while ((next = strchr(cp, '/'))) {

Please don't do this.

It is actually how it should be done.

No, Alexey, it really isn't.

Quoted 1 line

Kernel has such code in other places

.. and then you show that you do not understand the problem at all.

It's the unacceptable "double parentheses" disease I'm talking about. The "other places" you bring up DO NOT DO THAT.

Quoted 1 line

"while" loop is no different.

This is not at all about the while loop. Comprende?

We don't do

if ((a = b)) ..

or

while ((a = b)) ..

or anything like that.

Why? Because that is pure and utter crazy garbage. The above syntax is just insane.

Quoted 2 lines

I never saw this warning. I just wrote double parenth knowing the warning will be emitted. It's an old warning.

Yes, and you picked the wrong solution for it. You picked the "write bad code just to make the warning go away".

We don't make warnings go away by writing insane and bad code. We write sane code.

So I repeat:

Quoted 3 lines
Quoted 3 lines

The proper way to write this is

          while ((next = strchr(cp, '/')) != NULL) {

Notice the difference?

Because the "hide a warning by adding random parentheses" is not the way we do things in the kernel.

So yes, we also write

    while (next) {..

and you are correct that this case doesn't need the " != NULL".

But notice how it also doesn't need the crazy extra parentheses?

Linus

author maintainer
#8 lore raw

PATCH 5/91 proc: mandate ->proc_lseek in "struct proc_ops"

In reply to Andrew Morton

From: Alexey Dobriyan <[email protected]>
Subject: proc: mandate ->proc_lseek in "struct proc_ops"

Now that proc_ops are separate from file_operations and other operations it easy to check all instances to have ->proc_lseek hook and remove check in main code.

Note:
nonseekable_open() files naturally don't require ->proc_lseek.

Garbage collect pde_lseek() function.

---

 drivers/isdn/capi/kcapi_proc.c                     |    1 
 drivers/net/wireless/intersil/hostap/hostap_proc.c |    1 
 drivers/scsi/esas2r/esas2r_main.c                  |    1 
 fs/proc/inode.c                                    |   14 +----------
 include/linux/proc_fs.h                            |    1 
 tools/testing/selftests/proc/read.c                |    4 ++-
 6 files changed, 9 insertions(+), 13 deletions(-)
drivers/isdn/capi/kcapi_proc.c renamed from drivers/isdn/capi/kcapi_proc.c~proc-mandate-proc_lseek-in-struct-proc_ops +1 -0
@@ -201,6 +201,7 @@ static ssize_t empty_read(struct file *f
 
 static const struct proc_ops empty_proc_ops = {
 	.proc_read	= empty_read,
+	.proc_lseek	= default_llseek,
 };
 
 // ---------------------------------------------------------------------------
drivers/net/wireless/intersil/hostap/hostap_proc.c renamed from drivers/net/wireless/intersil/hostap/hostap_proc.c~proc-mandate-proc_lseek-in-struct-proc_ops +1 -0
@@ -227,6 +227,7 @@ static ssize_t prism2_aux_dump_proc_no_r
 
 static const struct proc_ops prism2_aux_dump_proc_ops = {
 	.proc_read	= prism2_aux_dump_proc_no_read,
+	.proc_lseek	= default_llseek,
 };
 
 
drivers/scsi/esas2r/esas2r_main.c renamed from drivers/scsi/esas2r/esas2r_main.c~proc-mandate-proc_lseek-in-struct-proc_ops +1 -0
@@ -616,6 +616,7 @@ static const struct file_operations esas
 };
 
 static const struct proc_ops esas2r_proc_ops = {
+	.proc_lseek		= default_llseek,
 	.proc_ioctl		= esas2r_proc_ioctl,
 #ifdef CONFIG_COMPAT
 	.proc_compat_ioctl	= compat_ptr_ioctl,
fs/proc/inode.c renamed from fs/proc/inode.c~proc-mandate-proc_lseek-in-struct-proc_ops +2 -12
@@ -273,25 +273,15 @@ void proc_entry_rundown(struct proc_dir_
 	spin_unlock(&de->pde_unload_lock);
 }
 
-static loff_t pde_lseek(struct proc_dir_entry *pde, struct file *file, loff_t offset, int whence)
-{
-	typeof_member(struct proc_ops, proc_lseek) lseek;
-
-	lseek = pde->proc_ops->proc_lseek;
-	if (!lseek)
-		lseek = default_llseek;
-	return lseek(file, offset, whence);
-}
-
 static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence)
 {
 	struct proc_dir_entry *pde = PDE(file_inode(file));
 	loff_t rv = -EINVAL;
 
 	if (pde_is_permanent(pde)) {
-		return pde_lseek(pde, file, offset, whence);
+		return pde->proc_ops->proc_lseek(file, offset, whence);
 	} else if (use_pde(pde)) {
-		rv = pde_lseek(pde, file, offset, whence);
+		rv = pde->proc_ops->proc_lseek(file, offset, whence);
 		unuse_pde(pde);
 	}
 	return rv;
include/linux/proc_fs.h renamed from include/linux/proc_fs.h~proc-mandate-proc_lseek-in-struct-proc_ops +1 -0
@@ -32,6 +32,7 @@ struct proc_ops {
 	ssize_t	(*proc_read)(struct file *, char __user *, size_t, loff_t *);
 	ssize_t (*proc_read_iter)(struct kiocb *, struct iov_iter *);
 	ssize_t	(*proc_write)(struct file *, const char __user *, size_t, loff_t *);
+	/* mandatory unless nonseekable_open() or equivalent is used */
 	loff_t	(*proc_lseek)(struct file *, loff_t, int);
 	int	(*proc_release)(struct inode *, struct file *);
 	__poll_t (*proc_poll)(struct file *, struct poll_table_struct *);
tools/testing/selftests/proc/read.c renamed from tools/testing/selftests/proc/read.c~proc-mandate-proc_lseek-in-struct-proc_ops +3 -1
@@ -14,7 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 // Test
-// 1) read of every file in /proc
+// 1) read and lseek on every file in /proc
 // 2) readlink of every symlink in /proc
 // 3) recursively (1) + (2) for every directory in /proc
 // 4) write to /proc/*/clear_refs and /proc/*/task/*/clear_refs
@@ -45,6 +45,8 @@ static void f_reg(DIR *d, const char *fi
 	fd = openat(dirfd(d), filename, O_RDONLY|O_NONBLOCK);
 	if (fd == -1)
 		return;
+	/* struct proc_ops::proc_lseek is mandatory if file is seekable. */
+	(void)lseek(fd, 0, SEEK_SET);
 	rv = read(fd, buf, sizeof(buf));
 	assert((0 <= rv && rv <= sizeof(buf)) || rv == -1);
 	close(fd);

_

author maintainer
#9 lore raw

PATCH 6/91 proc: delete redundant subset=pid check

In reply to Andrew Morton

From: Alexey Dobriyan <[email protected]>
Subject: proc: delete redundant subset=pid check

Two checks in lookup and readdir code should be enough to not have third check in open code.

Can't open what can't be looked up?

---

 fs/proc/inode.c |    4 ----
 1 file changed, 4 deletions(-)
fs/proc/inode.c renamed from fs/proc/inode.c~proc-delete-redundant-subset=pid-check +0 -4
@@ -483,7 +483,6 @@ proc_reg_get_unmapped_area(struct file *
 
 static int proc_reg_open(struct inode *inode, struct file *file)
 {
-	struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
 	struct proc_dir_entry *pde = PDE(inode);
 	int rv = 0;
 	typeof_member(struct proc_ops, proc_open) open;
@@ -497,9 +496,6 @@ static int proc_reg_open(struct inode *i
 		return rv;
 	}
 
-	if (fs_info->pidonly == PROC_PIDONLY_ON)
-		return -ENOENT;
-
 	/*
 	 * Ensure that
 	 * 1) PDE's ->release hook will be called no matter what

_

author maintainer
#10 lore raw

PATCH 7/91 selftests: proc: test subset=pid

In reply to Andrew Morton

From: Alexey Dobriyan <[email protected]>
Subject: selftests: proc: test subset=pid

Test that /proc instance mounted with

mount -t proc -o subset=pid

contains only ".", "..", "self", "thread-self" and pid directories.

Note:
Currently "subset=pid" doesn't return "." and ".." via readdir. This must be a bug.

---

 tools/testing/selftests/proc/Makefile          |    1 
 tools/testing/selftests/proc/proc-subset-pid.c |  121 +++++++++++++++
 2 files changed, 122 insertions(+)
tools/testing/selftests/proc/Makefile renamed from tools/testing/selftests/proc/Makefile~proc-test-subset=pid +1 -0
@@ -12,6 +12,7 @@ TEST_GEN_PROGS += proc-self-map-files-00
 TEST_GEN_PROGS += proc-self-map-files-002
 TEST_GEN_PROGS += proc-self-syscall
 TEST_GEN_PROGS += proc-self-wchan
+TEST_GEN_PROGS += proc-subset-pid
 TEST_GEN_PROGS += proc-uptime-001
 TEST_GEN_PROGS += proc-uptime-002
 TEST_GEN_PROGS += read
tools/testing/selftests/proc/proc-subset-pid.c new file +121 -0

121 lines not on this page · raw message

_

author maintainer
#11 lore raw

PATCH 8/91 proc/sysctl: fix function name error in comments

In reply to Andrew Morton

From: zhouchuangao <[email protected]>
Subject: proc/sysctl: fix function name error in comments

The function name should be modified to register_sysctl_paths instead of register_sysctl_table_path.

---

 fs/proc/proc_sysctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/proc_sysctl.c renamed from fs/proc/proc_sysctl.c~proc-sysctl-fix-function-name-error-in-comments +1 -1
@@ -1563,7 +1563,7 @@ err_register_leaves:
 }
 
 /**
- * register_sysctl_table_path - register a sysctl table hierarchy
+ * register_sysctl_paths - register a sysctl table hierarchy
  * @path: The path to the directory the sysctl table is in.
  * @table: the top-level table structure
  *

_

author maintainer
#12 lore raw

PATCH 9/91 include: remove pagemap.h from blkdev.h

In reply to Andrew Morton

From: "Matthew Wilcox (Oracle)" <[email protected]>
Subject: include: remove pagemap.h from blkdev.h

My UEK-derived config has 1030 files depending on pagemap.h before this change. Afterwards, just 326 files need to be rebuilt when I touch pagemap.h. I think blkdev.h is probably included too widely, but untangling that dependency is harder and this solves my problem. x86 allmodconfig builds, but there may be implicit include problems on other architectures.

---

 block/blk-settings.c      |    1 +
 drivers/block/brd.c       |    1 +
 drivers/block/loop.c      |    1 +
 drivers/md/bcache/super.c |    1 +
 drivers/nvdimm/btt.c      |    1 +
 drivers/nvdimm/pmem.c     |    1 +
 drivers/scsi/scsicam.c    |    1 +
 include/linux/blkdev.h    |    1 -
 include/linux/swap.h      |    1 +
 9 files changed, 8 insertions(+), 1 deletion(-)
block/blk-settings.c renamed from block/blk-settings.c~include-remove-pagemaph-from-blkdevh +1 -0
@@ -7,6 +7,7 @@
 #include <linux/init.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/pagemap.h>
 #include <linux/gcd.h>
 #include <linux/lcm.h>
 #include <linux/jiffies.h>
drivers/block/brd.c renamed from drivers/block/brd.c~include-remove-pagemaph-from-blkdevh +1 -0
@@ -18,6 +18,7 @@
 #include <linux/bio.h>
 #include <linux/highmem.h>
 #include <linux/mutex.h>
+#include <linux/pagemap.h>
 #include <linux/radix-tree.h>
 #include <linux/fs.h>
 #include <linux/slab.h>
drivers/block/loop.c renamed from drivers/block/loop.c~include-remove-pagemaph-from-blkdevh +1 -0
@@ -53,6 +53,7 @@
 #include <linux/moduleparam.h>
 #include <linux/sched.h>
 #include <linux/fs.h>
+#include <linux/pagemap.h>
 #include <linux/file.h>
 #include <linux/stat.h>
 #include <linux/errno.h>
drivers/md/bcache/super.c renamed from drivers/md/bcache/super.c~include-remove-pagemaph-from-blkdevh +1 -0
@@ -16,6 +16,7 @@
 #include "features.h"
 
 #include <linux/blkdev.h>
+#include <linux/pagemap.h>
 #include <linux/debugfs.h>
 #include <linux/genhd.h>
 #include <linux/idr.h>
drivers/nvdimm/btt.c renamed from drivers/nvdimm/btt.c~include-remove-pagemaph-from-blkdevh +1 -0
@@ -6,6 +6,7 @@
 #include <linux/highmem.h>
 #include <linux/debugfs.h>
 #include <linux/blkdev.h>
+#include <linux/pagemap.h>
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
drivers/nvdimm/pmem.c renamed from drivers/nvdimm/pmem.c~include-remove-pagemaph-from-blkdevh +1 -0
@@ -8,6 +8,7 @@
  */
 
 #include <linux/blkdev.h>
+#include <linux/pagemap.h>
 #include <linux/hdreg.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
drivers/scsi/scsicam.c renamed from drivers/scsi/scsicam.c~include-remove-pagemaph-from-blkdevh +1 -0
@@ -17,6 +17,7 @@
 #include <linux/genhd.h>
 #include <linux/kernel.h>
 #include <linux/blkdev.h>
+#include <linux/pagemap.h>
 #include <linux/msdos_partition.h>
 #include <asm/unaligned.h>
 
include/linux/blkdev.h renamed from include/linux/blkdev.h~include-remove-pagemaph-from-blkdevh +0 -1
@@ -11,7 +11,6 @@
 #include <linux/minmax.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
-#include <linux/pagemap.h>
 #include <linux/backing-dev-defs.h>
 #include <linux/wait.h>
 #include <linux/mempool.h>
include/linux/swap.h renamed from include/linux/swap.h~include-remove-pagemaph-from-blkdevh +1 -0
@@ -10,6 +10,7 @@
 #include <linux/sched.h>
 #include <linux/node.h>
 #include <linux/fs.h>
+#include <linux/pagemap.h>
 #include <linux/atomic.h>
 #include <linux/page-flags.h>
 #include <uapi/linux/mempolicy.h>

_

author maintainer
#13 lore raw

PATCH 10/91 kernel.h: drop inclusion in bitmap.h

In reply to Andrew Morton

From: Andy Shevchenko <[email protected]>
Subject: kernel.h: drop inclusion in bitmap.h

The bitmap.h header is used in a lot of code around the kernel. Besides that it includes kernel.h which sometimes makes a loop.

The problem here is many unneeded loops that make header hell dependencies. For example, how may you move bitmap_zalloc() from C-file to the header? Currently it's impossible. And bitmap.h here is only the tip of an iceberg.

kerne.h is a dump of everything that even has nothing in common at all. We may still have it, but in my new code I prefer to include only the headers that I want to use, without the bulk of unneeded kernel code.

Break the loop by introducing align.h, including it in kernel.h and bitmap.h followed by replacing kernel.h with limits.h.

---

 include/linux/align.h  |   15 +++++++++++++++
 include/linux/bitmap.h |    3 ++-
 include/linux/kernel.h |    9 +--------
 3 files changed, 18 insertions(+), 9 deletions(-)
include/linux/align.h new file +15 -0
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_ALIGN_H
+#define _LINUX_ALIGN_H
+
+#include <linux/const.h>
+
+/* @a is a power of 2 value */
+#define ALIGN(x, a)		__ALIGN_KERNEL((x), (a))
+#define ALIGN_DOWN(x, a)	__ALIGN_KERNEL((x) - ((a) - 1), (a))
+#define __ALIGN_MASK(x, mask)	__ALIGN_KERNEL_MASK((x), (mask))
+#define PTR_ALIGN(p, a)		((typeof(p))ALIGN((unsigned long)(p), (a)))
+#define PTR_ALIGN_DOWN(p, a)	((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
+#define IS_ALIGNED(x, a)		(((x) & ((typeof(x))(a) - 1)) == 0)
+
+#endif	/* _LINUX_ALIGN_H */
include/linux/bitmap.h renamed from include/linux/bitmap.h~kernelh-drop-inclusion-in-bitmaph +2 -1
@@ -4,10 +4,11 @@
 
 #ifndef __ASSEMBLY__
 
+#include <linux/align.h>
 #include <linux/types.h>
 #include <linux/bitops.h>
+#include <linux/limits.h>
 #include <linux/string.h>
-#include <linux/kernel.h>
 
 /*
  * bitmaps provide bit arrays that consume one or more unsigned
include/linux/kernel.h renamed from include/linux/kernel.h~kernelh-drop-inclusion-in-bitmaph +1 -8
@@ -3,6 +3,7 @@
 #define _LINUX_KERNEL_H
 
 #include <stdarg.h>
+#include <linux/align.h>
 #include <linux/limits.h>
 #include <linux/linkage.h>
 #include <linux/stddef.h>
@@ -30,14 +31,6 @@
  */
 #define REPEAT_BYTE(x)	((~0ul / 0xff) * (x))
 
-/* @a is a power of 2 value */
-#define ALIGN(x, a)		__ALIGN_KERNEL((x), (a))
-#define ALIGN_DOWN(x, a)	__ALIGN_KERNEL((x) - ((a) - 1), (a))
-#define __ALIGN_MASK(x, mask)	__ALIGN_KERNEL_MASK((x), (mask))
-#define PTR_ALIGN(p, a)		((typeof(p))ALIGN((unsigned long)(p), (a)))
-#define PTR_ALIGN_DOWN(p, a)	((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
-#define IS_ALIGNED(x, a)		(((x) & ((typeof(x))(a) - 1)) == 0)
-
 /* generic data direction definitions */
 #define READ			0
 #define WRITE			1

_

author maintainer
#14 lore raw

PATCH 11/91 linux/profile.h: remove unnecessary declaration

In reply to Andrew Morton

From: Wan Jiabing <[email protected]>
Subject: linux/profile.h: remove unnecessary declaration

Declaring struct pt_regs is unnecessary. On the one hand, there is no function using it; on the other hand, struct pt_regs has been declared in linux/kernel.h. Remove them.

---

 include/linux/profile.h |    3 ---
 1 file changed, 3 deletions(-)
include/linux/profile.h renamed from include/linux/profile.h~linux-profileh-remove-unnecessary-declaration +0 -3
@@ -15,7 +15,6 @@
 #define KVM_PROFILING	4
 
 struct proc_dir_entry;
-struct pt_regs;
 struct notifier_block;
 
 #if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
@@ -84,8 +83,6 @@ int task_handoff_unregister(struct notif
 int profile_event_register(enum profile_type, struct notifier_block * n);
 int profile_event_unregister(enum profile_type, struct notifier_block * n);
 
-struct pt_regs;
-
 #else
 
 #define prof_on 0

_

author maintainer
#15 lore raw

PATCH 12/91 kernel/async.c: fix pr_debug statement

In reply to Andrew Morton

From: Rasmus Villemoes <[email protected]>
Subject: kernel/async.c: fix pr_debug statement

An async_func_t returns void - any errors encountered it has to stash somewhere for consumers to discover later.

---

 kernel/async.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/async.c renamed from kernel/async.c~kernel-asyncc-fix-pr_debug-statement +1 -1
@@ -124,7 +124,7 @@ static void async_run_entry_fn(struct wo
 	if (initcall_debug && system_state < SYSTEM_RUNNING) {
 		rettime = ktime_get();
 		delta = ktime_sub(rettime, calltime);
-		pr_debug("initcall %lli_%pS returned 0 after %lld usecs\n",
+		pr_debug("initcall %lli_%pS returned after %lld usecs\n",
 			(long long)entry->cookie,
 			entry->func,
 			(long long)ktime_to_ns(delta) >> 10);

_

author maintainer
#16 lore raw

PATCH 13/91 kernel/cred.c: make init_groups static

In reply to Andrew Morton

From: Rasmus Villemoes <[email protected]>
Subject: kernel/cred.c: make init_groups static

init_groups is declared in both cred.h and init_task.h, but it is not actually referenced anywhere outside of cred.c where it is defined. So make it static and remove the declarations.

---

 include/linux/cred.h      |    1 -
 include/linux/init_task.h |    1 -
 kernel/cred.c             |    2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)
include/linux/cred.h renamed from include/linux/cred.h~kernel-credc-make-init_groups-static +0 -1
@@ -53,7 +53,6 @@ do {							\
 		groups_free(group_info);		\
 } while (0)
 
-extern struct group_info init_groups;
 #ifdef CONFIG_MULTIUSER
 extern struct group_info *groups_alloc(int);
 extern void groups_free(struct group_info *);
include/linux/init_task.h renamed from include/linux/init_task.h~kernel-credc-make-init_groups-static +0 -1
@@ -25,7 +25,6 @@
 extern struct files_struct init_files;
 extern struct fs_struct init_fs;
 extern struct nsproxy init_nsproxy;
-extern struct group_info init_groups;
 extern struct cred init_cred;
 
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
kernel/cred.c renamed from kernel/cred.c~kernel-credc-make-init_groups-static +1 -1
@@ -33,7 +33,7 @@ do {									\
 static struct kmem_cache *cred_jar;
 
 /* init to 2 - one for init_task, one to ensure it is never freed */
-struct group_info init_groups = { .usage = ATOMIC_INIT(2) };
+static struct group_info init_groups = { .usage = ATOMIC_INIT(2) };
 
 /*
  * The initial credentials for the initial task

_

author maintainer
#17 lore raw

PATCH 14/91 tools: disable -Wno-type-limits

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: tools: disable -Wno-type-limits

Patch series "lib/find_bit: fast path for small bitmaps", v6.

Bitmap operations are much simpler and faster in case of small bitmaps which fit into a single word. In linux/bitmap.c we have a machinery that allows compiler to replace actual function call with a few instructions if bitmaps passed into the function are small and their size is known at compile time.

find_*_bit() API lacks this functionality; but users will benefit from it a lot. One important example is cpumask subsystem when NR_CPUS <= BITS_PER_LONG.

This patch (of 12):

GENMASK(h, l) may be passed with unsigned types. In such case, type-limits warning is generated for example in case of GENMASK(h, 0).

Cc Alexey Klimov <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 tools/scripts/Makefile.include |    1 +
 1 file changed, 1 insertion(+)
tools/scripts/Makefile.include renamed from tools/scripts/Makefile.include~tools-disable-wno-type-limits +1 -0
@@ -38,6 +38,7 @@ EXTRA_WARNINGS += -Wswitch-enum
 EXTRA_WARNINGS += -Wundef
 EXTRA_WARNINGS += -Wwrite-strings
 EXTRA_WARNINGS += -Wformat
+EXTRA_WARNINGS += -Wno-type-limits
 
 # Makefiles suck: This macro sets a default value of $(2) for the
 # variable named by $(1), unless the variable has been set by

_

author maintainer
#18 lore raw

PATCH 15/91 tools: bitmap: sync function declarations with the kernel

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: tools: bitmap: sync function declarations with the kernel

Some functions in tools/include/linux/bitmap.h declare nbits as int. In the kernel nbits is declared as unsigned int.

Cc Alexey Klimov <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 tools/include/linux/bitmap.h |    8 ++++----
 tools/lib/bitmap.c           |    4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
tools/include/linux/bitmap.h renamed from tools/include/linux/bitmap.h~tools-bitmap-sync-function-declarations-with-the-kernel +4 -4
@@ -30,7 +30,7 @@ void bitmap_clear(unsigned long *map, un
 #define small_const_nbits(nbits) \
 	(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
 
-static inline void bitmap_zero(unsigned long *dst, int nbits)
+static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
 {
 	if (small_const_nbits(nbits))
 		*dst = 0UL;
@@ -66,7 +66,7 @@ static inline int bitmap_full(const unsi
 	return find_first_zero_bit(src, nbits) == nbits;
 }
 
-static inline int bitmap_weight(const unsigned long *src, int nbits)
+static inline int bitmap_weight(const unsigned long *src, unsigned int nbits)
 {
 	if (small_const_nbits(nbits))
 		return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
@@ -74,7 +74,7 @@ static inline int bitmap_weight(const un
 }
 
 static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
-			     const unsigned long *src2, int nbits)
+			     const unsigned long *src2, unsigned int nbits)
 {
 	if (small_const_nbits(nbits))
 		*dst = *src1 | *src2;
@@ -141,7 +141,7 @@ static inline void bitmap_free(unsigned
  * @buf: buffer to store output
  * @size: size of @buf
  */
-size_t bitmap_scnprintf(unsigned long *bitmap, int nbits,
+size_t bitmap_scnprintf(unsigned long *bitmap, unsigned int nbits,
 			char *buf, size_t size);
 
 /**
tools/lib/bitmap.c renamed from tools/lib/bitmap.c~tools-bitmap-sync-function-declarations-with-the-kernel +2 -2
@@ -28,11 +28,11 @@ void __bitmap_or(unsigned long *dst, con
 		dst[k] = bitmap1[k] | bitmap2[k];
 }
 
-size_t bitmap_scnprintf(unsigned long *bitmap, int nbits,
+size_t bitmap_scnprintf(unsigned long *bitmap, unsigned int nbits,
 			char *buf, size_t size)
 {
 	/* current bit is 'cur', most recently seen range is [rbot, rtop] */
-	int cur, rbot, rtop;
+	unsigned int cur, rbot, rtop;
 	bool first = true;
 	size_t ret = 0;
 

_

author maintainer
#19 lore raw

PATCH 16/91 tools: sync BITMAP_LAST_WORD_MASK() macro with the kernel

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: tools: sync BITMAP_LAST_WORD_MASK() macro with the kernel

Kernel version generates better code.

Cc Alexey Klimov <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 tools/include/linux/bitmap.h |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
tools/include/linux/bitmap.h renamed from tools/include/linux/bitmap.h~tools-sync-bitmap_last_word_mask-macro-with-the-kernel +1 -6
@@ -20,12 +20,7 @@ int __bitmap_equal(const unsigned long *
 void bitmap_clear(unsigned long *map, unsigned int start, int len);
 
 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
-
-#define BITMAP_LAST_WORD_MASK(nbits)					\
-(									\
-	((nbits) % BITS_PER_LONG) ?					\
-		(1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL		\
-)
+#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
 
 #define small_const_nbits(nbits) \
 	(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)

_

author maintainer
#20 lore raw

PATCH 17/91 arch: rearrange headers inclusion order in asm/bitops for m68k, sh and h8300

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: arch: rearrange headers inclusion order in asm/bitops for m68k, sh and h8300

m68k and sh include bitmap/{find,le}.h prior to ffs/fls headers. New fast-path implementation in find.h requires ffs/fls. Reordering the headers inclusion sequence helps to prevent compile-time implicit function declaration error.

[[email protected]: h8300: rearrange headers inclusion order in asm/bitops]
Cc Alexey Klimov <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 arch/h8300/include/asm/bitops.h |    8 ++++----
 arch/m68k/include/asm/bitops.h  |    6 +++---
 arch/sh/include/asm/bitops.h    |    5 +++--
 3 files changed, 10 insertions(+), 9 deletions(-)
arch/h8300/include/asm/bitops.h renamed from arch/h8300/include/asm/bitops.h~arch-rearrange-headers-inclusion-order-in-asm-bitops-for-m68k-and-sh +4 -4
@@ -9,6 +9,10 @@
 
 #include <linux/compiler.h>
 
+#include <asm-generic/bitops/fls.h>
+#include <asm-generic/bitops/__fls.h>
+#include <asm-generic/bitops/fls64.h>
+
 #ifdef __KERNEL__
 
 #ifndef _LINUX_BITOPS_H
@@ -173,8 +177,4 @@ static inline unsigned long __ffs(unsign
 
 #endif /* __KERNEL__ */
 
-#include <asm-generic/bitops/fls.h>
-#include <asm-generic/bitops/__fls.h>
-#include <asm-generic/bitops/fls64.h>
-
 #endif /* _H8300_BITOPS_H */
arch/m68k/include/asm/bitops.h renamed from arch/m68k/include/asm/bitops.h~arch-rearrange-headers-inclusion-order-in-asm-bitops-for-m68k-and-sh +3 -3
@@ -440,8 +440,6 @@ static inline unsigned long ffz(unsigned
 
 #endif
 
-#include <asm-generic/bitops/find.h>
-
 #ifdef __KERNEL__
 
 #if defined(CONFIG_CPU_HAS_NO_BITFIELDS)
@@ -525,10 +523,12 @@ static inline int __fls(int x)
 #define __clear_bit_unlock	clear_bit_unlock
 
 #include <asm-generic/bitops/ext2-atomic.h>
-#include <asm-generic/bitops/le.h>
 #include <asm-generic/bitops/fls64.h>
 #include <asm-generic/bitops/sched.h>
 #include <asm-generic/bitops/hweight.h>
+#include <asm-generic/bitops/le.h>
 #endif /* __KERNEL__ */
 
+#include <asm-generic/bitops/find.h>
+
 #endif /* _M68K_BITOPS_H */
arch/sh/include/asm/bitops.h renamed from arch/sh/include/asm/bitops.h~arch-rearrange-headers-inclusion-order-in-asm-bitops-for-m68k-and-sh +3 -2
@@ -58,15 +58,16 @@ static inline unsigned long __ffs(unsign
 	return result;
 }
 
-#include <asm-generic/bitops/find.h>
 #include <asm-generic/bitops/ffs.h>
 #include <asm-generic/bitops/hweight.h>
 #include <asm-generic/bitops/lock.h>
 #include <asm-generic/bitops/sched.h>
-#include <asm-generic/bitops/le.h>
 #include <asm-generic/bitops/ext2-atomic.h>
 #include <asm-generic/bitops/fls.h>
 #include <asm-generic/bitops/__fls.h>
 #include <asm-generic/bitops/fls64.h>
 
+#include <asm-generic/bitops/le.h>
+#include <asm-generic/bitops/find.h>
+
 #endif /* __ASM_SH_BITOPS_H */

_

author maintainer
#21 lore raw

PATCH 18/91 lib: extend the scope of small_const_nbits() macro

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: lib: extend the scope of small_const_nbits() macro

find_bit would also benefit from small_const_nbits() optimizations. The detailed comment is provided by Rasmus Villemoes.

Cc Alexey Klimov <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 include/asm-generic/bitsperlong.h |   12 ++++++++++++
 include/linux/bitmap.h            |    8 --------
 2 files changed, 12 insertions(+), 8 deletions(-)
include/asm-generic/bitsperlong.h renamed from include/asm-generic/bitsperlong.h~lib-extend-the-scope-of-small_const_nbits-macro +12 -0
@@ -23,4 +23,16 @@
 #define BITS_PER_LONG_LONG 64
 #endif
 
+/*
+ * small_const_nbits(n) is true precisely when it is known at compile-time
+ * that BITMAP_SIZE(n) is 1, i.e. 1 <= n <= BITS_PER_LONG. This allows
+ * various bit/bitmap APIs to provide a fast inline implementation. Bitmaps
+ * of size 0 are very rare, and a compile-time-known-size 0 is most likely
+ * a sign of error. They will be handled correctly by the bit/bitmap APIs,
+ * but using the out-of-line functions, so that the inline implementations
+ * can unconditionally dereference the pointer(s).
+ */
+#define small_const_nbits(nbits) \
+	(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG && (nbits) > 0)
+
 #endif /* __ASM_GENERIC_BITS_PER_LONG */
include/linux/bitmap.h renamed from include/linux/bitmap.h~lib-extend-the-scope-of-small_const_nbits-macro +0 -8
@@ -223,14 +223,6 @@ extern int bitmap_print_to_pagebuf(bool
 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
 #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
 
-/*
- * The static inlines below do not handle constant nbits==0 correctly,
- * so make such users (should any ever turn up) call the out-of-line
- * versions.
- */
-#define small_const_nbits(nbits) \
-	(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG && (nbits) > 0)
-
 static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
 {
 	unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);

_

author maintainer
#22 lore raw

PATCH 19/91 tools: sync small_const_nbits() macro with the kernel

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: tools: sync small_const_nbits() macro with the kernel

Sync implementation with the kernel and move the macro from tools/include/linux/bitmap.h to tools/include/asm-generic/bitsperlong.h

Cc Alexey Klimov <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 tools/include/asm-generic/bitsperlong.h |    3 +++
 tools/include/linux/bitmap.h            |    3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/include/asm-generic/bitsperlong.h renamed from tools/include/asm-generic/bitsperlong.h~tools-sync-small_const_nbits-macro-with-the-kernel +3 -0
@@ -18,4 +18,7 @@
 #define BITS_PER_LONG_LONG 64
 #endif
 
+#define small_const_nbits(nbits) \
+	(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG && (nbits) > 0)
+
 #endif /* __ASM_GENERIC_BITS_PER_LONG */
tools/include/linux/bitmap.h renamed from tools/include/linux/bitmap.h~tools-sync-small_const_nbits-macro-with-the-kernel +0 -3
@@ -22,9 +22,6 @@ void bitmap_clear(unsigned long *map, un
 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
 #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
 
-#define small_const_nbits(nbits) \
-	(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
-
 static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
 {
 	if (small_const_nbits(nbits))

_

author maintainer
#23 lore raw

PATCH 20/91 lib: inline _find_next_bit() wrappers

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: lib: inline _find_next_bit() wrappers

lib/find_bit.c declares five single-line wrappers for _find_next_bit(). We may turn those wrappers to inline functions. It eliminates unneeded function calls and opens room for compile-time optimizations.

Cc Alexey Klimov <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 include/asm-generic/bitops/find.h |   28 +++++++++++---
 include/asm-generic/bitops/le.h   |   17 ++++++--
 lib/find_bit.c                    |   56 +---------------------------
 3 files changed, 37 insertions(+), 64 deletions(-)
include/asm-generic/bitops/find.h renamed from include/asm-generic/bitops/find.h~lib-inline-_find_next_bit-wrappers +22 -6
@@ -2,6 +2,10 @@
 #ifndef _ASM_GENERIC_BITOPS_FIND_H_
 #define _ASM_GENERIC_BITOPS_FIND_H_
 
+extern unsigned long _find_next_bit(const unsigned long *addr1,
+		const unsigned long *addr2, unsigned long nbits,
+		unsigned long start, unsigned long invert, unsigned long le);
+
 #ifndef find_next_bit
 /**
  * find_next_bit - find the next set bit in a memory region
@@ -12,8 +16,12 @@
  * Returns the bit number for the next set bit
  * If no bits are set, returns @size.
  */
-extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
-		size, unsigned long offset);
+static inline
+unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
+			    unsigned long offset)
+{
+	return _find_next_bit(addr, NULL, size, offset, 0UL, 0);
+}
 #endif
 
 #ifndef find_next_and_bit
@@ -27,9 +35,13 @@ extern unsigned long find_next_bit(const
  * Returns the bit number for the next set bit
  * If no bits are set, returns @size.
  */
-extern unsigned long find_next_and_bit(const unsigned long *addr1,
+static inline
+unsigned long find_next_and_bit(const unsigned long *addr1,
 		const unsigned long *addr2, unsigned long size,
-		unsigned long offset);
+		unsigned long offset)
+{
+	return _find_next_bit(addr1, addr2, size, offset, 0UL, 0);
+}
 #endif
 
 #ifndef find_next_zero_bit
@@ -42,8 +54,12 @@ extern unsigned long find_next_and_bit(c
  * Returns the bit number of the next zero bit
  * If no bits are zero, returns @size.
  */
-extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
-		long size, unsigned long offset);
+static inline
+unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
+				 unsigned long offset)
+{
+	return _find_next_bit(addr, NULL, size, offset, ~0UL, 0);
+}
 #endif
 
 #ifdef CONFIG_GENERIC_FIND_FIRST_BIT
include/asm-generic/bitops/le.h renamed from include/asm-generic/bitops/le.h~lib-inline-_find_next_bit-wrappers +13 -4
@@ -2,6 +2,7 @@
 #ifndef _ASM_GENERIC_BITOPS_LE_H_
 #define _ASM_GENERIC_BITOPS_LE_H_
 
+#include <asm-generic/bitops/find.h>
 #include <asm/types.h>
 #include <asm/byteorder.h>
 
@@ -32,13 +33,21 @@ static inline unsigned long find_first_z
 #define BITOP_LE_SWIZZLE	((BITS_PER_LONG-1) & ~0x7)
 
 #ifndef find_next_zero_bit_le
-extern unsigned long find_next_zero_bit_le(const void *addr,
-		unsigned long size, unsigned long offset);
+static inline
+unsigned long find_next_zero_bit_le(const void *addr, unsigned
+		long size, unsigned long offset)
+{
+	return _find_next_bit(addr, NULL, size, offset, ~0UL, 1);
+}
 #endif
 
 #ifndef find_next_bit_le
-extern unsigned long find_next_bit_le(const void *addr,
-		unsigned long size, unsigned long offset);
+static inline
+unsigned long find_next_bit_le(const void *addr, unsigned
+		long size, unsigned long offset)
+{
+	return _find_next_bit(addr, NULL, size, offset, 0UL, 1);
+}
 #endif
 
 #ifndef find_first_zero_bit_le
lib/find_bit.c renamed from lib/find_bit.c~lib-inline-_find_next_bit-wrappers +2 -54

74 lines not on this page · raw message

_

author maintainer
#24 lore raw

PATCH 21/91 tools: sync find_next_bit implementation

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: tools: sync find_next_bit implementation

Sync the implementation with recent kernel changes.

Cc Alexey Klimov <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 tools/include/asm-generic/bitops/find.h |   27 ++++++++---
 tools/lib/find_bit.c                    |   52 ++++++++--------------
 2 files changed, 42 insertions(+), 37 deletions(-)
tools/include/asm-generic/bitops/find.h renamed from tools/include/asm-generic/bitops/find.h~tools-sync-find_next_bit-implementation +21 -6
@@ -2,6 +2,10 @@
 #ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_
 #define _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_
 
+extern unsigned long _find_next_bit(const unsigned long *addr1,
+		const unsigned long *addr2, unsigned long nbits,
+		unsigned long start, unsigned long invert, unsigned long le);
+
 #ifndef find_next_bit
 /**
  * find_next_bit - find the next set bit in a memory region
@@ -12,8 +16,12 @@
  * Returns the bit number for the next set bit
  * If no bits are set, returns @size.
  */
-extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
-		size, unsigned long offset);
+static inline
+unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
+			    unsigned long offset)
+{
+	return _find_next_bit(addr, NULL, size, offset, 0UL, 0);
+}
 #endif
 
 #ifndef find_next_and_bit
@@ -27,13 +35,16 @@ extern unsigned long find_next_bit(const
  * Returns the bit number for the next set bit
  * If no bits are set, returns @size.
  */
-extern unsigned long find_next_and_bit(const unsigned long *addr1,
+static inline
+unsigned long find_next_and_bit(const unsigned long *addr1,
 		const unsigned long *addr2, unsigned long size,
-		unsigned long offset);
+		unsigned long offset)
+{
+	return _find_next_bit(addr1, addr2, size, offset, 0UL, 0);
+}
 #endif
 
 #ifndef find_next_zero_bit
-
 /**
  * find_next_zero_bit - find the next cleared bit in a memory region
  * @addr: The address to base the search on
@@ -43,8 +54,12 @@ extern unsigned long find_next_and_bit(c
  * Returns the bit number of the next zero bit
  * If no bits are zero, returns @size.
  */
+static inline
 unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
-				 unsigned long offset);
+				 unsigned long offset)
+{
+	return _find_next_bit(addr, NULL, size, offset, ~0UL, 0);
+}
 #endif
 
 #ifndef find_first_bit
tools/lib/find_bit.c renamed from tools/lib/find_bit.c~tools-sync-find_next_bit-implementation +21 -31

77 lines not on this page · raw message

_

author maintainer
#25 lore raw

PATCH 22/91 lib: add fast path for find_next_*_bit()

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: lib: add fast path for find_next_*_bit()

Similarly to bitmap functions, find_next_*_bit() users will benefit if we'll handle a case of bitmaps that fit into a single word inline. In the very best case, the compiler may replace a function call with a few instructions.

This is the quite typical find_next_bit() user:

	unsigned int cpumask_next(int n, const struct cpumask *srcp)
	{
		/* -1 is a legal arg here. */
		if (n != -1)
			cpumask_check(n);
		return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1);
	}
	EXPORT_SYMBOL(cpumask_next);

Currently, on ARM64 the generated code looks like this:

	0000000000000000 <cpumask_next>:
	   0:   a9bf7bfd        stp     x29, x30, [sp, #-16]!
	   4:   11000402        add     w2, w0, #0x1
	   8:   aa0103e0        mov     x0, x1
	   c:   d2800401        mov     x1, #0x40                       // #64
	  10:   910003fd        mov     x29, sp
	  14:   93407c42        sxtw    x2, w2
	  18:   94000000        bl      0 <find_next_bit>
	  1c:   a8c17bfd        ldp     x29, x30, [sp], #16
	  20:   d65f03c0        ret
	  24:   d503201f        nop

After applying this patch:

	0000000000000140 <cpumask_next>:
	 140:   11000400        add     w0, w0, #0x1
	 144:   93407c00        sxtw    x0, w0
	 148:   f100fc1f        cmp     x0, #0x3f
	 14c:   54000168        b.hi    178 <cpumask_next+0x38>  // b.pmore
	 150:   f9400023        ldr     x3, [x1]
	 154:   92800001        mov     x1, #0xffffffffffffffff         // #-1
	 158:   9ac02020        lsl     x0, x1, x0
	 15c:   52800802        mov     w2, #0x40                       // #64
	 160:   8a030001        and     x1, x0, x3
	 164:   dac00020        rbit    x0, x1
	 168:   f100003f        cmp     x1, #0x0
	 16c:   dac01000        clz     x0, x0
	 170:   1a800040        csel    w0, w2, w0, eq  // eq = none
	 174:   d65f03c0        ret
	 178:   52800800        mov     w0, #0x40                       // #64
	 17c:   d65f03c0        ret

find_next_bit() call is replaced with 6 instructions. find_next_bit() itself is 41 instructions plus function call overhead.

Despite inlining, the scripts/bloat-o-meter report smaller .text size after applying the series:

	add/remove: 11/9 grow/shrink: 233/176 up/down: 5780/-6768 (-988)
Cc Alexey Klimov <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 include/asm-generic/bitops/find.h |   30 ++++++++++++++++++++++++++++
 include/asm-generic/bitops/le.h   |   21 +++++++++++++++++++
 2 files changed, 51 insertions(+)
include/asm-generic/bitops/find.h renamed from include/asm-generic/bitops/find.h~lib-add-fast-path-for-find_next__bit +30 -0
@@ -20,6 +20,16 @@ static inline
 unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
 			    unsigned long offset)
 {
+	if (small_const_nbits(size)) {
+		unsigned long val;
+
+		if (unlikely(offset >= size))
+			return size;
+
+		val = *addr & GENMASK(size - 1, offset);
+		return val ? __ffs(val) : size;
+	}
+
 	return _find_next_bit(addr, NULL, size, offset, 0UL, 0);
 }
 #endif
@@ -40,6 +50,16 @@ unsigned long find_next_and_bit(const un
 		const unsigned long *addr2, unsigned long size,
 		unsigned long offset)
 {
+	if (small_const_nbits(size)) {
+		unsigned long val;
+
+		if (unlikely(offset >= size))
+			return size;
+
+		val = *addr1 & *addr2 & GENMASK(size - 1, offset);
+		return val ? __ffs(val) : size;
+	}
+
 	return _find_next_bit(addr1, addr2, size, offset, 0UL, 0);
 }
 #endif
@@ -58,6 +78,16 @@ static inline
 unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
 				 unsigned long offset)
 {
+	if (small_const_nbits(size)) {
+		unsigned long val;
+
+		if (unlikely(offset >= size))
+			return size;
+
+		val = *addr | ~GENMASK(size - 1, offset);
+		return val == ~0UL ? size : ffz(val);
+	}
+
 	return _find_next_bit(addr, NULL, size, offset, ~0UL, 0);
 }
 #endif
include/asm-generic/bitops/le.h renamed from include/asm-generic/bitops/le.h~lib-add-fast-path-for-find_next__bit +21 -0
@@ -5,6 +5,7 @@
 #include <asm-generic/bitops/find.h>
 #include <asm/types.h>
 #include <asm/byteorder.h>
+#include <linux/swab.h>
 
 #if defined(__LITTLE_ENDIAN)
 
@@ -37,6 +38,16 @@ static inline
 unsigned long find_next_zero_bit_le(const void *addr, unsigned
 		long size, unsigned long offset)
 {
+	if (small_const_nbits(size)) {
+		unsigned long val = *(const unsigned long *)addr;
+
+		if (unlikely(offset >= size))
+			return size;
+
+		val = swab(val) | ~GENMASK(size - 1, offset);
+		return val == ~0UL ? size : ffz(val);
+	}
+
 	return _find_next_bit(addr, NULL, size, offset, ~0UL, 1);
 }
 #endif
@@ -46,6 +57,16 @@ static inline
 unsigned long find_next_bit_le(const void *addr, unsigned
 		long size, unsigned long offset)
 {
+	if (small_const_nbits(size)) {
+		unsigned long val = *(const unsigned long *)addr;
+
+		if (unlikely(offset >= size))
+			return size;
+
+		val = swab(val) & GENMASK(size - 1, offset);
+		return val ? __ffs(val) : size;
+	}
+
 	return _find_next_bit(addr, NULL, size, offset, 0UL, 1);
 }
 #endif

_

author maintainer
#26 lore raw

PATCH 23/91 lib: add fast path for find_first_*_bit() and find_last_bit()

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: lib: add fast path for find_first_*_bit() and find_last_bit()

Similarly to bitmap functions, users would benefit if we'll handle a case of small-size bitmaps that fit into a single word.

While here, move the find_last_bit() declaration to bitops/find.h where other find_*_bit() functions sit.

Cc Alexey Klimov <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 include/asm-generic/bitops/find.h |   50 +++++++++++++++++++++++++---
 include/linux/bitops.h            |   12 ------
 lib/find_bit.c                    |   12 +++---
 3 files changed, 52 insertions(+), 22 deletions(-)
include/asm-generic/bitops/find.h renamed from include/asm-generic/bitops/find.h~lib-add-fast-path-for-find_first__bit-and-find_last_bit +46 -4
@@ -5,6 +5,9 @@
 extern unsigned long _find_next_bit(const unsigned long *addr1,
 		const unsigned long *addr2, unsigned long nbits,
 		unsigned long start, unsigned long invert, unsigned long le);
+extern unsigned long _find_first_bit(const unsigned long *addr, unsigned long size);
+extern unsigned long _find_first_zero_bit(const unsigned long *addr, unsigned long size);
+extern unsigned long _find_last_bit(const unsigned long *addr, unsigned long size);
 
 #ifndef find_next_bit
 /**
@@ -102,8 +105,17 @@ unsigned long find_next_zero_bit(const u
  * Returns the bit number of the first set bit.
  * If no bits are set, returns @size.
  */
-extern unsigned long find_first_bit(const unsigned long *addr,
-				    unsigned long size);
+static inline
+unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
+{
+	if (small_const_nbits(size)) {
+		unsigned long val = *addr & GENMASK(size - 1, 0);
+
+		return val ? __ffs(val) : size;
+	}
+
+	return _find_first_bit(addr, size);
+}
 
 /**
  * find_first_zero_bit - find the first cleared bit in a memory region
@@ -113,8 +125,17 @@ extern unsigned long find_first_bit(cons
  * Returns the bit number of the first cleared bit.
  * If no bits are zero, returns @size.
  */
-extern unsigned long find_first_zero_bit(const unsigned long *addr,
-					 unsigned long size);
+static inline
+unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
+{
+	if (small_const_nbits(size)) {
+		unsigned long val = *addr | ~GENMASK(size - 1, 0);
+
+		return val == ~0UL ? size : ffz(val);
+	}
+
+	return _find_first_zero_bit(addr, size);
+}
 #else /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
 #ifndef find_first_bit
@@ -126,6 +147,27 @@ extern unsigned long find_first_zero_bit
 
 #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
+#ifndef find_last_bit
+/**
+ * find_last_bit - find the last set bit in a memory region
+ * @addr: The address to start the search at
+ * @size: The number of bits to search
+ *
+ * Returns the bit number of the last set bit, or size.
+ */
+static inline
+unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
+{
+	if (small_const_nbits(size)) {
+		unsigned long val = *addr & GENMASK(size - 1, 0);
+
+		return val ? __fls(val) : size;
+	}
+
+	return _find_last_bit(addr, size);
+}
+#endif
+
 /**
  * find_next_clump8 - find next 8-bit clump with set bits in a memory region
  * @clump: location to store copy of found clump
include/linux/bitops.h renamed from include/linux/bitops.h~lib-add-fast-path-for-find_first__bit-and-find_last_bit +0 -12
@@ -286,17 +286,5 @@ static __always_inline void __assign_bit
 })
 #endif
 
-#ifndef find_last_bit
-/**
- * find_last_bit - find the last set bit in a memory region
- * @addr: The address to start the search at
- * @size: The number of bits to search
- *
- * Returns the bit number of the last set bit, or size.
- */
-extern unsigned long find_last_bit(const unsigned long *addr,
-				   unsigned long size);
-#endif
-
 #endif /* __KERNEL__ */
 #endif
lib/find_bit.c renamed from lib/find_bit.c~lib-add-fast-path-for-find_first__bit-and-find_last_bit +6 -6
@@ -75,7 +75,7 @@ EXPORT_SYMBOL(_find_next_bit);
 /*
  * Find the first set bit in a memory region.
  */
-unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
+unsigned long _find_first_bit(const unsigned long *addr, unsigned long size)
 {
 	unsigned long idx;
 
@@ -86,14 +86,14 @@ unsigned long find_first_bit(const unsig
 
 	return size;
 }
-EXPORT_SYMBOL(find_first_bit);
+EXPORT_SYMBOL(_find_first_bit);
 #endif
 
 #ifndef find_first_zero_bit
 /*
  * Find the first cleared bit in a memory region.
  */
-unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
+unsigned long _find_first_zero_bit(const unsigned long *addr, unsigned long size)
 {
 	unsigned long idx;
 
@@ -104,11 +104,11 @@ unsigned long find_first_zero_bit(const
 
 	return size;
 }
-EXPORT_SYMBOL(find_first_zero_bit);
+EXPORT_SYMBOL(_find_first_zero_bit);
 #endif
 
 #ifndef find_last_bit
-unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
+unsigned long _find_last_bit(const unsigned long *addr, unsigned long size)
 {
 	if (size) {
 		unsigned long val = BITMAP_LAST_WORD_MASK(size);
@@ -124,7 +124,7 @@ unsigned long find_last_bit(const unsign
 	}
 	return size;
 }
-EXPORT_SYMBOL(find_last_bit);
+EXPORT_SYMBOL(_find_last_bit);
 #endif
 
 unsigned long find_next_clump8(unsigned long *clump, const unsigned long *addr,

_

author maintainer
#27 lore raw

PATCH 24/91 tools: sync lib/find_bit implementation

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: tools: sync lib/find_bit implementation

Add fast paths to find_*_bit() functions as per kernel implementation.

Cc Alexey Klimov <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 tools/include/asm-generic/bitops/find.h |   58 ++++++++++++++++++++--
 tools/lib/find_bit.c                    |    4 -
 2 files changed, 57 insertions(+), 5 deletions(-)
tools/include/asm-generic/bitops/find.h renamed from tools/include/asm-generic/bitops/find.h~tools-sync-lib-find_bit-implementation +55 -3
@@ -5,6 +5,9 @@
 extern unsigned long _find_next_bit(const unsigned long *addr1,
 		const unsigned long *addr2, unsigned long nbits,
 		unsigned long start, unsigned long invert, unsigned long le);
+extern unsigned long _find_first_bit(const unsigned long *addr, unsigned long size);
+extern unsigned long _find_first_zero_bit(const unsigned long *addr, unsigned long size);
+extern unsigned long _find_last_bit(const unsigned long *addr, unsigned long size);
 
 #ifndef find_next_bit
 /**
@@ -20,6 +23,16 @@ static inline
 unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
 			    unsigned long offset)
 {
+	if (small_const_nbits(size)) {
+		unsigned long val;
+
+		if (unlikely(offset >= size))
+			return size;
+
+		val = *addr & GENMASK(size - 1, offset);
+		return val ? __ffs(val) : size;
+	}
+
 	return _find_next_bit(addr, NULL, size, offset, 0UL, 0);
 }
 #endif
@@ -40,6 +53,16 @@ unsigned long find_next_and_bit(const un
 		const unsigned long *addr2, unsigned long size,
 		unsigned long offset)
 {
+	if (small_const_nbits(size)) {
+		unsigned long val;
+
+		if (unlikely(offset >= size))
+			return size;
+
+		val = *addr1 & *addr2 & GENMASK(size - 1, offset);
+		return val ? __ffs(val) : size;
+	}
+
 	return _find_next_bit(addr1, addr2, size, offset, 0UL, 0);
 }
 #endif
@@ -58,6 +81,16 @@ static inline
 unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
 				 unsigned long offset)
 {
+	if (small_const_nbits(size)) {
+		unsigned long val;
+
+		if (unlikely(offset >= size))
+			return size;
+
+		val = *addr | ~GENMASK(size - 1, offset);
+		return val == ~0UL ? size : ffz(val);
+	}
+
 	return _find_next_bit(addr, NULL, size, offset, ~0UL, 0);
 }
 #endif
@@ -72,8 +105,17 @@ unsigned long find_next_zero_bit(const u
  * Returns the bit number of the first set bit.
  * If no bits are set, returns @size.
  */
-extern unsigned long find_first_bit(const unsigned long *addr,
-				    unsigned long size);
+static inline
+unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
+{
+	if (small_const_nbits(size)) {
+		unsigned long val = *addr & GENMASK(size - 1, 0);
+
+		return val ? __ffs(val) : size;
+	}
+
+	return _find_first_bit(addr, size);
+}
 
 #endif /* find_first_bit */
 
@@ -87,7 +129,17 @@ extern unsigned long find_first_bit(cons
  * Returns the bit number of the first cleared bit.
  * If no bits are zero, returns @size.
  */
-unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size);
+static inline
+unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
+{
+	if (small_const_nbits(size)) {
+		unsigned long val = *addr | ~GENMASK(size - 1, 0);
+
+		return val == ~0UL ? size : ffz(val);
+	}
+
+	return _find_first_zero_bit(addr, size);
+}
 #endif
 
 #endif /*_TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_ */
tools/lib/find_bit.c renamed from tools/lib/find_bit.c~tools-sync-lib-find_bit-implementation +2 -2
@@ -83,7 +83,7 @@ unsigned long _find_next_bit(const unsig
 /*
  * Find the first set bit in a memory region.
  */
-unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
+unsigned long _find_first_bit(const unsigned long *addr, unsigned long size)
 {
 	unsigned long idx;
 
@@ -100,7 +100,7 @@ unsigned long find_first_bit(const unsig
 /*
  * Find the first cleared bit in a memory region.
  */
-unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
+unsigned long _find_first_zero_bit(const unsigned long *addr, unsigned long size)
 {
 	unsigned long idx;
 

_

author maintainer
#28 lore raw

PATCH 25/91 MAINTAINERS: add entry for the bitmap API

In reply to Andrew Morton

From: Yury Norov <[email protected]>
Subject: MAINTAINERS: add entry for the bitmap API

Add myself as maintainer for bitmap API and Andy and Rasmus as reviewers.

Cc Alexey Klimov <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Sterba <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Jianpeng Ma <[email protected]>
Cc Joe Perches <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Rich Felker <[email protected]>
Cc Stefano Brivio <[email protected]>
Cc Wei Yang <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 MAINTAINERS |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
MAINTAINERS renamed from MAINTAINERS~maintainers-add-entry-for-the-bitmap-api +16 -0
@@ -3205,6 +3205,22 @@ F:	Documentation/filesystems/bfs.rst
 F:	fs/bfs/
 F:	include/uapi/linux/bfs_fs.h
 
+BITMAP API
+M:	Yury Norov <[email protected]>
+R:	Andy Shevchenko <[email protected]>
+R:	Rasmus Villemoes <[email protected]>
+S:	Maintained
+F:	include/asm-generic/bitops/find.h
+F:	include/linux/bitmap.h
+F:	lib/bitmap.c
+F:	lib/find_bit.c
+F:	lib/find_bit_benchmark.c
+F:	lib/test_bitmap.c
+F:	tools/include/asm-generic/bitops/find.h
+F:	tools/include/linux/bitmap.h
+F:	tools/lib/bitmap.c
+F:	tools/lib/find_bit.c
+
 BLINKM RGB LED DRIVER
 M:	Jan-Simon Moeller <[email protected]>
 S:	Maintained

_

author maintainer
#29 lore raw

PATCH 26/91 lib/bch.c: fix a typo in the file bch.c

In reply to Andrew Morton

From: Bhaskar Chowdhury <[email protected]>
Subject: lib/bch.c: fix a typo in the file bch.c

s/buid/build/

---

 lib/bch.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bch.c renamed from lib/bch.c~lib-fix-a-typo-in-the-file-bchc +1 -1
@@ -584,7 +584,7 @@ static int find_affine4_roots(struct bch
 	k = a_log(bch, a);
 	rows[0] = c;
 
-	/* buid linear system to solve X^4+aX^2+bX+c = 0 */
+	/* build linear system to solve X^4+aX^2+bX+c = 0 */
 	for (i = 0; i < m; i++) {
 		rows[i+1] = bch->a_pow_tab[4*i]^
 			(a ? bch->a_pow_tab[mod_s(bch, k)] : 0)^

_

author maintainer
#30 lore raw

PATCH 27/91 lib: fix inconsistent indenting in process_bit1()

In reply to Andrew Morton

From: Wang Qing <[email protected]>
Subject: lib: fix inconsistent indenting in process_bit1()

Smatch gives the warning:
lib/decompress_unlzma.c:395 process_bit1() warn: inconsistent indenting

---

 lib/decompress_unlzma.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/decompress_unlzma.c renamed from lib/decompress_unlzma.c~lib-fix-inconsistent-indenting-in-process_bit1 +1 -1
@@ -391,7 +391,7 @@ static inline int INIT process_bit0(stru
 static inline int INIT process_bit1(struct writer *wr, struct rc *rc,
 					    struct cstate *cst, uint16_t *p,
 					    int pos_state, uint16_t *prob) {
-  int offset;
+	int offset;
 	uint16_t *prob_len;
 	int num_bits;
 	int len;

_

author maintainer
#31 lore raw

PATCH 28/91 lib/list_sort.c: fix typo in function description

In reply to Andrew Morton

From: ToastC <[email protected]>
Subject: lib/list_sort.c: fix typo in function description

Replace beautiully with beautifully

---

 lib/list_sort.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/list_sort.c renamed from lib/list_sort.c~lib-fix-typo-in-function-description +1 -1
@@ -137,7 +137,7 @@ static void merge_final(void *priv, list
  *
  *
  * The merging is controlled by "count", the number of elements in the
- * pending lists.  This is beautiully simple code, but rather subtle.
+ * pending lists.  This is beautifully simple code, but rather subtle.
  *
  * Each time we increment "count", we set one bit (bit k) and clear
  * bits k-1 .. 0.  Each time this happens (except the very first time

_

author maintainer
#32 lore raw

PATCH 29/91 lib/genalloc.c: fix a typo

In reply to Andrew Morton

From: Bhaskar Chowdhury <[email protected]>
Subject: lib/genalloc.c: Fix a typo

s/macthing/matching/

---

 lib/genalloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/genalloc.c renamed from lib/genalloc.c~lib-genallocc-fix-a-typo +1 -1
@@ -735,7 +735,7 @@ EXPORT_SYMBOL(gen_pool_first_fit_order_a
 
 /**
  * gen_pool_best_fit - find the best fitting region of memory
- * macthing the size requirement (no alignment constraint)
+ * matching the size requirement (no alignment constraint)
  * @map: The address to base the search on
  * @size: The bitmap size in bits
  * @start: The bitnumber to start searching at

_

author maintainer
#33 lore raw

PATCH 30/91 lib: crc8: pointer to data block should be const

In reply to Andrew Morton

From: Richard Fitzgerald <[email protected]>
Subject: lib: crc8: pointer to data block should be const

crc8() does not change the data passed to it, so the pointer argument should be declared const. This avoids callers that receive const data having to cast it to a non-const pointer to call crc8().

---

 include/linux/crc8.h |    2 +-
 lib/crc8.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/crc8.h renamed from include/linux/crc8.h~lib-crc8-pointer-to-data-block-should-be-const +1 -1
@@ -96,6 +96,6 @@ void crc8_populate_msb(u8 table[CRC8_TAB
  * Williams, Ross N., ross<at>ross.net
  * (see URL http://www.ross.net/crc/download/crc_v3.txt).
  */
-u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc);
+u8 crc8(const u8 table[CRC8_TABLE_SIZE], const u8 *pdata, size_t nbytes, u8 crc);
 
 #endif /* __CRC8_H_ */
lib/crc8.c renamed from lib/crc8.c~lib-crc8-pointer-to-data-block-should-be-const +1 -1
@@ -71,7 +71,7 @@ EXPORT_SYMBOL(crc8_populate_lsb);
  * @nbytes: number of bytes in data buffer.
  * @crc: previous returned crc8 value.
  */
-u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc)
+u8 crc8(const u8 table[CRC8_TABLE_SIZE], const u8 *pdata, size_t nbytes, u8 crc)
 {
 	/* loop over the buffer data */
 	while (nbytes-- > 0)

_

author maintainer
#34 lore raw

PATCH 31/91 lib: stackdepot: turn depot_lock spinlock to raw_spinlock

In reply to Andrew Morton

From: Zqiang <[email protected]>
Subject: lib: stackdepot: turn depot_lock spinlock to raw_spinlock

[    2.670635] BUG: sleeping function called from invalid context
at kernel/locking/rtmutex.c:951
[    2.670638] in_atomic(): 0, irqs_disabled(): 1, non_block: 0,
pid: 19, name: pgdatinit0
[    2.670768] Call Trace:
[    2.670800]  dump_stack+0x93/0xc2
[    2.670826]  ___might_sleep.cold+0x1b2/0x1f1
[    2.670838]  rt_spin_lock+0x3b/0xb0
[    2.670838]  stack_depot_save+0x1b9/0x440
[    2.670838]  kasan_save_stack+0x32/0x40
[    2.670838]  kasan_record_aux_stack+0xa5/0xb0
[    2.670838]  __call_rcu+0x117/0x880
[    2.670838]  __exit_signal+0xafb/0x1180
[    2.670838]  release_task+0x1d6/0x480
[    2.670838]  exit_notify+0x303/0x750
[    2.670838]  do_exit+0x678/0xcf0
[    2.670838]  kthread+0x364/0x4f0
[    2.670838]  ret_from_fork+0x22/0x30

In RT system, the spin_lock will be replaced by sleepable rt_mutex lock, in __call_rcu(), disable interrupts before calling kasan_record_aux_stack(), will trigger above calltrace, replace spinlock with raw_spinlock.

---

 lib/stackdepot.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/stackdepot.c renamed from lib/stackdepot.c~lib-stackdepot-turn-depot_lock-spinlock-to-raw_spinlock +3 -3
@@ -71,7 +71,7 @@ static void *stack_slabs[STACK_ALLOC_MAX
 static int depot_index;
 static int next_slab_inited;
 static size_t depot_offset;
-static DEFINE_SPINLOCK(depot_lock);
+static DEFINE_RAW_SPINLOCK(depot_lock);
 
 static bool init_stack_slab(void **prealloc)
 {
@@ -305,7 +305,7 @@ depot_stack_handle_t stack_depot_save(un
 			prealloc = page_address(page);
 	}
 
-	spin_lock_irqsave(&depot_lock, flags);
+	raw_spin_lock_irqsave(&depot_lock, flags);
 
 	found = find_stack(*bucket, entries, nr_entries, hash);
 	if (!found) {
@@ -329,7 +329,7 @@ depot_stack_handle_t stack_depot_save(un
 		WARN_ON(!init_stack_slab(&prealloc));
 	}
 
-	spin_unlock_irqrestore(&depot_lock, flags);
+	raw_spin_unlock_irqrestore(&depot_lock, flags);
 exit:
 	if (prealloc) {
 		/* Nobody used this memory, ok to free it. */

_

author maintainer
#35 lore raw

PATCH 32/91 lib/percpu_counter: tame kernel-doc compile warning

In reply to Andrew Morton

From: Alex Shi <[email protected]>
Subject: lib/percpu_counter: tame kernel-doc compile warning

commit 3e8f399da490 ("writeback: rework wb_[dec|inc]_stat family of functions") add some function description of percpu_counter_add_batch. but the double '*' in comments means a kernel-doc format comment which isn't right.

Since the whole file of lib/percpu_counter.c has no any other kernel-doc format comments, we'd better to remove this incomplete one to tame the kernel-doc warning:

lib/percpu_counter.c:83: warning: Function parameter or member 'fbc' not described in 'percpu_counter_add_batch' lib/percpu_counter.c:83: warning: Function parameter or member 'amount' not described in 'percpu_counter_add_batch' lib/percpu_counter.c:83: warning: Function parameter or member 'batch' not described in 'percpu_counter_add_batch'

---

 lib/percpu_counter.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/percpu_counter.c renamed from lib/percpu_counter.c~lib-percpu_counter-tame-kernel-doc-compile-warning +1 -1
@@ -72,7 +72,7 @@ void percpu_counter_set(struct percpu_co
 }
 EXPORT_SYMBOL(percpu_counter_set);
 
-/**
+/*
  * This function is both preempt and irq safe. The former is due to explicit
  * preemption disable. The latter is guaranteed by the fact that the slow path
  * is explicitly protected by an irq-safe spinlock whereas the fast patch uses

_

author maintainer
#36 lore raw

PATCH 33/91 lib/genalloc: add parameter description to fix doc compile warning

In reply to Andrew Morton

From: Alex Shi <[email protected]>
Subject: lib/genalloc: add parameter description to fix doc compile warning

commit 52fbf1134d47 ("lib/genalloc.c: fix allocation of aligned buffer
from non-aligned chunk") add a new parameter 'start_addr' w/o
description for it. That cause some doc compile warning:

lib/genalloc.c:649: warning: Function parameter or member 'start_addr' not described in 'gen_pool_first_fit' lib/genalloc.c:667: warning: Function parameter or member 'start_addr' not described in 'gen_pool_first_fit_align' lib/genalloc.c:694: warning: Function parameter or member 'start_addr' not described in 'gen_pool_fixed_alloc' lib/genalloc.c:729: warning: Function parameter or member 'start_addr' not described in 'gen_pool_first_fit_order_align' lib/genalloc.c:752: warning: Function parameter or member 'start_addr' not described in 'gen_pool_best_fit'

This patch fix this by adding parameter descriptions.

---

 lib/genalloc.c |    5 +++++
 1 file changed, 5 insertions(+)
lib/genalloc.c renamed from lib/genalloc.c~lib-genalloc-add-parameter-description-to-fix-doc-compile-warning +5 -0
@@ -642,6 +642,7 @@ EXPORT_SYMBOL(gen_pool_set_algo);
  * @nr: The number of zeroed bits we're looking for
  * @data: additional data - unused
  * @pool: pool to find the fit region memory from
+ * @start_addr: not used in this function
  */
 unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size,
 		unsigned long start, unsigned int nr, void *data,
@@ -660,6 +661,7 @@ EXPORT_SYMBOL(gen_pool_first_fit);
  * @nr: The number of zeroed bits we're looking for
  * @data: data for alignment
  * @pool: pool to get order from
+ * @start_addr: start addr of alloction chunk
  */
 unsigned long gen_pool_first_fit_align(unsigned long *map, unsigned long size,
 		unsigned long start, unsigned int nr, void *data,
@@ -687,6 +689,7 @@ EXPORT_SYMBOL(gen_pool_first_fit_align);
  * @nr: The number of zeroed bits we're looking for
  * @data: data for alignment
  * @pool: pool to get order from
+ * @start_addr: not used in this function
  */
 unsigned long gen_pool_fixed_alloc(unsigned long *map, unsigned long size,
 		unsigned long start, unsigned int nr, void *data,
@@ -721,6 +724,7 @@ EXPORT_SYMBOL(gen_pool_fixed_alloc);
  * @nr: The number of zeroed bits we're looking for
  * @data: additional data - unused
  * @pool: pool to find the fit region memory from
+ * @start_addr: not used in this function
  */
 unsigned long gen_pool_first_fit_order_align(unsigned long *map,
 		unsigned long size, unsigned long start,
@@ -742,6 +746,7 @@ EXPORT_SYMBOL(gen_pool_first_fit_order_a
  * @nr: The number of zeroed bits we're looking for
  * @data: additional data - unused
  * @pool: pool to find the fit region memory from
+ * @start_addr: not used in this function
  *
  * Iterate over the bitmap to find the smallest free region
  * which we can allocate the memory.

_

author maintainer
#37 lore raw

PATCH 34/91 lib: parser: clean up kernel-doc

In reply to Andrew Morton

From: Randy Dunlap <[email protected]>
Subject: lib: parser: clean up kernel-doc

Mark match_uint() as kernel-doc notation since it is already fully annotated as such. Use % prefix on constants in kernel-doc comments. Convert function return descriptions to use the "Return:" kernel-doc notation.

---

 lib/parser.c |   61 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 23 deletions(-)
lib/parser.c renamed from lib/parser.c~lib-parser-clean-up-kernel-doc +38 -23
@@ -98,7 +98,7 @@ static int match_one(char *s, const char
  * locations.
  *
  * Description: Detects which if any of a set of token strings has been passed
- * to it. Tokens can include up to MAX_OPT_ARGS instances of basic c-style
+ * to it. Tokens can include up to %MAX_OPT_ARGS instances of basic c-style
  * format identifiers which will be taken into account when matching the
  * tokens, and whose locations will be returned in the @args array.
  */
@@ -120,8 +120,10 @@ EXPORT_SYMBOL(match_token);
  * @base: base to use when converting string
  *
  * Description: Given a &substring_t and a base, attempts to parse the substring
- * as a number in that base. On success, sets @result to the integer represented
- * by the string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
+ * as a number in that base.
+ *
+ * Return: On success, sets @result to the integer represented by the
+ * string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
  */
 static int match_number(substring_t *s, int *result, int base)
 {
@@ -153,8 +155,10 @@ static int match_number(substring_t *s,
  * @base: base to use when converting string
  *
  * Description: Given a &substring_t and a base, attempts to parse the substring
- * as a number in that base. On success, sets @result to the integer represented
- * by the string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
+ * as a number in that base.
+ *
+ * Return: On success, sets @result to the integer represented by the
+ * string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
  */
 static int match_u64int(substring_t *s, u64 *result, int base)
 {
@@ -178,9 +182,10 @@ static int match_u64int(substring_t *s,
  * @s: substring_t to be scanned
  * @result: resulting integer on success
  *
- * Description: Attempts to parse the &substring_t @s as a decimal integer. On
- * success, sets @result to the integer represented by the string and returns 0.
- * Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
+ * Description: Attempts to parse the &substring_t @s as a decimal integer.
+ *
+ * Return: On success, sets @result to the integer represented by the string
+ * and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
  */
 int match_int(substring_t *s, int *result)
 {
@@ -188,14 +193,15 @@ int match_int(substring_t *s, int *resul
 }
 EXPORT_SYMBOL(match_int);
 
-/*
+/**
  * match_uint - scan a decimal representation of an integer from a substring_t
  * @s: substring_t to be scanned
  * @result: resulting integer on success
  *
- * Description: Attempts to parse the &substring_t @s as a decimal integer. On
- * success, sets @result to the integer represented by the string and returns 0.
- * Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
+ * Description: Attempts to parse the &substring_t @s as a decimal integer.
+ *
+ * Return: On success, sets @result to the integer represented by the string
+ * and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
  */
 int match_uint(substring_t *s, unsigned int *result)
 {
@@ -217,9 +223,10 @@ EXPORT_SYMBOL(match_uint);
  * @result: resulting unsigned long long on success
  *
  * Description: Attempts to parse the &substring_t @s as a long decimal
- * integer. On success, sets @result to the integer represented by the
- * string and returns 0.
- * Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
+ * integer.
+ *
+ * Return: On success, sets @result to the integer represented by the string
+ * and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
  */
 int match_u64(substring_t *s, u64 *result)
 {
@@ -232,9 +239,10 @@ EXPORT_SYMBOL(match_u64);
  * @s: substring_t to be scanned
  * @result: resulting integer on success
  *
- * Description: Attempts to parse the &substring_t @s as an octal integer. On
- * success, sets @result to the integer represented by the string and returns
- * 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
+ * Description: Attempts to parse the &substring_t @s as an octal integer.
+ *
+ * Return: On success, sets @result to the integer represented by the string
+ * and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
  */
 int match_octal(substring_t *s, int *result)
 {
@@ -248,8 +256,9 @@ EXPORT_SYMBOL(match_octal);
  * @result: resulting integer on success
  *
  * Description: Attempts to parse the &substring_t @s as a hexadecimal integer.
- * On success, sets @result to the integer represented by the string and
- * returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
+ *
+ * Return: On success, sets @result to the integer represented by the string
+ * and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
  */
 int match_hex(substring_t *s, int *result)
 {
@@ -263,10 +272,11 @@ EXPORT_SYMBOL(match_hex);
  * @str: the string to be parsed
  *
  * Description: Parse the string @str to check if matches wildcard
- * pattern @pattern. The pattern may contain two type wildcardes:
+ * pattern @pattern. The pattern may contain two types of wildcards:
  *   '*' - matches zero or more characters
  *   '?' - matches one character
- * If it's matched, return true, else return false.
+ *
+ * Return: If the @str matches the @pattern, return true, else return false.
  */
 bool match_wildcard(const char *pattern, const char *str)
 {
@@ -316,7 +326,9 @@ EXPORT_SYMBOL(match_wildcard);
  *
  * Description: Copy the characters in &substring_t @src to the
  * c-style string @dest.  Copy no more than @size - 1 characters, plus
- * the terminating NUL.  Return length of @src.
+ * the terminating NUL.
+ *
+ * Return: length of @src.
  */
 size_t match_strlcpy(char *dest, const substring_t *src, size_t size)
 {
@@ -338,6 +350,9 @@ EXPORT_SYMBOL(match_strlcpy);
  * Description: Allocates and returns a string filled with the contents of
  * the &substring_t @s. The caller is responsible for freeing the returned
  * string with kfree().
+ *
+ * Return: the address of the newly allocated NUL-terminated string or
+ * %NULL on error.
  */
 char *match_strdup(const substring_t *s)
 {

_

author maintainer
#38 lore raw

PATCH 35/91 include/linux/compat.h: remove unneeded declaration from COMPAT_SYSCALL_DEFINEx()

In reply to Andrew Morton

From: Masahiro Yamada <[email protected]>
Subject: include/linux/compat.h: remove unneeded declaration from COMPAT_SYSCALL_DEFINEx()

compat_sys##name is declared twice, just one line below.

With this removal SYSCALL_DEFINEx() (defined in <linux/syscalls.h>) and COMPAT_SYSCALL_DEFINEx() look symmetrical.

---

 include/linux/compat.h |    1 -
 1 file changed, 1 deletion(-)
include/linux/compat.h renamed from include/linux/compat.h~compat-remove-unneeded-declaration-from-compat_syscall_definex +0 -1
@@ -75,7 +75,6 @@
 	__diag_push();								\
 	__diag_ignore(GCC, 8, "-Wattribute-alias",				\
 		      "Type aliasing is used to sanitize syscall arguments");\
-	asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));	\
 	asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))	\
 		__attribute__((alias(__stringify(__se_compat_sys##name))));	\
 	ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO);				\

_

author maintainer
#39 lore raw

PATCH 36/91 checkpatch: warn when missing newline in return sysfs_emit() formats

In reply to Andrew Morton

From: Joe Perches <[email protected]>
Subject: checkpatch: warn when missing newline in return sysfs_emit() formats

return sysfs_emit() uses should include a newline.

Suggest adding a newline when one is missing. Add one using --fix too.

---

 scripts/checkpatch.pl |   11 +++++++++++
 1 file changed, 11 insertions(+)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-warn-when-missing-newline-in-return-sysfs_emit-formats +11 -0
@@ -7198,6 +7198,17 @@ sub process {
 			     "Using $1 should generally have parentheses around the comparison\n" . $herecurr);
 		}
 
+# return sysfs_emit(foo, fmt, ...) fmt without newline
+		if ($line =~ /\breturn\s+sysfs_emit\s*\(\s*$FuncArg\s*,\s*($String)/ &&
+		    substr($rawline, $-[6], $+[6] - $-[6]) !~ /\\n"$/) {
+			my $offset = $+[6] - 1;
+			if (WARN("SYSFS_EMIT",
+				 "return sysfs_emit(...) formats should include a terminating newline\n" . $herecurr) &&
+			    $fix) {
+				substr($fixed[$fixlinenr], $offset, 0) = '\\n';
+			}
+		}
+
 # nested likely/unlikely calls
 		if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) {
 			WARN("LIKELY_MISUSE",

_

author maintainer
#40 lore raw

PATCH 37/91 checkpatch: exclude four preprocessor sub-expressions from MACRO_ARG_REUSE

In reply to Andrew Morton

From: Vincent Mailhol <[email protected]>
Subject: checkpatch: exclude four preprocessor sub-expressions from MACRO_ARG_REUSE

__must_be_array, offsetof, sizeof_field and __stringify are all preprocessor macros and do not evaluate their arguments. As such, it is safe not to warn when arguments are being reused in those four sub-expressions.

Exclude those so that they can pass checkpatch.

---

 scripts/checkpatch.pl |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-exclude-four-preprocessor-sub-expressions-from-macro_arg_reuse +1 -1
@@ -5829,7 +5829,7 @@ sub process {
 			        next if ($arg =~ /\.\.\./);
 			        next if ($arg =~ /^type$/i);
 				my $tmp_stmt = $define_stmt;
-				$tmp_stmt =~ s/\b(sizeof|typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
+				$tmp_stmt =~ s/\b(__must_be_array|offsetof|sizeof|sizeof_field|__stringify|typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
 				$tmp_stmt =~ s/\#+\s*$arg\b//g;
 				$tmp_stmt =~ s/\b$arg\s*\#\#//g;
 				my $use_cnt = () = $tmp_stmt =~ /\b$arg\b/g;

_

author maintainer
#41 lore raw

PATCH 38/91 checkpatch: improve ALLOC_ARRAY_ARGS test

In reply to Andrew Morton

From: Christophe JAILLET <[email protected]>
Subject: checkpatch: improve ALLOC_ARRAY_ARGS test

The devm_ variant of 'kcalloc()' and 'kmalloc_array()' are not tested Add the corresponding check.

---

 scripts/checkpatch.pl |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-improve-alloc_array_args-test +1 -1
@@ -7006,7 +7006,7 @@ sub process {
 		}
 
 # check for alloc argument mismatch
-		if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
+		if ($line =~ /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\(\s*sizeof\b/) {
 			WARN("ALLOC_ARRAY_ARGS",
 			     "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
 		}

_

author maintainer
#42 lore raw

PATCH 39/91 kselftest: introduce new epoll test case

In reply to Andrew Morton

From: Davidlohr Bueso <[email protected]>
Subject: kselftest: introduce new epoll test case

Patch series "fs/epoll: restore user-visible behavior upon event ready".

This series tries to address a change in user visible behavior, reported in https://bugzilla.kernel.org/show_bug.cgi?id=208943.

Epoll does not report an event to all the threads running epoll_wait() on the same epoll descriptor. Unsurprisingly, this was bisected back to 339ddb53d373 (fs/epoll: remove unnecessary wakeups of nested epoll), which has had various problems in the past, beyond only nested epoll usage.

This patch (of 2):

This incorporates the testcase originally reported in:

     https://bugzilla.kernel.org/show_bug.cgi?id=208943

Which ensures an event is reported to all threads blocked on the same epoll descriptor, otherwise only a single thread will receive the wakeup once the event become ready.

---

 tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c |   44 ++++++++++
 1 file changed, 44 insertions(+)
tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c renamed from tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c~kselftest-introduce-new-epoll-test-case +44 -0
@@ -3449,4 +3449,48 @@ TEST(epoll63)
 	close(sfd[1]);
 }
 
+/*
+ *        t0    t1
+ *     (ew) \  / (ew)
+ *           e0
+ *            | (lt)
+ *           s0
+ */
+TEST(epoll64)
+{
+	pthread_t waiter[2];
+	struct epoll_event e;
+	struct epoll_mtcontext ctx = { 0 };
+
+	signal(SIGUSR1, signal_handler);
+
+	ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM, 0, ctx.sfd), 0);
+
+	ctx.efd[0] = epoll_create(1);
+	ASSERT_GE(ctx.efd[0], 0);
+
+	e.events = EPOLLIN;
+	ASSERT_EQ(epoll_ctl(ctx.efd[0], EPOLL_CTL_ADD, ctx.sfd[0], &e), 0);
+
+	/*
+	 * main will act as the emitter once both waiter threads are
+	 * blocked and expects to both be awoken upon the ready event.
+	 */
+	ctx.main = pthread_self();
+	ASSERT_EQ(pthread_create(&waiter[0], NULL, waiter_entry1a, &ctx), 0);
+	ASSERT_EQ(pthread_create(&waiter[1], NULL, waiter_entry1a, &ctx), 0);
+
+	usleep(100000);
+	ASSERT_EQ(write(ctx.sfd[1], "w", 1), 1);
+
+	ASSERT_EQ(pthread_join(waiter[0], NULL), 0);
+	ASSERT_EQ(pthread_join(waiter[1], NULL), 0);
+
+	EXPECT_EQ(ctx.count, 2);
+
+	close(ctx.efd[0]);
+	close(ctx.sfd[0]);
+	close(ctx.sfd[1]);
+}
+
 TEST_HARNESS_MAIN

_

author maintainer
#43 lore raw

PATCH 40/91 fs/epoll: restore waking from ep_done_scan()

In reply to Andrew Morton

From: Davidlohr Bueso <[email protected]>
Subject: fs/epoll: restore waking from ep_done_scan()

339ddb53d373 (fs/epoll: remove unnecessary wakeups of nested epoll) changed the userspace visible behavior of exclusive waiters blocked on a common epoll descriptor upon a single event becoming ready. Previously, all tasks doing epoll_wait would awake, and now only one is awoken, potentially causing missed wakeups on applications that rely on this behavior, such as Apache Qpid.

While the aforementioned commit aims at having only a wakeup single path in ep_poll_callback (with the exceptions of epoll_ctl cases), we need to restore the wakeup in what was the old ep_scan_ready_list() such that the next thread can be awoken, in a cascading style, after the waker's corresponding ep_send_events().

Fixes 339ddb53d373 ("fs/epoll: remove unnecessary wakeups of nested epoll")
Cc Al Viro <[email protected]>
Cc Jason Baron <[email protected]>
Cc Roman Penyaev <[email protected]>

---

 fs/eventpoll.c |    6 ++++++
 1 file changed, 6 insertions(+)
fs/eventpoll.c renamed from fs/eventpoll.c~fs-epoll-restore-waking-from-ep_done_scan +6 -0
@@ -657,6 +657,12 @@ static void ep_done_scan(struct eventpol
 	 */
 	list_splice(txlist, &ep->rdllist);
 	__pm_relax(ep->ws);
+
+	if (!list_empty(&ep->rdllist)) {
+		if (waitqueue_active(&ep->wq))
+			wake_up(&ep->wq);
+	}
+
 	write_unlock_irq(&ep->lock);
 }
 

_

author maintainer
#44 lore raw

PATCH 41/91 isofs: fix fall-through warnings for Clang

In reply to Andrew Morton

From: "Gustavo A. R. Silva" <[email protected]>
Subject: isofs: fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of just letting the code fall through to the next case.

---

 fs/isofs/rock.c |    1 +
 1 file changed, 1 insertion(+)
fs/isofs/rock.c renamed from fs/isofs/rock.c~isofs-fix-fall-through-warnings-for-clang +1 -0
@@ -767,6 +767,7 @@ repeat:
 			rs.cont_extent = isonum_733(rr->u.CE.extent);
 			rs.cont_offset = isonum_733(rr->u.CE.offset);
 			rs.cont_size = isonum_733(rr->u.CE.size);
+			break;
 		default:
 			break;
 		}

_

author maintainer
#45 lore raw

PATCH 42/91 fs/nilfs2: fix misspellings using codespell tool

In reply to Andrew Morton

From: Liu xuzhi <[email protected]>
Subject: fs/nilfs2: fix misspellings using codespell tool

Two typos are found out by codespell tool \
in 2217th and 2254th lines of segment.c:

$ codespell ./fs/nilfs2/
./segment.c:2217 :retured  ==> returned
./segment.c:2254: retured  ==> returned

Fix two typos found by codespell.

---

 fs/nilfs2/segment.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nilfs2/segment.c renamed from fs/nilfs2/segment.c~fs-nilfs2-fix-misspellings-using-codespell-tool +2 -2
@@ -2214,7 +2214,7 @@ static void nilfs_segctor_wakeup(struct
  * nilfs_construct_segment - construct a logical segment
  * @sb: super block
  *
- * Return Value: On success, 0 is retured. On errors, one of the following
+ * Return Value: On success, 0 is returned. On errors, one of the following
  * negative error code is returned.
  *
  * %-EROFS - Read only filesystem.
@@ -2251,7 +2251,7 @@ int nilfs_construct_segment(struct super
  * @start: start byte offset
  * @end: end byte offset (inclusive)
  *
- * Return Value: On success, 0 is retured. On errors, one of the following
+ * Return Value: On success, 0 is returned. On errors, one of the following
  * negative error code is returned.
  *
  * %-EROFS - Read only filesystem.

_

author maintainer
#46 lore raw

PATCH 43/91 nilfs2: fix typos in comments

In reply to Andrew Morton

From: Lu Jialin <[email protected]>
Subject: nilfs2: fix typos in comments

numer -> number in fs/nilfs2/cpfile.c
Decription -> Description in fs/nilfs2/ioctl.c isntance -> instance in fs/nilfs2/the_nilfs.c

---

 fs/nilfs2/cpfile.c    |    2 +-
 fs/nilfs2/ioctl.c     |    4 ++--
 fs/nilfs2/the_nilfs.c |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
fs/nilfs2/cpfile.c renamed from fs/nilfs2/cpfile.c~nilfs2-fix-typos-in-comments +1 -1
@@ -293,7 +293,7 @@ void nilfs_cpfile_put_checkpoint(struct
  * nilfs_cpfile_delete_checkpoints - delete checkpoints
  * @cpfile: inode of checkpoint file
  * @start: start checkpoint number
- * @end: end checkpoint numer
+ * @end: end checkpoint number
  *
  * Description: nilfs_cpfile_delete_checkpoints() deletes the checkpoints in
  * the period from @start to @end, excluding @end itself. The checkpoints
fs/nilfs2/ioctl.c renamed from fs/nilfs2/ioctl.c~nilfs2-fix-typos-in-comments +2 -2
@@ -1043,7 +1043,7 @@ out:
  * @inode: inode object
  * @argp: pointer on argument from userspace
  *
- * Decription: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It
+ * Description: nilfs_ioctl_trim_fs is the FITRIM ioctl handle function. It
  * checks the arguments from userspace and calls nilfs_sufile_trim_fs, which
  * performs the actual trim operation.
  *
@@ -1085,7 +1085,7 @@ static int nilfs_ioctl_trim_fs(struct in
  * @inode: inode object
  * @argp: pointer on argument from userspace
  *
- * Decription: nilfs_ioctl_set_alloc_range() function defines lower limit
+ * Description: nilfs_ioctl_set_alloc_range() function defines lower limit
  * of segments in bytes and upper limit of segments in bytes.
  * The NILFS_IOCTL_SET_ALLOC_RANGE is used by nilfs_resize utility.
  *
fs/nilfs2/the_nilfs.c renamed from fs/nilfs2/the_nilfs.c~nilfs2-fix-typos-in-comments +1 -1
@@ -195,7 +195,7 @@ static int nilfs_store_log_cursor(struct
 /**
  * load_nilfs - load and recover the nilfs
  * @nilfs: the_nilfs structure to be released
- * @sb: super block isntance used to recover past segment
+ * @sb: super block instance used to recover past segment
  *
  * load_nilfs() searches and load the latest super root,
  * attaches the last segment, and does recovery if needed.

_

author maintainer
#47 lore raw

PATCH 44/91 hpfs: replace one-element array with flexible-array member

In reply to Andrew Morton

From: "Gustavo A. R. Silva" <[email protected]>
Subject: hpfs: replace one-element array with flexible-array member

There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2].

Also, this helps with the ongoing efforts to enable -Warray-bounds by fixing the following warning:

CC [M] fs/hpfs/dir.o
fs/hpfs/dir.c: In function `hpfs_readdir':
fs/hpfs/dir.c:163:41: warning: array subscript 1 is above array bounds of u8[1]' {aka unsigned char[1]'} [-Warray-bounds]
163 | || de ->name[0] != 1 || de->name[1] != 1))

      |                                 ~~~~~~~~^~~

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

---

 fs/hpfs/hpfs.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/hpfs/hpfs.h renamed from fs/hpfs/hpfs.h~hpfs-replace-one-element-array-with-flexible-array-member +2 -1
@@ -356,7 +356,8 @@ struct hpfs_dirent {
   u8 no_of_acls;			/* number of ACL's (low 3 bits) */
   u8 ix;				/* code page index (of filename), see
 					   struct code_page_data */
-  u8 namelen, name[1];			/* file name */
+  u8 namelen;				/* file name length */
+  u8 name[];				/* file name */
   /* dnode_secno down;	  btree down pointer, if present,
      			  follows name on next word boundary, or maybe it
 			  precedes next dirent, which is on a word boundary. */

_

author maintainer
#48 lore raw

PATCH 45/91 do_wait: make PIDTYPE_PID case O(1) instead of O(n)

In reply to Andrew Morton

From: Jim Newsome <[email protected]>
Subject: do_wait: make PIDTYPE_PID case O(1) instead of O(n)

Add a special-case when waiting on a pid (via waitpid, waitid, wait4, etc) to avoid doing an O(n) scan of children and tracees, and instead do an O(1) lookup. This improves performance when waiting on a pid from a thread group with many children and/or tracees.

Time to fork and then call waitpid on the child, from a task that already has N children [1]:

N    | Before  | After
-----|---------|------
1    | 74 us   | 74 us
20   | 72 us   | 75 us
100  | 83 us   | 77 us
500  | 99 us   | 74 us
1000 | 179 us  | 75 us
5000 | 804 us  | 79 us
8000 | 1268 us | 78 us

[1]: https://lkml.org/lkml/2021/3/12/1567

This can make a substantial performance improvement for applications with a thread that has many children or tracees and frequently needs to wait on them. Tools that use ptrace to intercept syscalls for a large number of processes are likely to fall into this category. In particular this patch was developed while building a ptrace-based second generation of the Shadow emulator [2], for which it allows us to avoid quadratic scaling (without having to use a workaround that introduces a ~40% performance penalty) [3]. Other examples of tools that fall into this category which this patch may help include User Mode Linux [4] and DetTrace [5].

[2]: https://shadow.github.io/
[3]: https://github.com/shadow/shadow/issues/1134#issuecomment-798992292
[4]: https://en.wikipedia.org/wiki/User-mode_Linux
[5]: https://github.com/dettrace/dettrace

---

 kernel/exit.c |   67 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 57 insertions(+), 10 deletions(-)
kernel/exit.c renamed from kernel/exit.c~do_wait-make-pidtype_pid-case-o1-instead-of-on +57 -10
@@ -1440,9 +1440,48 @@ void __wake_up_parent(struct task_struct
 			   TASK_INTERRUPTIBLE, p);
 }
 
+static bool is_effectively_child(struct wait_opts *wo, bool ptrace,
+				 struct task_struct *target)
+{
+	struct task_struct *parent =
+		!ptrace ? target->real_parent : target->parent;
+
+	return current == parent || (!(wo->wo_flags & __WNOTHREAD) &&
+				     same_thread_group(current, parent));
+}
+
+/*
+ * Optimization for waiting on PIDTYPE_PID. No need to iterate through child
+ * and tracee lists to find the target task.
+ */
+static int do_wait_pid(struct wait_opts *wo)
+{
+	bool ptrace;
+	struct task_struct *target;
+	int retval;
+
+	ptrace = false;
+	target = pid_task(wo->wo_pid, PIDTYPE_TGID);
+	if (target && is_effectively_child(wo, ptrace, target)) {
+		retval = wait_consider_task(wo, ptrace, target);
+		if (retval)
+			return retval;
+	}
+
+	ptrace = true;
+	target = pid_task(wo->wo_pid, PIDTYPE_PID);
+	if (target && target->ptrace &&
+	    is_effectively_child(wo, ptrace, target)) {
+		retval = wait_consider_task(wo, ptrace, target);
+		if (retval)
+			return retval;
+	}
+
+	return 0;
+}
+
 static long do_wait(struct wait_opts *wo)
 {
-	struct task_struct *tsk;
 	int retval;
 
 	trace_sched_process_wait(wo->wo_pid);
@@ -1464,19 +1503,27 @@ repeat:
 
 	set_current_state(TASK_INTERRUPTIBLE);
 	read_lock(&tasklist_lock);
-	tsk = current;
-	do {
-		retval = do_wait_thread(wo, tsk);
-		if (retval)
-			goto end;
 
-		retval = ptrace_do_wait(wo, tsk);
+	if (wo->wo_type == PIDTYPE_PID) {
+		retval = do_wait_pid(wo);
 		if (retval)
 			goto end;
+	} else {
+		struct task_struct *tsk = current;
 
-		if (wo->wo_flags & __WNOTHREAD)
-			break;
-	} while_each_thread(current, tsk);
+		do {
+			retval = do_wait_thread(wo, tsk);
+			if (retval)
+				goto end;
+
+			retval = ptrace_do_wait(wo, tsk);
+			if (retval)
+				goto end;
+
+			if (wo->wo_flags & __WNOTHREAD)
+				break;
+		} while_each_thread(current, tsk);
+	}
 	read_unlock(&tasklist_lock);
 
 notask:

_

author maintainer
#49 lore raw

PATCH 46/91 kernel/fork.c: simplify copy_mm()

In reply to Andrew Morton

From: Rolf Eike Beer <[email protected]>
Subject: kernel/fork.c: simplify copy_mm()

All this can happen without a single goto.

---

 kernel/fork.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
kernel/fork.c renamed from kernel/fork.c~simplify-copy_mm +4 -11
@@ -1396,7 +1396,6 @@ fail_nomem:
 static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
 {
 	struct mm_struct *mm, *oldmm;
-	int retval;
 
 	tsk->min_flt = tsk->maj_flt = 0;
 	tsk->nvcsw = tsk->nivcsw = 0;
@@ -1423,21 +1422,15 @@ static int copy_mm(unsigned long clone_f
 	if (clone_flags & CLONE_VM) {
 		mmget(oldmm);
 		mm = oldmm;
-		goto good_mm;
+	} else {
+		mm = dup_mm(tsk, current->mm);
+		if (!mm)
+			return -ENOMEM;
 	}
 
-	retval = -ENOMEM;
-	mm = dup_mm(tsk, current->mm);
-	if (!mm)
-		goto fail_nomem;
-
-good_mm:
 	tsk->mm = mm;
 	tsk->active_mm = mm;
 	return 0;
-
-fail_nomem:
-	return retval;
 }
 
 static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)

_

author maintainer
#50 lore raw

PATCH 47/91 kernel/fork.c: fix typos

In reply to Andrew Morton

From: Xiaofeng Cao <[email protected]>
Subject: kernel/fork.c: fix typos

change 'ancestoral' to 'ancestral'
change 'reuseable' to 'reusable'
delete 'do' grammatically

---

 kernel/fork.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/fork.c renamed from kernel/fork.c~kernel-fork-fix-typo-issue +4 -4
@@ -1145,7 +1145,7 @@ void mmput_async(struct mm_struct *mm)
  * invocations: in mmput() nobody alive left, in execve task is single
  * threaded. sys_prctl(PR_SET_MM_MAP/EXE_FILE) also needs to set the
  * mm->exe_file, but does so without using set_mm_exe_file() in order
- * to do avoid the need for any locks.
+ * to avoid the need for any locks.
  */
 void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file)
 {
@@ -1736,7 +1736,7 @@ static int pidfd_release(struct inode *i
  * /proc/<pid>/status where Pid and NSpid are always shown relative to
  * the  pid namespace of the procfs instance. The difference becomes
  * obvious when sending around a pidfd between pid namespaces from a
- * different branch of the tree, i.e. where no ancestoral relation is
+ * different branch of the tree, i.e. where no ancestral relation is
  * present between the pid namespaces:
  * - create two new pid namespaces ns1 and ns2 in the initial pid
  *   namespace (also take care to create new mount namespaces in the
@@ -2728,8 +2728,8 @@ static bool clone3_args_valid(struct ker
 		return false;
 
 	/*
-	 * - make the CLONE_DETACHED bit reuseable for clone3
-	 * - make the CSIGNAL bits reuseable for clone3
+	 * - make the CLONE_DETACHED bit reusable for clone3
+	 * - make the CSIGNAL bits reusable for clone3
 	 */
 	if (kargs->flags & (CLONE_DETACHED | CSIGNAL))
 		return false;

_

author maintainer
#51 lore raw

PATCH 48/91 kernel/crash_core: add crashkernel=auto for vmcore creation

In reply to Andrew Morton

From: Saeed Mirzamohammadi <[email protected]>
Subject: kernel/crash_core: add crashkernel=auto for vmcore creation

This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs.

Cc Baoquan He <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc "Guilherme G. Piccoli" <[email protected]>
Cc Kees Cook <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "Steven Rostedt (VMware)" <[email protected]>
Cc YiFei Zhu <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Sami Tolvanen <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Colin Ian King <[email protected]>

---

 Documentation/admin-guide/kdump/kdump.rst       |    3 +-
 Documentation/admin-guide/kernel-parameters.txt |    6 ++++
 arch/Kconfig                                    |   20 ++++++++++++++
 kernel/crash_core.c                             |    7 ++++
 4 files changed, 35 insertions(+), 1 deletion(-)
arch/Kconfig renamed from arch/Kconfig~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +20 -0
@@ -14,6 +14,26 @@ menu "General architecture-dependent opt
 config CRASH_CORE
 	bool
 
+config CRASH_AUTO_STR
+	string "Memory reserved for crash kernel"
+	depends on CRASH_CORE
+	default "1G-64G:128M,64G-1T:256M,1T-:512M"
+	help
+	  This configures the reserved memory dependent
+	  on the value of System RAM. The syntax is:
+	  crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
+	              range=start-[end]
+
+	  For example:
+	      crashkernel=512M-2G:64M,2G-:128M
+
+	  This would mean:
+
+	      1) if the RAM is smaller than 512M, then don't reserve anything
+	         (this is the "rescue" case)
+	      2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
+	      3) if the RAM size is larger than 2G, then reserve 128M
+
 config KEXEC_CORE
 	select CRASH_CORE
 	bool
Documentation/admin-guide/kdump/kdump.rst renamed from Documentation/admin-guide/kdump/kdump.rst~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +2 -1
@@ -285,7 +285,8 @@ This would mean:
     2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
     3) if the RAM size is larger than 2G, then reserve 128M
 
-
+Or you can use crashkernel=auto to choose the crash kernel memory size
+based on the recommended configuration set for each arch.
 
 Boot into System Kernel
 =======================
Documentation/admin-guide/kernel-parameters.txt renamed from Documentation/admin-guide/kernel-parameters.txt~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +6 -0
@@ -751,6 +751,12 @@
 			a memory unit (amount[KMG]). See also
 			Documentation/admin-guide/kdump/kdump.rst for an example.
 
+	crashkernel=auto
+			[KNL] This parameter will set the reserved memory for
+			the crash kernel based on the value of the CRASH_AUTO_STR
+			that is the best effort estimation for each arch. See also
+			arch/Kconfig for further details.
+
 	crashkernel=size[KMG],high
 			[KNL, X86-64] range could be above 4G. Allow kernel
 			to allocate physical memory region from top, so could
kernel/crash_core.c renamed from kernel/crash_core.c~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +7 -0
@@ -7,6 +7,7 @@
 #include <linux/crash_core.h>
 #include <linux/utsname.h>
 #include <linux/vmalloc.h>
+#include <linux/kexec.h>
 
 #include <asm/page.h>
 #include <asm/sections.h>
@@ -250,6 +251,12 @@ static int __init __parse_crashkernel(ch
 	if (suffix)
 		return parse_crashkernel_suffix(ck_cmdline, crash_size,
 				suffix);
+#ifdef CONFIG_CRASH_AUTO_STR
+	if (strncmp(ck_cmdline, "auto", 4) == 0) {
+		ck_cmdline = CONFIG_CRASH_AUTO_STR;
+		pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n");
+	}
+#endif
 	/*
 	 * if the commandline contains a ':', then that's the extended
 	 * syntax -- if not, it must be the classic syntax

_

#52 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 7 lines · Andrew Morton

From: Saeed Mirzamohammadi <[email protected]>
Subject: kernel/crash_core: add crashkernel=auto for vmcore creation

This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs.

Ugh. I didn't realize how nasty this was until after I'd applied this patch.

I'm going to drop this patch, because the Kconfig thing for it is an unmitigated mess. I was confused by the question, and then the help message was actively misleading.

This is wrong for so many reasons:

- this is a classic case of "you shouldn't ask a user this".

The question makes no sense to any normal person, it certainly
didn't to me. Don't ask questions that don't have sane answers.

- the config help text is actively misleading, and claims that the
option is about how much memory is reserved for a crash kernel

Not so. It's the default string for when somebody uses "crashkernel=auto"

- this shouldn't be a config option at all, it's clearly a distro
setting, and should be on the kernel command line with the other distro settings.

So I'm dropping this, and I don't see it ever being applied in this form for the above reasons.

People, I've said this before, and apparently I need to say it again:
the kernel config is likely the nastiest part of building a local kernel, and the biggest impediment to people actually building their own kernels.

And people building their own kernel is the first step to becoming a kernel developer.

So the kernel configuration is already one of the less pleasant parts of the kernel, but that does NOT mean that we should strive to make it even worse.

Obscure, odd, strange config questions like this are a no-no. We're not making an already bad experience wose for something like this.

Linus

#53 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Hi Linus,

Quoted 21 lines · Linus Torvalds
Quoted 7 lines · Andrew Morton

From: Saeed Mirzamohammadi <[email protected]>
Subject: kernel/crash_core: add crashkernel=auto for vmcore creation

This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs.

Ugh. I didn't realize how nasty this was until after I'd applied this patch.

I'm going to drop this patch, because the Kconfig thing for it is an unmitigated mess. I was confused by the question, and then the help message was actively misleading.

This is wrong for so many reasons:

- this is a classic case of "you shouldn't ask a user this".

Quoted 7 lines

The question makes no sense to any normal person, it certainly
didn't to me. Don't ask questions that don't have sane answers.

- the config help text is actively misleading, and claims that the
option is about how much memory is reserved for a crash kernel

Not so. It's the default string for when somebody uses "crashkernel=auto"

Sorry for the confusion, we should have been more careful to reivew and add the commit log and kernel config description.

Quoted 4 lines

- this shouldn't be a config option at all, it's clearly a distro
setting, and should be on the kernel command line with the other distro settings.

Don't know kernel config is disliked sometime, will remember it in the future and more cautiously to add.

Crashkernel=auto exists in our distros for many years, and as David mentioned in other thread, we have been trying to adding rashkernel=auto support into upstream. We pursue crashkernel=auto being added to upstream because:

1) Empirical value is given to user by default;

It was required by customer originally, now has been an important part of kdump feature and supported in several main ARCHes. With crashkernel=auto, people w/o much knowledge of kdump details can use kdump to debug. Distros can provide the suggested values with crashkernel=auto which are got by investigation, analysis and tested widely on test environment.

2) Cover corner case/special case;

In some cases, kernel may need extra memory to handle, kdump kernel is not exceptional. E.g when sme/sev enabled, SWIOTLB will be enabled necessarily, even in kdump kernel. (Below sme/sev related commits for reference). Then extra 64M need be reserved for crashkernel. User doesn't need to know this, we already have done it for them.

commit c7753208a94c ("x86, swiotlb: Add memory encryption support") commit aba2d9a6385a ("iommu/amd: Do not disable SWIOTLB if SME is active") commit d7b417fa08d1 ("x86/mm: Add DMA support for SEV memory encryption")

We are eager to push crashkernel=auto to upstream becasue of our UPSTREAM FIRST rule. Since it has been in RHEL for many years, each time a new RHEL main release anchor a upstream kernel release and is prepared, these crashkernel=auto RHEL-only patches need be reviewed inside Redhat, then we will be questioned and challenged why they are not in upstream.

As for how to implement crashkernel=auto, we have tried several ways.

1) Add into kernel command line

The suggested value need be stored in user space if added into kernel command line, then added into kernel. This makes the suggested value separated from kernel itself. It's not what we expect to see. Because the suggested crashkernel value is strongly related to distros release. We could adjust the value between sub-releases of kernel because of of kernel change. Adding them into kernel command line make us lose the track of them in kernel.

2) Add a weak generic function and several arch dependent functions
3) Hardcode values in __parse_crashkernel()

Method 2) is taken in our RHEL7, 3) is used in RHEL8, RHEL-only patches add them. If we try to push them into upstram, any later value adjustment need a upstream patch posting. Otherwise, RHEL-only patch need be introduced again, Redhat internal reviewer will challenge us again. (Put the value hard coding pieces at bottom for reference).

4) Add kernel config to add default value

It's done in this patch. With the kernel config CRASH_AUTO_STR, Distros can add default value, and adjust it anytime in the future w/o bothering upstream. If crashkernel=auto is specified, only below 3 LOC added, to go to parse the CONFIG_CRASH_AUTO_STR directly.

@@ -250,6 +251,12 @@ static int __init __parse_crashkernel(ch
if (suffix)
return parse_crashkernel_suffix(ck_cmdline, crash_size,
suffix);
+#ifdef CONFIG_CRASH_AUTO_STR
+ if (strncmp(ck_cmdline, "auto", 4) == 0) {
+ ck_cmdline = CONFIG_CRASH_AUTO_STR;
+ pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n");
+ }
+#endif

Before this, we don't know Saeed Mirzamohammadi, the patch author. He could experience the same torture. We were wild with joy when noticing his patch. We were planning to launch new round of post to add crashkernel=auto, kernel config is our final option too. We could be too happy to forget polishing the commit log.

Not sure if I make myself clear. Basically, we expect crashkernel=auto to be added in upstream kernel. About how to implement it in kernel, we would like to hear upstream people's suggestion.

Thanks
Baoquan

Hard code crashkernel=auto values in __parse_crashkernel()
===========================================================
static int __init __parse_crashkernel(char *cmdline,
unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base, const char *name, const char *suffix)
{
......

        if (strncmp(ck_cmdline, "auto", 4) == 0) {
#if defined(CONFIG_X86_64) || defined(CONFIG_S390)
                ck_cmdline = "1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M";
#elif defined(CONFIG_ARM64)
                ck_cmdline = "2G-:448M";
#elif defined(CONFIG_PPC64)
                char *fadump_cmdline;

                fadump_cmdline = get_last_crashkernel(cmdline, "fadump=", NULL);
                fadump_cmdline = fadump_cmdline ?
                                fadump_cmdline + strlen("fadump=") : NULL;
                if (!fadump_cmdline || (strncmp(fadump_cmdline, "off", 3) == 0))
                        ck_cmdline = "2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G";
                else
                        ck_cmdline = "4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G";
#endif
                pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n");
        }

......
}
==================================================================

#54 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Add Kairui to CC since he is taking care of the crashkernel=auto code in our Distros.

Quoted 163 lines · Baoquan He

Hi Linus,

Quoted 21 lines · Linus Torvalds
Quoted 7 lines · Andrew Morton

From: Saeed Mirzamohammadi <[email protected]>
Subject: kernel/crash_core: add crashkernel=auto for vmcore creation

This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs.

Ugh. I didn't realize how nasty this was until after I'd applied this patch.

I'm going to drop this patch, because the Kconfig thing for it is an unmitigated mess. I was confused by the question, and then the help message was actively misleading.

This is wrong for so many reasons:

- this is a classic case of "you shouldn't ask a user this".

Quoted 7 lines

The question makes no sense to any normal person, it certainly
didn't to me. Don't ask questions that don't have sane answers.

- the config help text is actively misleading, and claims that the
option is about how much memory is reserved for a crash kernel

Not so. It's the default string for when somebody uses "crashkernel=auto"

Sorry for the confusion, we should have been more careful to reivew and add the commit log and kernel config description.

Quoted 4 lines

- this shouldn't be a config option at all, it's clearly a distro
setting, and should be on the kernel command line with the other distro settings.

Don't know kernel config is disliked sometime, will remember it in the future and more cautiously to add.

Crashkernel=auto exists in our distros for many years, and as David mentioned in other thread, we have been trying to adding rashkernel=auto support into upstream. We pursue crashkernel=auto being added to upstream because:

1) Empirical value is given to user by default;

It was required by customer originally, now has been an important part of kdump feature and supported in several main ARCHes. With crashkernel=auto, people w/o much knowledge of kdump details can use kdump to debug. Distros can provide the suggested values with crashkernel=auto which are got by investigation, analysis and tested widely on test environment.

2) Cover corner case/special case;

In some cases, kernel may need extra memory to handle, kdump kernel is not exceptional. E.g when sme/sev enabled, SWIOTLB will be enabled necessarily, even in kdump kernel. (Below sme/sev related commits for reference). Then extra 64M need be reserved for crashkernel. User doesn't need to know this, we already have done it for them.

commit c7753208a94c ("x86, swiotlb: Add memory encryption support") commit aba2d9a6385a ("iommu/amd: Do not disable SWIOTLB if SME is active") commit d7b417fa08d1 ("x86/mm: Add DMA support for SEV memory encryption")

We are eager to push crashkernel=auto to upstream becasue of our UPSTREAM FIRST rule. Since it has been in RHEL for many years, each time a new RHEL main release anchor a upstream kernel release and is prepared, these crashkernel=auto RHEL-only patches need be reviewed inside Redhat, then we will be questioned and challenged why they are not in upstream.

As for how to implement crashkernel=auto, we have tried several ways.

1) Add into kernel command line

The suggested value need be stored in user space if added into kernel command line, then added into kernel. This makes the suggested value separated from kernel itself. It's not what we expect to see. Because the suggested crashkernel value is strongly related to distros release. We could adjust the value between sub-releases of kernel because of of kernel change. Adding them into kernel command line make us lose the track of them in kernel.

2) Add a weak generic function and several arch dependent functions
3) Hardcode values in __parse_crashkernel()

Method 2) is taken in our RHEL7, 3) is used in RHEL8, RHEL-only patches add them. If we try to push them into upstram, any later value adjustment need a upstream patch posting. Otherwise, RHEL-only patch need be introduced again, Redhat internal reviewer will challenge us again. (Put the value hard coding pieces at bottom for reference).

4) Add kernel config to add default value

It's done in this patch. With the kernel config CRASH_AUTO_STR, Distros can add default value, and adjust it anytime in the future w/o bothering upstream. If crashkernel=auto is specified, only below 3 LOC added, to go to parse the CONFIG_CRASH_AUTO_STR directly.

kernel/crash_core.c renamed from kernel/crash_core.c~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +6 -0
@@ -250,6 +251,12 @@ static int __init __parse_crashkernel(ch
        if (suffix)
                return parse_crashkernel_suffix(ck_cmdline, crash_size,
                                suffix);
+#ifdef CONFIG_CRASH_AUTO_STR
+       if (strncmp(ck_cmdline, "auto", 4) == 0) {
+               ck_cmdline = CONFIG_CRASH_AUTO_STR;
+               pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n");
+       }
+#endif
 
 

Before this, we don't know Saeed Mirzamohammadi, the patch author. He could experience the same torture. We were wild with joy when noticing his patch. We were planning to launch new round of post to add crashkernel=auto, kernel config is our final option too. We could be too happy to forget polishing the commit log.

Not sure if I make myself clear. Basically, we expect crashkernel=auto to be added in upstream kernel. About how to implement it in kernel, we would like to hear upstream people's suggestion.

Thanks
Baoquan

Hard code crashkernel=auto values in __parse_crashkernel()
===========================================================
static int __init __parse_crashkernel(char *cmdline,
unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base, const char *name, const char *suffix)
{
......

        if (strncmp(ck_cmdline, "auto", 4) == 0) {
#if defined(CONFIG_X86_64) || defined(CONFIG_S390)
                ck_cmdline = "1G-4G:160M,4G-64G:192M,64G-1T:256M,1T-:512M";
#elif defined(CONFIG_ARM64)
                ck_cmdline = "2G-:448M";
#elif defined(CONFIG_PPC64)
                char *fadump_cmdline;

                fadump_cmdline = get_last_crashkernel(cmdline, "fadump=", NULL);
                fadump_cmdline = fadump_cmdline ?
                                fadump_cmdline + strlen("fadump=") : NULL;
                if (!fadump_cmdline || (strncmp(fadump_cmdline, "off", 3) == 0))
                        ck_cmdline = "2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G";
                else
                        ck_cmdline = "4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-:180G";
#endif
                pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n");
        }

......
}
==================================================================

#55 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

In reply to Andrew Morton
Quoted 111 lines · Andrew Morton

From: Saeed Mirzamohammadi <[email protected]>
Subject: kernel/crash_core: add crashkernel=auto for vmcore creation

This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs.

Cc Baoquan He <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc "Guilherme G. Piccoli" <[email protected]>
Cc Kees Cook <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "Steven Rostedt (VMware)" <[email protected]>
Cc YiFei Zhu <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Sami Tolvanen <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Colin Ian King <[email protected]>

---

  Documentation/admin-guide/kdump/kdump.rst       |    3 +-
  Documentation/admin-guide/kernel-parameters.txt |    6 ++++
  arch/Kconfig                                    |   20 ++++++++++++++
  kernel/crash_core.c                             |    7 ++++
  4 files changed, 35 insertions(+), 1 deletion(-)
arch/Kconfig renamed from arch/Kconfig~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +20 -0
@@ -14,6 +14,26 @@ menu "General architecture-dependent opt
  config CRASH_CORE
  	bool
 
+config CRASH_AUTO_STR
+	string "Memory reserved for crash kernel"
+	depends on CRASH_CORE
+	default "1G-64G:128M,64G-1T:256M,1T-:512M"
+	help
+	  This configures the reserved memory dependent
+	  on the value of System RAM. The syntax is:
+	  crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
+	              range=start-[end]
+
+	  For example:
+	      crashkernel=512M-2G:64M,2G-:128M
+
+	  This would mean:
+
+	      1) if the RAM is smaller than 512M, then don't reserve anything
+	         (this is the "rescue" case)
+	      2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
+	      3) if the RAM size is larger than 2G, then reserve 128M
+
  config KEXEC_CORE
  	select CRASH_CORE
  	bool
Documentation/admin-guide/kdump/kdump.rst renamed from Documentation/admin-guide/kdump/kdump.rst~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +2 -1
@@ -285,7 +285,8 @@ This would mean:
      2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
      3) if the RAM size is larger than 2G, then reserve 128M
 
-
+Or you can use crashkernel=auto to choose the crash kernel memory size
+based on the recommended configuration set for each arch.
 
  Boot into System Kernel
  =======================
Documentation/admin-guide/kernel-parameters.txt renamed from Documentation/admin-guide/kernel-parameters.txt~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +6 -0
@@ -751,6 +751,12 @@
  			a memory unit (amount[KMG]). See also
  			Documentation/admin-guide/kdump/kdump.rst for an example.
 
+	crashkernel=auto
+			[KNL] This parameter will set the reserved memory for
+			the crash kernel based on the value of the CRASH_AUTO_STR
+			that is the best effort estimation for each arch. See also
+			arch/Kconfig for further details.
+
  	crashkernel=size[KMG],high
  			[KNL, X86-64] range could be above 4G. Allow kernel
  			to allocate physical memory region from top, so could
kernel/crash_core.c renamed from kernel/crash_core.c~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +1 -0
@@ -7,6 +7,7 @@
  #include <linux/crash_core.h>
  #include <linux/utsname.h>
  #include <linux/vmalloc.h>
+#include <linux/kexec.h>
 
  #include <asm/page.h>
  #include <asm/sections.h>

kernel/crash_core.c static int __init __parse_crashkernel(ch · line 259

Quoted 9 lines
kernel/crash_core.c renamed from kernel/crash_core.c~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +6 -0
@@ -250,6 +251,12 @@ static int __init __parse_crashkernel(ch
  	if (suffix)
  		return parse_crashkernel_suffix(ck_cmdline, crash_size,
  				suffix);
+#ifdef CONFIG_CRASH_AUTO_STR
+	if (strncmp(ck_cmdline, "auto", 4) == 0) {
+		ck_cmdline = CONFIG_CRASH_AUTO_STR;
+		pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n");
+	}
+#endif

I remember that the original "crashkernel=auto" as once proposed by Red Hat people did not receive a warm welcome.

Let me take a look .... oh, there it is from 2009

https://marc.info/?t=125006512600002&r=1&w=2

and then we had it in 2018

https://lkml.org/lkml/2018/5/20/262

The issue I have with this: it's just plain wrong when you take memory hotplug into serious account as we see it quite heavily in VMs. You don't know what you'll need when building a kernel. Just pass it via the cmdline ...

Signature · 3 lines
Thanks,

David / dhildenb
#56 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 1 line · David Hildenbrand

On 07.05.21 03:04, Andrew Morton wrote:

......

Quoted 81 lines
Quoted 69 lines
  Documentation/admin-guide/kdump/kdump.rst       |    3 +-
  Documentation/admin-guide/kernel-parameters.txt |    6 ++++
  arch/Kconfig                                    |   20 ++++++++++++++
  kernel/crash_core.c                             |    7 ++++
  4 files changed, 35 insertions(+), 1 deletion(-)
arch/Kconfig renamed from arch/Kconfig~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +20 -0
@@ -14,6 +14,26 @@ menu "General architecture-dependent opt
  config CRASH_CORE
  	bool
+config CRASH_AUTO_STR
+	string "Memory reserved for crash kernel"
+	depends on CRASH_CORE
+	default "1G-64G:128M,64G-1T:256M,1T-:512M"
+	help
+	  This configures the reserved memory dependent
+	  on the value of System RAM. The syntax is:
+	  crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
+	              range=start-[end]
+
+	  For example:
+	      crashkernel=512M-2G:64M,2G-:128M
+
+	  This would mean:
+
+	      1) if the RAM is smaller than 512M, then don't reserve anything
+	         (this is the "rescue" case)
+	      2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
+	      3) if the RAM size is larger than 2G, then reserve 128M
+
  config KEXEC_CORE
  	select CRASH_CORE
  	bool
Documentation/admin-guide/kdump/kdump.rst renamed from Documentation/admin-guide/kdump/kdump.rst~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +2 -1
@@ -285,7 +285,8 @@ This would mean:
      2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
      3) if the RAM size is larger than 2G, then reserve 128M
-
+Or you can use crashkernel=auto to choose the crash kernel memory size
+based on the recommended configuration set for each arch.
  Boot into System Kernel
  =======================
Documentation/admin-guide/kernel-parameters.txt renamed from Documentation/admin-guide/kernel-parameters.txt~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +6 -0
@@ -751,6 +751,12 @@
  			a memory unit (amount[KMG]). See also
  			Documentation/admin-guide/kdump/kdump.rst for an example.
+	crashkernel=auto
+			[KNL] This parameter will set the reserved memory for
+			the crash kernel based on the value of the CRASH_AUTO_STR
+			that is the best effort estimation for each arch. See also
+			arch/Kconfig for further details.
+
  	crashkernel=size[KMG],high
  			[KNL, X86-64] range could be above 4G. Allow kernel
  			to allocate physical memory region from top, so could
kernel/crash_core.c renamed from kernel/crash_core.c~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +1 -0
@@ -7,6 +7,7 @@
  #include <linux/crash_core.h>
  #include <linux/utsname.h>
  #include <linux/vmalloc.h>
+#include <linux/kexec.h>
  #include <asm/page.h>
  #include <asm/sections.h>

kernel/crash_core.c static int __init __parse_crashkernel(ch · line 259

Quoted 9 lines
kernel/crash_core.c renamed from kernel/crash_core.c~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +6 -0
@@ -250,6 +251,12 @@ static int __init __parse_crashkernel(ch
  	if (suffix)
  		return parse_crashkernel_suffix(ck_cmdline, crash_size,
  				suffix);
+#ifdef CONFIG_CRASH_AUTO_STR
+	if (strncmp(ck_cmdline, "auto", 4) == 0) {
+		ck_cmdline = CONFIG_CRASH_AUTO_STR;
+		pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n");
+	}
+#endif

I remember that the original "crashkernel=auto" as once proposed by Red Hat people did not receive a warm welcome.

Quoted 7 lines

Let me take a look .... oh, there it is from 2009

https://marc.info/?t=125006512600002&r=1&w=2

and then we had it in 2018

https://lkml.org/lkml/2018/5/20/262

Thanks for digging these two out, otherwise I may need do for people to know the history better.

Quoted 5 lines

The issue I have with this: it's just plain wrong when you take memory hotplug into serious account as we see it quite heavily in VMs. You don't know what you'll need when building a kernel. Just pass it via the cmdline

Hmm, kdump may have no issue with memory hotplug in crashkernel reservation aspect. The system RAM size is not correlated to crashkernel size directly, that's why the default value in this patch is not linear related to system RAM size. The proportion of crashkernel size to the total RAM size is thing we take into account. Usually crashkernel 160M is enough on most of systems. If system RAM size is larger, extra memory can be added just in case, and not bring much impact to system.

With our investigation, PCIe devices impact the crashkernel size, and cpu number. There are always pci devices which driver require tens of KB meomry, even MB. E.g in below patch, my colleague Coiby found out the i40e network card even cost 1.5G memory to initialize its ringbuffer on ppc, and 85M on x86_64.

[PATCH v1 0/3] Reducing memory usage of i40e for kdump
http://lists.infradead.org/pipermail/kexec/2021-March/022117.html

Even though not all pci devices need surprisingly large memory like i40e, system with hundreds of pci devices can also cost more memory than expected. This kind of system usually is high end server, specified crashkernel value need be set manually.

So system RAM size is the least important part to influence crashkernel costing. Say my x1 laptop, even though I extended the RAM to 100TB, 160M crashkernel is still enough. Just we would like to get a tiny extra part to add to crashkernel if the total RAM is very large, that's the rule for crashkernel=auto. As for VMs, given their very few devices, virtio disk, NAT nic, etc, no matter how much memory is deployed and hot added/removed, crashkernel size won't be influenced very much. My personal understanding about it.

Thanks
Baoquan

#57 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 10 lines
Quoted 7 lines

Let me take a look .... oh, there it is from 2009

https://marc.info/?t=125006512600002&r=1&w=2

and then we had it in 2018

https://lkml.org/lkml/2018/5/20/262

Thanks for digging these two out, otherwise I may need do for people to know the history better.

Sure, I stumbled over this myself recently when wondering about what fadump is.

Quoted 7 lines
Quoted 3 lines

The issue I have with this: it's just plain wrong when you take memory hotplug into serious account as we see it quite heavily in VMs. You don't know what you'll need when building a kernel. Just pass it via the cmdline

Hmm, kdump may have no issue with memory hotplug in crashkernel reservation aspect. The system RAM size is not correlated to crashkernel size directly, that's why the default value in this patch is

"Not correlated directly" ...

"1G-64G:128M,64G-1T:256M,1T-:512M"

Am I still asleep and dreaming? :)

Quoted 5 lines

not linear related to system RAM size. The proportion of crashkernel size to the total RAM size is thing we take into account. Usually crashkernel 160M is enough on most of systems. If system RAM size is larger, extra memory can be added just in case, and not bring much impact to system.

So, all the rules we have are essentially broken because they rely completely on the system RAM during boot.

Quoted 10 lines

With our investigation, PCIe devices impact the crashkernel size, and cpu number. There are always pci devices which driver require tens of KB meomry, even MB. E.g in below patch, my colleague Coiby found out the i40e network card even cost 1.5G memory to initialize its ringbuffer on ppc, and 85M on x86_64.

[PATCH v1 0/3] Reducing memory usage of i40e for kdump
http://lists.infradead.org/pipermail/kexec/2021-March/022117.html

Quoted 6 lines

Even though not all pci devices need surprisingly large memory like i40e, system with hundreds of pci devices can also cost more memory than expected. This kind of system usually is high end server, specified crashkernel value need be set manually.

So system RAM size is the least important part to influence crashkernel

Aehm, not with fadump, no?

Quoted 7 lines

costing. Say my x1 laptop, even though I extended the RAM to 100TB, 160M crashkernel is still enough. Just we would like to get a tiny extra part to add to crashkernel if the total RAM is very large, that's the rule for crashkernel=auto. As for VMs, given their very few devices, virtio disk, NAT nic, etc, no matter how much memory is deployed and hot added/removed, crashkernel size won't be influenced very much. My personal understanding about it.

That's an interesting observation. But you're telling me that we end up wasting memory for the crashkernel because "crashkernel=auto" which is supposed to do something magical good automatically does something very suboptimal? Oh my ... this is broken.

Long story short: crashkernel=auto is pure ugliness.

Why can't we construct a crashkernel in user space when installing/activating kdump and requiring a reboot for kdump to be active as long as that crashkernel setting is not properly respected?

Just have a look at the system properties (is_qemu(), #PCI, ...) and propose a value for "crashkernel=". Check that that value is at least active when activating kdump. Otherwise don't enable kdump and fail.

Yes, it can be difficult with some newer/older kernels having some different demands, but things should change drastically, and a distro can always update its advises along with the kernel, no?

You could even have a kernel interface that gives you the current crashkernel size (maybe already there) vs. the recommended crashkernel size. Make kdump or *whoever* activate that in the cmdline and let kdump check if both values are satisfied when booting up.

Also: this approach here doesn't make any sense when you want to do something dependent on other cmdline parameters. Take "fadump=on" vs "fadump=off" as an example. You just cannot handle it properly as proposed in this patch. To me the approach in this patch makes least sense TBH.

Signature · 3 lines
Thanks,

David / dhildenb
#58 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 23 lines · David Hildenbrand
Quoted 10 lines
Quoted 7 lines

Let me take a look .... oh, there it is from 2009

https://marc.info/?t=125006512600002&r=1&w=2

and then we had it in 2018

https://lkml.org/lkml/2018/5/20/262

Thanks for digging these two out, otherwise I may need do for people to know the history better.

Sure, I stumbled over this myself recently when wondering about what fadump is.

Quoted 7 lines
Quoted 3 lines

The issue I have with this: it's just plain wrong when you take memory hotplug into serious account as we see it quite heavily in VMs. You don't know what you'll need when building a kernel. Just pass it via the cmdline

Hmm, kdump may have no issue with memory hotplug in crashkernel reservation aspect. The system RAM size is not correlated to crashkernel size directly, that's why the default value in this patch is

Quoted 5 lines

"Not correlated directly" ...

"1G-64G:128M,64G-1T:256M,1T-:512M"

Am I still asleep and dreaming? :)

Well, I said 'Not correlated directly', then gave sentences to explan the reason. I would like to repeat them:

1) Crashkernel need more memory on some systems mainly because of device driver. You can take a system, no matter how much memory you increse or decrease total system RAM size, the crashkernel size needed is invariable.

- The extreme case I have give about the i40e.
- And the more devices, narutally the more memory needed.

2) About "1G-64G:128M,64G-1T:256M,1T-:512M", I also said the different value is because taking very low proprotion of extra memory to avoid potential risk, it's cost effective. Here, add another 90M which is 0.13% of 64G, 0.0085% of 1TB.

Hope it can help people sober up.

Quoted 10 lines
Quoted 7 lines

not linear related to system RAM size. The proportion of crashkernel size to the total RAM size is thing we take into account. Usually crashkernel 160M is enough on most of systems. If system RAM size is larger, extra memory can be added just in case, and not bring much impact to system.

So, all the rules we have are essentially broken because they rely completely on the system RAM during boot.

How do you get this?

Crashkernel=auto is a default value. PC, VMs, normal workstation and server which are the overall majority can work well with it. I can say the number is 99%. Only very few high end workstation, servers which contain many PCI devices need investigation to decide crashkernel size. A possible manual setting and rebooting is needed for them. You call this 'essentially broken'? So you later suggestd constructing crashkernel value in user space and rebooting is not broken? Even though it's the similar thing? what is your logic behind your conclusion?

Crashkernel=auto is mainly targetting most of systems, help people w/o much knowledge of kdump implementation to use it for debugging.

I can say more about the benefit of crashkernel=auto. On Fedora, the community distros sponsord by Redhat, the kexec/kdump is also maintained by us. Fedora kernel is mainline kernel, so no crashkernel=auto provided. We almost never get bug report from users, means almost nobody use it. We hope Fedora users' usage can help test functionality of component.

Quoted 11 lines
Quoted 11 lines

With our investigation, PCIe devices impact the crashkernel size, and cpu number. There are always pci devices which driver require tens of KB meomry, even MB. E.g in below patch, my colleague Coiby found out the i40e network card even cost 1.5G memory to initialize its ringbuffer on ppc, and 85M on x86_64.

[PATCH v1 0/3] Reducing memory usage of i40e for kdump
http://lists.infradead.org/pipermail/kexec/2021-March/022117.html

Quoted 8 lines
Quoted 6 lines

Even though not all pci devices need surprisingly large memory like i40e, system with hundreds of pci devices can also cost more memory than expected. This kind of system usually is high end server, specified crashkernel value need be set manually.

So system RAM size is the least important part to influence crashkernel

Aehm, not with fadump, no?

Fadump makes use of crashkernel reservation, but has different mechanism to dumping. It needs a kernel config too if this patch is accepted, or it can add it to command line from a user space program, I will talk about that later. This depends on IBM's decision, I have added Hari to CC, they will make the best choice after consideration.

}

Quoted 9 lines
Quoted 8 lines

costing. Say my x1 laptop, even though I extended the RAM to 100TB, 160M crashkernel is still enough. Just we would like to get a tiny extra part to add to crashkernel if the total RAM is very large, that's the rule for crashkernel=auto. As for VMs, given their very few devices, virtio disk, NAT nic, etc, no matter how much memory is deployed and hot added/removed, crashkernel size won't be influenced very much. My personal understanding about it.

Quoted 6 lines

That's an interesting observation. But you're telling me that we end up wasting memory for the crashkernel because "crashkernel=auto" which is supposed to do something magical good automatically does something very suboptimal? Oh my ... this is broken.

Long story short: crashkernel=auto is pure ugliness.

Very interesting. Your long story is clear to me, but your short story confuses me a lot.

Let me try to sort out and understand. In your first reply, you asserted "it's plain wrong when taking memory hotplug serious account as we see it quite heavily in VMs", means you plain don't know if it's wrong, but you say it's plain wrong. I answered you 'no, not at all' with detailed explanation, means it's plain opposite to your assertion. So then you quickly came to 'crashkernel=auto is pure ugliness'. If a simple crashkernel=auto is added to cover 99% systems, and advanced operation only need be done for the rest which is tiny proportion, this is called pure ugliness, what's pure beauty? Here I say 99%, I could be very conservative.

Quoted 9 lines

Why can't we construct a crashkernel in user space when installing/activating kdump and requiring a reboot for kdump to be active as long as that crashkernel setting is not properly respected?

Just have a look at the system properties (is_qemu(), #PCI, ...) and propose a value for "crashkernel=". Check that that value is at least active when activating kdump. Otherwise don't enable kdump and fail.

Quoted 8 lines

Yes, it can be difficult with some newer/older kernels having some different demands, but things should change drastically, and a distro can always update its advises along with the kernel, no?

You could even have a kernel interface that gives you the current crashkernel size (maybe already there) vs. the recommended crashkernel size. Make kdump or *whoever* activate that in the cmdline and let kdump check if both values are satisfied when booting up.

Now, let's go to your long story.

Yes, if you haven't seen our patch in fedora kexec-tools maining list, your suggested approach is the exactly same thing we are doing, please check below patch.

[PATCH v2] kdumpctl: Add kdumpctl estimate
https://lists.fedoraproject.org/archives/list/[email protected]/thread/YCEOJHQXKVEIVNB23M2TDAJGYVNP5MJZ/

We will provide a new feature in user space script, to let user check if their current crashkernel size is good or not. If not, they can adjust accordingly.

But, where's the current crashkernel size coming from? Surely crashkernel=auto. You wouldn't add a random crashkernel size then compared with the recommended crashkernel size, then reboot, will you? If crashkernel=auto get the expected size, no need to reboot. Means 99% of systems has no need to reboot. Only very few of systems, need reboot after checking the recommended size.

Long story short. crashkernel=auto will give a default value, trying to cover most of systems. (Very few high end server need check if it's enough and adjust with the help of user space tools. Then reboot.)

Quoted 5 lines

Also: this approach here doesn't make any sense when you want to do something dependent on other cmdline parameters. Take "fadump=on" vs "fadump=off" as an example. You just cannot handle it properly as proposed in this patch. To me the approach in this patch makes least sense TBH.

Why? We don't have this kind of judgement in kernel? Crashkernel=auto is a generic mechanism, and has been added much earlier. Fadump was added later by IBM for their need on ppc only, it relies on crashkernel reservation but different mechanism of dumping. If it has different value than kdump, a special hanlding is certainly needed. Who tell it has to be 'fadump=on'? They can check the value in user space program and add into cmdline as you suggested, they can also make it into auto. The most suitable is the best.

And I have several questions to ask, hope you can help answer:

1) Have you ever met crashkernel=auto broken on virt platform?

Asking this because you are from Virt team, and crashkernel=auto has been there in RHEL for many years, and we have been working with Virt team to support dumping. We haven't seen any bug report or complaint about crashkernel=auto from Virt.

2) Adding crashkernel=auto, and the kdumpctl estimate as user space program to get a recommended size, then reboot. Removing crashkernel=auto, only the kdumpctl estimate to get a recommended size, always reboot. In RHEL we will take the 1st option. Are you willing to take the 2nd one for Virt platform since you think crashkernel=auto is plain wrong, pure ugliness, essentially broken, least sense?

Thanks
Baoquan

#59 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 15 lines
Quoted 6 lines

"Not correlated directly" ...

"1G-64G:128M,64G-1T:256M,1T-:512M"

Am I still asleep and dreaming? :)

Well, I said 'Not correlated directly', then gave sentences to explan the reason. I would like to repeat them:

1) Crashkernel need more memory on some systems mainly because of device driver. You can take a system, no matter how much memory you increse or decrease total system RAM size, the crashkernel size needed is invariable.

Quoted 7 lines

- The extreme case I have give about the i40e.
- And the more devices, narutally the more memory needed.

2) About "1G-64G:128M,64G-1T:256M,1T-:512M", I also said the different value is because taking very low proprotion of extra memory to avoid potential risk, it's cost effective. Here, add another 90M which is 0.13% of 64G, 0.0085% of 1TB.

Just let me clarify the problem I am having with all of this:

We model the crashkernel size as a function of the memory size. Yet, it's pretty much independent of the memory size. That screams for "ugly".

The main problem is that early during boot we don't have a clue how much crashkernel memory we may need. So what I see is that we are mostly using a heuristic based on the memory size to come up with the right answer how much devices we might have. That just feels very wrong.

I can understand the reasoning of "using a fraction of the memory size" when booting up just to be on the safe side as we don't know", and that motivation is much better than what I read so far. But then I wonder if we cannot handle that any better? Because this feels very suboptimal to me and I feel like there can be cases where the heuristic is just wrong.

As one example, can I add a whole bunch of devices to a 32GB VM and break "crashkernel=auto"?

As another example, when I boot a 64G VM, the crashkernel size will be 512MB, although I really only might need 128MB. That's an effective overhead of 0.5%. And especially when we take memory ballooning etc. into account it can effectively be more than that.

Let's do a more detailed look. PPC64 in kernel-ark:

"2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G";

Assume I would only need 385M on a simple 16GB VM. We would have an overhead of ~4%. But maybe on ppc64 we do have to take the memory size into account (my assumption and, thus, my comment regarding memory hotplug)?

I wonder if we could always try allocating larger granularity (falling back to smaller if it fails), and once the kernel is able to come up with a better answer how many devices there are and, thus, how big the crashkernel area really should be, shrink the preallocated crashkernel (either from the kernel or from user space)? Not completely trivial but possible I think. It's trivial when we allocate a memmap for the crashkernel (I think we mostly do but I might be wrong).

The "crashkernel=auto" would really do something magical good instead of implement some heuristic base don the memory size.

[...]

Quoted 5 lines
Quoted 2 lines

So, all the rules we have are essentially broken because they rely completely on the system RAM during boot.

How do you get this?

Quoted 8 lines

Crashkernel=auto is a default value. PC, VMs, normal workstation and server which are the overall majority can work well with it. I can say the number is 99%. Only very few high end workstation, servers which contain many PCI devices need investigation to decide crashkernel size. A possible manual setting and rebooting is needed for them. You call this 'essentially broken'? So you later suggestd constructing crashkernel value in user space and rebooting is not broken? Even though it's the similar thing? what is your logic behind your conclusion?

A kernel early during boot can only guess. A kernel late during boot knows. Please correct me if I'm wrong.

Quoted 10 lines

Crashkernel=auto is mainly targetting most of systems, help people w/o much knowledge of kdump implementation to use it for debugging.

I can say more about the benefit of crashkernel=auto. On Fedora, the community distros sponsord by Redhat, the kexec/kdump is also maintained by us. Fedora kernel is mainline kernel, so no crashkernel=auto provided. We almost never get bug report from users, means almost nobody use it. We hope Fedora users' usage can help test functionality of component.

I know how helpful "crashkernel=auto" was so far, but I am also aware that there was strong pushback in the past, and I remember for the reasons I gave. IMHO we should refine that approach instead of trying to push the same thing upstream every couple of years.

I ran into the "512MB crashkernel" on a 64G VM with memory ballooning issue already but didn't report a BZ, because so far, I was under the impression that more memory means more crashkernel. But you explained to me that I was just running into a (for my use case) bad heuristic.

Quoted 10 lines
Quoted 3 lines
Quoted 1 line

So system RAM size is the least important part to influence crashkernel

Aehm, not with fadump, no?

Fadump makes use of crashkernel reservation, but has different mechanism to dumping. It needs a kernel config too if this patch is accepted, or it can add it to command line from a user space program, I will talk about that later. This depends on IBM's decision, I have added Hari to CC, they will make the best choice after consideration.

I was looking at RHEL8, and there we have

fadump_cmdline = get_last_crashkernel(cmdline, "fadump=", NULL);
...
if (!fadump_cmdline || (strncmp(fadump_cmdline, "off", 3) == 0))

	ck_cmdline = ...
else
	ck_cmdline = ...

which was a runtime check for fadump.

Something that cannot be modeled properly at least with this patch here.

Quoted 17 lines

}

Quoted 9 lines
Quoted 8 lines

costing. Say my x1 laptop, even though I extended the RAM to 100TB, 160M crashkernel is still enough. Just we would like to get a tiny extra part to add to crashkernel if the total RAM is very large, that's the rule for crashkernel=auto. As for VMs, given their very few devices, virtio disk, NAT nic, etc, no matter how much memory is deployed and hot added/removed, crashkernel size won't be influenced very much. My personal understanding about it.

Quoted 6 lines

That's an interesting observation. But you're telling me that we end up wasting memory for the crashkernel because "crashkernel=auto" which is supposed to do something magical good automatically does something very suboptimal? Oh my ... this is broken.

Long story short: crashkernel=auto is pure ugliness.

Quoted 8 lines

Very interesting. Your long story is clear to me, but your short story confuses me a lot.

Let me try to sort out and understand. In your first reply, you asserted "it's plain wrong when taking memory hotplug serious account as we see it quite heavily in VMs", means you plain don't know if it's wrong, but you say it's plain wrong. I answered you 'no, not at all' with detailed explanation, means it's plain opposite to your assertion.

Yep, I might be partially wrong about memory hotplug thingy, mostly because I had the RHEL8 rule for ppc64 (including fadump) in mind. For dynamic resizing of VMs, the current rules for VMs can be very sub-optimal.

Let's relax "plain wrong" to "the heuristic can be very suboptimal because it uses something mostly unrelated to come up with an answer". And it's simply not plain wrong because in practice it gets the job done. Mostly.

Quoted 5 lines

So then you quickly came to 'crashkernel=auto is pure ugliness'. If a simple crashkernel=auto is added to cover 99% systems, and advanced operation only need be done for the rest which is tiny proportion, this is called pure ugliness, what's pure beauty? Here I say 99%, I could be very conservative.

I don't like wasting memory just because we cannot come up with a better heuristic. Yes, it somewhat gets the job done, but I call that ugly. My humble opinion.

[...]

Quoted 11 lines

Yes, if you haven't seen our patch in fedora kexec-tools maining list, your suggested approach is the exactly same thing we are doing, please check below patch.

[PATCH v2] kdumpctl: Add kdumpctl estimate
https://lists.fedoraproject.org/archives/list/[email protected]/thread/YCEOJHQXKVEIVNB23M2TDAJGYVNP5MJZ/

We will provide a new feature in user space script, to let user check if their current crashkernel size is good or not. If not, they can adjust accordingly.

That's good, thanks for the pointer -- wasn't aware of that.

Quoted 11 lines

But, where's the current crashkernel size coming from? Surely crashkernel=auto. You wouldn't add a random crashkernel size then compared with the recommended crashkernel size, then reboot, will you? If crashkernel=auto get the expected size, no need to reboot. Means 99% of systems has no need to reboot. Only very few of systems, need reboot after checking the recommended size.

Long story short. crashkernel=auto will give a default value, trying to cover most of systems. (Very few high end server need check if it's enough and adjust with the help of user space tools. Then reboot.)

Then we might really want to investigate into shrinking a possibly larger allocation dynamically during boot.

Quoted 6 lines
Quoted 5 lines

Also: this approach here doesn't make any sense when you want to do something dependent on other cmdline parameters. Take "fadump=on" vs "fadump=off" as an example. You just cannot handle it properly as proposed in this patch. To me the approach in this patch makes least sense TBH.

Quoted 8 lines

Why? We don't have this kind of judgement in kernel? Crashkernel=auto is a generic mechanism, and has been added much earlier. Fadump was added later by IBM for their need on ppc only, it relies on crashkernel reservation but different mechanism of dumping. If it has different value than kdump, a special hanlding is certainly needed. Who tell it has to be 'fadump=on'? They can check the value in user space program and add into cmdline as you suggested, they can also make it into auto. The most suitable is the best.

Take a look at the RHEL8 handling to see where my comment is coming from.

Quoted 4 lines

And I have several questions to ask, hope you can help answer:

1) Have you ever met crashkernel=auto broken on virt platform?

I have encountered it being very suboptimal. I call wasting hundreds of MB problematic, especially when dynamically resizing of VMs (for example, using memory ballooning)

Quoted 5 lines

Asking this because you are from Virt team, and crashkernel=auto has been there in RHEL for many years, and we have been working with Virt team to support dumping. We haven't seen any bug report or complaint about crashkernel=auto from Virt.

I've had plenty of bug reports where people try inflating the balloon fairly heavily but don't take the crashkernel size into account. The bigger the crashkernel size, the bigger the issue when people try squeezing the last couple of MB out of their VMs. I keep repeating to them "with crashkernel=auto, you have to be careful about how much memory might get set aside for the crashkernel and, therefore, reduces your effective guest OS RAM size and reduces the maximum balloon size".

Quoted 7 lines

2) Adding crashkernel=auto, and the kdumpctl estimate as user space program to get a recommended size, then reboot. Removing crashkernel=auto, only the kdumpctl estimate to get a recommended size, always reboot. In RHEL we will take the 1st option. Are you willing to take the 2nd one for Virt platform since you think crashkernel=auto is plain wrong, pure ugliness, essentially broken, least sense?

We are talking about upstreaming stuff here and I am wearing my upstream hat here. I'm stating (just like people decades ago) that this might not be the right approach for upstream, at least not as it stands.

And no, I don't have time to solve problems/implement solutions/upstream patches to tackle fundamental issues that have been there for decades.

I'll be happy to help looking into dynamic shrinking of the crashkernel size if that approach makes sense. We could even let user space trigger that resizing -- without a reboot.

Signature · 3 lines
Thanks,

David / dhildenb
#60 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 33 lines · David Hildenbrand
Quoted 15 lines
Quoted 6 lines

"Not correlated directly" ...

"1G-64G:128M,64G-1T:256M,1T-:512M"

Am I still asleep and dreaming? :)

Well, I said 'Not correlated directly', then gave sentences to explan the reason. I would like to repeat them:

1) Crashkernel need more memory on some systems mainly because of device driver. You can take a system, no matter how much memory you increse or decrease total system RAM size, the crashkernel size needed is invariable.

Quoted 7 lines

- The extreme case I have give about the i40e.
- And the more devices, narutally the more memory needed.

2) About "1G-64G:128M,64G-1T:256M,1T-:512M", I also said the different value is because taking very low proprotion of extra memory to avoid potential risk, it's cost effective. Here, add another 90M which is 0.13% of 64G, 0.0085% of 1TB.

Just let me clarify the problem I am having with all of this:

We model the crashkernel size as a function of the memory size. Yet, it's pretty much independent of the memory size. That screams for "ugly".

The main problem is that early during boot we don't have a clue how much crashkernel memory we may need. So what I see is that we are mostly using a heuristic based on the memory size to come up with the right answer how much devices we might have. That just feels very wrong.

Quoted 5 lines

I can understand the reasoning of "using a fraction of the memory size" when booting up just to be on the safe side as we don't know", and that motivation is much better than what I read so far. But then I wonder if we cannot handle that any better? Because this feels very suboptimal to me and I feel like there can be cases where the heuristic is just wrong.

Yes, I understand what you said. Our headache is mainly from bare metal system worrying the reservation is not enough becuase of many devices.

On VM, it is truly different. With much less devices, it does waste some memory. Usually a fixed minimal size can cover 99.9% of system unless too many devices attached/added to VM, I am not sure what's the probability it could happen. While, by the help of /sys/kernel/kexec_crash_size, you can shrink it to an small enough but available size. Just you may need to reload kdump kernel because the loaded kernel should have been erazed and out of control. The shrinking should be done at early stage of kernel running, I would say, lest crash may happen during that period.

We ever tried several different ways to enlarge the crashkernel size dynamically, but didn't think of a good way.

Quoted 4 lines

As one example, can I add a whole bunch of devices to a 32GB VM and break "crashkernel=auto"?

Quoted 8 lines

As another example, when I boot a 64G VM, the crashkernel size will be 512MB, although I really only might need 128MB. That's an effective overhead of 0.5%. And especially when we take memory ballooning etc. into account it can effectively be more than that.

Let's do a more detailed look. PPC64 in kernel-ark:

"2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G";

Yes, the wasting mainly happens on ppc. Its 64K page size, caused the difference with other ARCHes. On x86_64, s390, it's much better, assuming most of VM won't own memory bigger than 64G, their crashkernel size will be 160M most of time.

Quoted 32 lines

Assume I would only need 385M on a simple 16GB VM. We would have an overhead of ~4%. But maybe on ppc64 we do have to take the memory size into account (my assumption and, thus, my comment regarding memory hotplug)?

I wonder if we could always try allocating larger granularity (falling back to smaller if it fails), and once the kernel is able to come up with a better answer how many devices there are and, thus, how big the crashkernel area really should be, shrink the preallocated crashkernel (either from the kernel or from user space)? Not completely trivial but possible I think. It's trivial when we allocate a memmap for the crashkernel (I think we mostly do but I might be wrong).

The "crashkernel=auto" would really do something magical good instead of implement some heuristic base don the memory size.

[...]

Quoted 5 lines
Quoted 2 lines

So, all the rules we have are essentially broken because they rely completely on the system RAM during boot.

How do you get this?

Quoted 8 lines

Crashkernel=auto is a default value. PC, VMs, normal workstation and server which are the overall majority can work well with it. I can say the number is 99%. Only very few high end workstation, servers which contain many PCI devices need investigation to decide crashkernel size. A possible manual setting and rebooting is needed for them. You call this 'essentially broken'? So you later suggestd constructing crashkernel value in user space and rebooting is not broken? Even though it's the similar thing? what is your logic behind your conclusion?

Quoted 2 lines

A kernel early during boot can only guess. A kernel late during boot knows. Please correct me if I'm wrong.

Well, I would not say it's guess, and would like to call them experical values from statistical data. With a priori vlaue given by 'auto', basically normal users of kdump don't need to care about the setting. E.g on Fedora, 'auto' can cover all systems, assume nobody would deploy it on a high end server. Everything we do is to make thing simple enough. If you don't know how to set, just add 'crashkernel=auto' to cmdline, then everything is done. I believe you agree that not everybody would like to dig into kexec/kdump just for getting how big crashkernel size need be set when they want to use kdump functionality.

Quoted 17 lines
Quoted 11 lines

Crashkernel=auto is mainly targetting most of systems, help people w/o much knowledge of kdump implementation to use it for debugging.

I can say more about the benefit of crashkernel=auto. On Fedora, the community distros sponsord by Redhat, the kexec/kdump is also maintained by us. Fedora kernel is mainline kernel, so no crashkernel=auto provided. We almost never get bug report from users, means almost nobody use it. We hope Fedora users' usage can help test functionality of component.

I know how helpful "crashkernel=auto" was so far, but I am also aware that there was strong pushback in the past, and I remember for the reasons I gave. IMHO we should refine that approach instead of trying to push the same thing upstream every couple of years.

Quoted 4 lines

I ran into the "512MB crashkernel" on a 64G VM with memory ballooning issue already but didn't report a BZ, because so far, I was under the impression that more memory means more crashkernel. But you explained to me that I was just running into a (for my use case) bad heuristic.

I re-read the old posts, didn't see strong push-back. People just gave some different ideas instead. When we were silent, we tried different way, e.g the enlarging crashkernel at run time as told at above, but failed. Reusing free pages and user space pages of 1st kernel in kdump kernel, also failed. We also talked with people to consult if it's doable to remove 'auto' support, nobody would like to give an affirmative answer. I know SUSE is using the way you mentioned to get a recommended size for long time, but it needs severeal more steps and need reboot. We prefer to take that way too as an improvement. The simpler, the better.

Besides, 'auto' doesn't introduce tons of complicated code, and we don't think of it with a pat on the head, then try to push to pollute kernel.

Quoted 17 lines
Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

So system RAM size is the least important part to influence crashkernel

Aehm, not with fadump, no?

Fadump makes use of crashkernel reservation, but has different mechanism to dumping. It needs a kernel config too if this patch is accepted, or it can add it to command line from a user space program, I will talk about that later. This depends on IBM's decision, I have added Hari to CC, they will make the best choice after consideration.

I was looking at RHEL8, and there we have

fadump_cmdline = get_last_crashkernel(cmdline, "fadump=", NULL);
...
if (!fadump_cmdline || (strncmp(fadump_cmdline, "off", 3) == 0))

Quoted 7 lines
	ck_cmdline = ...
else
	ck_cmdline = ...

which was a runtime check for fadump.

Something that cannot be modeled properly at least with this patch here.

Yes, I believe it won't be done like that. A static detection or a global switch variable can solve it.

Quoted 129 lines
Quoted 18 lines

}

Quoted 9 lines
Quoted 8 lines

costing. Say my x1 laptop, even though I extended the RAM to 100TB, 160M crashkernel is still enough. Just we would like to get a tiny extra part to add to crashkernel if the total RAM is very large, that's the rule for crashkernel=auto. As for VMs, given their very few devices, virtio disk, NAT nic, etc, no matter how much memory is deployed and hot added/removed, crashkernel size won't be influenced very much. My personal understanding about it.

Quoted 6 lines

That's an interesting observation. But you're telling me that we end up wasting memory for the crashkernel because "crashkernel=auto" which is supposed to do something magical good automatically does something very suboptimal? Oh my ... this is broken.

Long story short: crashkernel=auto is pure ugliness.

Quoted 8 lines

Very interesting. Your long story is clear to me, but your short story confuses me a lot.

Let me try to sort out and understand. In your first reply, you asserted "it's plain wrong when taking memory hotplug serious account as we see it quite heavily in VMs", means you plain don't know if it's wrong, but you say it's plain wrong. I answered you 'no, not at all' with detailed explanation, means it's plain opposite to your assertion.

Yep, I might be partially wrong about memory hotplug thingy, mostly because I had the RHEL8 rule for ppc64 (including fadump) in mind. For dynamic resizing of VMs, the current rules for VMs can be very sub-optimal.

Let's relax "plain wrong" to "the heuristic can be very suboptimal because it uses something mostly unrelated to come up with an answer". And it's simply not plain wrong because in practice it gets the job done. Mostly.

Quoted 5 lines

So then you quickly came to 'crashkernel=auto is pure ugliness'. If a simple crashkernel=auto is added to cover 99% systems, and advanced operation only need be done for the rest which is tiny proportion, this is called pure ugliness, what's pure beauty? Here I say 99%, I could be very conservative.

I don't like wasting memory just because we cannot come up with a better heuristic. Yes, it somewhat gets the job done, but I call that ugly. My humble opinion.

[...]

Quoted 11 lines

Yes, if you haven't seen our patch in fedora kexec-tools maining list, your suggested approach is the exactly same thing we are doing, please check below patch.

[PATCH v2] kdumpctl: Add kdumpctl estimate
https://lists.fedoraproject.org/archives/list/[email protected]/thread/YCEOJHQXKVEIVNB23M2TDAJGYVNP5MJZ/

We will provide a new feature in user space script, to let user check if their current crashkernel size is good or not. If not, they can adjust accordingly.

That's good, thanks for the pointer -- wasn't aware of that.

Quoted 11 lines

But, where's the current crashkernel size coming from? Surely crashkernel=auto. You wouldn't add a random crashkernel size then compared with the recommended crashkernel size, then reboot, will you? If crashkernel=auto get the expected size, no need to reboot. Means 99% of systems has no need to reboot. Only very few of systems, need reboot after checking the recommended size.

Long story short. crashkernel=auto will give a default value, trying to cover most of systems. (Very few high end server need check if it's enough and adjust with the help of user space tools. Then reboot.)

Then we might really want to investigate into shrinking a possibly larger allocation dynamically during boot.

Quoted 6 lines
Quoted 5 lines

Also: this approach here doesn't make any sense when you want to do something dependent on other cmdline parameters. Take "fadump=on" vs "fadump=off" as an example. You just cannot handle it properly as proposed in this patch. To me the approach in this patch makes least sense TBH.

Quoted 8 lines

Why? We don't have this kind of judgement in kernel? Crashkernel=auto is a generic mechanism, and has been added much earlier. Fadump was added later by IBM for their need on ppc only, it relies on crashkernel reservation but different mechanism of dumping. If it has different value than kdump, a special hanlding is certainly needed. Who tell it has to be 'fadump=on'? They can check the value in user space program and add into cmdline as you suggested, they can also make it into auto. The most suitable is the best.

Take a look at the RHEL8 handling to see where my comment is coming from.

Quoted 4 lines

And I have several questions to ask, hope you can help answer:

1) Have you ever met crashkernel=auto broken on virt platform?

I have encountered it being very suboptimal. I call wasting hundreds of MB problematic, especially when dynamically resizing of VMs (for example, using memory ballooning)

Quoted 5 lines

Asking this because you are from Virt team, and crashkernel=auto has been there in RHEL for many years, and we have been working with Virt team to support dumping. We haven't seen any bug report or complaint about crashkernel=auto from Virt.

I've had plenty of bug reports where people try inflating the balloon fairly heavily but don't take the crashkernel size into account. The bigger the crashkernel size, the bigger the issue when people try squeezing the last couple of MB out of their VMs. I keep repeating to them "with crashkernel=auto, you have to be careful about how much memory might get set aside for the crashkernel and, therefore, reduces your effective guest OS RAM size and reduces the maximum balloon size".

Quoted 7 lines

2) Adding crashkernel=auto, and the kdumpctl estimate as user space program to get a recommended size, then reboot. Removing crashkernel=auto, only the kdumpctl estimate to get a recommended size, always reboot. In RHEL we will take the 1st option. Are you willing to take the 2nd one for Virt platform since you think crashkernel=auto is plain wrong, pure ugliness, essentially broken, least sense?

We are talking about upstreaming stuff here and I am wearing my upstream hat here. I'm stating (just like people decades ago) that this might not be the right approach for upstream, at least not as it stands.

Quoted 6 lines

And no, I don't have time to solve problems/implement solutions/upstream patches to tackle fundamental issues that have been there for decades.

I'll be happy to help looking into dynamic shrinking of the crashkernel size if that approach makes sense. We could even let user space trigger that resizing -- without a reboot.

Don't reply each inline comment since I believe they have been covered by the earlier reply. Thanks for looking to this and telling your thought, to let us know that in fact you really care about the extra memory on VMs which we have realized, but didn't realized it really cause issue.

Thanks
Baoquan

#61 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 19 lines
Quoted 6 lines

I can understand the reasoning of "using a fraction of the memory size" when booting up just to be on the safe side as we don't know", and that motivation is much better than what I read so far. But then I wonder if we cannot handle that any better? Because this feels very suboptimal to me and I feel like there can be cases where the heuristic is just wrong.

Yes, I understand what you said. Our headache is mainly from bare metal system worrying the reservation is not enough becuase of many devices.

On VM, it is truly different. With much less devices, it does waste some memory. Usually a fixed minimal size can cover 99.9% of system unless too many devices attached/added to VM, I am not sure what's the probability it could happen. While, by the help of /sys/kernel/kexec_crash_size, you can shrink it to an small enough but available size. Just you may need to reload kdump kernel because the loaded kernel should have been erazed and out of control. The shrinking should be done at early stage of kernel running, I would say, lest crash may happen during that period.

Quoted 2 lines

We ever tried several different ways to enlarge the crashkernel size dynamically, but didn't think of a good way.

Yes, enlarging it at runtime much more difficult than shrinking.

[...]

Quoted 12 lines
Quoted 2 lines

A kernel early during boot can only guess. A kernel late during boot knows. Please correct me if I'm wrong.

Well, I would not say it's guess, and would like to call them experical values from statistical data. With a priori vlaue given by 'auto', basically normal users of kdump don't need to care about the setting. E.g on Fedora, 'auto' can cover all systems, assume nobody would deploy it on a high end server. Everything we do is to make thing simple enough. If you don't know how to set, just add 'crashkernel=auto' to cmdline, then everything is done. I believe you agree that not everybody would like to dig into kexec/kdump just for getting how big crashkernel size need be set when they want to use kdump functionality.

Oh absolutely. But OTOH, most users will leave the value untouched if it works -- and complain at least in the VM environment to me about surpises waste of system RAM with "crashkernel=auto".

[...]

Quoted 10 lines
Quoted 9 lines

I know how helpful "crashkernel=auto" was so far, but I am also aware that there was strong pushback in the past, and I remember for the reasons I gave. IMHO we should refine that approach instead of trying to push the same thing upstream every couple of years.

I ran into the "512MB crashkernel" on a 64G VM with memory ballooning issue already but didn't report a BZ, because so far, I was under the impression that more memory means more crashkernel. But you explained to me that I was just running into a (for my use case) bad heuristic.

Quoted 5 lines

I re-read the old posts, didn't see strong push-back. People just gave some different ideas instead. When we were silent, we tried different way, e.g the enlarging crashkernel at run time as told at above, but failed. Reusing free pages and user space pages of 1st kernel in kdump kernel, also failed. We also talked with people to consult if it's

Thanks for an insight into the history.

Quoted 4 lines

doable to remove 'auto' support, nobody would like to give an affirmative answer. I know SUSE is using the way you mentioned to get a recommended size for long time, but it needs severeal more steps and need reboot. We prefer to take that way too as an improvement. The simpler, the better.

At least I'm happy to hear that other people had the same idea as me ;)

I can understand the desire for simplicity. it would be great to hear SUSEs perception of the problem and how they would ideally want to move forward with this.

[...]

Quoted 9 lines
Quoted 3 lines

I'll be happy to help looking into dynamic shrinking of the crashkernel size if that approach makes sense. We could even let user space trigger that resizing -- without a reboot.

Don't reply each inline comment since I believe they have been covered by the earlier reply. Thanks for looking to this and telling your thought, to let us know that in fact you really care about the extra memory on VMs which we have realized, but didn't realized it really cause issue.

I mess with dynamic resizing of VMs, that's why I usually take a closer look at all things that do stuff based on the initial VM size; yes, there is still a lot other such things out there.

It also bugged me for quite a bit that we don't have a sane way to achieve what we're doing here upstream. It somewhat feels like "this doesn't belong in the kernel and is user policy" but then, the existing kernel support is suboptimal.

Maybe reserving some "maybe too big but okayish to boot the system in a sane environment -- e.g., X% of system RAM and at least Y" size first and shrinking it later as triggered by user space early (where we do seem to have a way to pre-calculate things now) might actually be a good direction to look into.

Signature · 3 lines
Thanks,

David / dhildenb
#62 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Hi David,
On 05/10/21 at 01:01pm, David Hildenbrand wrote:
[snip]

Quoted 10 lines

It also bugged me for quite a bit that we don't have a sane way to achieve what we're doing here upstream. It somewhat feels like "this doesn't belong in the kernel and is user policy" but then, the existing kernel support is suboptimal.

Maybe reserving some "maybe too big but okayish to boot the system in a sane environment -- e.g., X% of system RAM and at least Y" size first and shrinking it later as triggered by user space early (where we do seem to have a way to pre-calculate things now) might actually be a good direction to look into.

Hmm, that is also an option we considered before. Even for your suggestion we still need a kernel option to set the default ratio/value. and the ratio/value should be another patch which expands crashkernel syntax.

Actually the kconfig help text in this patch is indeed misleading, it is not introducing crashkernel=a:b... and no need to explain about the crashkernel syntax, the config option is actually just some interface we can add any valid crashkernel settings to be used by default. So current patch help text describes the default value of crash auto str, instead of describes what crash auto str is.

And crashkernel=auto makes this more flexibly. We can tune the values easily when upgrading. But if we pass a fixed value in userspace we can not know if the value is set by distribution automatically or by user manually thus we can not blindly update it.

Thanks
Dave

#63 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 1 line · Dave Young

Hi David,

Hi Dave,

Quoted 13 lines · David Hildenbrand

[snip]

Quoted 10 lines

It also bugged me for quite a bit that we don't have a sane way to achieve what we're doing here upstream. It somewhat feels like "this doesn't belong in the kernel and is user policy" but then, the existing kernel support is suboptimal.

Maybe reserving some "maybe too big but okayish to boot the system in a sane environment -- e.g., X% of system RAM and at least Y" size first and shrinking it later as triggered by user space early (where we do seem to have a way to pre-calculate things now) might actually be a good direction to look into.

Quoted 4 lines

Hmm, that is also an option we considered before. Even for your suggestion we still need a kernel option to set the default ratio/value. and the ratio/value should be another patch which expands crashkernel syntax.

Right.

Quoted 7 lines

Actually the kconfig help text in this patch is indeed misleading, it is not introducing crashkernel=a:b... and no need to explain about the crashkernel syntax, the config option is actually just some interface we can add any valid crashkernel settings to be used by default. So current patch help text describes the default value of crash auto str, instead of describes what crash auto str is.

Right. And I would much rather prefer either

a) handling "auto" completely in the kernel, not just setting some questionable default at compile time
b) passing it explicitly in via the cmdline

Quoted 5 lines

And crashkernel=auto makes this more flexibly. We can tune the values easily when upgrading. But if we pass a fixed value in userspace we can not know if the value is set by distribution automatically or by user manually thus we can not blindly update it.

I think there are two different cases:

1. kernel space updates the value later during boot. "crashkernel=auto" really does the right thing, meaning

a) allocate something reasonable and safe during early boot
b) update the allocation during late boot when we know what kind of system we're running on

Then, we indeed care about "crashkernel=auto" in the kernel and I think it would be a nice thing to have. The only question is on how to make that a little configurable, depending on different thingies we might want to run in the crashkernel (assuming someone doesn't want kdump).

2. user space updates the value later during boot

IMHO we don't really car who decided on the value as we do the update from user space. If an admin messes with crashkernel=, the admin can also mess with kdump not doing any overwrites (e.g., make that configurable, or detect the overwrite in kdump somehow).

Signature · 3 lines
Thanks,

David / dhildenb
#64 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 33 lines · David Hildenbrand
Quoted 1 line · Dave Young

Hi David,

Hi Dave,

Quoted 13 lines · David Hildenbrand

[snip]

Quoted 10 lines

It also bugged me for quite a bit that we don't have a sane way to achieve what we're doing here upstream. It somewhat feels like "this doesn't belong in the kernel and is user policy" but then, the existing kernel support is suboptimal.

Maybe reserving some "maybe too big but okayish to boot the system in a sane environment -- e.g., X% of system RAM and at least Y" size first and shrinking it later as triggered by user space early (where we do seem to have a way to pre-calculate things now) might actually be a good direction to look into.

Quoted 4 lines

Hmm, that is also an option we considered before. Even for your suggestion we still need a kernel option to set the default ratio/value. and the ratio/value should be another patch which expands crashkernel syntax.

Right.

Quoted 7 lines

Actually the kconfig help text in this patch is indeed misleading, it is not introducing crashkernel=a:b... and no need to explain about the crashkernel syntax, the config option is actually just some interface we can add any valid crashkernel settings to be used by default. So current patch help text describes the default value of crash auto str, instead of describes what crash auto str is.

Quoted 4 lines

Right. And I would much rather prefer either

a) handling "auto" completely in the kernel, not just setting some questionable default at compile time

Thanks for the suggestions.

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Quoted 36 lines

b) passing it explicitly in via the cmdline

Quoted 5 lines

And crashkernel=auto makes this more flexibly. We can tune the values easily when upgrading. But if we pass a fixed value in userspace we can not know if the value is set by distribution automatically or by user manually thus we can not blindly update it.

I think there are two different cases:

1. kernel space updates the value later during boot. "crashkernel=auto" really does the right thing, meaning

a) allocate something reasonable and safe during early boot
b) update the allocation during late boot when we know what kind of system we're running on

Then, we indeed care about "crashkernel=auto" in the kernel and I think it would be a nice thing to have. The only question is on how to make that a little configurable, depending on different thingies we might want to run in the crashkernel (assuming someone doesn't want kdump).

2. user space updates the value later during boot

IMHO we don't really car who decided on the value as we do the update from user space. If an admin messes with crashkernel=, the admin can also mess with kdump not doing any overwrites (e.g., make that configurable, or detect the overwrite in kdump somehow).

Signature · 3 lines
Thanks,

David / dhildenb
maintainer
#65 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Hi Baoquan,

Quoted 41 lines · Baoquan He
Quoted 33 lines · David Hildenbrand
Quoted 1 line · Dave Young

Hi David,

Hi Dave,

Quoted 13 lines · David Hildenbrand

[snip]

Quoted 10 lines

It also bugged me for quite a bit that we don't have a sane way to achieve what we're doing here upstream. It somewhat feels like "this doesn't belong in the kernel and is user policy" but then, the existing kernel support is suboptimal.

Maybe reserving some "maybe too big but okayish to boot the system in a sane environment -- e.g., X% of system RAM and at least Y" size first and shrinking it later as triggered by user space early (where we do seem to have a way to pre-calculate things now) might actually be a good direction to look into.

Quoted 4 lines

Hmm, that is also an option we considered before. Even for your suggestion we still need a kernel option to set the default ratio/value. and the ratio/value should be another patch which expands crashkernel syntax.

Right.

Quoted 7 lines

Actually the kconfig help text in this patch is indeed misleading, it is not introducing crashkernel=a:b... and no need to explain about the crashkernel syntax, the config option is actually just some interface we can add any valid crashkernel settings to be used by default. So current patch help text describes the default value of crash auto str, instead of describes what crash auto str is.

Quoted 4 lines

Right. And I would much rather prefer either

a) handling "auto" completely in the kernel, not just setting some questionable default at compile time

Thanks for the suggestions.

Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Quoted 38 lines
Quoted 36 lines

b) passing it explicitly in via the cmdline

Quoted 5 lines

And crashkernel=auto makes this more flexibly. We can tune the values easily when upgrading. But if we pass a fixed value in userspace we can not know if the value is set by distribution automatically or by user manually thus we can not blindly update it.

I think there are two different cases:

1. kernel space updates the value later during boot. "crashkernel=auto" really does the right thing, meaning

a) allocate something reasonable and safe during early boot
b) update the allocation during late boot when we know what kind of system we're running on

Then, we indeed care about "crashkernel=auto" in the kernel and I think it would be a nice thing to have. The only question is on how to make that a little configurable, depending on different thingies we might want to run in the crashkernel (assuming someone doesn't want kdump).

2. user space updates the value later during boot

IMHO we don't really car who decided on the value as we do the update from user space. If an admin messes with crashkernel=, the admin can also mess with kdump not doing any overwrites (e.g., make that configurable, or detect the overwrite in kdump somehow).

Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Sincerely yours,
Mike.
#66 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 15 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

a) roughly the same kernel
b) with roughly the same drivers

The "user space" part is completely under user space control, depending on what application will be run after kexec.

So I wonder if something like

crashkernel=auto,100M

whereby "100M" corresponds to user space demands in addition to the variable part depend on the current kernel + drivers.

would already be somewhat sufficient for main use cases I guess.

Of course, that approach will get more complicated if the user space portion heavily depends on the drivers etc. Then we need more tunables.

Signature · 3 lines
Thanks,

David / dhildenb
#67 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 38 lines · David Hildenbrand
Quoted 14 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

Quoted 5 lines

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

a) roughly the same kernel
b) with roughly the same drivers

As replied to Mike, kernel size is undecided for different kernel with different configs. We can define a default minimal size to cover kernel and driver on systems with not many devices, but hardcoding the size into upstream is not helpful. If the size is big, users will be asked to check and shrink always. If the size is too small, a new value need be got and added to cmdline and reboot.

Quoted 21 lines

The "user space" part is completely under user space control, depending on what application will be run after kexec.

So I wonder if something like

crashkernel=auto,100M

whereby "100M" corresponds to user space demands in addition to the variable part depend on the current kernel + drivers.

would already be somewhat sufficient for main use cases I guess.

Of course, that approach will get more complicated if the user space portion heavily depends on the drivers etc. Then we need more tunables.

Signature · 3 lines
Thanks,

David / dhildenb
#68 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 42 lines · Baoquan He
Quoted 41 lines · David Hildenbrand
Quoted 14 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

Quoted 6 lines
Quoted 2 lines

a) roughly the same kernel
b) with roughly the same drivers

As replied to Mike, kernel size is undecided for different kernel with different configs. We can define a default minimal size to cover kernel and driver on systems with not many devices, but hardcoding the size

I never talked about hardcoding, did I?

Quoted 3 lines

into upstream is not helpful. If the size is big, users will be asked to check and shrink always. If the size is too small, a new value need be got and added to cmdline and reboot.

Signature · 3 lines
Thanks,

David / dhildenb
#69 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 43 lines · David Hildenbrand
Quoted 42 lines · Baoquan He
Quoted 41 lines · David Hildenbrand
Quoted 14 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

a) roughly the same kernel
b) with roughly the same drivers

As replied to Mike, kernel size is undecided for different kernel with different configs. We can define a default minimal size to cover kernel and driver on systems with not many devices, but hardcoding the size

I never talked about hardcoding, did I?

Sorry, I didn't make it clear. I said hardcoding, meaning a hardcoding min value. No matter what formula we take, it needs a default MIN value to restrict the lowest size, right? That MIN value is the hardcoding I meant. With it properly chosen, most of systems have no need to shrink or adjust the crashkernel, given most of systems own memory less than 64G. Let alone the later estimation is done in 1st kernel, very likely it will get a bigger value as really needed.

Quoted 11 lines
Quoted 4 lines

into upstream is not helpful. If the size is big, users will be asked to check and shrink always. If the size is too small, a new value need be got and added to cmdline and reboot.

Signature · 3 lines
Thanks,

David / dhildenb
#70 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

In reply to Baoquan He
Quoted 45 lines · Baoquan He
Quoted 38 lines · David Hildenbrand
Quoted 14 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

Quoted 5 lines

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

a) roughly the same kernel
b) with roughly the same drivers

Quoted 23 lines

As replied to Mike, kernel size is undecided for different kernel with different configs. We can define a default minimal size to cover kernel and driver on systems with not many devices, but hardcoding the size into upstream is not helpful. If the size is big, users will be asked to check and shrink always. If the size is too small, a new value need be got and added to cmdline and reboot.

Quoted 16 lines

The "user space" part is completely under user space control, depending on what application will be run after kexec.

So I wonder if something like

crashkernel=auto,100M

whereby "100M" corresponds to user space demands in addition to the variable part depend on the current kernel + drivers.

would already be somewhat sufficient for main use cases I guess.

Of course, that approach will get more complicated if the user space portion heavily depends on the drivers etc. Then we need more tunables.

I actually like this idea of "crashkernel=auto,100M" at first look, it gives some tunable space for userspace, and kernel can just take care of its own memory usage. Userspace is completely undeterminable.

But unfortunately estimating kernel usage for kdump is also very hard. It's heavily related to the kdump kernel's cmdline, and kernel has many kdump specified behavior/workaround that affects mem usage, and kernel kconfig also affects it.

Just for example, nr_cpus=1, noefi are commonly used for kdump kernel cmdline to reduce memory usage, but it's also completely acceptable to not use such kernel params for kdump kernel. Even a rough estimation most likely won't work, those moving parts can change the memory usage by a lot.

So basically the kdump's memory usage (userspace or kernel) is not estimable from kernel side in a generic way. It's strictly bonded to distro implementation and config.

And also that's why this patch started with adding a kconfig, so distros can set a value that corresponds to their default setup.

Baoquan has added reasons why passing the crashkernel= config via cmdline also mess things up. So at the time this patch is sent, having a tunable (via kconfig) crashkernel=auto seemed the most helpful way. I'm not sure if there is a better way to make it distro tunable if not through kconfig.

--
Best Regards,
Kairui Song

#71 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

In reply to Baoquan He
Quoted 45 lines · Baoquan He
Quoted 38 lines · David Hildenbrand
Quoted 14 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

Quoted 5 lines

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

a) roughly the same kernel
b) with roughly the same drivers

Quoted 7 lines

As replied to Mike, kernel size is undecided for different kernel with different configs. We can define a default minimal size to cover kernel and driver on systems with not many devices, but hardcoding the size into upstream is not helpful. If the size is big, users will be asked to check and shrink always. If the size is too small, a new value need be got and added to cmdline and reboot.

Hi Baoquan, Kairui, Dave,

so IIUC now, our "old" kernel cannot actually tell us any reliable "crashkernel area size" because

a) it has no idea with which cmdline parameters the crashkernel will be started with, and these can have a big impact.
b) it has no idea which driver will be loaded in the crashkernel.
c) It has no idea what will be running in the crashkernel user space.

AFAIKS, best we can do without further information is, therefore, use some heuristic to a) allocate some memory early during boot in the kernel and b) later refine our allocation, triggered by user space (-> shrink the crashkernel area).

I dislike calling a) "auto". It provides a default based on some heuristic (boot memory size), and that default might be very unfortunate in some scenarios (-> waste memory).

While we could discuss calling the current approach ( a) )"crashkernel=default", whereby the default is encoded at compile time as determined by a distributor, I still still quite don't like it because it feels like this is not necessary. We have a way to pass something like that via the cmdline, so it's just a matter of properly using that feature from user space.

AFAIKS, all you want is most probably a more dynamic way to construct a kernel cmdline, with some properties specific to a kernel.

Let's assume the following:

a) When a distributor ships a kernel, he also ships some kind of defaults file. Let's assume for simplicity

/lib/modules/5.11.19-200.fc33.x86_64/defaults.conf

The file might contain

CRASHKERNEL_DEFAULT=WHATEVER

b) When generating the cmdline for e.g., /boot/loader/entries/XXX-5.11.19-200.fc33.x86_64.conf we run some script that consult that file in addition to /etc/default/grub. For example, if the kdump service was installed and /etc/default/grub does not contain "crashkernel=" (except when we encounter "crashkernel=auto" for compat handling), we add "crashkernel=WHATEVER". Of course, we might do more involved stuff based on the current setup, user config, etc.

c) When we install the kdump service, all we have to do is re-generate the boot entries AFAIKS. Just like we would when adding "crashkernel=auto" right now.

The end result would also allow for having per-kernel defaults and change them on kernel updates. Would require some thought on how to make it fly in user space, how to "ship" the defaults etc.

Signature · 3 lines
Thanks,

David / dhildenb
#72 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 106 lines · David Hildenbrand
Quoted 45 lines · Baoquan He
Quoted 38 lines · David Hildenbrand
Quoted 14 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

Quoted 5 lines

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

a) roughly the same kernel
b) with roughly the same drivers

Quoted 7 lines

As replied to Mike, kernel size is undecided for different kernel with different configs. We can define a default minimal size to cover kernel and driver on systems with not many devices, but hardcoding the size into upstream is not helpful. If the size is big, users will be asked to check and shrink always. If the size is too small, a new value need be got and added to cmdline and reboot.

Hi Baoquan, Kairui, Dave,

so IIUC now, our "old" kernel cannot actually tell us any reliable "crashkernel area size" because

a) it has no idea with which cmdline parameters the crashkernel will be started with, and these can have a big impact.
b) it has no idea which driver will be loaded in the crashkernel.
c) It has no idea what will be running in the crashkernel user space.

AFAIKS, best we can do without further information is, therefore, use some heuristic to a) allocate some memory early during boot in the kernel and b) later refine our allocation, triggered by user space (-> shrink the crashkernel area).

I dislike calling a) "auto". It provides a default based on some heuristic (boot memory size), and that default might be very unfortunate in some scenarios (-> waste memory).

While we could discuss calling the current approach ( a) )"crashkernel=default", whereby the default is encoded at compile time as determined by a distributor, I still still quite don't like it because it feels like this is not necessary. We have a way to pass something like that via the cmdline, so it's just a matter of properly using that feature from user space.

AFAIKS, all you want is most probably a more dynamic way to construct a kernel cmdline, with some properties specific to a kernel.

Let's assume the following:

a) When a distributor ships a kernel, he also ships some kind of defaults file. Let's assume for simplicity

/lib/modules/5.11.19-200.fc33.x86_64/defaults.conf

The file might contain

CRASHKERNEL_DEFAULT=WHATEVER

b) When generating the cmdline for e.g., /boot/loader/entries/XXX-5.11.19-200.fc33.x86_64.conf we run some script that consult that file in addition to /etc/default/grub. For example, if the kdump service was installed and /etc/default/grub does not contain "crashkernel=" (except when we encounter "crashkernel=auto" for compat handling), we add "crashkernel=WHATEVER". Of course, we might do more involved stuff based on the current setup, user config, etc.

Quoted 8 lines

c) When we install the kdump service, all we have to do is re-generate the boot entries AFAIKS. Just like we would when adding "crashkernel=auto" right now.

The end result would also allow for having per-kernel defaults and change them on kernel updates. Would require some thought on how to make it fly in user space, how to "ship" the defaults etc.

Thanks for looking into this, and really appreciate your insight, comments and patience.

We had a sync in team about various viable solutions the other day, and also talked about the similar one as you suggested here since it seems to be able to resolve the concerns we have for a replacement of crashkernel=auto. We will try these in userspace in our side, hope it won't introduce risk and can replace crashkernel=auto perfectly.

#73 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

Quoted 112 lines · Baoquan He
Quoted 111 lines · David Hildenbrand
Quoted 45 lines · Baoquan He
Quoted 38 lines · David Hildenbrand
Quoted 14 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

Quoted 5 lines

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

a) roughly the same kernel
b) with roughly the same drivers

Quoted 7 lines

As replied to Mike, kernel size is undecided for different kernel with different configs. We can define a default minimal size to cover kernel and driver on systems with not many devices, but hardcoding the size into upstream is not helpful. If the size is big, users will be asked to check and shrink always. If the size is too small, a new value need be got and added to cmdline and reboot.

Hi Baoquan, Kairui, Dave,

so IIUC now, our "old" kernel cannot actually tell us any reliable "crashkernel area size" because

a) it has no idea with which cmdline parameters the crashkernel will be started with, and these can have a big impact.
b) it has no idea which driver will be loaded in the crashkernel.
c) It has no idea what will be running in the crashkernel user space.

AFAIKS, best we can do without further information is, therefore, use some heuristic to a) allocate some memory early during boot in the kernel and b) later refine our allocation, triggered by user space (-> shrink the crashkernel area).

I dislike calling a) "auto". It provides a default based on some heuristic (boot memory size), and that default might be very unfortunate in some scenarios (-> waste memory).

While we could discuss calling the current approach ( a) )"crashkernel=default", whereby the default is encoded at compile time as determined by a distributor, I still still quite don't like it because it feels like this is not necessary. We have a way to pass something like that via the cmdline, so it's just a matter of properly using that feature from user space.

AFAIKS, all you want is most probably a more dynamic way to construct a kernel cmdline, with some properties specific to a kernel.

Let's assume the following:

a) When a distributor ships a kernel, he also ships some kind of defaults file. Let's assume for simplicity

/lib/modules/5.11.19-200.fc33.x86_64/defaults.conf

The file might contain

CRASHKERNEL_DEFAULT=WHATEVER

b) When generating the cmdline for e.g., /boot/loader/entries/XXX-5.11.19-200.fc33.x86_64.conf we run some script that consult that file in addition to /etc/default/grub. For example, if the kdump service was installed and /etc/default/grub does not contain "crashkernel=" (except when we encounter "crashkernel=auto" for compat handling), we add "crashkernel=WHATEVER". Of course, we might do more involved stuff based on the current setup, user config, etc.

c) When we install the kdump service, all we have to do is re-generate the boot entries AFAIKS. Just like we would when adding "crashkernel=auto" right now.

Quoted 6 lines
Quoted 3 lines

The end result would also allow for having per-kernel defaults and change them on kernel updates. Would require some thought on how to make it fly in user space, how to "ship" the defaults etc.

Thanks for looking into this, and really appreciate your insight, comments and patience.

Thanks for being patient with me :)

Quoted 6 lines

We had a sync in team about various viable solutions the other day, and also talked about the similar one as you suggested here since it seems to be able to resolve the concerns we have for a replacement of crashkernel=auto. We will try these in userspace in our side, hope it won't introduce risk and can replace crashkernel=auto perfectly.

Sure, and as I said, if we want to look into shrinking of the crashkernel area triggered by user space, I'm happy to help.

Signature · 3 lines
Thanks,

David / dhildenb
#74 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

[Add kexec list, for people interested about the old replies, please find in linux-mm archive]

Quoted 123 lines · David Hildenbrand
Quoted 112 lines · Baoquan He
Quoted 111 lines · David Hildenbrand
Quoted 45 lines · Baoquan He
Quoted 38 lines · David Hildenbrand
Quoted 14 lines
Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Right, and we can easily allocate a bit more as a safety net temporarily when we can actually shrink the area later.

Quoted 4 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

Yes.

Quoted 3 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

Here is my thinking:

There seems to be some kind of formula we can roughly use to come up with the final crashkernel size. Baoquan for sure knows all the dirty details, I assume it's roughly "core kernel + drivers + user space".

Quoted 5 lines

In the kernel, we can only come up with "core kernel + drivers" expecting that we will run

a) roughly the same kernel
b) with roughly the same drivers

Quoted 7 lines

As replied to Mike, kernel size is undecided for different kernel with different configs. We can define a default minimal size to cover kernel and driver on systems with not many devices, but hardcoding the size into upstream is not helpful. If the size is big, users will be asked to check and shrink always. If the size is too small, a new value need be got and added to cmdline and reboot.

Hi Baoquan, Kairui, Dave,

so IIUC now, our "old" kernel cannot actually tell us any reliable "crashkernel area size" because

a) it has no idea with which cmdline parameters the crashkernel will be started with, and these can have a big impact.
b) it has no idea which driver will be loaded in the crashkernel.
c) It has no idea what will be running in the crashkernel user space.

AFAIKS, best we can do without further information is, therefore, use some heuristic to a) allocate some memory early during boot in the kernel and b) later refine our allocation, triggered by user space (-> shrink the crashkernel area).

I dislike calling a) "auto". It provides a default based on some heuristic (boot memory size), and that default might be very unfortunate in some scenarios (-> waste memory).

While we could discuss calling the current approach ( a) )"crashkernel=default", whereby the default is encoded at compile time as determined by a distributor, I still still quite don't like it because it feels like this is not necessary. We have a way to pass something like that via the cmdline, so it's just a matter of properly using that feature from user space.

AFAIKS, all you want is most probably a more dynamic way to construct a kernel cmdline, with some properties specific to a kernel.

Let's assume the following:

a) When a distributor ships a kernel, he also ships some kind of defaults file. Let's assume for simplicity

/lib/modules/5.11.19-200.fc33.x86_64/defaults.conf

The file might contain

CRASHKERNEL_DEFAULT=WHATEVER

b) When generating the cmdline for e.g., /boot/loader/entries/XXX-5.11.19-200.fc33.x86_64.conf we run some script that consult that file in addition to /etc/default/grub. For example, if the kdump service was installed and /etc/default/grub does not contain "crashkernel=" (except when we encounter "crashkernel=auto" for compat handling), we add "crashkernel=WHATEVER". Of course, we might do more involved stuff based on the current setup, user config, etc.

c) When we install the kdump service, all we have to do is re-generate the boot entries AFAIKS. Just like we would when adding "crashkernel=auto" right now.

Quoted 6 lines
Quoted 3 lines

The end result would also allow for having per-kernel defaults and change them on kernel updates. Would require some thought on how to make it fly in user space, how to "ship" the defaults etc.

Thanks for looking into this, and really appreciate your insight, comments and patience.

Thanks for being patient with me :)

Quoted 1 line
Quoted 9 lines
Quoted 5 lines

We had a sync in team about various viable solutions the other day, and also talked about the similar one as you suggested here since it seems to be able to resolve the concerns we have for a replacement of crashkernel=auto. We will try these in userspace in our side, hope it won't introduce risk and can replace crashkernel=auto perfectly.

Sure, and as I said, if we want to look into shrinking of the crashkernel area triggered by user space, I'm happy to help.

David, Baoquan, thank you both for exploring the issue. Let's try to do it like this in downstream.

Kdump initramfs is created for kdump needed only with less memory requirements, but fadump depends on the normal kernel initramfs thus fadump needs more memory than kdump.

Hari, with this new no-auto approach, another thing we need to consider is how fadump will use same value if you do not introduce a new param. As you are working in dracut to pack kdump initramfs into 1st kernel initramfs, it is possible that kdump and fadump can use same value, maybe kdump crashkernel value plus some static number for powerpc only. Anyway just a thought. Please provide your comments if any.

Thanks
Dave

#75 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

In reply to Mike Rapoport
Quoted 59 lines · Mike Rapoport

Hi Baoquan,

Quoted 41 lines · Baoquan He
Quoted 33 lines · David Hildenbrand
Quoted 1 line · Dave Young

Hi David,

Hi Dave,

Quoted 13 lines · David Hildenbrand

[snip]

Quoted 10 lines

It also bugged me for quite a bit that we don't have a sane way to achieve what we're doing here upstream. It somewhat feels like "this doesn't belong in the kernel and is user policy" but then, the existing kernel support is suboptimal.

Maybe reserving some "maybe too big but okayish to boot the system in a sane environment -- e.g., X% of system RAM and at least Y" size first and shrinking it later as triggered by user space early (where we do seem to have a way to pre-calculate things now) might actually be a good direction to look into.

Quoted 4 lines

Hmm, that is also an option we considered before. Even for your suggestion we still need a kernel option to set the default ratio/value. and the ratio/value should be another patch which expands crashkernel syntax.

Right.

Quoted 7 lines

Actually the kconfig help text in this patch is indeed misleading, it is not introducing crashkernel=a:b... and no need to explain about the crashkernel syntax, the config option is actually just some interface we can add any valid crashkernel settings to be used by default. So current patch help text describes the default value of crash auto str, instead of describes what crash auto str is.

Quoted 4 lines

Right. And I would much rather prefer either

a) handling "auto" completely in the kernel, not just setting some questionable default at compile time

Thanks for the suggestions.

Quoted 8 lines

If the way adding default value into kernel config is disliked, this a) option looks good. We can get value with x% of system RAM, but clamp it with CRASH_KERNEL_MIN/MAX. The CRASH_KERNEL_MIN/MAX may need be defined with a default value for different ARCHes. It's very close to our current implementation, and handling 'auto' in kernel.

And kernel config provided so that people can tune the MIN/MAX value, but no need to post patch to do the tuning each time if have to?

Maybe I'm missing something, but the whole point is to avoid kernel configuration option at all. If the crashkernel=auto works good for 99% of the cases, there is no need to provide build time configuration along with it. There are plenty of ways users can control crashkernel reservations with the existing 2-4 (depending on architecture) command line options.

Quoted 3 lines

Simply hard coding a reasonable defaults (e.g. "1G-64G:128M,64G-1T:256M,1T-:512M"), and using these defaults when crashkernel=auto is set would cover the same 99% of users you referred to.

Thanks for looking into this, Mike.

The crashkernel=auto works well for 99% of systems with a prerequisite that values of 'auto' corresponds to a certain kernel, e.g distros kernel. Say so because the kernel configs of a distros kernel decides the kernel size, and also the initrd size. A generic default value for crashkernel=auto doesn't make much sense when we make it into distros. That's why we want to add the default value into kernel config originally. Then asking for a minimal size with a kernel config tunable as the second best when handle 'auto' in kernel as David's option a) suggested.

Here it's a little not clear to me about why kernel config has to be avoided. We have this kind of tunable, e.g CONFIG_CMA_SIZE_SEL_MBYTES.

Quoted 3 lines

If we can resize the reservation later during boot this will also address David's concern about the wasted memory.

We can't resize the reservation, we can only shrink currently.

Quoted 4 lines

You mentioned that amount of memory that is required for crash kernel reservation depends on the devices present on the system. Is is possible to detect how much memory is required at late stages of boot?

It may be doable to detect at late stage of boot, need investigation, now we are working to do after system bootup. The thing is the detection is very coarse-grained. We count all loaded kernel modules in. But in kdump kernel, only very necessary modules is added in our distros. e.g if we dump through network, NIC modules are collected. otherwise we filter it out to reduce memory usage in kdump kernel. For most of normal systems with dozens of devices, memory required by device driver in kdump kernel is limited. On VM guests, it's even much less since only very necessary devices are added, e.g disk/NIC/serial.

So, I said 99% of systems can be covered by default value, it's based on a certain kernel with fixed kernel configs, mainly related to distros. Adding a permanent default value in upstream kernel doesn't make much sense, if no tunable provided for distros to adjust.

Quoted 44 lines
Quoted 39 lines
Quoted 37 lines

b) passing it explicitly in via the cmdline

Quoted 5 lines

And crashkernel=auto makes this more flexibly. We can tune the values easily when upgrading. But if we pass a fixed value in userspace we can not know if the value is set by distribution automatically or by user manually thus we can not blindly update it.

I think there are two different cases:

1. kernel space updates the value later during boot. "crashkernel=auto" really does the right thing, meaning

a) allocate something reasonable and safe during early boot
b) update the allocation during late boot when we know what kind of system we're running on

Then, we indeed care about "crashkernel=auto" in the kernel and I think it would be a nice thing to have. The only question is on how to make that a little configurable, depending on different thingies we might want to run in the crashkernel (assuming someone doesn't want kdump).

2. user space updates the value later during boot

IMHO we don't really car who decided on the value as we do the update from user space. If an admin messes with crashkernel=, the admin can also mess with kdump not doing any overwrites (e.g., make that configurable, or detect the overwrite in kdump somehow).

Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Sincerely yours,
Mike.
#76 lore raw

Re: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation

In reply to David Hildenbrand
Quoted 48 lines · David Hildenbrand
Quoted 1 line · Dave Young

Hi David,

Hi Dave,

Quoted 13 lines · David Hildenbrand

[snip]

Quoted 10 lines

It also bugged me for quite a bit that we don't have a sane way to achieve what we're doing here upstream. It somewhat feels like "this doesn't belong in the kernel and is user policy" but then, the existing kernel support is suboptimal.

Maybe reserving some "maybe too big but okayish to boot the system in a sane environment -- e.g., X% of system RAM and at least Y" size first and shrinking it later as triggered by user space early (where we do seem to have a way to pre-calculate things now) might actually be a good direction to look into.

Quoted 4 lines

Hmm, that is also an option we considered before. Even for your suggestion we still need a kernel option to set the default ratio/value. and the ratio/value should be another patch which expands crashkernel syntax.

Right.

Quoted 7 lines

Actually the kconfig help text in this patch is indeed misleading, it is not introducing crashkernel=a:b... and no need to explain about the crashkernel syntax, the config option is actually just some interface we can add any valid crashkernel settings to be used by default. So current patch help text describes the default value of crash auto str, instead of describes what crash auto str is.

Right. And I would much rather prefer either

a) handling "auto" completely in the kernel, not just setting some questionable default at compile time
b) passing it explicitly in via the cmdline

Quoted 5 lines

And crashkernel=auto makes this more flexibly. We can tune the values easily when upgrading. But if we pass a fixed value in userspace we can not know if the value is set by distribution automatically or by user manually thus we can not blindly update it.

I think there are two different cases:

Quoted 6 lines

1. kernel space updates the value later during boot. "crashkernel=auto" really does the right thing, meaning

a) allocate something reasonable and safe during early boot
b) update the allocation during late boot when we know what kind of system we're running on

Sorry for my laggy reply :)

As for kernel late boot action, the other notable issue is most device drivers are kernel modules, they are loaded with udev. Especially about some complex storage/network drivers, they often use a lot memory. Kairui has a tool named "memstrack" which can be used for monitor the module loading phase peak memory. But that can only be done in userspace for now.

And we have some different setups for normal boot and kdump kernel, eg. some special cmdline eg. nr_cpu=1; and also some in kernel handling for example some patches merged in networking drivers to use less memory in kdump kernel via smaller queues etc.

Otherwise about other kernel memory requirement can be done in kernel.

Quoted 7 lines

Then, we indeed care about "crashkernel=auto" in the kernel and I think it would be a nice thing to have. The only question is on how to make that a little configurable, depending on different thingies we might want to run in the crashkernel (assuming someone doesn't want kdump).

Quoted 12 lines

2. user space updates the value later during boot

IMHO we don't really car who decided on the value as we do the update from user space. If an admin messes with crashkernel=, the admin can also mess with kdump not doing any overwrites (e.g., make that configurable, or detect the overwrite in kdump somehow).

Signature · 3 lines
Thanks,

David / dhildenb

Thanks
Dave

author maintainer
#77 lore raw

PATCH 49/91 kexec: add kexec reboot string

In reply to Andrew Morton

From: Joe LeVeque <[email protected]>
Subject: kexec: Add kexec reboot string

The purpose is to notify the kernel module for fast reboot.

Upstream a patch from the SONiC network operating system [1].

[1]: https://github.com/Azure/sonic-linux-kernel/pull/46

---

 kernel/kexec_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kexec_core.c renamed from kernel/kexec_core.c~kexec-add-kexec-reboot-string +1 -1
@@ -1165,7 +1165,7 @@ int kernel_kexec(void)
 #endif
 	{
 		kexec_in_progress = true;
-		kernel_restart_prepare(NULL);
+		kernel_restart_prepare("kexec reboot");
 		migrate_to_reboot_cpu();
 
 		/*

_

author maintainer
#78 lore raw

PATCH 50/91 kernel: kexec_file: fix error return code of kexec_calculate_store_digests()

In reply to Andrew Morton

From: Jia-Ju Bai <[email protected]>
Subject: kernel: kexec_file: fix error return code of kexec_calculate_store_digests()

When vzalloc() returns NULL to sha_regions, no error return code of kexec_calculate_store_digests() is assigned. To fix this bug, ret is assigned with -ENOMEM in this case.

Fixes a43cac0d9dc2 ("kexec: split kexec_file syscall code to kexec_file.c")

---

 kernel/kexec_file.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/kexec_file.c renamed from kernel/kexec_file.c~kernel-kexec_file-fix-error-return-code-of-kexec_calculate_store_digests +3 -1
@@ -740,8 +740,10 @@ static int kexec_calculate_store_digests
 
 	sha_region_sz = KEXEC_SEGMENT_MAX * sizeof(struct kexec_sha_region);
 	sha_regions = vzalloc(sha_region_sz);
-	if (!sha_regions)
+	if (!sha_regions) {
+		ret = -ENOMEM;
 		goto out_free_desc;
+	}
 
 	desc->tfm   = tfm;
 

_

author maintainer
#79 lore raw

PATCH 51/91 kexec: dump kmessage before machine_kexec

In reply to Andrew Morton

From: Pavel Tatashin <[email protected]>
Subject: kexec: dump kmessage before machine_kexec

kmsg_dump(KMSG_DUMP_SHUTDOWN) is called before machine_restart(), machine_halt(), machine_power_off(), the only one that is missing is machine_kexec().

The dmesg output that it contains can be used to study the shutdown performance of both kernel and systemd during kexec reboot.

Here is example of dmesg data collected after kexec:

root@dplat-cp22:~# cat /sys/fs/pstore/dmesg-ramoops-0 | tail
...
<6>[   70.914592] psci: CPU3 killed (polled 0 ms)
<5>[   70.915705] CPU4: shutdown
<6>[   70.916643] psci: CPU4 killed (polled 4 ms)
<5>[   70.917715] CPU5: shutdown
<6>[   70.918725] psci: CPU5 killed (polled 0 ms)
<5>[   70.919704] CPU6: shutdown
<6>[   70.920726] psci: CPU6 killed (polled 4 ms)
<5>[   70.921642] CPU7: shutdown
<6>[   70.922650] psci: CPU7 killed (polled 0 ms)

---

 kernel/kexec_core.c |    2 ++
 1 file changed, 2 insertions(+)
kernel/kexec_core.c renamed from kernel/kexec_core.c~kexec-dump-kmessage-before-machine_kexec +2 -0
@@ -37,6 +37,7 @@
 #include <linux/compiler.h>
 #include <linux/hugetlb.h>
 #include <linux/objtool.h>
+#include <linux/kmsg_dump.h>
 
 #include <asm/page.h>
 #include <asm/sections.h>
@@ -1179,6 +1180,7 @@ int kernel_kexec(void)
 		machine_shutdown();
 	}
 
+	kmsg_dump(KMSG_DUMP_SHUTDOWN);
 	machine_kexec(kexec_image);
 
 #ifdef CONFIG_KEXEC_JUMP

_

author maintainer
#80 lore raw

PATCH 52/91 gcov: combine common code

In reply to Andrew Morton

From: Johannes Berg <[email protected]>
Subject: gcov: combine common code

There's a lot of duplicated code between gcc and clang implementations, move it over to fs.c to simplify the code, there's no reason to believe that for small data like this one would not just implement the simple convert_to_gcda() function.

---

 kernel/gcov/base.c    |   49 +++++++++++
 kernel/gcov/clang.c   |  167 ----------------------------------------
 kernel/gcov/fs.c      |  116 +++++++++++++++++++++++++++
 kernel/gcov/gcc_4_7.c |  167 ----------------------------------------
 kernel/gcov/gcov.h    |   14 ---
 5 files changed, 171 insertions(+), 342 deletions(-)
kernel/gcov/base.c renamed from kernel/gcov/base.c~gcov-combine-common-code +49 -0
@@ -49,6 +49,55 @@ void gcov_enable_events(void)
 	mutex_unlock(&gcov_lock);
 }
 
+/**
+ * store_gcov_u32 - store 32 bit number in gcov format to buffer
+ * @buffer: target buffer or NULL
+ * @off: offset into the buffer
+ * @v: value to be stored
+ *
+ * Number format defined by gcc: numbers are recorded in the 32 bit
+ * unsigned binary form of the endianness of the machine generating the
+ * file. Returns the number of bytes stored. If @buffer is %NULL, doesn't
+ * store anything.
+ */
+size_t store_gcov_u32(void *buffer, size_t off, u32 v)
+{
+	u32 *data;
+
+	if (buffer) {
+		data = buffer + off;
+		*data = v;
+	}
+
+	return sizeof(*data);
+}
+
+/**
+ * store_gcov_u64 - store 64 bit number in gcov format to buffer
+ * @buffer: target buffer or NULL
+ * @off: offset into the buffer
+ * @v: value to be stored
+ *
+ * Number format defined by gcc: numbers are recorded in the 32 bit
+ * unsigned binary form of the endianness of the machine generating the
+ * file. 64 bit numbers are stored as two 32 bit numbers, the low part
+ * first. Returns the number of bytes stored. If @buffer is %NULL, doesn't store
+ * anything.
+ */
+size_t store_gcov_u64(void *buffer, size_t off, u64 v)
+{
+	u32 *data;
+
+	if (buffer) {
+		data = buffer + off;
+
+		data[0] = (v & 0xffffffffUL);
+		data[1] = (v >> 32);
+	}
+
+	return sizeof(*data) * 2;
+}
+
 #ifdef CONFIG_MODULES
 /* Update list and generate events when modules are unloaded. */
 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
kernel/gcov/clang.c renamed from kernel/gcov/clang.c~gcov-combine-common-code +1 -166

188 lines not on this page · raw message

kernel/gcov/fs.c renamed from kernel/gcov/fs.c~gcov-combine-common-code +116 -0

128 lines not on this page · raw message

kernel/gcov/gcc_4_7.c renamed from kernel/gcov/gcc_4_7.c~gcov-combine-common-code +1 -166

188 lines not on this page · raw message

kernel/gcov/gcov.h renamed from kernel/gcov/gcov.h~gcov-combine-common-code +4 -10
@@ -48,6 +48,7 @@ struct gcov_info *gcov_info_next(struct
 void gcov_info_link(struct gcov_info *info);
 void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info);
 bool gcov_info_within_module(struct gcov_info *info, struct module *mod);
+size_t convert_to_gcda(char *buffer, struct gcov_info *info);
 
 /* Base interface. */
 enum gcov_action {
@@ -58,16 +59,9 @@ enum gcov_action {
 void gcov_event(enum gcov_action action, struct gcov_info *info);
 void gcov_enable_events(void);
 
-/* Iterator control. */
-struct seq_file;
-struct gcov_iterator;
-
-struct gcov_iterator *gcov_iter_new(struct gcov_info *info);
-void gcov_iter_free(struct gcov_iterator *iter);
-void gcov_iter_start(struct gcov_iterator *iter);
-int gcov_iter_next(struct gcov_iterator *iter);
-int gcov_iter_write(struct gcov_iterator *iter, struct seq_file *seq);
-struct gcov_info *gcov_iter_get_info(struct gcov_iterator *iter);
+/* writing helpers */
+size_t store_gcov_u32(void *buffer, size_t off, u32 v);
+size_t store_gcov_u64(void *buffer, size_t off, u64 v);
 
 /* gcov_info control. */
 void gcov_info_reset(struct gcov_info *info);

_

author maintainer
#81 lore raw

PATCH 53/91 gcov: simplify buffer allocation

In reply to Andrew Morton

From: Johannes Berg <[email protected]>
Subject: gcov: simplify buffer allocation

Use just a single vmalloc() with struct_size() instead of a separate kmalloc() for the iter struct.

---

 kernel/gcov/fs.c |   24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)
kernel/gcov/fs.c renamed from kernel/gcov/fs.c~gcov-simplify-buffer-allocation +9 -15
@@ -97,9 +97,9 @@ __setup("gcov_persist=", gcov_persist_se
  */
 struct gcov_iterator {
 	struct gcov_info *info;
-	void *buffer;
 	size_t size;
 	loff_t pos;
+	char buffer[];
 };
 
 /**
@@ -111,25 +111,20 @@ struct gcov_iterator {
 static struct gcov_iterator *gcov_iter_new(struct gcov_info *info)
 {
 	struct gcov_iterator *iter;
+	size_t size;
+
+	/* Dry-run to get the actual buffer size. */
+	size = convert_to_gcda(NULL, info);
 
-	iter = kzalloc(sizeof(struct gcov_iterator), GFP_KERNEL);
+	iter = vmalloc(struct_size(iter, buffer, size));
 	if (!iter)
-		goto err_free;
+		return NULL;
 
 	iter->info = info;
-	/* Dry-run to get the actual buffer size. */
-	iter->size = convert_to_gcda(NULL, info);
-	iter->buffer = vmalloc(iter->size);
-	if (!iter->buffer)
-		goto err_free;
-
+	iter->size = size;
 	convert_to_gcda(iter->buffer, info);
 
 	return iter;
-
-err_free:
-	kfree(iter);
-	return NULL;
 }
 
 
@@ -139,8 +134,7 @@ err_free:
  */
 static void gcov_iter_free(struct gcov_iterator *iter)
 {
-	vfree(iter->buffer);
-	kfree(iter);
+	vfree(iter);
 }
 
 /**

_

author maintainer
#82 lore raw

PATCH 54/91 gcov: use kvmalloc()

In reply to Andrew Morton

From: Johannes Berg <[email protected]>
Subject: gcov: use kvmalloc()

Using vmalloc() in gcov is really quite wasteful, many of the objects allocated are really small (e.g. I've seen 24 bytes.) Use kvmalloc() to automatically pick the better of kmalloc() or vmalloc() depending on the size.

---

 kernel/gcov/clang.c   |   12 ++++++------
 kernel/gcov/fs.c      |    6 +++---
 kernel/gcov/gcc_4_7.c |    6 +++---
 3 files changed, 12 insertions(+), 12 deletions(-)
kernel/gcov/clang.c renamed from kernel/gcov/clang.c~gcov-use-kvmalloc +6 -6
@@ -49,7 +49,7 @@
 #include <linux/printk.h>
 #include <linux/ratelimit.h>
 #include <linux/slab.h>
-#include <linux/vmalloc.h>
+#include <linux/mm.h>
 #include "gcov.h"
 
 typedef void (*llvm_gcov_callback)(void);
@@ -333,8 +333,8 @@ void gcov_info_add(struct gcov_info *dst
 static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)
 {
 	size_t cv_size; /* counter values size */
-	struct gcov_fn_info *fn_dup = kmemdup(fn, sizeof(*fn),
-			GFP_KERNEL);
+	struct gcov_fn_info *fn_dup = kmemdup(fn, sizeof(*fn), GFP_KERNEL);
+
 	if (!fn_dup)
 		return NULL;
 	INIT_LIST_HEAD(&fn_dup->head);
@@ -344,7 +344,7 @@ static struct gcov_fn_info *gcov_fn_info
 		goto err_name;
 
 	cv_size = fn->num_counters * sizeof(fn->counters[0]);
-	fn_dup->counters = vmalloc(cv_size);
+	fn_dup->counters = kvmalloc(cv_size, GFP_KERNEL);
 	if (!fn_dup->counters)
 		goto err_counters;
 	memcpy(fn_dup->counters, fn->counters, cv_size);
@@ -368,7 +368,7 @@ static struct gcov_fn_info *gcov_fn_info
 	INIT_LIST_HEAD(&fn_dup->head);
 
 	cv_size = fn->num_counters * sizeof(fn->counters[0]);
-	fn_dup->counters = vmalloc(cv_size);
+	fn_dup->counters = kvmalloc(cv_size, GFP_KERNEL);
 	if (!fn_dup->counters) {
 		kfree(fn_dup);
 		return NULL;
@@ -439,7 +439,7 @@ void gcov_info_free(struct gcov_info *in
 	struct gcov_fn_info *fn, *tmp;
 
 	list_for_each_entry_safe(fn, tmp, &info->functions, head) {
-		vfree(fn->counters);
+		kvfree(fn->counters);
 		list_del(&fn->head);
 		kfree(fn);
 	}
kernel/gcov/fs.c renamed from kernel/gcov/fs.c~gcov-use-kvmalloc +3 -3
@@ -26,7 +26,7 @@
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/seq_file.h>
-#include <linux/vmalloc.h>
+#include <linux/mm.h>
 #include "gcov.h"
 
 /**
@@ -116,7 +116,7 @@ static struct gcov_iterator *gcov_iter_n
 	/* Dry-run to get the actual buffer size. */
 	size = convert_to_gcda(NULL, info);
 
-	iter = vmalloc(struct_size(iter, buffer, size));
+	iter = kvmalloc(struct_size(iter, buffer, size), GFP_KERNEL);
 	if (!iter)
 		return NULL;
 
@@ -134,7 +134,7 @@ static struct gcov_iterator *gcov_iter_n
  */
 static void gcov_iter_free(struct gcov_iterator *iter)
 {
-	vfree(iter);
+	kvfree(iter);
 }
 
 /**
kernel/gcov/gcc_4_7.c renamed from kernel/gcov/gcc_4_7.c~gcov-use-kvmalloc +3 -3
@@ -15,7 +15,7 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/vmalloc.h>
+#include <linux/mm.h>
 #include "gcov.h"
 
 #if (__GNUC__ >= 10)
@@ -309,7 +309,7 @@ struct gcov_info *gcov_info_dup(struct g
 
 			cv_size = sizeof(gcov_type) * sci_ptr->num;
 
-			dci_ptr->values = vmalloc(cv_size);
+			dci_ptr->values = kvmalloc(cv_size, GFP_KERNEL);
 
 			if (!dci_ptr->values)
 				goto err_free;
@@ -351,7 +351,7 @@ void gcov_info_free(struct gcov_info *in
 		ci_ptr = info->functions[fi_idx]->ctrs;
 
 		for (ct_idx = 0; ct_idx < active; ct_idx++, ci_ptr++)
-			vfree(ci_ptr->values);
+			kvfree(ci_ptr->values);
 
 		kfree(info->functions[fi_idx]);
 	}

_

author maintainer
#83 lore raw

PATCH 55/91 gcov: clang: drop support for clang-10 and older

In reply to Andrew Morton

From: Nick Desaulniers <[email protected]>
Subject: gcov: clang: drop support for clang-10 and older

LLVM changed the expected function signatures for llvm_gcda_start_file() and llvm_gcda_emit_function() in the clang-11 release. Drop the older implementations and require folks to upgrade their compiler if they're interested in GCOV support.

---

 kernel/gcov/Kconfig |    1 
 kernel/gcov/clang.c |  103 ------------------------------------------
 2 files changed, 1 insertion(+), 103 deletions(-)
kernel/gcov/clang.c renamed from kernel/gcov/clang.c~gcov-clang-drop-support-for-clang-10-and-older +0 -103
@@ -69,16 +69,10 @@ struct gcov_fn_info {
 
 	u32 ident;
 	u32 checksum;
-#if CONFIG_CLANG_VERSION < 110000
-	u8 use_extra_checksum;
-#endif
 	u32 cfg_checksum;
 
 	u32 num_counters;
 	u64 *counters;
-#if CONFIG_CLANG_VERSION < 110000
-	const char *function_name;
-#endif
 };
 
 static struct gcov_info *current_info;
@@ -108,16 +102,6 @@ void llvm_gcov_init(llvm_gcov_callback w
 }
 EXPORT_SYMBOL(llvm_gcov_init);
 
-#if CONFIG_CLANG_VERSION < 110000
-void llvm_gcda_start_file(const char *orig_filename, const char version[4],
-		u32 checksum)
-{
-	current_info->filename = orig_filename;
-	memcpy(&current_info->version, version, sizeof(current_info->version));
-	current_info->checksum = checksum;
-}
-EXPORT_SYMBOL(llvm_gcda_start_file);
-#else
 void llvm_gcda_start_file(const char *orig_filename, u32 version, u32 checksum)
 {
 	current_info->filename = orig_filename;
@@ -125,28 +109,7 @@ void llvm_gcda_start_file(const char *or
 	current_info->checksum = checksum;
 }
 EXPORT_SYMBOL(llvm_gcda_start_file);
-#endif
 
-#if CONFIG_CLANG_VERSION < 110000
-void llvm_gcda_emit_function(u32 ident, const char *function_name,
-		u32 func_checksum, u8 use_extra_checksum, u32 cfg_checksum)
-{
-	struct gcov_fn_info *info = kzalloc(sizeof(*info), GFP_KERNEL);
-
-	if (!info)
-		return;
-
-	INIT_LIST_HEAD(&info->head);
-	info->ident = ident;
-	info->checksum = func_checksum;
-	info->use_extra_checksum = use_extra_checksum;
-	info->cfg_checksum = cfg_checksum;
-	if (function_name)
-		info->function_name = kstrdup(function_name, GFP_KERNEL);
-
-	list_add_tail(&info->head, &current_info->functions);
-}
-#else
 void llvm_gcda_emit_function(u32 ident, u32 func_checksum, u32 cfg_checksum)
 {
 	struct gcov_fn_info *info = kzalloc(sizeof(*info), GFP_KERNEL);
@@ -160,7 +123,6 @@ void llvm_gcda_emit_function(u32 ident,
 	info->cfg_checksum = cfg_checksum;
 	list_add_tail(&info->head, &current_info->functions);
 }
-#endif
 EXPORT_SYMBOL(llvm_gcda_emit_function);
 
 void llvm_gcda_emit_arcs(u32 num_counters, u64 *counters)
@@ -291,16 +253,8 @@ int gcov_info_is_compatible(struct gcov_
 		!list_is_last(&fn_ptr2->head, &info2->functions)) {
 		if (fn_ptr1->checksum != fn_ptr2->checksum)
 			return false;
-#if CONFIG_CLANG_VERSION < 110000
-		if (fn_ptr1->use_extra_checksum != fn_ptr2->use_extra_checksum)
-			return false;
-		if (fn_ptr1->use_extra_checksum &&
-			fn_ptr1->cfg_checksum != fn_ptr2->cfg_checksum)
-			return false;
-#else
 		if (fn_ptr1->cfg_checksum != fn_ptr2->cfg_checksum)
 			return false;
-#endif
 		fn_ptr1 = list_next_entry(fn_ptr1, head);
 		fn_ptr2 = list_next_entry(fn_ptr2, head);
 	}
@@ -329,35 +283,6 @@ void gcov_info_add(struct gcov_info *dst
 	}
 }
 
-#if CONFIG_CLANG_VERSION < 110000
-static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)
-{
-	size_t cv_size; /* counter values size */
-	struct gcov_fn_info *fn_dup = kmemdup(fn, sizeof(*fn), GFP_KERNEL);
-
-	if (!fn_dup)
-		return NULL;
-	INIT_LIST_HEAD(&fn_dup->head);
-
-	fn_dup->function_name = kstrdup(fn->function_name, GFP_KERNEL);
-	if (!fn_dup->function_name)
-		goto err_name;
-
-	cv_size = fn->num_counters * sizeof(fn->counters[0]);
-	fn_dup->counters = kvmalloc(cv_size, GFP_KERNEL);
-	if (!fn_dup->counters)
-		goto err_counters;
-	memcpy(fn_dup->counters, fn->counters, cv_size);
-
-	return fn_dup;
-
-err_counters:
-	kfree(fn_dup->function_name);
-err_name:
-	kfree(fn_dup);
-	return NULL;
-}
-#else
 static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn)
 {
 	size_t cv_size; /* counter values size */
@@ -378,7 +303,6 @@ static struct gcov_fn_info *gcov_fn_info
 
 	return fn_dup;
 }
-#endif
 
 /**
  * gcov_info_dup - duplicate profiling data set
@@ -419,21 +343,6 @@ err:
  * gcov_info_free - release memory for profiling data set duplicate
  * @info: profiling data set duplicate to free
  */
-#if CONFIG_CLANG_VERSION < 110000
-void gcov_info_free(struct gcov_info *info)
-{
-	struct gcov_fn_info *fn, *tmp;
-
-	list_for_each_entry_safe(fn, tmp, &info->functions, head) {
-		kfree(fn->function_name);
-		vfree(fn->counters);
-		list_del(&fn->head);
-		kfree(fn);
-	}
-	kfree(info->filename);
-	kfree(info);
-}
-#else
 void gcov_info_free(struct gcov_info *info)
 {
 	struct gcov_fn_info *fn, *tmp;
@@ -446,7 +355,6 @@ void gcov_info_free(struct gcov_info *in
 	kfree(info->filename);
 	kfree(info);
 }
-#endif
 
 /**
  * convert_to_gcda - convert profiling data set to gcda file format
@@ -469,21 +377,10 @@ size_t convert_to_gcda(char *buffer, str
 		u32 i;
 
 		pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION);
-#if CONFIG_CLANG_VERSION < 110000
-		pos += store_gcov_u32(buffer, pos,
-			fi_ptr->use_extra_checksum ? 3 : 2);
-#else
 		pos += store_gcov_u32(buffer, pos, 3);
-#endif
 		pos += store_gcov_u32(buffer, pos, fi_ptr->ident);
 		pos += store_gcov_u32(buffer, pos, fi_ptr->checksum);
-#if CONFIG_CLANG_VERSION < 110000
-		if (fi_ptr->use_extra_checksum)
-			pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum);
-#else
 		pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum);
-#endif
-
 		pos += store_gcov_u32(buffer, pos, GCOV_TAG_COUNTER_BASE);
 		pos += store_gcov_u32(buffer, pos, fi_ptr->num_counters * 2);
 		for (i = 0; i < fi_ptr->num_counters; i++)
kernel/gcov/Kconfig renamed from kernel/gcov/Kconfig~gcov-clang-drop-support-for-clang-10-and-older +1 -0
@@ -4,6 +4,7 @@ menu "GCOV-based kernel profiling"
 config GCOV_KERNEL
 	bool "Enable gcov-based kernel profiling"
 	depends on DEBUG_FS
+	depends on !CC_IS_CLANG || CLANG_VERSION >= 110000
 	select CONSTRUCTORS
 	default n
 	help

_

author maintainer
#84 lore raw

PATCH 56/91 smp: kernel/panic.c - silence warnings

In reply to Andrew Morton

From: He Ying <[email protected]>
Subject: smp: kernel/panic.c - silence warnings

We found these warnings in kernel/panic.c by using sparse tool:
warning: symbol 'panic_smp_self_stop' was not declared.
warning: symbol 'nmi_panic_self_stop' was not declared.
warning: symbol 'crash_smp_send_stop' was not declared.

To avoid them, add declarations for these three functions in include/linux/smp.h.

---

 include/linux/smp.h |    8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/smp.h renamed from include/linux/smp.h~smp-kernel-panicc-silence-warnings +8 -0
@@ -56,6 +56,14 @@ void on_each_cpu_cond_mask(smp_cond_func
 int smp_call_function_single_async(int cpu, call_single_data_t *csd);
 
 /*
+ * Cpus stopping functions in panic. All have default weak definitions.
+ * Architecture-dependent code may override them.
+ */
+void panic_smp_self_stop(void);
+void nmi_panic_self_stop(struct pt_regs *regs);
+void crash_smp_send_stop(void);
+
+/*
  * Call a function on all processors
  */
 static inline void on_each_cpu(smp_call_func_t func, void *info, int wait)

_

author maintainer
#85 lore raw

PATCH 57/91 delayacct: clear right task's flag after blkio completes

In reply to Andrew Morton

From: Yafang Shao <[email protected]>
Subject: delayacct: clear right task's flag after blkio completes

When I was implementing a latency analyze tool by using task->delays and other things, I found there's issue in delayacct. The issue is it should clear the target's flag instead of current's in delayacct_blkio_end().

When I git blame delayacct, I found there're some similar issues we have
fixed in delayacct_blkio_end().
'Commit c96f5471ce7d ("delayacct: Account blkio completion on the correct task")' fixed the issue that it should account blkio completion on the target
task instead of current.
'Commit b512719f771a ("delayacct: fix crash in delayacct_blkio_end() after delayacct init failure")' fixed the issue that it should check target task's delays instead of
current task'. It seems that delayacct_blkio_{begin, end} are error prone.
So I introduce a new paratmeter - the target task 'p' into these helpers,
after that change, the callsite will specifilly set the right task, which
should make it less error prone.

---

 include/linux/delayacct.h |   20 ++++++++++----------
 mm/memory.c               |    8 ++++----
 2 files changed, 14 insertions(+), 14 deletions(-)
include/linux/delayacct.h renamed from include/linux/delayacct.h~delayacct-clear-right-tasks-flag-after-blkio-completes +10 -10
@@ -82,16 +82,16 @@ static inline int delayacct_is_task_wait
 		return 0;
 }
 
-static inline void delayacct_set_flag(int flag)
+static inline void delayacct_set_flag(struct task_struct *p, int flag)
 {
-	if (current->delays)
-		current->delays->flags |= flag;
+	if (p->delays)
+		p->delays->flags |= flag;
 }
 
-static inline void delayacct_clear_flag(int flag)
+static inline void delayacct_clear_flag(struct task_struct *p, int flag)
 {
-	if (current->delays)
-		current->delays->flags &= ~flag;
+	if (p->delays)
+		p->delays->flags &= ~flag;
 }
 
 static inline void delayacct_tsk_init(struct task_struct *tsk)
@@ -114,7 +114,7 @@ static inline void delayacct_tsk_free(st
 
 static inline void delayacct_blkio_start(void)
 {
-	delayacct_set_flag(DELAYACCT_PF_BLKIO);
+	delayacct_set_flag(current, DELAYACCT_PF_BLKIO);
 	if (current->delays)
 		__delayacct_blkio_start();
 }
@@ -123,7 +123,7 @@ static inline void delayacct_blkio_end(s
 {
 	if (p->delays)
 		__delayacct_blkio_end(p);
-	delayacct_clear_flag(DELAYACCT_PF_BLKIO);
+	delayacct_clear_flag(p, DELAYACCT_PF_BLKIO);
 }
 
 static inline int delayacct_add_tsk(struct taskstats *d,
@@ -166,9 +166,9 @@ static inline void delayacct_thrashing_e
 }
 
 #else
-static inline void delayacct_set_flag(int flag)
+static inline void delayacct_set_flag(struct task_struct *p, int flag)
 {}
-static inline void delayacct_clear_flag(int flag)
+static inline void delayacct_clear_flag(struct task_struct *p, int flag)
 {}
 static inline void delayacct_init(void)
 {}
mm/memory.c renamed from mm/memory.c~delayacct-clear-right-tasks-flag-after-blkio-completes +4 -4
@@ -3339,7 +3339,7 @@ vm_fault_t do_swap_page(struct vm_fault
 	}
 
 
-	delayacct_set_flag(DELAYACCT_PF_SWAPIN);
+	delayacct_set_flag(current, DELAYACCT_PF_SWAPIN);
 	page = lookup_swap_cache(entry, vma, vmf->address);
 	swapcache = page;
 
@@ -3388,7 +3388,7 @@ vm_fault_t do_swap_page(struct vm_fault
 					vmf->address, &vmf->ptl);
 			if (likely(pte_same(*vmf->pte, vmf->orig_pte)))
 				ret = VM_FAULT_OOM;
-			delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
+			delayacct_clear_flag(current, DELAYACCT_PF_SWAPIN);
 			goto unlock;
 		}
 
@@ -3402,13 +3402,13 @@ vm_fault_t do_swap_page(struct vm_fault
 		 * owner processes (which may be unknown at hwpoison time)
 		 */
 		ret = VM_FAULT_HWPOISON;
-		delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
+		delayacct_clear_flag(current, DELAYACCT_PF_SWAPIN);
 		goto out_release;
 	}
 
 	locked = lock_page_or_retry(page, vma->vm_mm, vmf->flags);
 
-	delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
+	delayacct_clear_flag(current, DELAYACCT_PF_SWAPIN);
 	if (!locked) {
 		ret |= VM_FAULT_RETRY;
 		goto out_release;

_

author maintainer
#86 lore raw

PATCH 58/91 gdb: lx-symbols: store the abspath()

In reply to Andrew Morton

From: Johannes Berg <[email protected]>
Subject: gdb: lx-symbols: store the abspath()

If we store the relative path, the user might later cd to a different directory, and that would break the automatic symbol resolving that happens when a module is loaded into the target kernel. Fix this by storing the abspath() of each path given, just like we already do for the cwd (os.getcwd() is absolute.)

---

 scripts/gdb/linux/symbols.py |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/gdb/linux/symbols.py renamed from scripts/gdb/linux/symbols.py~gdb-lx-symbols-store-the-abspath +2 -1
@@ -164,7 +164,8 @@ lx-symbols command."""
             saved_state['breakpoint'].enabled = saved_state['enabled']
 
     def invoke(self, arg, from_tty):
-        self.module_paths = [os.path.expanduser(p) for p in arg.split()]
+        self.module_paths = [os.path.abspath(os.path.expanduser(p))
+                             for p in arg.split()]
         self.module_paths.append(os.getcwd())
 
         # enforce update

_

author maintainer
#87 lore raw

PATCH 59/91 scripts/gdb: document lx_current is only supported by x86

In reply to Andrew Morton

From: Barry Song <[email protected]>
Subject: scripts/gdb: document lx_current is only supported by x86

Patch series "scripts/gdb: clarify the platforms supporting lx_current and add arm64 support", v2.

lx_current depends on per_cpu current_task variable which exists on x86 only. so it actually works on x86 only. the 1st patch documents this clearly; the 2nd patch adds support for arm64.

This patch (of 2):

x86 is the only architecture which has per_cpu current_task:
arch$ git grep current_task | grep -i per_cpu x86/include/asm/current.h:DECLARE_PER_CPU(struct task_struct *, current_task); x86/kernel/cpu/common.c:DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned = x86/kernel/cpu/common.c:EXPORT_PER_CPU_SYMBOL(current_task); x86/kernel/cpu/common.c:DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; x86/kernel/cpu/common.c:EXPORT_PER_CPU_SYMBOL(current_task);
x86/kernel/smpboot.c: per_cpu(current_task, cpu) = idle;

On other architectures, lx_current() will lead to a python exception:
(gdb) p $lx_current().pid
Python Exception <class 'gdb.error'> No symbol "current_task" in current context.:
Error occurred in Python: No symbol "current_task" in current context.

To avoid more people struggling and wasting time in other architectures, document it.

---

 Documentation/dev-tools/gdb-kernel-debugging.rst |    2 +-
 scripts/gdb/linux/cpus.py                        |   10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
Documentation/dev-tools/gdb-kernel-debugging.rst renamed from Documentation/dev-tools/gdb-kernel-debugging.rst~scripts-gdb-document-lx_current-is-only-supported-by-x86 +1 -1
@@ -114,7 +114,7 @@ Examples of using the Linux-provided gdb
     [     0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
     ....
 
-- Examine fields of the current task struct::
+- Examine fields of the current task struct(supported by x86 only)::
 
     (gdb) p $lx_current().pid
     $1 = 4998
scripts/gdb/linux/cpus.py renamed from scripts/gdb/linux/cpus.py~scripts-gdb-document-lx_current-is-only-supported-by-x86 +8 -2
@@ -156,6 +156,13 @@ Note that VAR has to be quoted as string
 
 PerCpu()
 
+def get_current_task(cpu):
+    if utils.is_target_arch("x86"):
+         var_ptr = gdb.parse_and_eval("&current_task")
+         return per_cpu(var_ptr, cpu).dereference()
+    else:
+        raise gdb.GdbError("Sorry, obtaining the current task is not yet "
+                           "supported with this arch")
 
 class LxCurrentFunc(gdb.Function):
     """Return current task.
@@ -167,8 +174,7 @@ number. If CPU is omitted, the CPU of th
         super(LxCurrentFunc, self).__init__("lx_current")
 
     def invoke(self, cpu=-1):
-        var_ptr = gdb.parse_and_eval("&current_task")
-        return per_cpu(var_ptr, cpu).dereference()
+        return get_current_task(cpu)
 
 
 LxCurrentFunc()

_

author maintainer
#88 lore raw

PATCH 60/91 scripts/gdb: add lx_current support for arm64

In reply to Andrew Morton

From: Barry Song <[email protected]>
Subject: scripts/gdb: add lx_current support for arm64

arm64 uses SP_EL0 to save the current task_struct address. While running in EL0, SP_EL0 is clobbered by userspace. So if the upper bit is not 1 (not TTBR1), the current address is invalid. This patch checks the upper bit of SP_EL0, if the upper bit is 1, lx_current() of arm64 will return the derefrence of current task. Otherwise, lx_current() will tell users they are running in userspace(EL0).

While arm64 is running in EL0, it is actually pointless to print current task as the memory of kernel space is not accessible in EL0.

---

 Documentation/dev-tools/gdb-kernel-debugging.rst |    2 +-
 scripts/gdb/linux/cpus.py                        |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
Documentation/dev-tools/gdb-kernel-debugging.rst renamed from Documentation/dev-tools/gdb-kernel-debugging.rst~scripts-gdb-add-lx_current-support-for-arm64 +1 -1
@@ -114,7 +114,7 @@ Examples of using the Linux-provided gdb
     [     0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
     ....
 
-- Examine fields of the current task struct(supported by x86 only)::
+- Examine fields of the current task struct(supported by x86 and arm64 only)::
 
     (gdb) p $lx_current().pid
     $1 = 4998
scripts/gdb/linux/cpus.py renamed from scripts/gdb/linux/cpus.py~scripts-gdb-add-lx_current-support-for-arm64 +13 -0
@@ -16,6 +16,9 @@ import gdb
 from linux import tasks, utils
 
 
+task_type = utils.CachedType("struct task_struct")
+
+
 MAX_CPUS = 4096
 
 
@@ -157,9 +160,19 @@ Note that VAR has to be quoted as string
 PerCpu()
 
 def get_current_task(cpu):
+    task_ptr_type = task_type.get_type().pointer()
+
     if utils.is_target_arch("x86"):
          var_ptr = gdb.parse_and_eval("&current_task")
          return per_cpu(var_ptr, cpu).dereference()
+    elif utils.is_target_arch("aarch64"):
+         current_task_addr = gdb.parse_and_eval("$SP_EL0")
+         if((current_task_addr >> 63) != 0):
+             current_task = current_task_addr.cast(task_ptr_type)
+             return current_task.dereference()
+         else:
+             raise gdb.GdbError("Sorry, obtaining the current task is not allowed "
+                                "while running in userspace(EL0)")
     else:
         raise gdb.GdbError("Sorry, obtaining the current task is not yet "
                            "supported with this arch")

_

author maintainer
#89 lore raw

PATCH 61/91 kernel/resource: make walk_system_ram_res() find all busy IORESOURCE_SYSTEM_RAM resources

In reply to Andrew Morton

From: David Hildenbrand <[email protected]>
Subject: kernel/resource: make walk_system_ram_res() find all busy IORESOURCE_SYSTEM_RAM resources

Patch series "kernel/resource: make walk_system_ram_res() and walk_mem_res() search the whole tree", v2.

Playing with kdump+virtio-mem I noticed that kexec_file_load() does not consider System RAM added via dax/kmem and virtio-mem when preparing the elf header for kdump. Looking into the details, the logic used in walk_system_ram_res() and walk_mem_res() seems to be outdated.

walk_system_ram_range() already does the right thing, let's change walk_system_ram_res() and walk_mem_res(), and clean up.

Loading a kdump kernel via "kexec -p -s" ... will result in the kdump kernel to also dump dax/kmem and virtio-mem added System RAM now.

Note: kexec-tools on x86-64 also have to be updated to consider this memory in the kexec_load() case when processing /proc/iomem.

This patch (of 3):

It used to be true that we can have system RAM (IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY) only on the first level in the resource tree. However, this is no longer holds for driver-managed system RAM (i.e., added via dax/kmem and virtio-mem), which gets added on lower levels, for example, inside device containers.

We have two users of walk_system_ram_res(), which currently only consideres the first level:

a) kernel/kexec_file.c:kexec_walk_resources() -- We properly skip IORESOURCE_SYSRAM_DRIVER_MANAGED resources via locate_mem_hole_callback(), so even after this change, we won't be placing kexec images onto dax/kmem and virtio-mem added memory. No change.

b) arch/x86/kernel/crash.c:fill_up_crash_elf_data() -- we're currently not adding relevant ranges to the crash elf header, resulting in them not getting dumped via kdump.

This change fixes loading a crashkernel via kexec_file_load() and including dax/kmem and virtio-mem added System RAM in the crashdump on x86-64. Note that e.g,, arm64 relies on memblock data and, therefore, always considers all added System RAM already.

Let's find all IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY resources, making the function behave like walk_system_ram_range().

Fixes ebf71552bb0e ("virtio-mem: Add parent resource for all added "System RAM"")
Fixes c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like normal RAM")
Cc Greg Kroah-Hartman <[email protected]>
Cc Dan Williams <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Dave Young <[email protected]>
Cc Baoquan He <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Keith Busch <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Qian Cai <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Eric Biederman <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Tom Lendacky <[email protected]>
Cc Brijesh Singh <[email protected]>
Cc "Eric W. Biederman" <[email protected]>

---

 kernel/resource.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/resource.c renamed from kernel/resource.c~kernel-resource-make-walk_system_ram_res-find-all-busy-ioresource_system_ram-resources +1 -1
@@ -457,7 +457,7 @@ int walk_system_ram_res(u64 start, u64 e
 {
 	unsigned long flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
 
-	return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, true,
+	return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, false,
 				     arg, func);
 }
 

_

author maintainer
#90 lore raw

PATCH 62/91 kernel/resource: make walk_mem_res() find all busy IORESOURCE_MEM resources

In reply to Andrew Morton

From: David Hildenbrand <[email protected]>
Subject: kernel/resource: make walk_mem_res() find all busy IORESOURCE_MEM resources

It used to be true that we can have system RAM (IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY) only on the first level in the resource tree. However, this is no longer holds for driver-managed system RAM (i.e., added via dax/kmem and virtio-mem), which gets added on lower levels, for example, inside device containers.

IORESOURCE_SYSTEM_RAM is defined as IORESOURCE_MEM | IORESOURCE_SYSRAM and just a special type of IORESOURCE_MEM.

The function walk_mem_res() only considers the first level and is used in arch/x86/mm/ioremap.c:__ioremap_check_mem() only. We currently fail to identify System RAM added by dax/kmem and virtio-mem as "IORES_MAP_SYSTEM_RAM", for example, allowing for remapping of such "normal RAM" in __ioremap_caller().

Let's find all IORESOURCE_MEM | IORESOURCE_BUSY resources, making the function behave similar to walk_system_ram_res().

Fixes ebf71552bb0e ("virtio-mem: Add parent resource for all added "System RAM"")
Fixes c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like normal RAM")
Cc Greg Kroah-Hartman <[email protected]>
Cc Dan Williams <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Dave Young <[email protected]>
Cc Baoquan He <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Keith Busch <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Qian Cai <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Eric Biederman <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Tom Lendacky <[email protected]>
Cc Brijesh Singh <[email protected]>

---

 kernel/resource.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/resource.c renamed from kernel/resource.c~kernel-resource-make-walk_mem_res-find-all-busy-ioresource_mem-resources +1 -1
@@ -470,7 +470,7 @@ int walk_mem_res(u64 start, u64 end, voi
 {
 	unsigned long flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 
-	return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, true,
+	return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, false,
 				     arg, func);
 }
 

_

author maintainer
#91 lore raw

PATCH 63/91 kernel/resource: remove first_lvl / siblings_only logic

In reply to Andrew Morton

From: David Hildenbrand <[email protected]>
Subject: kernel/resource: remove first_lvl / siblings_only logic

All functions that search for IORESOURCE_SYSTEM_RAM or IORESOURCE_MEM resources now properly consider the whole resource tree, not just the first level. Let's drop the unused first_lvl / siblings_only logic.

Remove documentation that indicates that some functions behave differently, all consider the full resource tree now.

Cc Greg Kroah-Hartman <[email protected]>
Cc Dan Williams <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Dave Young <[email protected]>
Cc Baoquan He <[email protected]>
Cc Vivek Goyal <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Keith Busch <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Qian Cai <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Eric Biederman <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Tom Lendacky <[email protected]>
Cc Brijesh Singh <[email protected]>

---

 kernel/resource.c |   45 +++++++++++---------------------------------
 1 file changed, 12 insertions(+), 33 deletions(-)
kernel/resource.c renamed from kernel/resource.c~kernel-resource-remove-first_lvl-siblings_only-logic +12 -33
@@ -64,12 +64,8 @@ static DEFINE_RWLOCK(resource_lock);
 static struct resource *bootmem_resource_free;
 static DEFINE_SPINLOCK(bootmem_resource_lock);
 
-static struct resource *next_resource(struct resource *p, bool sibling_only)
+static struct resource *next_resource(struct resource *p)
 {
-	/* Caller wants to traverse through siblings only */
-	if (sibling_only)
-		return p->sibling;
-
 	if (p->child)
 		return p->child;
 	while (!p->sibling && p->parent)
@@ -81,7 +77,7 @@ static void *r_next(struct seq_file *m,
 {
 	struct resource *p = v;
 	(*pos)++;
-	return (void *)next_resource(p, false);
+	return (void *)next_resource(p);
 }
 
 #ifdef CONFIG_PROC_FS
@@ -330,14 +326,10 @@ EXPORT_SYMBOL(release_resource);
  * of the resource that's within [@start..@end]; if none is found, returns
  * -ENODEV.  Returns -EINVAL for invalid parameters.
  *
- * This function walks the whole tree and not just first level children
- * unless @first_lvl is true.
- *
  * @start:	start address of the resource searched for
  * @end:	end address of same resource
  * @flags:	flags which the resource must have
  * @desc:	descriptor the resource must have
- * @first_lvl:	walk only the first level children, if set
  * @res:	return ptr, if resource found
  *
  * The caller must specify @start, @end, @flags, and @desc
@@ -345,9 +337,8 @@ EXPORT_SYMBOL(release_resource);
  */
 static int find_next_iomem_res(resource_size_t start, resource_size_t end,
 			       unsigned long flags, unsigned long desc,
-			       bool first_lvl, struct resource *res)
+			       struct resource *res)
 {
-	bool siblings_only = true;
 	struct resource *p;
 
 	if (!res)
@@ -358,7 +349,7 @@ static int find_next_iomem_res(resource_
 
 	read_lock(&resource_lock);
 
-	for (p = iomem_resource.child; p; p = next_resource(p, siblings_only)) {
+	for (p = iomem_resource.child; p; p = next_resource(p)) {
 		/* If we passed the resource we are looking for, stop */
 		if (p->start > end) {
 			p = NULL;
@@ -369,13 +360,6 @@ static int find_next_iomem_res(resource_
 		if (p->end < start)
 			continue;
 
-		/*
-		 * Now that we found a range that matches what we look for,
-		 * check the flags and the descriptor. If we were not asked to
-		 * use only the first level, start looking at children as well.
-		 */
-		siblings_only = first_lvl;
-
 		if ((p->flags & flags) != flags)
 			continue;
 		if ((desc != IORES_DESC_NONE) && (desc != p->desc))
@@ -402,14 +386,14 @@ static int find_next_iomem_res(resource_
 
 static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end,
 				 unsigned long flags, unsigned long desc,
-				 bool first_lvl, void *arg,
+				 void *arg,
 				 int (*func)(struct resource *, void *))
 {
 	struct resource res;
 	int ret = -EINVAL;
 
 	while (start < end &&
-	       !find_next_iomem_res(start, end, flags, desc, first_lvl, &res)) {
+	       !find_next_iomem_res(start, end, flags, desc, &res)) {
 		ret = (*func)(&res, arg);
 		if (ret)
 			break;
@@ -431,7 +415,6 @@ static int __walk_iomem_res_desc(resourc
  * @arg: function argument for the callback @func
  * @func: callback function that is called for each qualifying resource area
  *
- * This walks through whole tree and not just first level children.
  * All the memory ranges which overlap start,end and also match flags and
  * desc are valid candidates.
  *
@@ -441,7 +424,7 @@ static int __walk_iomem_res_desc(resourc
 int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start,
 		u64 end, void *arg, int (*func)(struct resource *, void *))
 {
-	return __walk_iomem_res_desc(start, end, flags, desc, false, arg, func);
+	return __walk_iomem_res_desc(start, end, flags, desc, arg, func);
 }
 EXPORT_SYMBOL_GPL(walk_iomem_res_desc);
 
@@ -457,8 +440,8 @@ int walk_system_ram_res(u64 start, u64 e
 {
 	unsigned long flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
 
-	return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, false,
-				     arg, func);
+	return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, arg,
+				     func);
 }
 
 /*
@@ -470,17 +453,14 @@ int walk_mem_res(u64 start, u64 end, voi
 {
 	unsigned long flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 
-	return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, false,
-				     arg, func);
+	return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, arg,
+				     func);
 }
 
 /*
  * This function calls the @func callback against all memory ranges of type
  * System RAM which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY.
  * It is to be used only for System RAM.
- *
- * This will find System RAM ranges that are children of top-level resources
- * in addition to top-level System RAM resources.
  */
 int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
 			  void *arg, int (*func)(unsigned long, unsigned long, void *))
@@ -495,8 +475,7 @@ int walk_system_ram_range(unsigned long
 	end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1;
 	flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
 	while (start < end &&
-	       !find_next_iomem_res(start, end, flags, IORES_DESC_NONE,
-				    false, &res)) {
+	       !find_next_iomem_res(start, end, flags, IORES_DESC_NONE, &res)) {
 		pfn = PFN_UP(res.start);
 		end_pfn = PFN_DOWN(res.end + 1);
 		if (end_pfn > pfn)

_

author maintainer
#92 lore raw

PATCH 64/91 kernel/resource: allow region_intersects users to hold resource_lock

In reply to Andrew Morton

From: Alistair Popple <[email protected]>
Subject: kernel/resource: allow region_intersects users to hold resource_lock

Introduce a version of region_intersects() that can be called with the resource_lock already held. This is used in a future fix to __request_free_mem_region().

[[email protected]: make __region_intersects static]
Cc David Hildenbrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Dan Williams <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc John Hubbard <[email protected]>
Cc Jerome Glisse <[email protected]>
Cc Balbir Singh <[email protected]>
Cc Muchun Song <[email protected]>

---

 kernel/resource.c |   52 ++++++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 21 deletions(-)
kernel/resource.c renamed from kernel/resource.c~kernel-resource-allow-region_intersects-users-to-hold-resource_lock +31 -21
@@ -502,6 +502,34 @@ int __weak page_is_ram(unsigned long pfn
 }
 EXPORT_SYMBOL_GPL(page_is_ram);
 
+static int __region_intersects(resource_size_t start, size_t size,
+			unsigned long flags, unsigned long desc)
+{
+	struct resource res;
+	int type = 0; int other = 0;
+	struct resource *p;
+
+	res.start = start;
+	res.end = start + size - 1;
+
+	for (p = iomem_resource.child; p ; p = p->sibling) {
+		bool is_type = (((p->flags & flags) == flags) &&
+				((desc == IORES_DESC_NONE) ||
+				 (desc == p->desc)));
+
+		if (resource_overlaps(p, &res))
+			is_type ? type++ : other++;
+	}
+
+	if (type == 0)
+		return REGION_DISJOINT;
+
+	if (other == 0)
+		return REGION_INTERSECTS;
+
+	return REGION_MIXED;
+}
+
 /**
  * region_intersects() - determine intersection of region with known resources
  * @start: region start address
@@ -525,31 +553,13 @@ EXPORT_SYMBOL_GPL(page_is_ram);
 int region_intersects(resource_size_t start, size_t size, unsigned long flags,
 		      unsigned long desc)
 {
-	struct resource res;
-	int type = 0; int other = 0;
-	struct resource *p;
-
-	res.start = start;
-	res.end = start + size - 1;
+	int ret;
 
 	read_lock(&resource_lock);
-	for (p = iomem_resource.child; p ; p = p->sibling) {
-		bool is_type = (((p->flags & flags) == flags) &&
-				((desc == IORES_DESC_NONE) ||
-				 (desc == p->desc)));
-
-		if (resource_overlaps(p, &res))
-			is_type ? type++ : other++;
-	}
+	ret = __region_intersects(start, size, flags, desc);
 	read_unlock(&resource_lock);
 
-	if (type == 0)
-		return REGION_DISJOINT;
-
-	if (other == 0)
-		return REGION_INTERSECTS;
-
-	return REGION_MIXED;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(region_intersects);
 

_

author maintainer
#93 lore raw

PATCH 65/91 kernel/resource: refactor __request_region to allow external locking

In reply to Andrew Morton

From: Alistair Popple <[email protected]>
Subject: kernel/resource: refactor __request_region to allow external locking

Refactor the portion of __request_region() done whilst holding the resource_lock into a separate function to allow callers to hold the lock.

---

 kernel/resource.c |   52 +++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 20 deletions(-)
kernel/resource.c renamed from kernel/resource.c~kernel-resource-refactor-__request_region-to-allow-external-locking +32 -20
@@ -1160,31 +1160,16 @@ struct address_space *iomem_get_mapping(
 	return smp_load_acquire(&iomem_inode)->i_mapping;
 }
 
-/**
- * __request_region - create a new busy resource region
- * @parent: parent resource descriptor
- * @start: resource start address
- * @n: resource region size
- * @name: reserving caller's ID string
- * @flags: IO resource flags
- */
-struct resource * __request_region(struct resource *parent,
+static int __request_region_locked(struct resource *res, struct resource *parent,
 				   resource_size_t start, resource_size_t n,
 				   const char *name, int flags)
 {
 	DECLARE_WAITQUEUE(wait, current);
-	struct resource *res = alloc_resource(GFP_KERNEL);
-	struct resource *orig_parent = parent;
-
-	if (!res)
-		return NULL;
 
 	res->name = name;
 	res->start = start;
 	res->end = start + n - 1;
 
-	write_lock(&resource_lock);
-
 	for (;;) {
 		struct resource *conflict;
 
@@ -1220,13 +1205,40 @@ struct resource * __request_region(struc
 			continue;
 		}
 		/* Uhhuh, that didn't work out.. */
-		free_resource(res);
-		res = NULL;
-		break;
+		return -EBUSY;
 	}
+
+	return 0;
+}
+
+/**
+ * __request_region - create a new busy resource region
+ * @parent: parent resource descriptor
+ * @start: resource start address
+ * @n: resource region size
+ * @name: reserving caller's ID string
+ * @flags: IO resource flags
+ */
+struct resource *__request_region(struct resource *parent,
+				  resource_size_t start, resource_size_t n,
+				  const char *name, int flags)
+{
+	struct resource *res = alloc_resource(GFP_KERNEL);
+	int ret;
+
+	if (!res)
+		return NULL;
+
+	write_lock(&resource_lock);
+	ret = __request_region_locked(res, parent, start, n, name, flags);
 	write_unlock(&resource_lock);
 
-	if (res && orig_parent == &iomem_resource)
+	if (ret) {
+		free_resource(res);
+		return NULL;
+	}
+
+	if (parent == &iomem_resource)
 		revoke_iomem(res);
 
 	return res;

_

author maintainer
#94 lore raw

PATCH 66/91 kernel/resource: fix locking in request_free_mem_region

In reply to Andrew Morton

From: Alistair Popple <[email protected]>
Subject: kernel/resource: fix locking in request_free_mem_region

request_free_mem_region() is used to find an empty range of physical addresses for hotplugging ZONE_DEVICE memory. It does this by iterating over the range of possible addresses using region_intersects() to see if the range is free before calling request_mem_region() to allocate the region.

However the resource_lock is dropped between these two calls meaning by the time request_mem_region() is called in request_free_mem_region() another thread may have already reserved the requested region. This results in unexpected failures and a message in the kernel log from hitting this condition:

/*
* mm/hmm.c reserves physical addresses which then
* become unavailable to other users. Conflicts are
* not expected. Warn to aid debugging if encountered. */
if (conflict->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) {
pr_warn("Unaddressable device %s %pR conflicts with %pR",
conflict->name, conflict, res);

These unexpected failures can be corrected by holding resource_lock across the two calls. This also requires memory allocation to be performed prior to taking the lock.

---

 kernel/resource.c |   45 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 38 insertions(+), 7 deletions(-)
kernel/resource.c renamed from kernel/resource.c~kernel-resource-fix-locking-in-request_free_mem_region +38 -7
@@ -1780,25 +1780,56 @@ static struct resource *__request_free_m
 {
 	resource_size_t end, addr;
 	struct resource *res;
+	struct region_devres *dr = NULL;
 
 	size = ALIGN(size, 1UL << PA_SECTION_SHIFT);
 	end = min_t(unsigned long, base->end, (1UL << MAX_PHYSMEM_BITS) - 1);
 	addr = end - size + 1UL;
 
+	res = alloc_resource(GFP_KERNEL);
+	if (!res)
+		return ERR_PTR(-ENOMEM);
+
+	if (dev) {
+		dr = devres_alloc(devm_region_release,
+				sizeof(struct region_devres), GFP_KERNEL);
+		if (!dr) {
+			free_resource(res);
+			return ERR_PTR(-ENOMEM);
+		}
+	}
+
+	write_lock(&resource_lock);
 	for (; addr > size && addr >= base->start; addr -= size) {
-		if (region_intersects(addr, size, 0, IORES_DESC_NONE) !=
+		if (__region_intersects(addr, size, 0, IORES_DESC_NONE) !=
 				REGION_DISJOINT)
 			continue;
 
-		if (dev)
-			res = devm_request_mem_region(dev, addr, size, name);
-		else
-			res = request_mem_region(addr, size, name);
-		if (!res)
-			return ERR_PTR(-ENOMEM);
+		if (!__request_region_locked(res, &iomem_resource, addr, size,
+						name, 0))
+			break;
+
+		if (dev) {
+			dr->parent = &iomem_resource;
+			dr->start = addr;
+			dr->n = size;
+			devres_add(dev, dr);
+		}
+
 		res->desc = IORES_DESC_DEVICE_PRIVATE_MEMORY;
+		write_unlock(&resource_lock);
+
+		/*
+		 * A driver is claiming this region so revoke any mappings.
+		 */
+		revoke_iomem(res);
 		return res;
 	}
+	write_unlock(&resource_lock);
+
+	free_resource(res);
+	if (dr)
+		devres_free(dr);
 
 	return ERR_PTR(-ERANGE);
 }

_

author maintainer
#95 lore raw

PATCH 67/91 selftests: remove duplicate include

In reply to Andrew Morton

From: Zhang Yunkai <[email protected]>
Subject: selftests: remove duplicate include

'assert.h' included in 'sparsebit.c' is duplicated. It is also included in the 161th line.
'string.h' included in 'mincore_selftest.c' is duplicated. It is also included in the 15th line.
'sched.h' included in 'tlbie_test.c' is duplicated. It is also included in the 33th line.

---

 tools/testing/selftests/kvm/lib/sparsebit.c        |    1 -
 tools/testing/selftests/mincore/mincore_selftest.c |    1 -
 tools/testing/selftests/powerpc/mm/tlbie_test.c    |    1 -
 3 files changed, 3 deletions(-)
tools/testing/selftests/kvm/lib/sparsebit.c renamed from tools/testing/selftests/kvm/lib/sparsebit.c~selftests-remove-duplicate-include +0 -1
@@ -1890,7 +1890,6 @@ void sparsebit_validate_internal(struct
  */
 
 #include <stdlib.h>
-#include <assert.h>
 
 struct range {
 	sparsebit_idx_t first, last;
tools/testing/selftests/mincore/mincore_selftest.c renamed from tools/testing/selftests/mincore/mincore_selftest.c~selftests-remove-duplicate-include +0 -1
@@ -14,7 +14,6 @@
 #include <sys/mman.h>
 #include <string.h>
 #include <fcntl.h>
-#include <string.h>
 
 #include "../kselftest.h"
 #include "../kselftest_harness.h"
tools/testing/selftests/powerpc/mm/tlbie_test.c renamed from tools/testing/selftests/powerpc/mm/tlbie_test.c~selftests-remove-duplicate-include +0 -1
@@ -33,7 +33,6 @@
 #include <sched.h>
 #include <time.h>
 #include <stdarg.h>
-#include <sched.h>
 #include <pthread.h>
 #include <signal.h>
 #include <sys/prctl.h>

_

author maintainer
#96 lore raw

PATCH 68/91 kernel/async.c: stop guarding pr_debug() statements

In reply to Andrew Morton

From: Rasmus Villemoes <[email protected]>
Subject: kernel/async.c: stop guarding pr_debug() statements

It's currently nigh impossible to get these pr_debug()s to print something. Being guarded by initcall_debug means one has to enable tons of other debug output during boot, and the system_state condition further means it's impossible to get them when loading modules later.

Also, the compiler can't know that these global conditions do not change, so there are W=2 warnings

kernel/async.c:125:9: warning: calltime' may be used uninitialized in this function [-Wmaybe-uninitialized] kernel/async.c:300:9: warning: starttime' may be used uninitialized in this function [-Wmaybe-uninitialized]

Make it possible, for a DYNAMIC_DEBUG kernel, to get these to print their messages by booting with appropriate 'dyndbg="file async.c +p"' command line argument. For a non-DYNAMIC_DEBUG kernel, pr_debug() compiles to nothing.

This does cost doing an unconditional ktime_get() for the starttime value, but the corresponding ktime_get for the end time can be elided by factoring it into a function which only gets called if the printk() arguments end up being evaluated.

---

 kernel/async.c |   48 +++++++++++++++++++----------------------------
 1 file changed, 20 insertions(+), 28 deletions(-)
kernel/async.c renamed from kernel/async.c~kernel-asyncc-stop-guarding-pr_debug-statements +20 -28
@@ -78,6 +78,12 @@ static DECLARE_WAIT_QUEUE_HEAD(async_don
 
 static atomic_t entry_count;
 
+static long long microseconds_since(ktime_t start)
+{
+	ktime_t now = ktime_get();
+	return ktime_to_ns(ktime_sub(now, start)) >> 10;
+}
+
 static async_cookie_t lowest_in_progress(struct async_domain *domain)
 {
 	struct async_entry *first = NULL;
@@ -111,24 +117,18 @@ static void async_run_entry_fn(struct wo
 	struct async_entry *entry =
 		container_of(work, struct async_entry, work);
 	unsigned long flags;
-	ktime_t calltime, delta, rettime;
+	ktime_t calltime;
 
 	/* 1) run (and print duration) */
-	if (initcall_debug && system_state < SYSTEM_RUNNING) {
-		pr_debug("calling  %lli_%pS @ %i\n",
-			(long long)entry->cookie,
-			entry->func, task_pid_nr(current));
-		calltime = ktime_get();
-	}
+	pr_debug("calling  %lli_%pS @ %i\n", (long long)entry->cookie,
+		 entry->func, task_pid_nr(current));
+	calltime = ktime_get();
+
 	entry->func(entry->data, entry->cookie);
-	if (initcall_debug && system_state < SYSTEM_RUNNING) {
-		rettime = ktime_get();
-		delta = ktime_sub(rettime, calltime);
-		pr_debug("initcall %lli_%pS returned after %lld usecs\n",
-			(long long)entry->cookie,
-			entry->func,
-			(long long)ktime_to_ns(delta) >> 10);
-	}
+
+	pr_debug("initcall %lli_%pS returned after %lld usecs\n",
+		 (long long)entry->cookie, entry->func,
+		 microseconds_since(calltime));
 
 	/* 2) remove self from the pending queues */
 	spin_lock_irqsave(&async_lock, flags);
@@ -287,23 +287,15 @@ EXPORT_SYMBOL_GPL(async_synchronize_full
  */
 void async_synchronize_cookie_domain(async_cookie_t cookie, struct async_domain *domain)
 {
-	ktime_t starttime, delta, endtime;
+	ktime_t starttime;
 
-	if (initcall_debug && system_state < SYSTEM_RUNNING) {
-		pr_debug("async_waiting @ %i\n", task_pid_nr(current));
-		starttime = ktime_get();
-	}
+	pr_debug("async_waiting @ %i\n", task_pid_nr(current));
+	starttime = ktime_get();
 
 	wait_event(async_done, lowest_in_progress(domain) >= cookie);
 
-	if (initcall_debug && system_state < SYSTEM_RUNNING) {
-		endtime = ktime_get();
-		delta = ktime_sub(endtime, starttime);
-
-		pr_debug("async_continuing @ %i after %lli usec\n",
-			task_pid_nr(current),
-			(long long)ktime_to_ns(delta) >> 10);
-	}
+	pr_debug("async_continuing @ %i after %lli usec\n", task_pid_nr(current),
+		 microseconds_since(starttime));
 }
 EXPORT_SYMBOL_GPL(async_synchronize_cookie_domain);
 

_

author maintainer
#97 lore raw

PATCH 69/91 kernel/async.c: remove async_unregister_domain()

In reply to Andrew Morton

From: Rasmus Villemoes <[email protected]>
Subject: kernel/async.c: remove async_unregister_domain()

No callers in the tree.

---

 include/linux/async.h |    1 -
 kernel/async.c        |   18 ------------------
 2 files changed, 19 deletions(-)
include/linux/async.h renamed from include/linux/async.h~kernel-asyncc-remove-async_unregister_domain +0 -1
@@ -112,7 +112,6 @@ async_schedule_dev_domain(async_func_t f
 	return async_schedule_node_domain(func, dev, dev_to_node(dev), domain);
 }
 
-void async_unregister_domain(struct async_domain *domain);
 extern void async_synchronize_full(void);
 extern void async_synchronize_full_domain(struct async_domain *domain);
 extern void async_synchronize_cookie(async_cookie_t cookie);
kernel/async.c renamed from kernel/async.c~kernel-asyncc-remove-async_unregister_domain +0 -18
@@ -246,24 +246,6 @@ void async_synchronize_full(void)
 EXPORT_SYMBOL_GPL(async_synchronize_full);
 
 /**
- * async_unregister_domain - ensure no more anonymous waiters on this domain
- * @domain: idle domain to flush out of any async_synchronize_full instances
- *
- * async_synchronize_{cookie|full}_domain() are not flushed since callers
- * of these routines should know the lifetime of @domain
- *
- * Prefer ASYNC_DOMAIN_EXCLUSIVE() declarations over flushing
- */
-void async_unregister_domain(struct async_domain *domain)
-{
-	spin_lock_irq(&async_lock);
-	WARN_ON(!domain->registered || !list_empty(&domain->pending));
-	domain->registered = 0;
-	spin_unlock_irq(&async_lock);
-}
-EXPORT_SYMBOL_GPL(async_unregister_domain);
-
-/**
  * async_synchronize_full_domain - synchronize all asynchronous function within a certain domain
  * @domain: the domain to synchronize
  *

_

author maintainer
#98 lore raw

PATCH 70/91 init/initramfs.c: do unpacking asynchronously

In reply to Andrew Morton

From: Rasmus Villemoes <[email protected]>
Subject: init/initramfs.c: do unpacking asynchronously

Patch series "background initramfs unpacking, and CONFIG_MODPROBE_PATH", v3.

These two patches are independent, but better-together.

The second is a rather trivial patch that simply allows the developer to change "/sbin/modprobe" to something else - e.g. the empty string, so that all request_module() during early boot return -ENOENT early, without even spawning a usermode helper, needlessly synchronizing with the initramfs unpacking.

The first patch delegates decompressing the initramfs to a worker thread, allowing do_initcalls() in main.c to proceed to the device_ and late_ initcalls without waiting for that decompression (and populating of rootfs) to finish. Obviously, some of those later calls may rely on the initramfs being available, so I've added synchronization points in the firmware loader and usermodehelper paths - there might be other places that would need this, but so far no one has been able to think of any places I have missed.

There's not much to win if most of the functionality needed during boot is only available as modules. But systems with a custom-made .config and initramfs can boot faster, partly due to utilizing more than one cpu earlier, partly by avoiding known-futile modprobe calls (which would still trigger synchronization with the initramfs unpacking, thus eliminating most of the first benefit).

This patch (of 2):

Most of the boot process doesn't actually need anything from the initramfs, until of course PID1 is to be executed. So instead of doing the decompressing and populating of the initramfs synchronously in populate_rootfs() itself, push that off to a worker thread.

This is primarily motivated by an embedded ppc target, where unpacking even the rather modest sized initramfs takes 0.6 seconds, which is long enough that the external watchdog becomes unhappy that it doesn't get attention soon enough. By doing the initramfs decompression in a worker thread, we get to do the device_initcalls and hence start petting the watchdog much sooner.

Normal desktops might benefit as well. On my mostly stock Ubuntu kernel, my initramfs is a 26M xz-compressed blob, decompressing to around 126M. That takes almost two seconds:

[    0.201454] Trying to unpack rootfs image as initramfs...
[    1.976633] Freeing initrd memory: 29416K

Before this patch, these lines occur consecutively in dmesg. With this patch, the timestamps on these two lines is roughly the same as above, but with 172 lines inbetween - so more than one cpu has been kept busy doing work that would otherwise only happen after the populate_rootfs() finished.

Should one of the initcalls done after rootfs_initcall time (i.e., device_ and late_ initcalls) need something from the initramfs (say, a kernel module or a firmware blob), it will simply wait for the initramfs unpacking to be done before proceeding, which should in theory make this completely safe.

But if some driver pokes around in the filesystem directly and not via one of the official kernel interfaces (i.e. request_firmware*(), call_usermodehelper*) that theory may not hold - also, I certainly might have missed a spot when sprinkling wait_for_initramfs(). So there is an escape hatch in the form of an initramfs_async= command line parameter.

---

 Documentation/admin-guide/kernel-parameters.txt |   12 ++++
 drivers/base/firmware_loader/main.c             |    2 
 include/linux/initrd.h                          |    2 
 init/initramfs.c                                |   38 +++++++++++++-
 init/main.c                                     |    1 
 kernel/umh.c                                    |    2 
 6 files changed, 56 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt renamed from Documentation/admin-guide/kernel-parameters.txt~init-initramfsc-do-unpacking-asynchronously +12 -0
@@ -1839,6 +1839,18 @@
 			initcall functions.  Useful for debugging built-in
 			modules and initcalls.
 
+	initramfs_async= [KNL]
+			Format: <bool>
+			Default: 1
+			This parameter controls whether the initramfs
+			image is unpacked asynchronously, concurrently
+			with devices being probed and
+			initialized. This should normally just work,
+			but as a debugging aid, one can get the
+			historical behaviour of the initramfs
+			unpacking being completed before device_ and
+			late_ initcalls.
+
 	initrd=		[BOOT] Specify the location of the initial ramdisk
 
 	initrdmem=	[KNL] Specify a physical address and size from which to
drivers/base/firmware_loader/main.c renamed from drivers/base/firmware_loader/main.c~init-initramfsc-do-unpacking-asynchronously +2 -0
@@ -15,6 +15,7 @@
 #include <linux/kernel_read_file.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/initrd.h>
 #include <linux/timer.h>
 #include <linux/vmalloc.h>
 #include <linux/interrupt.h>
@@ -504,6 +505,7 @@ fw_get_filesystem_firmware(struct device
 	if (!path)
 		return -ENOMEM;
 
+	wait_for_initramfs();
 	for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
 		size_t file_size = 0;
 		size_t *file_size_ptr = NULL;
include/linux/initrd.h renamed from include/linux/initrd.h~init-initramfsc-do-unpacking-asynchronously +2 -0
@@ -20,8 +20,10 @@ extern void free_initrd_mem(unsigned lon
 
 #ifdef CONFIG_BLK_DEV_INITRD
 extern void __init reserve_initrd_mem(void);
+extern void wait_for_initramfs(void);
 #else
 static inline void __init reserve_initrd_mem(void) {}
+static inline void wait_for_initramfs(void) {}
 #endif
 
 extern phys_addr_t phys_initrd_start;
init/initramfs.c renamed from init/initramfs.c~init-initramfsc-do-unpacking-asynchronously +37 -1
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/init.h>
+#include <linux/async.h>
 #include <linux/fs.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -541,6 +542,14 @@ static int __init keepinitrd_setup(char
 __setup("keepinitrd", keepinitrd_setup);
 #endif
 
+static bool __initdata initramfs_async = true;
+static int __init initramfs_async_setup(char *str)
+{
+	strtobool(str, &initramfs_async);
+	return 1;
+}
+__setup("initramfs_async=", initramfs_async_setup);
+
 extern char __initramfs_start[];
 extern unsigned long __initramfs_size;
 #include <linux/initrd.h>
@@ -658,7 +667,7 @@ static void __init populate_initrd_image
 }
 #endif /* CONFIG_BLK_DEV_RAM */
 
-static int __init populate_rootfs(void)
+static void __init do_populate_rootfs(void *unused, async_cookie_t cookie)
 {
 	/* Load the built in initramfs */
 	char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
@@ -693,6 +702,33 @@ done:
 	initrd_end = 0;
 
 	flush_delayed_fput();
+}
+
+static ASYNC_DOMAIN_EXCLUSIVE(initramfs_domain);
+static async_cookie_t initramfs_cookie;
+
+void wait_for_initramfs(void)
+{
+	if (!initramfs_cookie) {
+		/*
+		 * Something before rootfs_initcall wants to access
+		 * the filesystem/initramfs. Probably a bug. Make a
+		 * note, avoid deadlocking the machine, and let the
+		 * caller's access fail as it used to.
+		 */
+		pr_warn_once("wait_for_initramfs() called before rootfs_initcalls\n");
+		return;
+	}
+	async_synchronize_cookie_domain(initramfs_cookie + 1, &initramfs_domain);
+}
+EXPORT_SYMBOL_GPL(wait_for_initramfs);
+
+static int __init populate_rootfs(void)
+{
+	initramfs_cookie = async_schedule_domain(do_populate_rootfs, NULL,
+						 &initramfs_domain);
+	if (!initramfs_async)
+		wait_for_initramfs();
 	return 0;
 }
 rootfs_initcall(populate_rootfs);
init/main.c renamed from init/main.c~init-initramfsc-do-unpacking-asynchronously +1 -0
@@ -1561,6 +1561,7 @@ static noinline void __init kernel_init_
 
 	kunit_run_all_tests();
 
+	wait_for_initramfs();
 	console_on_rootfs();
 
 	/*
kernel/umh.c renamed from kernel/umh.c~init-initramfsc-do-unpacking-asynchronously +2 -0
@@ -27,6 +27,7 @@
 #include <linux/ptrace.h>
 #include <linux/async.h>
 #include <linux/uaccess.h>
+#include <linux/initrd.h>
 
 #include <trace/events/module.h>
 
@@ -107,6 +108,7 @@ static int call_usermodehelper_exec_asyn
 
 	commit_creds(new);
 
+	wait_for_initramfs();
 	retval = kernel_execve(sub_info->path,
 			       (const char *const *)sub_info->argv,
 			       (const char *const *)sub_info->envp);

_

author maintainer
#99 lore raw

PATCH 71/91 modules: add CONFIG_MODPROBE_PATH

In reply to Andrew Morton

From: Rasmus Villemoes <[email protected]>
Subject: modules: add CONFIG_MODPROBE_PATH

Allow the developer to specifiy the initial value of the modprobe_path[] string. This can be used to set it to the empty string initially, thus effectively disabling request_module() during early boot until userspace writes a new value via the /proc/sys/kernel/modprobe interface. [1]

When building a custom kernel (often for an embedded target), it's normal to build everything into the kernel that is needed for booting, and indeed the initramfs often contains no modules at all, so every such request_module() done before userspace init has mounted the real rootfs is a waste of time.

This is particularly useful when combined with the previous patch, which made the initramfs unpacking asynchronous - for that to work, it had to make any usermodehelper call wait for the unpacking to finish before attempting to invoke the userspace helper. By eliminating all such (known-to-be-futile) calls of usermodehelper, the initramfs unpacking and the {device,late}_initcalls can proceed in parallel for much longer.

For a relatively slow ppc board I'm working on, the two patches combined lead to 0.2s faster boot - but more importantly, the fact that the initramfs unpacking proceeds completely in the background while devices get probed means I get to handle the gpio watchdog in time without getting reset.

[1] __request_module() already has an early -ENOENT return when modprobe_path is the empty string.

---

 init/Kconfig  |   12 ++++++++++++
 kernel/kmod.c |    2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
init/Kconfig renamed from init/Kconfig~modules-add-config_modprobe_path +12 -0
@@ -2299,6 +2299,18 @@ config MODULE_ALLOW_MISSING_NAMESPACE_IM
 
 	  If unsure, say N.
 
+config MODPROBE_PATH
+	string "Path to modprobe binary"
+	default "/sbin/modprobe"
+	help
+	  When kernel code requests a module, it does so by calling
+	  the "modprobe" userspace utility. This option allows you to
+	  set the path where that binary is found. This can be changed
+	  at runtime via the sysctl file
+	  /proc/sys/kernel/modprobe. Setting this to the empty string
+	  removes the kernel's ability to request modules (but
+	  userspace can still load modules explicitly).
+
 config TRIM_UNUSED_KSYMS
 	bool "Trim unused exported kernel symbols" if EXPERT
 	depends on !COMPILE_TEST
kernel/kmod.c renamed from kernel/kmod.c~modules-add-config_modprobe_path +1 -1
@@ -58,7 +58,7 @@ static DECLARE_WAIT_QUEUE_HEAD(kmod_wq);
 /*
 	modprobe_path is set via /proc/sys.
 */
-char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
+char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH;
 
 static void free_modprobe_argv(struct subprocess_info *info)
 {

_

author maintainer
#100 lore raw

PATCH 72/91 ipc/sem.c: mundane typo fixes

In reply to Andrew Morton

From: Bhaskar Chowdhury <[email protected]>
Subject: ipc/sem.c: mundane typo fixes

s/runtine/runtime/
s/AQUIRE/ACQUIRE/
s/seperately/separately/
s/wont/won\'t/
s/succesfull/successful/

---

 ipc/sem.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
ipc/sem.c renamed from ipc/sem.c~ipc-semc-mundane-typo-fixes +5 -5
@@ -36,7 +36,7 @@
  * - two Linux specific semctl() commands: SEM_STAT, SEM_INFO.
  * - undo adjustments at process exit are limited to 0..SEMVMX.
  * - namespace are supported.
- * - SEMMSL, SEMMNS, SEMOPM and SEMMNI can be configured at runtine by writing
+ * - SEMMSL, SEMMNS, SEMOPM and SEMMNI can be configured at runtime by writing
  *   to /proc/sys/kernel/sem.
  * - statistics about the usage are reported in /proc/sysvipc/sem.
  *
@@ -224,7 +224,7 @@ static int sysvipc_sem_proc_show(struct
  * Setting it to a result code is a RELEASE, this is ensured by both a
  * smp_store_release() (for case a) and while holding sem_lock()
  * (for case b).
- * The AQUIRE when reading the result code without holding sem_lock() is
+ * The ACQUIRE when reading the result code without holding sem_lock() is
  * achieved by using READ_ONCE() + smp_acquire__after_ctrl_dep().
  * (case a above).
  * Reading the result code while holding sem_lock() needs no further barriers,
@@ -821,7 +821,7 @@ static inline int check_restart(struct s
 
 	/* It is impossible that someone waits for the new value:
 	 * - complex operations always restart.
-	 * - wait-for-zero are handled seperately.
+	 * - wait-for-zero are handled separately.
 	 * - q is a previously sleeping simple operation that
 	 *   altered the array. It must be a decrement, because
 	 *   simple increments never sleep.
@@ -1046,7 +1046,7 @@ static void do_smart_update(struct sem_a
 			 * - No complex ops, thus all sleeping ops are
 			 *   decrease.
 			 * - if we decreased the value, then any sleeping
-			 *   semaphore ops wont be able to run: If the
+			 *   semaphore ops won't be able to run: If the
 			 *   previous value was too small, then the new
 			 *   value will be too small, too.
 			 */
@@ -2108,7 +2108,7 @@ static long do_semtimedop(int semid, str
 	queue.dupsop = dupsop;
 
 	error = perform_atomic_semop(sma, &queue);
-	if (error == 0) { /* non-blocking succesfull path */
+	if (error == 0) { /* non-blocking successful path */
 		DEFINE_WAKE_Q(wake_q);
 
 		/*

_

author maintainer
#101 lore raw

PATCH 73/91 mm: fix some typos and code style problems

In reply to Andrew Morton

From: Shijie Luo <[email protected]>
Subject: mm: fix some typos and code style problems

fix some typos and code style problems in mm.

gfp.h: s/MAXNODES/MAX_NUMNODES
mmzone.h: s/then/than
rmap.c: s/__vma_split()/__vma_adjust()
swap.c: s/__mod_zone_page_stat/__mod_zone_page_state, s/is is/is swap_state.c: s/whoes/whose
z3fold.c: code style problem fix in z3fold_unregister_migration zsmalloc.c: s/of/or, s/give/given

---

 include/linux/gfp.h    |    2 +-
 include/linux/mmzone.h |    2 +-
 mm/rmap.c              |    2 +-
 mm/swap.c              |    4 ++--
 mm/swap_state.c        |    2 +-
 mm/z3fold.c            |    2 +-
 mm/zsmalloc.c          |    4 ++--
 7 files changed, 9 insertions(+), 9 deletions(-)
include/linux/gfp.h renamed from include/linux/gfp.h~mm-fix-some-typos-and-code-style-problems +1 -1
@@ -490,7 +490,7 @@ static inline int gfp_zonelist(gfp_t fla
 
 /*
  * We get the zone list from the current node and the gfp_mask.
- * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones.
+ * This zone list contains a maximum of MAX_NUMNODES*MAX_NR_ZONES zones.
  * There are two zonelists per node, one for all zones with memory and
  * one containing just zones from the node the zonelist belongs to.
  *
include/linux/mmzone.h renamed from include/linux/mmzone.h~mm-fix-some-typos-and-code-style-problems +1 -1
@@ -55,7 +55,7 @@ enum migratetype {
 	 * pageblocks to MIGRATE_CMA which can be done by
 	 * __free_pageblock_cma() function.  What is important though
 	 * is that a range of pageblocks must be aligned to
-	 * MAX_ORDER_NR_PAGES should biggest page be bigger then
+	 * MAX_ORDER_NR_PAGES should biggest page be bigger than
 	 * a single pageblock.
 	 */
 	MIGRATE_CMA,
mm/rmap.c renamed from mm/rmap.c~mm-fix-some-typos-and-code-style-problems +1 -1
@@ -257,7 +257,7 @@ static inline void unlock_anon_vma_root(
  * Attach the anon_vmas from src to dst.
  * Returns 0 on success, -ENOMEM on failure.
  *
- * anon_vma_clone() is called by __vma_split(), __split_vma(), copy_vma() and
+ * anon_vma_clone() is called by __vma_adjust(), __split_vma(), copy_vma() and
  * anon_vma_fork(). The first three want an exact copy of src, while the last
  * one, anon_vma_fork(), may try to reuse an existing anon_vma to prevent
  * endless growth of anon_vma. Since dst->anon_vma is set to NULL before call,
mm/swap.c renamed from mm/swap.c~mm-fix-some-typos-and-code-style-problems +2 -2
@@ -496,7 +496,7 @@ void lru_cache_add_inactive_or_unevictab
 	if (unlikely(unevictable) && !TestSetPageMlocked(page)) {
 		int nr_pages = thp_nr_pages(page);
 		/*
-		 * We use the irq-unsafe __mod_zone_page_stat because this
+		 * We use the irq-unsafe __mod_zone_page_state because this
 		 * counter is not modified from interrupt context, and the pte
 		 * lock is held(spinlock), which implies preemption disabled.
 		 */
@@ -808,7 +808,7 @@ inline void __lru_add_drain_all(bool for
 	 * below which drains the page vectors.
 	 *
 	 * Let x, y, and z represent some system CPU numbers, where x < y < z.
-	 * Assume CPU #z is is in the middle of the for_each_online_cpu loop
+	 * Assume CPU #z is in the middle of the for_each_online_cpu loop
 	 * below and has already reached CPU #y's per-cpu data. CPU #x comes
 	 * along, adds some pages to its per-cpu vectors, then calls
 	 * lru_add_drain_all().
mm/swap_state.c renamed from mm/swap_state.c~mm-fix-some-typos-and-code-style-problems +1 -1
@@ -792,7 +792,7 @@ static void swap_ra_info(struct vm_fault
  *
  * Returns the struct page for entry and addr, after queueing swapin.
  *
- * Primitive swap readahead code. We simply read in a few pages whoes
+ * Primitive swap readahead code. We simply read in a few pages whose
  * virtual addresses are around the fault address in the same vma.
  *
  * Caller must hold read mmap_lock if vmf->vma is not NULL.
mm/z3fold.c renamed from mm/z3fold.c~mm-fix-some-typos-and-code-style-problems +1 -1
@@ -391,7 +391,7 @@ static void z3fold_unregister_migration(
 {
 	if (pool->inode)
 		iput(pool->inode);
- }
+}
 
 /* Initializes the z3fold header of a newly allocated z3fold page */
 static struct z3fold_header *init_z3fold_page(struct page *page, bool headless,
mm/zsmalloc.c renamed from mm/zsmalloc.c~mm-fix-some-typos-and-code-style-problems +2 -2
@@ -61,7 +61,7 @@
 #define ZSPAGE_MAGIC	0x58
 
 /*
- * This must be power of 2 and greater than of equal to sizeof(link_free).
+ * This must be power of 2 and greater than or equal to sizeof(link_free).
  * These two conditions ensure that any 'struct link_free' itself doesn't
  * span more than 1 page which avoids complex case of mapping 2 pages simply
  * to restore link_free pointer values.
@@ -530,7 +530,7 @@ static void set_zspage_mapping(struct zs
  * class maintains a list of zspages where each zspage is divided
  * into equal sized chunks. Each allocation falls into one of these
  * classes depending on its size. This function returns index of the
- * size class which has chunk size big enough to hold the give size.
+ * size class which has chunk size big enough to hold the given size.
  */
 static int get_size_class_index(int size)
 {

_

author maintainer
#102 lore raw

PATCH 74/91 drivers/char: remove /dev/kmem for good

In reply to Andrew Morton

From: David Hildenbrand <[email protected]>
Subject: drivers/char: remove /dev/kmem for good

Patch series "drivers/char: remove /dev/kmem for good".

Exploring /dev/kmem and /dev/mem in the context of memory hot(un)plug and memory ballooning, I started questioning the existence of /dev/kmem.

Comparing it with the /proc/kcore implementation, it does not seem to be able to deal with things like

a) Pages unmapped from the direct mapping (e.g., to be used by secretmem) -> kern_addr_valid(). virt_addr_valid() is not sufficient.

b) Special cases like gart aperture memory that is not to be touched -> mem_pfn_is_ram()

Unless I am missing something, it's at least broken in some cases and might fault/crash the machine.

Looks like its existence has been questioned before in 2005 and 2010 [1], after ~11 additional years, it might make sense to revive the discussion.

CONFIG_DEVKMEM is only enabled in a single defconfig (on purpose or by mistake?). All distributions disable it: in Ubuntu it has been disabled for more than 10 years, in Debian since 2.6.31, in Fedora at least starting with FC3, in RHEL starting with RHEL4, in SUSE starting from 15sp2, and OpenSUSE has it disabled as well.

1) /dev/kmem was popular for rootkits [2] before it got disabled basically everywhere. Ubuntu documents [3] "There is no modern user of /dev/kmem any more beyond attackers using it to load kernel rootkits.". RHEL documents in a BZ [5] "it served no practical purpose other than to serve as a potential security problem or to enable binary module drivers to access structures/functions they shouldn't be touching"

2) /proc/kcore is a decent interface to have a controlled way to read kernel memory for debugging puposes. (will need some extensions to deal with memory offlining/unplug, memory ballooning, and poisoned pages, though)

3) It might be useful for corner case debugging [1]. KDB/KGDB might be a better fit, especially, to write random memory; harder to shoot yourself into the foot.

4) "Kernel Memory Editor" [4] hasn't seen any updates since 2000 and seems to be incompatible with 64bit [1]. For educational purposes, /proc/kcore might be used to monitor value updates -- or older kernels can be used.

5) It's broken on arm64, and therefore, completely disabled there.

Looks like it's essentially unused and has been replaced by better suited interfaces for individual tasks (/proc/kcore, KDB/KGDB). Let's just remove it.

[1] https://lwn.net/Articles/147901/
[2] https://www.linuxjournal.com/article/10505
[3] https://wiki.ubuntu.com/Security/Features#A.2Fdev.2Fkmem_disabled
[4] https://sourceforge.net/projects/kme/
[5] https://bugzilla.redhat.com/show_bug.cgi?id=154796

Cc Linus Torvalds <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "Alexander A. Klimov" <[email protected]>
Cc Alexander Viro <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc Andrey Zhizhikin <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Brian Cain <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Chris Zankel <[email protected]>
Cc Corentin Labbe <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Gerald Schaefer <[email protected]>
Cc Greentime Hu <[email protected]>
Cc Gregory Clement <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Helge Deller <[email protected]>
Cc Hillf Danton <[email protected]>
Cc huang ying <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc James Troup <[email protected]>
Cc Jiaxun Yang <[email protected]>
Cc Jonas Bonn <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Kairui Song <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Kuninori Morimoto <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Lorenzo Pieralisi <[email protected]>
Cc Luc Van Oostenryck <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Matt Turner <[email protected]>
Cc Max Filippov <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Niklas Schnelle <[email protected]>
Cc Oleksiy Avramchenko <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc "Pavel Machek (CIP)" <[email protected]>
Cc Pavel Machek <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Rich Felker <[email protected]>
Cc Robert Richter <[email protected]>
Cc Rob Herring <[email protected]>
Cc Russell King <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Sebastian Hesselbarth <[email protected]>
Cc Stafford Horne <[email protected]>
Cc Stefan Kristiansson <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Sudeep Holla <[email protected]>
Cc Theodore Dubois <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Viresh Kumar <[email protected]>
Cc William Cohen <[email protected]>
Cc Xiaoming Ni <[email protected]>
Cc Yoshinori Sato <[email protected]>

---

 Documentation/admin-guide/devices.txt     |    2 
 arch/arm/configs/dove_defconfig           |    1 
 arch/arm/configs/magician_defconfig       |    1 
 arch/arm/configs/moxart_defconfig         |    1 
 arch/arm/configs/mps2_defconfig           |    1 
 arch/arm/configs/mvebu_v5_defconfig       |    1 
 arch/arm/configs/xcep_defconfig           |    1 
 arch/hexagon/configs/comet_defconfig      |    1 
 arch/m68k/configs/amcore_defconfig        |    1 
 arch/openrisc/configs/or1ksim_defconfig   |    1 
 arch/sh/configs/edosk7705_defconfig       |    1 
 arch/sh/configs/se7206_defconfig          |    1 
 arch/sh/configs/sh2007_defconfig          |    1 
 arch/sh/configs/sh7724_generic_defconfig  |    1 
 arch/sh/configs/sh7770_generic_defconfig  |    1 
 arch/sh/configs/sh7785lcr_32bit_defconfig |    1 
 arch/sparc/configs/sparc64_defconfig      |    1 
 arch/xtensa/configs/xip_kc705_defconfig   |    1 
 drivers/char/Kconfig                      |   10 
 drivers/char/mem.c                        |  231 --------------------
 include/linux/fs.h                        |    2 
 include/linux/vmalloc.h                   |    2 
 kernel/configs/android-base.config        |    1 
 mm/ksm.c                                  |    2 
 mm/vmalloc.c                              |    2 
 25 files changed, 5 insertions(+), 264 deletions(-)
arch/arm/configs/dove_defconfig renamed from arch/arm/configs/dove_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -63,7 +63,6 @@ CONFIG_INPUT_EVDEV=y
 # CONFIG_MOUSE_PS2 is not set
 # CONFIG_SERIO is not set
 CONFIG_LEGACY_PTY_COUNT=16
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_RUNTIME_UARTS=2
arch/arm/configs/magician_defconfig renamed from arch/arm/configs/magician_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -72,7 +72,6 @@ CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_UINPUT=m
 # CONFIG_SERIO is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_PXA=y
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_HW_RANDOM is not set
arch/arm/configs/moxart_defconfig renamed from arch/arm/configs/moxart_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -79,7 +79,6 @@ CONFIG_INPUT_EVBUG=y
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
 # CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=1
arch/arm/configs/mps2_defconfig renamed from arch/arm/configs/mps2_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -69,7 +69,6 @@ CONFIG_SMSC911X=y
 # CONFIG_VT is not set
 # CONFIG_LEGACY_PTYS is not set
 CONFIG_SERIAL_NONSTANDARD=y
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_MPS2_UART_CONSOLE=y
 CONFIG_SERIAL_MPS2_UART=y
 # CONFIG_HW_RANDOM is not set
arch/arm/configs/mvebu_v5_defconfig renamed from arch/arm/configs/mvebu_v5_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -100,7 +100,6 @@ CONFIG_INPUT_EVDEV=y
 CONFIG_KEYBOARD_GPIO=y
 # CONFIG_INPUT_MOUSE is not set
 CONFIG_LEGACY_PTY_COUNT=16
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_RUNTIME_UARTS=2
arch/arm/configs/xcep_defconfig renamed from arch/arm/configs/xcep_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -53,7 +53,6 @@ CONFIG_NET_ETHERNET=y
 # CONFIG_INPUT_KEYBOARD is not set
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_SERIO is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_PXA=y
 CONFIG_SERIAL_PXA_CONSOLE=y
 # CONFIG_LEGACY_PTYS is not set
arch/hexagon/configs/comet_defconfig renamed from arch/hexagon/configs/comet_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -34,7 +34,6 @@ CONFIG_NET_ETHERNET=y
 # CONFIG_SERIO is not set
 # CONFIG_CONSOLE_TRANSLATIONS is not set
 CONFIG_LEGACY_PTY_COUNT=64
-# CONFIG_DEVKMEM is not set
 # CONFIG_HW_RANDOM is not set
 CONFIG_SPI=y
 CONFIG_SPI_DEBUG=y
arch/m68k/configs/amcore_defconfig renamed from arch/m68k/configs/amcore_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -60,7 +60,6 @@ CONFIG_DM9000=y
 # CONFIG_VT is not set
 # CONFIG_UNIX98_PTYS is not set
 # CONFIG_DEVMEM is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_MCF=y
 CONFIG_SERIAL_MCF_BAUDRATE=115200
 CONFIG_SERIAL_MCF_CONSOLE=y
arch/openrisc/configs/or1ksim_defconfig renamed from arch/openrisc/configs/or1ksim_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -43,7 +43,6 @@ CONFIG_MICREL_PHY=y
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
 # CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_OF_PLATFORM=y
arch/sh/configs/edosk7705_defconfig renamed from arch/sh/configs/edosk7705_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -23,7 +23,6 @@ CONFIG_SH_PCLK_FREQ=31250000
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
 # CONFIG_UNIX98_PTYS is not set
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_HW_RANDOM is not set
arch/sh/configs/se7206_defconfig renamed from arch/sh/configs/se7206_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -71,7 +71,6 @@ CONFIG_SMC91X=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=4
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
arch/sh/configs/sh2007_defconfig renamed from arch/sh/configs/sh2007_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -75,7 +75,6 @@ CONFIG_INPUT_FF_MEMLESS=y
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_SERIO is not set
 CONFIG_VT_HW_CONSOLE_BINDING=y
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
 # CONFIG_LEGACY_PTYS is not set
arch/sh/configs/sh7724_generic_defconfig renamed from arch/sh/configs/sh7724_generic_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -18,7 +18,6 @@ CONFIG_CPU_IDLE=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=6
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
arch/sh/configs/sh7770_generic_defconfig renamed from arch/sh/configs/sh7770_generic_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -20,7 +20,6 @@ CONFIG_CPU_IDLE=y
 # CONFIG_INPUT is not set
 # CONFIG_SERIO is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=6
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
arch/sh/configs/sh7785lcr_32bit_defconfig renamed from arch/sh/configs/sh7785lcr_32bit_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -66,7 +66,6 @@ CONFIG_INPUT_FF_MEMLESS=m
 CONFIG_INPUT_EVDEV=y
 CONFIG_INPUT_EVBUG=m
 CONFIG_VT_HW_CONSOLE_BINDING=y
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=6
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
arch/sparc/configs/sparc64_defconfig renamed from arch/sparc/configs/sparc64_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -122,7 +122,6 @@ CONFIG_INPUT_SPARCSPKR=y
 # CONFIG_SERIO_SERPORT is not set
 CONFIG_SERIO_PCIPS2=m
 CONFIG_SERIO_RAW=m
-# CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_SUNSU=y
 CONFIG_SERIAL_SUNSU_CONSOLE=y
 CONFIG_SERIAL_SUNSAB=y
arch/xtensa/configs/xip_kc705_defconfig renamed from arch/xtensa/configs/xip_kc705_defconfig~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -72,7 +72,6 @@ CONFIG_MARVELL_PHY=y
 # CONFIG_INPUT_KEYBOARD is not set
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_SERIO is not set
-CONFIG_DEVKMEM=y
 CONFIG_SERIAL_8250=y
 # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
 CONFIG_SERIAL_8250_CONSOLE=y
Documentation/admin-guide/devices.txt renamed from Documentation/admin-guide/devices.txt~drivers-char-remove-dev-kmem-for-good +1 -1
@@ -4,7 +4,7 @@
 
    1 char	Memory devices
 		  1 = /dev/mem		Physical memory access
-		  2 = /dev/kmem		Kernel virtual memory access
+		  2 = /dev/kmem		OBSOLETE - replaced by /proc/kcore
 		  3 = /dev/null		Null device
 		  4 = /dev/port		I/O port access
 		  5 = /dev/zero		Null byte source
drivers/char/Kconfig renamed from drivers/char/Kconfig~drivers-char-remove-dev-kmem-for-good +0 -10
@@ -334,16 +334,6 @@ config DEVMEM
 	  memory.
 	  When in doubt, say "Y".
 
-config DEVKMEM
-	bool "/dev/kmem virtual device support"
-	# On arm64, VMALLOC_START < PAGE_OFFSET, which confuses kmem read/write
-	depends on !ARM64
-	help
-	  Say Y here if you want to support the /dev/kmem device. The
-	  /dev/kmem device is rarely used, but can be used for certain
-	  kind of kernel debugging operations.
-	  When in doubt, say "N".
-
 config NVRAM
 	tristate "/dev/nvram support"
 	depends on X86 || HAVE_ARCH_NVRAM_OPS
drivers/char/mem.c renamed from drivers/char/mem.c~drivers-char-remove-dev-kmem-for-good +0 -231

255 lines not on this page · raw message

include/linux/fs.h renamed from include/linux/fs.h~drivers-char-remove-dev-kmem-for-good +1 -1
@@ -145,7 +145,7 @@ typedef int (dio_iodone_t)(struct kiocb
 /* Expect random access pattern */
 #define FMODE_RANDOM		((__force fmode_t)0x1000)
 
-/* File is huge (eg. /dev/kmem): treat loff_t as unsigned */
+/* File is huge (eg. /dev/mem): treat loff_t as unsigned */
 #define FMODE_UNSIGNED_OFFSET	((__force fmode_t)0x2000)
 
 /* File is opened with O_PATH; almost nothing can be done with it */
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~drivers-char-remove-dev-kmem-for-good +1 -1
@@ -227,7 +227,7 @@ static inline void set_vm_flush_reset_pe
 }
 #endif
 
-/* for /dev/kmem */
+/* for /proc/kcore */
 extern long vread(char *buf, char *addr, unsigned long count);
 extern long vwrite(char *buf, char *addr, unsigned long count);
 
kernel/configs/android-base.config renamed from kernel/configs/android-base.config~drivers-char-remove-dev-kmem-for-good +0 -1
@@ -1,5 +1,4 @@
 #  KEEP ALPHABETICALLY SORTED
-# CONFIG_DEVKMEM is not set
 # CONFIG_DEVMEM is not set
 # CONFIG_FHANDLE is not set
 # CONFIG_INET_LRO is not set
mm/ksm.c renamed from mm/ksm.c~drivers-char-remove-dev-kmem-for-good +1 -1
@@ -459,7 +459,7 @@ static inline bool ksm_test_exit(struct
  * but taking great care only to touch a ksm page, in a VM_MERGEABLE vma,
  * in case the application has unmapped and remapped mm,addr meanwhile.
  * Could a ksm page appear anywhere else?  Actually yes, in a VM_PFNMAP
- * mmap of /dev/mem or /dev/kmem, where we would not want to touch it.
+ * mmap of /dev/mem, where we would not want to touch it.
  *
  * FAULT_FLAG/FOLL_REMOTE are because we do this outside the context
  * of the process that owns 'vma'.  We also do not want to enforce
mm/vmalloc.c renamed from mm/vmalloc.c~drivers-char-remove-dev-kmem-for-good +1 -1
@@ -3219,7 +3219,7 @@ static int aligned_vwrite(char *buf, cha
  * Note: In usual ops, vread() is never necessary because the caller
  * should know vmalloc() area is valid and can use memcpy().
  * This is for routines which have to access vmalloc area without
- * any information, as /dev/kmem.
+ * any information, as /proc/kcore.
  *
  * Return: number of bytes for which addr and buf should be increased
  * (same number as @count) or %0 if [addr...addr+count) doesn't

_

author maintainer
#103 lore raw

PATCH 75/91 mm: remove xlate_dev_kmem_ptr()

In reply to Andrew Morton

From: David Hildenbrand <[email protected]>
Subject: mm: remove xlate_dev_kmem_ptr()

Since /dev/kmem has been removed, let's remove the xlate_dev_kmem_ptr() leftovers.

Cc Linus Torvalds <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc Matt Turner <[email protected]>
Cc Russell King <[email protected]>
Cc Brian Cain <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Thomas Bogendoerfer <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Yoshinori Sato <[email protected]>
Cc Rich Felker <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Luc Van Oostenryck <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Greentime Hu <[email protected]>
Cc Sebastian Andrzej Siewior <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Jiaxun Yang <[email protected]>
Cc "Peter Zijlstra (Intel)" <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Gerald Schaefer <[email protected]>
Cc Niklas Schnelle <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Kuninori Morimoto <[email protected]>

---

 arch/alpha/include/asm/io.h     |    5 -----
 arch/arm/include/asm/io.h       |    5 -----
 arch/hexagon/include/asm/io.h   |    1 -
 arch/ia64/include/asm/io.h      |    1 -
 arch/ia64/include/asm/uaccess.h |   18 ------------------
 arch/m68k/include/asm/io_mm.h   |    5 -----
 arch/mips/include/asm/io.h      |    5 -----
 arch/parisc/include/asm/io.h    |    5 -----
 arch/powerpc/include/asm/io.h   |    5 -----
 arch/s390/include/asm/io.h      |    5 -----
 arch/sh/include/asm/io.h        |    5 -----
 arch/sparc/include/asm/io_64.h  |    5 -----
 include/asm-generic/io.h        |   11 -----------
 13 files changed, 76 deletions(-)
arch/alpha/include/asm/io.h renamed from arch/alpha/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -602,11 +602,6 @@ extern void outsl (unsigned long port, c
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #endif /* __KERNEL__ */
 
 #endif /* __ALPHA_IO_H */
arch/arm/include/asm/io.h renamed from arch/arm/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -430,11 +430,6 @@ extern void pci_iounmap(struct pci_dev *
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #include <asm-generic/io.h>
 
 #ifdef CONFIG_MMU
arch/hexagon/include/asm/io.h renamed from arch/hexagon/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -1
@@ -64,7 +64,6 @@ static inline void *phys_to_virt(unsigne
  * convert a physical pointer to a virtual kernel pointer for
  * /dev/mem access.
  */
-#define xlate_dev_kmem_ptr(p)    __va(p)
 #define xlate_dev_mem_ptr(p)    __va(p)
 
 /*
arch/ia64/include/asm/io.h renamed from arch/ia64/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -1
@@ -277,7 +277,6 @@ extern void memset_io(volatile void __io
 #define memcpy_fromio memcpy_fromio
 #define memcpy_toio memcpy_toio
 #define memset_io memset_io
-#define xlate_dev_kmem_ptr xlate_dev_kmem_ptr
 #define xlate_dev_mem_ptr xlate_dev_mem_ptr
 #include <asm-generic/io.h>
 #undef PCI_IOBASE
arch/ia64/include/asm/uaccess.h renamed from arch/ia64/include/asm/uaccess.h~mm-remove-xlate_dev_kmem_ptr +0 -18
@@ -272,22 +272,4 @@ xlate_dev_mem_ptr(phys_addr_t p)
 	return ptr;
 }
 
-/*
- * Convert a virtual cached kernel memory pointer to an uncached pointer
- */
-static __inline__ void *
-xlate_dev_kmem_ptr(void *p)
-{
-	struct page *page;
-	void *ptr;
-
-	page = virt_to_page((unsigned long)p);
-	if (PageUncached(page))
-		ptr = (void *)__pa(p) + __IA64_UNCACHED_OFFSET;
-	else
-		ptr = p;
-
-	return ptr;
-}
-
 #endif /* _ASM_IA64_UACCESS_H */
arch/m68k/include/asm/io_mm.h renamed from arch/m68k/include/asm/io_mm.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -397,11 +397,6 @@ static inline void isa_delay(void)
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #define readb_relaxed(addr)	readb(addr)
 #define readw_relaxed(addr)	readw(addr)
 #define readl_relaxed(addr)	readl(addr)
arch/mips/include/asm/io.h renamed from arch/mips/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -564,11 +564,6 @@ extern void (*_dma_cache_inv)(unsigned l
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 void __ioread64_copy(void *to, const void __iomem *from, size_t count);
 
 #endif /* _ASM_IO_H */
arch/parisc/include/asm/io.h renamed from arch/parisc/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -316,11 +316,6 @@ extern void iowrite64be(u64 val, void __
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 extern int devmem_is_allowed(unsigned long pfn);
 
 #endif
arch/powerpc/include/asm/io.h renamed from arch/powerpc/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -663,11 +663,6 @@ static inline void name at					\
 #define xlate_dev_mem_ptr(p)	__va(p)
 
 /*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
-/*
  * We don't do relaxed operations yet, at least not with this semantic
  */
 #define readb_relaxed(addr)	readb(addr)
arch/s390/include/asm/io.h renamed from arch/s390/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -20,11 +20,6 @@ void *xlate_dev_mem_ptr(phys_addr_t phys
 #define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
 void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #define IO_SPACE_LIMIT 0
 
 void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot);
arch/sh/include/asm/io.h renamed from arch/sh/include/asm/io.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -283,11 +283,6 @@ static inline void __iomem *ioremap_prot
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
 int valid_phys_addr_range(phys_addr_t addr, size_t size);
 int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
arch/sparc/include/asm/io_64.h renamed from arch/sparc/include/asm/io_64.h~mm-remove-xlate_dev_kmem_ptr +0 -5
@@ -454,11 +454,6 @@ void sbus_set_sbus64(struct device *, in
  */
 #define xlate_dev_mem_ptr(p)	__va(p)
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#define xlate_dev_kmem_ptr(p)	p
-
 #endif
 
 #endif /* !(__SPARC64_IO_H) */
include/asm-generic/io.h renamed from include/asm-generic/io.h~mm-remove-xlate_dev_kmem_ptr +0 -11
@@ -1064,17 +1064,6 @@ static inline void pci_iounmap(struct pc
 #endif
 #endif /* CONFIG_GENERIC_IOMAP */
 
-/*
- * Convert a virtual cached pointer to an uncached pointer
- */
-#ifndef xlate_dev_kmem_ptr
-#define xlate_dev_kmem_ptr xlate_dev_kmem_ptr
-static inline void *xlate_dev_kmem_ptr(void *addr)
-{
-	return addr;
-}
-#endif
-
 #ifndef xlate_dev_mem_ptr
 #define xlate_dev_mem_ptr xlate_dev_mem_ptr
 static inline void *xlate_dev_mem_ptr(phys_addr_t addr)

_

author maintainer
#104 lore raw

PATCH 76/91 mm/vmalloc: remove vwrite()

In reply to Andrew Morton

From: David Hildenbrand <[email protected]>
Subject: mm/vmalloc: remove vwrite()

The last user (/dev/kmem) is gone. Let's drop it.

Cc Linus Torvalds <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Oleksiy Avramchenko <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Minchan Kim <[email protected]>
Cc huang ying <[email protected]>

---

 include/linux/vmalloc.h |    1 
 mm/nommu.c              |   10 ---
 mm/vmalloc.c            |  116 --------------------------------------
 3 files changed, 1 insertion(+), 126 deletions(-)
include/linux/vmalloc.h renamed from include/linux/vmalloc.h~mm-vmalloc-remove-vwrite +0 -1
@@ -229,7 +229,6 @@ static inline void set_vm_flush_reset_pe
 
 /* for /proc/kcore */
 extern long vread(char *buf, char *addr, unsigned long count);
-extern long vwrite(char *buf, char *addr, unsigned long count);
 
 /*
  *	Internals.  Dont't use..
mm/nommu.c renamed from mm/nommu.c~mm-vmalloc-remove-vwrite +0 -10
@@ -210,16 +210,6 @@ long vread(char *buf, char *addr, unsign
 	return count;
 }
 
-long vwrite(char *buf, char *addr, unsigned long count)
-{
-	/* Don't allow overflow */
-	if ((unsigned long) addr + count < count)
-		count = -(unsigned long) addr;
-
-	memcpy(addr, buf, count);
-	return count;
-}
-
 /*
  *	vmalloc  -  allocate virtually contiguous memory
  *
mm/vmalloc.c renamed from mm/vmalloc.c~mm-vmalloc-remove-vwrite +1 -115

134 lines not on this page · raw message

_

author maintainer
#105 lore raw

PATCH 77/91 arm: print alloc free paths for address in registers

In reply to Andrew Morton

From: Maninder Singh <[email protected]>
Subject: arm: print alloc free paths for address in registers

In case of a use after free kernel oops, the freeing path of the object is required to debug futher. In most of cases the object address is present in one of the registers.

Thus check the register's address and if it belongs to slab, print its alloc and free path.

e.g. in the below issue register r6 belongs to slab, and a use after free issue occurred on one of its dereferenced values:

[   20.182197] Unable to handle kernel paging request at virtual address 6b6b6b6f
....
[   20.185035] pc : [<c0538afc>]    lr : [<c0465674>]    psr: 60000013
[   20.185271] sp : c8927d40  ip : ffffefff  fp : c8aa8020
[   20.185462] r10: c8927e10  r9 : 00000001  r8 : 00400cc0
[   20.185674] r7 : 00000000  r6 : c8ab0180  r5 : c1804a80  r4 : c8aa8008
[   20.185924] r3 : c1a5661c  r2 : 00000000  r1 : 6b6b6b6b  r0 : c139bf48
.....
[   20.191499] Register r6 information: slab kmalloc-64 start c8ab0140 data offset 64 pointer offset 0 size 64 allocated at meminfo_proc_show+0x40/0x4fc
[   20.192078]     meminfo_proc_show+0x40/0x4fc
[   20.192263]     seq_read_iter+0x18c/0x4c4
[   20.192430]     proc_reg_read_iter+0x84/0xac
[   20.192617]     generic_file_splice_read+0xe8/0x17c
[   20.192816]     splice_direct_to_actor+0xb8/0x290
[   20.193008]     do_splice_direct+0xa0/0xe0
[   20.193185]     do_sendfile+0x2d0/0x438
[   20.193345]     sys_sendfile64+0x12c/0x140
[   20.193523]     ret_fast_syscall+0x0/0x58
[   20.193695]     0xbeeacde4
[   20.193822]  Free path:
[   20.193935]     meminfo_proc_show+0x5c/0x4fc
[   20.194115]     seq_read_iter+0x18c/0x4c4
[   20.194285]     proc_reg_read_iter+0x84/0xac
[   20.194475]     generic_file_splice_read+0xe8/0x17c
[   20.194685]     splice_direct_to_actor+0xb8/0x290
[   20.194870]     do_splice_direct+0xa0/0xe0
[   20.195014]     do_sendfile+0x2d0/0x438
[   20.195174]     sys_sendfile64+0x12c/0x140
[   20.195336]     ret_fast_syscall+0x0/0x58
[   20.195491]     0xbeeacde4
Cc Al Viro <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc David Rientjes <[email protected]>
Cc Dmitry Safonov <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc Russell King <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 arch/arm/include/asm/bug.h |    1 +
 arch/arm/kernel/process.c  |   11 +++++++++++
 arch/arm/kernel/traps.c    |    1 +
 3 files changed, 13 insertions(+)
arch/arm/include/asm/bug.h renamed from arch/arm/include/asm/bug.h~arm-print-alloc-free-paths-for-address-in-registers +1 -0
@@ -88,5 +88,6 @@ extern asmlinkage void c_backtrace(unsig
 struct mm_struct;
 void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr);
 extern void __show_regs(struct pt_regs *);
+extern void __show_regs_alloc_free(struct pt_regs *regs);
 
 #endif
arch/arm/kernel/process.c renamed from arch/arm/kernel/process.c~arm-print-alloc-free-paths-for-address-in-registers +11 -0
@@ -92,6 +92,17 @@ void arch_cpu_idle_exit(void)
 	ledtrig_cpu(CPU_LED_IDLE_END);
 }
 
+void __show_regs_alloc_free(struct pt_regs *regs)
+{
+	int i;
+
+	/* check for r0 - r12 only */
+	for (i = 0; i < 13; i++) {
+		pr_alert("Register r%d information:", i);
+		mem_dump_obj((void *)regs->uregs[i]);
+	}
+}
+
 void __show_regs(struct pt_regs *regs)
 {
 	unsigned long flags;
arch/arm/kernel/traps.c renamed from arch/arm/kernel/traps.c~arm-print-alloc-free-paths-for-address-in-registers +1 -0
@@ -287,6 +287,7 @@ static int __die(const char *str, int er
 
 	print_modules();
 	__show_regs(regs);
+	__show_regs_alloc_free(regs);
 	pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n",
 		 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk));
 

_

author maintainer
#106 lore raw

PATCH 78/91 scripts/spelling.txt: add "overlfow"

In reply to Andrew Morton

From: Drew Fustini <[email protected]>
Subject: scripts/spelling.txt: add "overlfow"

Add typo "overlfow" for "overflow". This typo was found and fixed in net/sctp/tsnmap.c.

---

 scripts/spelling.txt |    1 +
 1 file changed, 1 insertion(+)
scripts/spelling.txt renamed from scripts/spelling.txt~scripts-spellingtxt-add-overlfow +1 -0
@@ -1027,6 +1027,7 @@ oustanding||outstanding
 overaall||overall
 overhread||overhead
 overlaping||overlapping
+overlfow||overflow
 overide||override
 overrided||overridden
 overriden||overridden

_

author maintainer
#107 lore raw

PATCH 79/91 scripts/spelling.txt: add "diabled" typo

In reply to Andrew Morton

From: zuoqilin <[email protected]>
Subject: scripts/spelling.txt: Add "diabled" typo

Increase "diabled" spelling error check.

---

 scripts/spelling.txt |    1 +
 1 file changed, 1 insertion(+)
scripts/spelling.txt renamed from scripts/spelling.txt~scripts-spellingtxt-add-diabled-typo +1 -0
@@ -480,6 +480,7 @@ devided||divided
 deviece||device
 devision||division
 diable||disable
+diabled||disabled
 dicline||decline
 dictionnary||dictionary
 didnt||didn't

_

author maintainer
#108 lore raw

PATCH 80/91 scripts/spelling.txt: add "overflw"

In reply to Andrew Morton

From: Drew Fustini <[email protected]>
Subject: scripts/spelling.txt: add "overflw"

Add typo "overflw" for "overflow". This typo was found and fixed in drivers/clocksource/timer-pistachio.c.

---

 scripts/spelling.txt |    1 +
 1 file changed, 1 insertion(+)
scripts/spelling.txt renamed from scripts/spelling.txt~scripts-spellingtxt-add-overflw +1 -0
@@ -1028,6 +1028,7 @@ oustanding||outstanding
 overaall||overall
 overhread||overhead
 overlaping||overlapping
+overflw||overflow
 overlfow||overflow
 overide||override
 overrided||overridden

_

author maintainer
#109 lore raw

PATCH 81/91 mm/slab.c: fix spelling mistake "disired" -> "desired"

In reply to Andrew Morton

From: Colin Ian King <[email protected]>
Subject: mm/slab.c: fix spelling mistake "disired" -> "desired"

There is a spelling mistake in a comment. Fix it.

---

 mm/slab.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slab.c renamed from mm/slab.c~mm-slab-fix-spelling-mistake-disired-desired +1 -1
@@ -2284,7 +2284,7 @@ void __kmem_cache_release(struct kmem_ca
  * Because if it is the case, that means we defer the creation of
  * the kmalloc_{dma,}_cache of size sizeof(slab descriptor) to this point.
  * And we eventually call down to __kmem_cache_create(), which
- * in turn looks up in the kmalloc_{dma,}_caches for the disired-size one.
+ * in turn looks up in the kmalloc_{dma,}_caches for the desired-size one.
  * This is a "chicken-and-egg" problem.
  *
  * So the off-slab slab descriptor shall come from the kmalloc_{dma,}_caches,

_

author maintainer
#110 lore raw

PATCH 82/91 include/linux/pgtable.h: few spelling fixes

In reply to Andrew Morton

From: Bhaskar Chowdhury <[email protected]>
Subject: include/linux/pgtable.h: few spelling fixes

Few spelling fixes throughout the file.

---

 include/linux/pgtable.h |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/linux/pgtable.h renamed from include/linux/pgtable.h~mm-few-spelling-fixes +5 -5
@@ -426,7 +426,7 @@ static inline void ptep_set_wrprotect(st
 
 /*
  * On some architectures hardware does not set page access bit when accessing
- * memory page, it is responsibilty of software setting this bit. It brings
+ * memory page, it is responsibility of software setting this bit. It brings
  * out extra page fault penalty to track page access bit. For optimization page
  * access bit can be set during all page fault flow on these arches.
  * To be differentiate with macro pte_mkyoung, this macro is used on platforms
@@ -519,7 +519,7 @@ extern pgtable_t pgtable_trans_huge_with
 /*
  * This is an implementation of pmdp_establish() that is only suitable for an
  * architecture that doesn't have hardware dirty/accessed bits. In this case we
- * can't race with CPU which sets these bits and non-atomic aproach is fine.
+ * can't race with CPU which sets these bits and non-atomic approach is fine.
  */
 static inline pmd_t generic_pmdp_establish(struct vm_area_struct *vma,
 		unsigned long address, pmd_t *pmdp, pmd_t pmd)
@@ -852,7 +852,7 @@ static inline void __ptep_modify_prot_co
  * updates, but to prevent any updates it may make from being lost.
  *
  * This does not protect against other software modifications of the
- * pte; the appropriate pte lock must be held over the transation.
+ * pte; the appropriate pte lock must be held over the transaction.
  *
  * Note that this interface is intended to be batchable, meaning that
  * ptep_modify_prot_commit may not actually update the pte, but merely
@@ -1281,13 +1281,13 @@ static inline int pmd_none_or_trans_huge
 	 *
 	 * The complete check uses is_pmd_migration_entry() in linux/swapops.h
 	 * But using that requires moving current function and pmd_trans_unstable()
-	 * to linux/swapops.h to resovle dependency, which is too much code move.
+	 * to linux/swapops.h to resolve dependency, which is too much code move.
 	 *
 	 * !pmd_present() is equivalent to is_pmd_migration_entry() currently,
 	 * because !pmd_present() pages can only be under migration not swapped
 	 * out.
 	 *
-	 * pmd_none() is preseved for future condition checks on pmd migration
+	 * pmd_none() is preserved for future condition checks on pmd migration
 	 * entries and not confusing with this function name, although it is
 	 * redundant with !pmd_present().
 	 */

_

author maintainer
#111 lore raw

PATCH 83/91 kernel/umh.c: fix some spelling mistakes

In reply to Andrew Morton

From: zhouchuangao <[email protected]>
Subject: kernel/umh.c: fix some spelling mistakes

Fix some spelling mistakes, and modify the order of the parameter comments to be consistent with the order of the parameters passed to the function.

---

 kernel/umh.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/umh.c renamed from kernel/umh.c~umh-fix-some-spelling-mistakes +3 -3
@@ -338,8 +338,8 @@ static void helper_unlock(void)
  * @argv: arg vector for process
  * @envp: environment for process
  * @gfp_mask: gfp mask for memory allocation
- * @cleanup: a cleanup function
  * @init: an init function
+ * @cleanup: a cleanup function
  * @data: arbitrary context sensitive data
  *
  * Returns either %NULL on allocation failure, or a subprocess_info
@@ -350,7 +350,7 @@ static void helper_unlock(void)
  * exec.  A non-zero return code causes the process to error out, exit,
  * and return the failure to the calling process
  *
- * The cleanup function is just before ethe subprocess_info is about to
+ * The cleanup function is just before the subprocess_info is about to
  * be freed.  This can be used for freeing the argv and envp.  The
  * Function must be runnable in either a process context or the
  * context in which call_usermodehelper_exec is called.
@@ -386,7 +386,7 @@ EXPORT_SYMBOL(call_usermodehelper_setup)
 
 /**
  * call_usermodehelper_exec - start a usermode application
- * @sub_info: information about the subprocessa
+ * @sub_info: information about the subprocess
  * @wait: wait for the application to finish and return status.
  *        when UMH_NO_WAIT don't wait at all, but you get no useful error back
  *        when the program couldn't be exec'ed. This makes it safe to call

_

author maintainer
#112 lore raw

PATCH 84/91 kernel/user_namespace.c: fix typos

In reply to Andrew Morton

From: Xiaofeng Cao <[email protected]>
Subject: kernel/user_namespace.c: fix typos

change 'verifing' to 'verifying'
change 'certaint' to 'certain'
change 'approprpiate' to 'appropriate'

---

 kernel/user_namespace.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/user_namespace.c renamed from kernel/user_namespace.c~kernel-user_namespace-fix-typo-issue +3 -3
@@ -85,7 +85,7 @@ int create_user_ns(struct cred *new)
 	/*
 	 * Verify that we can not violate the policy of which files
 	 * may be accessed that is specified by the root directory,
-	 * by verifing that the root directory is at the root of the
+	 * by verifying that the root directory is at the root of the
 	 * mount namespace which allows all files to be accessed.
 	 */
 	ret = -EPERM;
@@ -1014,7 +1014,7 @@ static ssize_t map_write(struct file *fi
 			goto out;
 		ret = -EINVAL;
 	}
-	/* Be very certaint the new map actually exists */
+	/* Be very certain the new map actually exists */
 	if (new_map.nr_extents == 0)
 		goto out;
 
@@ -1169,7 +1169,7 @@ static bool new_idmap_permitted(const st
 
 	/* Allow the specified ids if we have the appropriate capability
 	 * (CAP_SETUID or CAP_SETGID) over the parent user namespace.
-	 * And the opener of the id file also had the approprpiate capability.
+	 * And the opener of the id file also has the appropriate capability.
 	 */
 	if (ns_capable(ns->parent, cap_setid) &&
 	    file_ns_capable(file, ns->parent, cap_setid))

_

author maintainer
#113 lore raw

PATCH 85/91 kernel/up.c: fix typo

In reply to Andrew Morton

From: Bhaskar Chowdhury <[email protected]>
Subject: kernel/up.c: fix typo

s/condtions/conditions/

---

 kernel/up.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/up.c renamed from kernel/up.c~kernel-fix-a-typo-in-the-file-upc +1 -1
@@ -38,7 +38,7 @@ EXPORT_SYMBOL(smp_call_function_single_a
 
 /*
  * Preemption is disabled here to make sure the cond_func is called under the
- * same condtions in UP and SMP.
+ * same conditions in UP and SMP.
  */
 void on_each_cpu_cond_mask(smp_cond_func_t cond_func, smp_call_func_t func,
 			   void *info, bool wait, const struct cpumask *mask)

_

author maintainer
#114 lore raw

PATCH 86/91 kernel/sys.c: fix typo

In reply to Andrew Morton

From: Xiaofeng Cao <[email protected]>
Subject: kernel/sys.c: fix typo

change 'infite'     to 'infinite'
change 'concurent'  to 'concurrent'
change 'memvers'    to 'members'

change 'decendants' to 'descendants'
change 'argumets' to 'arguments'

---

 kernel/sys.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
kernel/sys.c renamed from kernel/sys.c~kernel-sys-fix-typo-issue +7 -7
@@ -1590,7 +1590,7 @@ int do_prlimit(struct task_struct *tsk,
 
 	/*
 	 * RLIMIT_CPU handling. Arm the posix CPU timer if the limit is not
-	 * infite. In case of RLIM_INFINITY the posix CPU timer code
+	 * infinite. In case of RLIM_INFINITY the posix CPU timer code
 	 * ignores the rlimit.
 	 */
 	 if (!retval && new_rlim && resource == RLIMIT_CPU &&
@@ -2029,7 +2029,7 @@ static int prctl_set_mm_map(int opt, con
 	}
 
 	/*
-	 * arg_lock protects concurent updates but we still need mmap_lock for
+	 * arg_lock protects concurrent updates but we still need mmap_lock for
 	 * read to exclude races with sys_brk.
 	 */
 	mmap_read_lock(mm);
@@ -2041,7 +2041,7 @@ static int prctl_set_mm_map(int opt, con
 	 * output in procfs mostly, except
 	 *
 	 *  - @start_brk/@brk which are used in do_brk_flags but kernel lookups
-	 *    for VMAs when updating these memvers so anything wrong written
+	 *    for VMAs when updating these members so anything wrong written
 	 *    here cause kernel to swear at userspace program but won't lead
 	 *    to any problem in kernel itself
 	 */
@@ -2143,7 +2143,7 @@ static int prctl_set_mm(int opt, unsigne
 	error = -EINVAL;
 
 	/*
-	 * arg_lock protects concurent updates of arg boundaries, we need
+	 * arg_lock protects concurrent updates of arg boundaries, we need
 	 * mmap_lock for a) concurrent sys_brk, b) finding VMA for addr
 	 * validation.
 	 */
@@ -2210,7 +2210,7 @@ static int prctl_set_mm(int opt, unsigne
 	 * If command line arguments and environment
 	 * are placed somewhere else on stack, we can
 	 * set them up here, ARG_START/END to setup
-	 * command line argumets and ENV_START/END
+	 * command line arguments and ENV_START/END
 	 * for environment.
 	 */
 	case PR_SET_MM_START_STACK:
@@ -2258,8 +2258,8 @@ static int prctl_get_tid_address(struct
 static int propagate_has_child_subreaper(struct task_struct *p, void *data)
 {
 	/*
-	 * If task has has_child_subreaper - all its decendants
-	 * already have these flag too and new decendants will
+	 * If task has has_child_subreaper - all its descendants
+	 * already have these flag too and new descendants will
 	 * inherit it on fork, skip them.
 	 *
 	 * If we've found child_reaper - skip descendants in

_

author maintainer
#115 lore raw

PATCH 87/91 fs: fat: fix spelling typo of values

In reply to Andrew Morton

From: dingsenjie <[email protected]>
Subject: fs: fat: fix spelling typo of values

vaules -> values

---

 fs/fat/fatent.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/fatent.c renamed from fs/fat/fatent.c~fs-fat-fix-spelling-typo-of-values +1 -1
@@ -771,7 +771,7 @@ int fat_trim_fs(struct inode *inode, str
 	/*
 	 * FAT data is organized as clusters, trim at the granulary of cluster.
 	 *
-	 * fstrim_range is in byte, convert vaules to cluster index.
+	 * fstrim_range is in byte, convert values to cluster index.
 	 * Treat sectors before data region as all used, not to trim them.
 	 */
 	ent_start = max_t(u64, range->start>>sbi->cluster_bits, FAT_START_ENT);

_

author maintainer
#116 lore raw

PATCH 88/91 ipc/sem.c: spelling fix

In reply to Andrew Morton

From: Bhaskar Chowdhury <[email protected]>
Subject: ipc/sem.c: spelling fix

s/purpuse/purpose/

---

 ipc/sem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ipc/sem.c renamed from ipc/sem.c~ipc-semc-couple-of-spelling-fixes +1 -1
@@ -786,7 +786,7 @@ static inline void wake_up_sem_queue_pre
 {
 	get_task_struct(q->sleeper);
 
-	/* see SEM_BARRIER_2 for purpuse/pairing */
+	/* see SEM_BARRIER_2 for purpose/pairing */
 	smp_store_release(&q->status, error);
 
 	wake_q_add_safe(wake_q, q->sleeper);

_