* refs/heads/tmp-ce5de62:
Revert "BACKPORT: tracing: Remove unnecessary DEBUG_FS dependency"
Linux 5.4.24
blktrace: Protect q->blk_trace with RCU
kvm: nVMX: VMWRITE checks unsupported field before read-only field
kvm: nVMX: VMWRITE checks VMCS-link pointer before VMCS field
mm, thp: fix defrag setting if newline is not used
mm/huge_memory.c: use head to check huge zero page
mm/gup: allow FOLL_FORCE for get_user_pages_fast()
mm/debug.c: always print flags in dump_page()
locking/lockdep: Fix lockdep_stats indentation problem
xfs: clear kernel only flags in XFS_IOC_ATTRMULTI_BY_HANDLE
bus: tegra-aconnect: Remove PM_CLK dependency
netfilter: nf_flowtable: fix documentation
netfilter: nft_tunnel: no need to call htons() when dumping ports
thermal: brcmstb_thermal: Do not use DT coefficients
thermal: db8500: Depromote debug print
ubifs: Fix ino_t format warnings in orphan_delete()
rcu: Allow only one expedited GP to run concurrently with wakeups
KVM: x86: Remove spurious clearing of async #PF MSR
KVM: x86: Remove spurious kvm_mmu_unload() from vcpu destruction path
x86/resctrl: Check monitoring static key in the MBM overflow handler
perf ui gtk: Add missing zalloc object
perf hists browser: Restore ESC as "Zoom out" of DSO/thread/etc
pwm: omap-dmtimer: put_device() after of_find_device_by_node()
lib/vdso: Update coarse timekeeper unconditionally
lib/vdso: Make __arch_update_vdso_data() logic understandable
kprobes: Set unoptimized flag after unoptimizing code
ima: ima/lsm policy rule loading logic bug fixes
drivers: net: xgene: Fix the order of the arguments of 'alloc_etherdev_mqs()'
RDMA/hns: Bugfix for posting a wqe with sge
RDMA/hns: Simplify the calculation and usage of wqe idx for post verbs
f2fs: fix to add swap extent correctly
sched/fair: Optimize select_idle_cpu
KVM: Check for a bad hva before dropping into the ghc slow path
KVM: SVM: Override default MMIO mask if memory encryption is enabled
mwifiex: delete unused mwifiex_get_intf_num()
mwifiex: drop most magic numbers from mwifiex_process_tdls_action_frame()
namei: only return -ECHILD from follow_dotdot_rcu()
kbuild: make single target builds even faster
kbuild: remove unneeded variable, single-all
kbuild: move headers_check rule to usr/include/Makefile
kbuild: remove header compile test
selftests: Install settings files to fix TIMEOUT failures
net: ena: make ena rxfh support ETH_RSS_HASH_NO_CHANGE
net/smc: no peer ID in CLC decline for SMCD
net: atlantic: fix out of range usage of active_vlans array
net: atlantic: fix potential error handling
net: atlantic: fix use after free kasan warn
net: netlink: cap max groups which will be considered in netlink_bind()
s390/qeth: vnicc Fix EOPNOTSUPP precedence
nvme-pci: Hold cq_poll_lock while completing CQEs
usb: charger: assign specific number for enum value
hv_netvsc: Fix unwanted wakeup in netvsc_attach()
kbuild: fix DT binding schema rule to detect command line changes
mac80211: Remove a redundant mutex unlock
nl80211: fix potential leak in AP start
drm/i915/gvt: Separate display reset from ALL_ENGINES reset
drm/i915/gvt: Fix orphan vgpu dmabuf_objs' lifetime
i2c: jz4780: silence log flood on txabrt
i2c: altera: Fix potential integer overflow
MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()'
HID: hiddev: Fix race in in hiddev_disconnect()
HID: alps: Fix an error handling path in 'alps_input_configured()'
netfilter: xt_hashlimit: reduce hashlimit_mutex scope for htable_put()
netfilter: ipset: Fix forceadd evaluation path
vhost: Check docket sk_family instead of call getname
net/smc: transfer fasync_list in case of fallback
netfilter: ipset: Fix "INFO: rcu detected stall in hash_xxx" reports
io_uring: fix 32-bit compatability with sendmsg/recvmsg
cpufreq: Fix policy initialization for internal governor drivers
amdgpu/gmc_v9: save/restore sdpif regs during S3
Revert "PM / devfreq: Modify the device name as devfreq(X) for sysfs"
tracing: Disable trace_printk() on post poned tests
macintosh: therm_windtunnel: fix regression when instantiating devices
drm/radeon: Inline drm_get_pci_dev
drm/amdgpu: Drop DRIVER_USE_AGP
HID: core: increase HID report buffer size to 8KiB
HID: core: fix off-by-one memset in hid_report_raw_event()
HID: ite: Only bind to keyboard USB interface on Acer SW5-012 keyboard dock
KVM: VMX: check descriptor table exits on instruction emulation
ACPI: watchdog: Fix gas->access_width usage
ACPICA: Introduce ACPI_ACCESS_BYTE_WIDTH() macro
audit: always check the netlink payload length in audit_receive_msg()
audit: fix error handling in audit_data_to_entry()
ext4: potential crash on allocation error in ext4_alloc_flex_bg_array()
nvme/pci: move cqe check after device shutdown
nvme: prevent warning triggered by nvme_stop_keep_alive
nvme/tcp: fix bug on double requeue when send fails
net: hns3: fix a copying IPv6 address error in hclge_fd_get_flow_tuples()
net: hns3: add management table after IMP reset
mac80211: fix wrong 160/80+80 MHz setting
cfg80211: add missing policy for NL80211_ATTR_STATUS_CODE
cifs: Fix mode output in debugging statements
ice: update Unit Load Status bitmask to check after reset
net: ena: ena-com.c: prevent NULL pointer dereference
net: ena: ethtool: use correct value for crc32 hash
net: ena: fix corruption of dev_idx_to_host_tbl
net: ena: fix incorrectly saving queue numbers when setting RSS indirection table
net: ena: rss: store hash function as values and not bits
net: ena: rss: fix failure to get indirection table
net: ena: rss: do not allocate key when not supported
net: ena: fix incorrect default RSS key
net: ena: add missing ethtool TX timestamping indication
net: ena: fix uses of round_jiffies()
net: ena: fix potential crash when rxfh key is NULL
i40e: Fix the conditional for i40e_vc_validate_vqs_bitmaps
soc/tegra: fuse: Fix build with Tegra194 configuration
amdgpu: Prevent build errors regarding soft/hard-float FP ABI tags
drm/amd/display: Add initialitions for PLL2 clock source
drm/amd/display: Limit minimum DPPCLK to 100MHz.
drm/amd/display: Check engine is not NULL before acquiring
RDMA/siw: Remove unwanted WARN_ON in siw_cm_llp_data_ready()
drm/amd/display: Do not set optimized_require to false after plane disable
ARM: dts: sti: fixup sound frame-inversion for stihxxx-b2120.dtsi
ceph: do not execute direct write in parallel if O_APPEND is specified
perf/x86/msr: Add Tremont support
perf/x86/cstate: Add Tremont support
perf/x86/intel: Add Elkhart Lake support
perf/smmuv3: Use platform_get_irq_optional() for wired interrupt
NFSv4: Fix races between open and dentry revalidation
qmi_wwan: unconditionally reject 2 ep interfaces
qmi_wwan: re-add DW5821e pre-production variant
s390/zcrypt: fix card and queue total counter wrap
cfg80211: check wiphy driver existence for drvinfo report
mac80211: consider more elements in parsing CRC
dax: pass NOWAIT flag to iomap_apply
sched/fair: Prevent unlimited runtime on throttled group
timers/nohz: Update NOHZ load in remote tick
sched/core: Don't skip remote tick for idle CPUs
drm/msm: Set dma maximum segment size for mdss
ipmi:ssif: Handle a possible NULL pointer reference
ipv6: Fix nlmsg_flags when splitting a multipath route
ipv6: Fix route replacement with dev-only route
bonding: fix lockdep warning in bond_get_stats()
net: export netdev_next_lower_dev_rcu()
bonding: add missing netdev_update_lockdep_key()
bnxt_en: Issue PCIe FLR in kdump kernel to cleanup pending DMAs.
bnxt_en: Improve device shutdown method.
sctp: move the format error check out of __sctp_sf_do_9_1_abort
udp: rehash on disconnect
Revert "net: dev: introduce support for sch BYPASS for lockless qdisc"
qede: Fix race between rdma destroy workqueue and link change event
nfc: pn544: Fix occasional HW initialization failure
net/tls: Fix to avoid gettig invalid tls record
net: sched: correct flower port blocking
net: phy: restore mdio regs in the iproc mdio driver
net: mscc: fix in frame extraction
net: macb: ensure interface is not suspended on at91rm9200
net: fib_rules: Correctly set table field when table number exceeds 8 bits
net: dsa: b53: Ensure the default VID is untagged
EDAC: skx_common: downgrade message importance on missing PCI device
io_uring: grab ->fs as part of async offload
ANDROID: abi_gki_aarch64_whitelist: add module_layout and task_struct
ANDROID: gki_defconfig: disable KPROBES, update ABI
FROMGIT: scsi: ufs: Select INITIAL ADAPT type for HS Gear4
FROMLIST: scsi: ufs: Use ufshcd_config_pwr_mode() when scale gear
FROMGIT: scsi: ufs-qcom: Apply QUIRK_HOST_TACTIVATE for WDC UFS devices
FROMGIT: scsi: ufs: Allow vendor device quirks to be applied early
BACKPORT: scsi: ufs: Delete struct ufs_dev_desc
ANDROID: gki_defconfig: enable IOMMU_LIMIT_IOVA_ALIGNMENT
FROMLIST: iommu/iova: Support limiting IOVA alignment
FROMLIST: iommu/iova: Add a best-fit algorithm
FROMLIST: iommu/dma: Allow drivers to reserve an iova range
ANDROID: Unconditionally create bridge tracepoints
ANDROID: gki_defconfig: Enable MFD_SYSCON on x86
ANDROID: update ABI for CONFIG_IIO_* changes
ANDROID: gki_defconfig: add CONFIG_IIO_BUFFER and CONFIG_IIO_TRIGGER
ANDROID: gki: set CONFIG_SERIAL_SPRD_CONSOLE for earlycon
ANDROID: Re-add default y for VIRTIO_PCI_LEGACY
ANDROID: GKI: build in HVC_DRIVER
ANDROID: Removed default m for virtual sw crypto device
ANDROID: Remove default y on BRIDGE_IGMP_SNOOPING
ANDROID: GKI: Added missing SND configs
ANDROID: scsi: ufs: allow ufs variants to override sg entry size
ANDROID: GKI: Remove CONFIG_BRIDGE from arm64 config
ANDROID: Enable HID_NINTENDO as y
FROMLIST: HID: nintendo: add nintendo switch controller driver
UPSTREAM: iommu/arm-smmu: Restore naming of driver parameter prefix
ANDROID: gki_defconfig: Remove 'BRIDGE_NETFILTER is not set'
UPSTREAM: net: disable BRIDGE_NETFILTER by default
Linux 5.4.23
ASoC: SOF: Intel: hda: Add iDisp4 DAI
bpf: Selftests build error in sockmap_basic.c
s390/mm: Explicitly compare PAGE_DEFAULT_KEY against zero in storage_key_init_range
s390/kaslr: Fix casts in get_random
net/mlx5e: Fix crash in recovery flow without devlink reporter
net/mlx5: Fix sleep while atomic in mlx5_eswitch_get_vepa
net/mlx5e: Reset RQ doorbell counter before moving RQ state from RST to RDY
xen: Enable interrupts when calling _cond_resched()
ata: ahci: Add shutdown to freeze hardware resources of ahci
io_uring: prevent sq_thread from spinning when it should stop
rxrpc: Fix call RCU cleanup using non-bh-safe locks
netfilter: xt_hashlimit: limit the max size of hashtable
ALSA: seq: Fix concurrent access to queue current tick/time
ALSA: seq: Avoid concurrent access to queue flags
ALSA: rawmidi: Avoid bit fields for state flags
io_uring: fix __io_iopoll_check deadlock in io_sq_thread
arm64: lse: Fix LSE atomics with LLVM
bpf, offload: Replace bitwise AND by logical AND in bpf_prog_offload_info_fill
genirq/proc: Reject invalid affinity masks (again)
crypto: rename sm3-256 to sm3 in hash_algo_name
iommu/vt-d: Fix compile warning from intel-svm.h
ecryptfs: replace BUG_ON with error handling code
ASoC: fsl_sai: Fix exiting path on probing failure
ASoC: atmel: fix atmel_ssc_set_audio link failure
staging: greybus: use after free in gb_audio_manager_remove_all()
staging: rtl8723bs: fix copy of overlapping memory
usb: dwc2: Fix in ISOC request length checking
usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus
scsi: Revert "target: iscsi: Wait for all commands to finish before freeing a session"
scsi: Revert "RDMA/isert: Fix a recently introduced regression related to logout"
drm/msm/dpu: fix BGR565 vs RGB565 confusion
drm/i915/gt: Protect defer_request() from new waiters
drm/bridge: tc358767: fix poll timeouts
drm/i915/gvt: more locking for ppgtt mm LRU list
drm/i915/execlists: Always force a context reload when rewinding RING_TAIL
drm/i915/gt: Detect if we miss WaIdleLiteRestore
Revert "dmaengine: imx-sdma: Fix memory leak"
Btrfs: fix deadlock during fast fsync when logging prealloc extents beyond eof
btrfs: don't set path->leave_spinning for truncate
Btrfs: fix race between shrinking truncate and fiemap
Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
btrfs: do not check delayed items are empty for single transaction cleanup
btrfs: reset fs_root to NULL on error in open_ctree
btrfs: fix bytes_may_use underflow in prealloc error condtition
btrfs: destroy qgroup extent records on transaction abort
KVM: apic: avoid calculating pending eoi from an uninitialized val
KVM: nVMX: handle nested posted interrupts when apicv is disabled for L1
KVM: nVMX: clear PIN_BASED_POSTED_INTR from nested pinbased_ctls only when apicv is globally disabled
KVM: nVMX: Check IO instruction VM-exit conditions
KVM: nVMX: Refactor IO bitmap checks into helper function
ext4: fix race between writepages and enabling EXT4_EXTENTS_FL
ext4: rename s_journal_flag_rwsem to s_writepages_rwsem
ext4: fix mount failure with quota configured as module
ext4: fix potential race between s_flex_groups online resizing and access
ext4: fix potential race between s_group_info online resizing and access
ext4: fix potential race between online resizing and write operations
ext4: add cond_resched() to __ext4_find_entry()
ext4: fix a data race in EXT4_I(inode)->i_disksize
KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI
KVM: nVMX: Don't emulate instructions in guest mode
sched/psi: Fix OOB write when writing 0 bytes to PSI files
drm/i915: Update drm/i915 bug filing URL
drm/i915: Wean off drm_pci_alloc/drm_pci_free
drm/nouveau/kms/gv100-: Re-set LUT after clearing for modesets
drm/amdgpu/gfx10: disable gfxoff when reading rlc clock
drm/amdgpu/gfx9: disable gfxoff when reading rlc clock
drm/amdgpu/soc15: fix xclk for raven
mm: Avoid creating virtual address aliases in brk()/mmap()/mremap()
lib/stackdepot.c: fix global out-of-bounds in stack_slabs
mm/sparsemem: pfn_to_page is not valid yet on SPARSEMEM
mm/vmscan.c: don't round up scan size for online memory cgroup
genirq/irqdomain: Make sure all irq domain flags are distinct
nvme-multipath: Fix memory leak with ana_log_buf
mm/memcontrol.c: lost css_put in memcg_expand_shrinker_maps()
Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()"
ACPI: PM: s2idle: Check fixed wakeup events in acpi_s2idle_wake()
MAINTAINERS: Update drm/i915 bug filing URL
serdev: ttyport: restore client ops on deregistration
tty: serial: qcom_geni_serial: Fix RX cancel command failure
tty: serial: imx: setup the correct sg entry for tx dma
tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode
serial: 8250: Check UPF_IRQ_SHARED in advance
x86/cpu/amd: Enable the fixed Instructions Retired counter IRPERF
x86/mce/amd: Fix kobject lifetime
x86/mce/amd: Publish the bank pointer only after setup has succeeded
x86/ima: use correct identifier for SetupMode variable
jbd2: fix ocfs2 corrupt when clearing block group bits
arm64: memory: Add missing brackets to untagged_addr() macro
powerpc/hugetlb: Fix 8M hugepages on 8xx
powerpc/hugetlb: Fix 512k hugepages on 8xx with 16k page size
powerpc/entry: Fix an #if which should be an #ifdef in entry_32.S
powerpc/tm: Fix clearing MSR[TS] in current when reclaiming on signal delivery
powerpc/eeh: Fix deadlock handling dead PHB
powerpc/8xx: Fix clearing of bits 20-23 in ITLB miss
drm/panfrost: perfcnt: Reserve/use the AS attached to the perfcnt MMU context
staging: rtl8723bs: Fix potential overuse of kernel memory
staging: rtl8723bs: Fix potential security hole
staging: rtl8188eu: Fix potential overuse of kernel memory
staging: rtl8188eu: Fix potential security hole
scsi: Revert "target/core: Inline transport_lun_remove_cmd()"
usb: dwc3: debug: fix string position formatting mixup with ret and len
usb: dwc3: gadget: Check for IOC/LST bit in TRB->ctrl fields
usb: dwc2: Fix SET/CLEAR_FEATURE and GET_STATUS flows
USB: hub: Fix the broken detection of USB3 device in SMSC hub
USB: hub: Don't record a connect-change event during reset-resume
USB: Fix novation SourceControl XL after suspend
usb: uas: fix a plug & unplug racing
USB: quirks: blacklist duplicate ep on Sound Devices USBPre2
USB: core: add endpoint-blacklist quirk
usb: host: xhci: update event ring dequeue pointer on purpose
xhci: Fix memory leak when caching protocol extended capability PSI tables - take 2
xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms
xhci: fix runtime pm enabling for quirky Intel hosts
xhci: Force Maximum Packet size for Full-speed bulk devices to valid range.
staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi.
staging: android: ashmem: Disallow ashmem memory from being remapped
vt: vt_ioctl: fix race in VT_RESIZEX
vt: selection, handle pending signals in paste_selection
vt: fix scrollback flushing on background consoles
floppy: check FDC index for errors before assigning it
e1000e: Use rtnl_lock to prevent race conditions between net and pci/pm
USB: misc: iowarrior: add support for the 100 device
USB: misc: iowarrior: add support for the 28 and 28L devices
USB: misc: iowarrior: add support for 2 OEMed devices
thunderbolt: Prevent crash if non-active NVMem file is read
btrfs: handle logged extent failure properly
ecryptfs: fix a memory leak bug in ecryptfs_init_messaging()
ecryptfs: fix a memory leak bug in parse_tag_1_packet()
tpm: Initialize crypto_id of allocated_banks to HASH_ALGO__LAST
ASoC: sun8i-codec: Fix setting DAI data format
ASoC: codec2codec: avoid invalid/double-free of pcm runtime
ALSA: hda/realtek - Apply quirk for yet another MSI laptop
ALSA: hda/realtek - Apply quirk for MSI GP63, too
ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs
iommu/qcom: Fix bogus detach logic
UPSTREAM: sched/psi: Fix OOB write when writing 0 bytes to PSI files
ANDROID: build.config.gki.aarch64: enable symbol trimming
ANDROID: kbuild: avoid excessively long argument lists
ANDROID: gki_defconfig: Enable CONFIG_RD_LZ4
ANDROID: net: wireless: Add module_param(mac_prefix) to mac80211_hwsim
ANDROID: gki: Enable BINFMT_MISC as part of GKI
ANDROID: gki_defconfig: disable CONFIG_CRYPTO_MD4
FROMLIST: kbuild: generate autoksyms.h early
FROMLIST: kbuild: split adjust_autoksyms.sh in two parts
FROMLIST: kbuild: allow symbol whitelisting with TRIM_UNUSED_KSYMS
ANDROID: ABI/Whitelist: update for unisoc
ANDROID: Disable wq fp check in CFI builds
ANDROID: gki_defconfig: Disable CONFIG_RT_GROUP_SCHED
FROMGIT: of: property: Add device link support for power-domains and hwlocks
ANDROID: drm/msm/a6xx: Make a6xx_gmu_bo.iova a dma_addr_t
FROMLIST: of: of_reserved_mem: Increase limit on number of reserved regions
ANDROID: dm: Add wrapped key support in dm-default-key
ANDROID: dm: add support for passing through derive_raw_secret
ANDROID: block: Prevent crypto fallback for wrapped keys
FROMLIST: drm/msm/a6xx: Use the DMA API for GMU memory objects
FROMLIST: arm64: dts: sdm845: Set the virtual address range for GMU allocations
UPSTREAM: of: Make of_dma_get_range() work on bus nodes
UPSTREAM: of/address: Fix of_pci_range_parser_one translation of DMA addresses
UPSTREAM: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'
UPSTREAM: of: Factor out #{addr,size}-cells parsing
UPSTREAM: of: address: Follow DMA parent for "dma-coherent"
UPSTREAM: of/address: Introduce of_get_next_dma_parent() helper
UPSTREAM: of: Make of_dma_get_range() private
ANDROID: fix merge issue in 5.4.22
ANDROID: update ABI for 5.4.22
Linux 5.4.22
rtc: Kconfig: select REGMAP_I2C when necessary
bcache: properly initialize 'path' and 'err' in register_bcache()
drm/amdgpu/display: handle multiple numbers of fclks in dcn_calcs.c (v2)
s390/pci: Recover handle in clp_set_pci_fn()
mlxsw: spectrum_dpipe: Add missing error path
fuse: don't overflow LLONG_MAX with end offset
virtio_balloon: prevent pfn array overflow
cifs: log warning message (once) if out of disk space
i40e: Relax i40e_xsk_wakeup's return value when PF is busy
help_next should increase position index
NFS: Fix memory leaks
drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_voltage
drm/amdgpu/smu10: fix smu10_get_clock_by_type_with_latency
brd: check and limit max_part par
microblaze: Prevent the overflow of the start
asm-generic/tlb: add missing CONFIG symbol
iwlwifi: mvm: Check the sta is not NULL in iwl_mvm_cfg_he_sta()
iwlwifi: mvm: Fix thermal zone registration
nvme-pci: remove nvmeq->tags
nvmet: Pass lockdep expression to RCU lists
irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL
bcache: fix incorrect data type usage in btree_flush_write()
bcache: explicity type cast in bset_bkey_last()
bcache: fix memory corruption in bch_cache_accounting_clear()
reiserfs: prevent NULL pointer dereference in reiserfs_insert_item()
lib/scatterlist.c: adjust indentation in __sg_alloc_table
ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans()
ocfs2: make local header paths relative to C files
btrfs: do not do delalloc reservation under page lock
powerpc: Do not consider weak unresolved symbol relocations as bad
radeon: insert 10ms sleep in dce5_crtc_load_lut
trigger_next should increase position index
ftrace: fpid_next() should increase position index
char: hpet: Fix out-of-bounds read bug
drm/nouveau/disp/nv50-: prevent oops when no channel method map provided
irqchip/gic-v3: Only provision redistributors that are enabled in ACPI
drm/amd/display: do not allocate display_mode_lib unnecessarily
rbd: work around -Wuninitialized warning
ceph: check availability of mds cluster on mount after wait timeout
powerpc/mm: Don't log user reads to 0xffffffff
bpf: map_seq_next should always increase position index
cifs: fix NULL dereference in match_prepath
cifs: Fix mount options set in automount
cifs: fix unitialized variable poential problem with network I/O cache lock patch
iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop
rtw88: fix potential NULL skb access in TX ISR
hostap: Adjust indentation in prism2_hostapd_add_sta
ALSA: usb-audio: add quirks for Line6 Helix devices fw>=2.82
ARM: 8951/1: Fix Kexec compilation issue.
selftests/eeh: Bump EEH wait time to 60s
powerpc/pseries/lparcfg: Fix display of Maximum Memory
jbd2: make sure ESHUTDOWN to be recorded in the journal superblock
jbd2: switch to use jbd2_journal_abort() when failed to submit the commit record
selftests: bpf: Reset global state between reuseport test runs
alarmtimer: Make alarmtimer platform device child of RTC device
iommu/vt-d: Remove unnecessary WARN_ON_ONCE()
bcache: fix use-after-free in register_bcache()
bcache: rework error unwinding in register_bcache
bcache: cached_dev_free needs to put the sb page
btrfs: Fix split-brain handling when changing FSID to metadata uuid
btrfs: separate definition of assertion failure handlers
media: uvcvideo: Add a quirk to force GEO GC6500 Camera bits-per-pixel value
powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV
drm/nouveau/mmu: fix comptag memory leak
sunrpc: Fix potential leaks in sunrpc_cache_unhash()
ALSA: hda - Add docking station support for Lenovo Thinkpad T420s
bpf, btf: Always output invariant hit in pahole DWARF to BTF transform
driver core: platform: fix u32 greater or equal to zero comparison
s390/ftrace: generate traced function stack frame
s390: adjust -mpacked-stack support check for clang 10
x86/decoder: Add TEST opcode to Group3-2
objtool: Fix ARCH=x86_64 build error
kbuild: use -S instead of -E for precise cc-option test in Kconfig
spi: spi-fsl-qspi: Ensure width is respected in spi-mem operations
ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()
irqchip/mbigen: Set driver .suppress_bind_attrs to avoid remove problems
regulator: core: Fix exported symbols to the exported GPL version
remoteproc: Initialize rproc_class before use
module: avoid setting info->name early in case we can fall back to info->mod->name
btrfs: device stats, log when stats are zeroed
btrfs: safely advance counter when looking up bio csums
btrfs: fix possible NULL-pointer dereference in integrity checks
pwm: Remove set but not set variable 'pwm'
ide: serverworks: potential overflow in svwks_set_pio_mode()
cmd64x: potential buffer overflow in cmd64x_program_timings()
pwm: omap-dmtimer: Remove PWM chip in .remove before making it unfunctional
x86/mm: Fix NX bit clearing issue in kernel_map_pages_in_pgd
f2fs: fix memleak of kobject
regulator: vctrl-regulator: Avoid deadlock getting and setting the voltage
ASoC: SOF: Intel: hda: Fix SKL dai count
debugobjects: Fix various data races
watchdog/softlockup: Enforce that timestamp is valid on boot
perf/x86/amd: Constrain Large Increment per Cycle events
sched/topology: Assert non-NUMA topology masks don't (partially) overlap
sched/core: Fix size of rq::uclamp initialization
arm64: dts: ti: k3-j721e-main: Add missing power-domains for smmu
KVM: PPC: Remove set but not used variable 'ra', 'rs', 'rt'
EDAC/sifive: Fix return value check in ecc_register()
drm/amd/display: fixup DML dependencies
arm64: fix alternatives with LLVM's integrated assembler
arm64: lse: fix LSE atomics with LLVM's integrated assembler
RDMA/mlx5: Don't fake udata for kernel path
ALSA: usb-audio: add implicit fb quirk for MOTU M Series
crypto: essiv - fix AEAD capitalization and preposition use in help text
scsi: iscsi: Don't destroy session if there are outstanding connections
scsi: ufs-mediatek: add apply_dev_quirks variant operation
scsi: ufs: pass device information to apply_dev_quirks
f2fs: free sysfs kobject
f2fs: set I_LINKABLE early to avoid wrong access by vfs
ALSA: usb-audio: unlock on error in probe
iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE
kbuild: remove *.tmp file when filechk fails
usb: musb: omap2430: Get rid of musb .set_vbus for omap2430 glue
perf/imx_ddr: Fix cpu hotplug state cleanup
drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
gpiolib: Set lockdep class for hierarchical irq domains
dm thin: don't allow changing data device during thin-pool reload
drm/nouveau/fault/gv100-: fix memory leak on module unload
drm/nouveau/drm/ttm: Remove set but not used variable 'mem'
drm/nouveau: Fix copy-paste error in nouveau_fence_wait_uevent_handler
drm/nouveau/gr/gk20a,gm200-: add terminators to method lists read from fw
drm/nouveau/secboot/gm20b: initialize pointer in gm20b_secboot_new()
vme: bridges: reduce stack usage
bpf: Return -EBADRQC for invalid map type in __bpf_tx_xdp_map
ASoC: SOF: Intel: hda-dai: fix compilation warning in pcm_prepare
driver core: Print device when resources present in really_probe()
driver core: platform: Prevent resouce overflow from causing infinite loops
visorbus: fix uninitialized variable access
misc: xilinx_sdfec: fix xsdfec_poll()'s return type
tty: synclink_gt: Adjust indentation in several functions
tty: synclinkmp: Adjust indentation in several functions
raid6/test: fix a compilation warning
ASoC: atmel: fix build error with CONFIG_SND_ATMEL_SOC_DMA=m
ALSA: usb-audio: Add boot quirk for MOTU M Series
ARM: dts: rockchip: add reg property to brcmf sub node for rk3188-bqedison2qc
arm64: dts: rockchip: add reg property to brcmf sub-nodes
arm64: dts: rockchip: fix dwmmc clock name for px30
clocksource: davinci: only enable clockevents once tim34 is initialized
wan: ixp4xx_hss: fix compile-testing on 64-bit
x86/nmi: Remove irq_work from the long duration NMI handler
bnxt: Detach page from page pool before sending up the stack
Input: edt-ft5x06 - work around first register access error
rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls
efi/x86: Don't panic or BUG() on non-critical error conditions
soc/tegra: fuse: Correct straps' address for older Tegra124 device trees
IB/hfi1: Add RcvShortLengthErrCnt to hfi1stats
IB/hfi1: Add software counter for ctxt0 seq drop
staging: rtl8188: avoid excessive stack usage
drm/mediatek: Add gamma property according to hardware capability
udf: Fix free space reporting for metadata and virtual partitions
usbip: Fix unsafe unaligned pointer usage
ARM: dts: stm32: Add power-supply for DSI panel on stm32f469-disco
usb: dwc3: use proper initializers for property entries
drm: remove the newline for CRC source name.
RDMA/hns: Avoid printing address of mtt page
mlx5: work around high stack usage with gcc
drm/amdkfd: Fix permissions of hang_hws
iommu/vt-d: Avoid sending invalid page response
iommu/vt-d: Match CPU and IOMMU paging mode
ACPI: button: Add DMI quirk for Razer Blade Stealth 13 late 2019 lid switch
ASoC: Intel: sof_rt5682: Ignore the speaker amp when there isn't one.
vfio/spapr/nvlink2: Skip unpinning pages on error exit
tools lib api fs: Fix gcc9 stringop-truncation compilation error
net: phy: fixed_phy: fix use-after-free when checking link GPIO
ALSA: sh: Fix compile warning wrt const
ALSA: hda/realtek - Apply mic mute LED quirk for Dell E7xx laptops, too
clk: uniphier: Add SCSSI clock gate for each channel
clk: Use parent node pointer during registration if necessary
ALSA: sh: Fix unused variable warnings
clk: sunxi-ng: add mux and pll notifiers for A64 CPU clock
RDMA/rxe: Fix error type of mmap_offset
fbdev: fix numbering of fbcon options
ASoC: soc-topology: fix endianness issues
reset: uniphier: Add SCSSI reset control for each channel
pinctrl: sh-pfc: sh7269: Fix CAN function GPIOs
drm/fbdev: Fallback to non tiled mode if all tiles not present
PM / devfreq: rk3399_dmc: Add COMPILE_TEST and HAVE_ARM_SMCCC dependency
PM / devfreq: exynos-ppmu: Fix excessive stack usage
x86/vdso: Provide missing include file
crypto: chtls - Fixed memory leak
net: phy: realtek: add logging for the RGMII TX delay configuration
bpf: Print error message for bpftool cgroup show
dmaengine: imx-sdma: Fix memory leak
dmaengine: Store module owner in dma_device struct
clk: actually call the clock init before any other callback of the clock
iommu/iova: Silence warnings under memory pressure
iommu/amd: Only support x2APIC with IVHD type 11h/40h
iommu/amd: Check feature support bit before accessing MSI capability registers
arm64: dts: qcom: db845c: Enable ath10k 8bit host-cap quirk
scsi: lpfc: Fix: Rework setting of fdmi symbolic node name registration
selinux: ensure we cleanup the internal AVC counters on error in avc_update()
ARM: dts: r8a7779: Add device node for ARM global timer
clk: renesas: rcar-gen3: Allow changing the RPC[D2] clocks
drm/mediatek: handle events when enabling/disabling crtc
crypto: inside-secure - add unspecified HAS_IOMEM dependency
scsi: aic7xxx: Adjust indentation in ahc_find_syncrate
scsi: ufs: Complete pending requests in host reset and restore path
nfsd: Clone should commit src file metadata too
ACPICA: Disassembler: create buffer fields in ACPI_PARSE_LOAD_PASS1
clk: qcom: smd: Add missing bimc clock
drm/amdgpu: fix KIQ ring test fail in TDR of SRIOV
orinoco: avoid assertion in case of NULL pointer
rtlwifi: rtl_pci: Fix -Wcast-function-type
iwlegacy: Fix -Wcast-function-type
ipw2x00: Fix -Wcast-function-type
b43legacy: Fix -Wcast-function-type
PCI: Add DMA alias quirk for PLX PEX NTB
PCI: Add nr_devfns parameter to pci_add_dma_alias()
ALSA: usx2y: Adjust indentation in snd_usX2Y_hwdep_dsp_status
netfilter: nft_tunnel: add the missing ERSPAN_VERSION nla_policy
fore200e: Fix incorrect checks of NULL pointer dereference
r8169: check that Realtek PHY driver module is loaded
samples/bpf: Set -fno-stack-protector when building BPF programs
reiserfs: Fix spurious unlock in reiserfs_fill_super() error handling
media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros
selftests/net: make so_txtime more robust to timer variance
gpu/drm: ingenic: Avoid null pointer deference in plane atomic update
Revert "nfp: abm: fix memory leak in nfp_abm_u32_knode_replace"
PCI: Increase D3 delay for AMD Ryzen5/7 XHCI controllers
PCI: Add generic quirk for increasing D3hot delay
media: cx23885: Add support for AVerMedia CE310B
PCI: iproc: Apply quirk_paxc_bridge() for module as well as built-in
bus: ti-sysc: Implement quirk handling for CLKDM_NOAUTO
ARM: dts: imx6: rdu2: Limit USBH1 to Full Speed
ARM: dts: imx6: rdu2: Disable WP for USDHC2 and USDHC3
ARM: exynos_defconfig: Bring back explicitly wanted options
clk: imx: Add correct failure handling for clk based helpers
padata: validate cpumask without removed CPU during offline
arm64: dts: qcom: msm8996: Disable USB2 PHY suspend by core
selinux: ensure we cleanup the internal AVC counters on error in avc_insert()
opp: Free static OPPs on errors while adding them
arm: dts: allwinner: H3: Add PMU node
arm64: dts: allwinner: H5: Add PMU node
arm64: dts: allwinner: H6: Add PMU mode
NFC: port100: Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu().
net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
regulator: rk808: Lower log level on optional GPIOs being not available
ASoC: intel: sof_rt5682: Add support for tgl-max98357a-rt5682
ASoC: intel: sof_rt5682: Add quirk for number of HDMI DAI's
modules: lockdep: Suppress suspicious RCU usage warning
arm64: dts: rockchip: Fix NanoPC-T4 cooling maps
drm/panel: simple: Add Logic PD Type 28 display support
drm/amdgpu: Ensure ret is always initialized when using SOC15_WAIT_ON_RREG
ath10k: correct the tlv len of ath10k_wmi_tlv_op_gen_config_pno_start
drm/amdgpu: remove 4 set but not used variable in amdgpu_atombios_get_connector_info_from_object_table
bpf, sockhash: Synchronize_rcu before free'ing map
drm/amdkfd: Fix a bug in SDMA RLC queue counting under HWS mode
clk: qcom: rcg2: Don't crash if our parent can't be found; return an error
clk: qcom: Don't overwrite 'cfg' in clk_rcg2_dfs_populate_freq()
kconfig: fix broken dependency in randconfig-generated .config
block, bfq: do not plug I/O for bfq_queues with no proc refs
drivers/block/zram/zram_drv.c: fix error return codes not being returned in writeback_store
Btrfs: keep pages dirty when using btrfs_writepage_fixup_worker
KVM: s390: ENOTSUPP -> EOPNOTSUPP fixups
nbd: add a flush_workqueue in nbd_start_device
tracing: Simplify assignment parsing for hist triggers
drm/amd/display: Retrain dongles when SINK_COUNT becomes non-zero
rtc: i2c/spi: Avoid inclusion of REGMAP support when not needed
selftests: settings: tests can be in subsubdirs
brcmfmac: sdio: Fix OOB interrupt initialization on brcm43362
rtw88: fix rate mask for 1SS chip
ath10k: Correct the DMA direction for management tx buffers
ext4, jbd2: ensure panic when aborting with zero errno
ARM: 8952/1: Disable kmemleak on XIP kernels
tracing: Fix very unlikely race of registering two stat tracers
tracing: Fix tracing_stat return values in error handling paths
powerpc/iov: Move VF pdev fixup into pcibios_fixup_iov()
s390/pci: Fix possible deadlock in recover_store()
wan/hdlc_x25: fix skb handling
dmaengine: fsl-qdma: fix duplicated argument to &&
udf: Allow writing to 'Rewritable' partitions
pwm: omap-dmtimer: Simplify error handling
x86/sysfb: Fix check for bad VRAM size
clk: ti: dra7: fix parent for gmac_clkctrl
ext4: fix deadlock allocating bio_post_read_ctx from mempool
jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal
kselftest: Minimise dependency of get_size on C library interfaces
drm/amd/display: Clear state after exiting fixed active VRR state
clocksource/drivers/bcm2835_timer: Fix memory leak of timer
usb: dwc2: Fix IN FIFO allocation
usb: gadget: udc: fix possible sleep-in-atomic-context bugs in gr_probe()
drm/nouveau/nouveau: fix incorrect sizeof on args.src an args.dst
spi: fsl-lpspi: fix only one cs-gpio working
drm/amdgpu/sriov: workaround on rev_id for Navi12 under sriov
uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()
raid6/test: fix a compilation error
net: ethernet: ixp4xx: Standard module init
sparc: Add .exit.data section.
MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
efi/x86: Map the entire EFI vendor string before copying it
pinctrl: baytrail: Do not clear IRQ flags on direct-irq enabled pins
IB/core: Let IB core distribute cache update events
kernel/module: Fix memleak in module_add_modinfo_attrs()
media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run()
char/random: silence a lockdep splat with printk()
x86/fpu: Deactivate FPU state after failure during state load
iommu/vt-d: Fix off-by-one in PASID allocation
gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_irq_map/unmap()
clk: meson: meson8b: make the CCF use the glitch-free mali mux
powerpc/powernv/iov: Ensure the pdn for VFs always contains a valid PE number
clk: at91: sam9x60: fix programmable clock prescaler
media: sun4i-csi: Fix [HV]sync polarity handling
media: sun4i-csi: Fix data sampling polarity handling
media: sun4i-csi: Deal with DRAM offset
media: i2c: mt9v032: fix enum mbus codes and frame sizes
media: ov5640: Fix check for PLL1 exceeding max allowed rate
pxa168fb: Fix the function used to release some memory in an error handling path
drm/msm/adreno: fix zap vs no-zap handling
drm/mipi_dbi: Fix off-by-one bugs in mipi_dbi_blank()
printk: fix exclusive_console replaying
pinctrl: sh-pfc: sh7264: Fix CAN function GPIOs
gianfar: Fix TX timestamping with a stacked DSA driver
ALSA: ctl: allow TLV read operation for callback type of element in locked case
ext4: fix ext4_dax_read/write inode locking sequence for IOCB_NOWAIT
leds: pca963x: Fix open-drain initialization
drm/amd/display: Map ODM memory correctly when doing ODM combine
PCI: Fix pci_add_dma_alias() bitmask size
brcmfmac: Fix use after free in brcmf_sdio_readframes()
brcmfmac: Fix memory leak in brcmf_p2p_create_p2pdev()
cpu/hotplug, stop_machine: Fix stop_machine vs hotplug order
clk: meson: pll: Fix by 0 division in __pll_params_to_rate()
media: meson: add missing allocation failure check on new_buf
f2fs: call f2fs_balance_fs outside of locked page
f2fs: preallocate DIO blocks when forcing buffered_io
rcu: Fix data-race due to atomic_t copy-by-value
rcu: Fix missed wakeup of exp_wq waiters
rcu/nocb: Fix dump_tree hierarchy print always active
drm/qxl: Complete exception handling in qxl_device_init()
wil6210: fix break that is never reached because of zero'ing of a retry counter
ath10k: Fix qmi init error handling
drm/gma500: Fixup fbdev stolen size usage evaluation
net/sched: flower: add missing validation of TCA_FLOWER_FLAGS
net/sched: matchall: add missing validation of TCA_MATCHALL_FLAGS
net: dsa: tag_qca: Make sure there is headroom for tag
net/smc: fix leak of kernel memory to user space
enic: prevent waking up stopped tx queues over watchdog reset
core: Don't skip generic XDP program execution for cloned SKBs
ANDROID: ufs, block: fix crypto power management and move into block layer
ANDROID: rtc: class: support hctosys from modular RTC drivers
ANDROID: update the abi after clk changes
ANDROID: update abi for f2fs/fscrypt merge
ANDROID: Kconfig.gki: Remove most of the built in qcom clks
FROMLIST: f2fs: Handle casefolding with Encryption
FROMLIST: fscrypt: Have filesystems handle their d_ops
FROMLIST: ext4: Use generic casefolding support
FROMLIST: f2fs: Use generic casefolding support
FROMLIST: Add standard casefolding support
FROMLIST: unicode: Add utf8_casefold_hash
ANDROID: gki: Set CONFIG_SERIAL_SAMSUNG for early con.
UPSTREAM: tty: serial: samsung_tty: remove SERIAL_SAMSUNG_DEBUG
UPSTREAM: tty: serial: samsung_tty: build it for any platform
UPSTREAM: tty: serial: samsung_tty: do not abuse the struct uart_port unused fields
UPSTREAM: tty: serial: samsung_tty: fix blank line checkpatch warning
UPSTREAM: tty: serial: samsung_tty: fix up minor comment formatting
UPSTREAM: tty: serial: samsung_tty: use 'unsigned int' not 'unsigned'
UPSTREAM: tty: serial: samsung_tty: use standard debugging macros
UPSTREAM: tty: serial: samsung_tty: drop unneded dbg() calls
UPSTREAM: tty: serial: samsung_tty: delete samsung.h
UPSTREAM: tty: serial: samsung.h: remove reset_port callback from struct s3c24xx_uart_info
UPSTREAM: tty: serial: samsung.h: fix up minor comment issues
UPSTREAM: tty: serial: samsung_tty: fix build warning
UPSTREAM: tty: serial: samsung: allow driver to be built by anyone
UPSTREAM: tty: serial: samsung: remove variable 'ufstat' set but not used
UPSTREAM: {tty: serial, nand: onenand}: samsung: rename to fix build warning
UPSTREAM: random: ignore GRND_RANDOM in getentropy(2)
UPSTREAM: random: add GRND_INSECURE to return best-effort non-cryptographic bytes
UPSTREAM: linux/random.h: Mark CONFIG_ARCH_RANDOM functions __must_check
UPSTREAM: linux/random.h: Use false with bool
UPSTREAM: linux/random.h: Remove arch_has_random, arch_has_random_seed
UPSTREAM: random: remove some dead code of poolinfo
UPSTREAM: random: fix typo in add_timer_randomness()
UPSTREAM: random: Add and use pr_fmt()
UPSTREAM: random: convert to ENTROPY_BITS for better code readability
UPSTREAM: random: remove unnecessary unlikely()
UPSTREAM: random: remove kernel.random.read_wakeup_threshold
UPSTREAM: random: delete code to pull data into pools
UPSTREAM: random: remove the blocking pool
UPSTREAM: random: make /dev/random be almost like /dev/urandom
UPSTREAM: random: Add a urandom_read_nowait() for random APIs that don't warn
UPSTREAM: random: Don't wake crng_init_wait when crng_init == 1
UPSTREAM: char/random: silence a lockdep splat with printk()
ANDROID: Incremental fs: Support xattrs
BACKPORT: sched/fair: Remove wake_cap()
UPSTREAM: sched/core: Remove for_each_lower_domain()
UPSTREAM: sched/topology: Remove SD_BALANCE_WAKE on asymmetric capacity systems
UPSTREAM: sched/fair: Add asymmetric CPU capacity wakeup scan
ANDROID: ufs: add quirk to fix abnormal ocs fatal error
FROMLIST: ufs: fix a bug on printing PRDT
ANDROID: update abi for 5.4.21
ANDROID: clang: update to 10.0.4
Linux 5.4.21
mmc: core: Rework wp-gpio handling
gpio: add gpiod_toggle_active_low()
KVM: x86/mmu: Fix struct guest_walker arrays for 5-level paging
ext4: choose hardlimit when softlimit is larger than hardlimit in ext4_statfs_project()
jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer
jbd2: move the clearing of b_modified flag to the journal_unmap_buffer()
Revert "drm/sun4i: drv: Allow framebuffer modifiers in mode config"
NFSv4.1 make cachethis=no for writes
perf stat: Don't report a null stalled cycles per insn metric
KVM: x86: Mask off reserved bit from #DB exception payload
arm64: dts: fast models: Fix FVP PCI interrupt-map property
cifs: fix mount option display for sec=krb5i
mac80211: fix quiet mode activation in action frames
hwmon: (pmbus/ltc2978) Fix PMBus polling of MFR_COMMON definitions.
perf/x86/intel: Fix inaccurate period in context switch for auto-reload
spmi: pmic-arb: Set lockdep class for hierarchical irq domains
sched/uclamp: Reject negative values in cpu_uclamp_write()
s390/time: Fix clk type in get_tod_clock
RDMA/core: Fix protection fault in get_pkey_idx_qp_list
RDMA/rxe: Fix soft lockup problem due to using tasklets in softirq
RDMA/hfi1: Fix memory leak in _dev_comp_vect_mappings_create
RDMA/iw_cxgb4: initiate CLOSE when entering TERM
RDMA/core: Fix invalid memory access in spec_filter_size
IB/umad: Fix kernel crash while unloading ib_umad
IB/rdmavt: Reset all QPs when the device is shut down
IB/hfi1: Close window for pq and request coliding
IB/hfi1: Acquire lock to release TID entries when user file is closed
IB/mlx5: Return failure when rts2rts_qp_counters_set_id is not supported
drivers: ipmi: fix off-by-one bounds check that leads to a out-of-bounds write
nvme: fix the parameter order for nvme_get_log in nvme_get_fw_slot_info
bus: moxtet: fix potential stack buffer overflow
drm/panfrost: Make sure the shrinker does not reclaim referenced BOs
drm/vgem: Close use-after-free race in vgem_gem_create
s390/uv: Fix handling of length extensions
s390/pkey: fix missing length of protected key on return
perf/x86/amd: Add missing L2 misses event spec to AMD Family 17h's event map
KVM: nVMX: Use correct root level for nested EPT shadow page tables
EDAC/mc: Fix use-after-free and memleaks during device removal
EDAC/sysfs: Remove csrow objects on errors
cifs: make sure we do not overflow the max EA buffer size
xprtrdma: Fix DMA scatter-gather list mapping imbalance
arm64: ssbs: Fix context-switch when SSBS is present on all CPUs
gpio: xilinx: Fix bug where the wrong GPIO register is written to
ARM: npcm: Bring back GPIOLIB support
btrfs: log message when rw remount is attempted with unclean tree-log
btrfs: print message when tree-log replay starts
btrfs: ref-verify: fix memory leaks
Btrfs: fix race between using extent maps and merging them
ext4: improve explanation of a mount failure caused by a misconfigured kernel
ext4: add cond_resched() to ext4_protect_reserved_inode
ext4: fix checksum errors with indexed dirs
ext4: fix support for inode sizes > 1024 bytes
ext4: don't assume that mmp_nodename/bdevname have NUL
ALSA: usb-audio: Add clock validity quirk for Denon MC7000/MCX8000
ALSA: usb-audio: sound: usb: usb true/false for bool return type
ACPI: PM: s2idle: Prevent spurious SCIs from waking up the system
ACPICA: Introduce acpi_any_gpe_status_set()
ACPI: PM: s2idle: Avoid possible race related to the EC GPE
ACPI: EC: Fix flushing of pending work
ALSA: usb-audio: Apply sample rate quirk for Audioengine D1
ALSA: hda/realtek - Fix silent output on MSI-GL73
ALSA: hda/realtek - Add more codec supported Headset Button
ALSA: usb-audio: Fix UAC2/3 effect unit parsing
Input: synaptics - remove the LEN0049 dmi id from topbuttonpad list
Input: synaptics - enable SMBus on ThinkPad L470
Input: synaptics - switch T470s to RMI4 by default
ANDROID: ABI/Whitelist: initial unisoc whitelist
ANDROID: Fix ABI representation after enabling CONFIG_NET_NS
ANDROID: gki_defconfig: Enable CONFIG_NET_NS
ANDROID: gki_defconfig: Enable XDP_SOCKETS
ANDROID: gki_defconfig: Enable MAC80211_RC_MINSTREL
ANDROID: virtio: virtio_input: pass _DIRECT only if the device advertises _DIRECT
ANDROID: staging: ion: delete unused heap types and IDs
ANDROID: gki_defconfig: disable system_contig ion heap.
ANDROID: cf build: Use merge_configs
ANDROID: net: bpf: Allow TC programs to call BPF_FUNC_skb_change_head
ANDROID: gki_defconfig: Disable SDCARD_FS
Linux 5.4.20
selinux: fall back to ref-walk if audit is required
libertas: make lbs_ibss_join_existing() return error code on rates overflow
libertas: don't exit from lbs_ibss_join_existing() with RCU read lock held
mwifiex: Fix possible buffer overflows in mwifiex_cmd_append_vsie_tlv()
mwifiex: Fix possible buffer overflows in mwifiex_ret_wmm_get_status()
dmaengine: axi-dmac: add a check for devm_regmap_init_mmio
clk: meson: g12a: fix missing uart2 in regmap table
mfd: max77650: Select REGMAP_IRQ in Kconfig
regmap: fix writes to non incrementing registers
pinctrl: sh-pfc: r8a7778: Fix duplicate SDSELF_B and SD1_CLK_B
pinctrl: sh-pfc: r8a77965: Fix DU_DOTCLKIN3 drive/bias control
selinux: fix regression introduced by move_mount(2) syscall
selinux: revert "stop passing MAY_NOT_BLOCK to the AVC upon follow_link"
bcache: avoid unnecessary btree nodes flushing in btree_flush_write()
dt-bindings: iio: adc: ad7606: Fix wrong maxItems value
media: i2c: adv748x: Fix unsafe macros
drivers: watchdog: stm32_iwdg: set WDOG_HW_RUNNING at probe
crypto: caam/qi2 - fix typo in algorithm's driver name
crypto: atmel-sha - fix error handling when setting hmac key
crypto: artpec6 - return correct error code for failed setkey()
crypto: testmgr - don't try to decrypt uninitialized buffers
mtd: sharpslpart: Fix unsigned comparison to zero
mtd: onenand_base: Adjust indentation in onenand_read_ops_nolock
arm64: nofpsmid: Handle TIF_FOREIGN_FPSTATE flag cleanly
KVM: arm64: Treat emulated TVAL TimerValue as a signed 32-bit integer
KVM: arm64: pmu: Fix chained SW_INCR counters
KVM: arm64: pmu: Don't increment SW_INCR if PMCR.E is unset
KVM: arm: Make inject_abt32() inject an external abort instead
KVM: arm: Fix DFSR setting for non-LPAE aarch32 guests
KVM: arm/arm64: Fix young bit from mmu notifier
arm64: ptrace: nofpsimd: Fail FP/SIMD regset operations
arm64: cpufeature: Set the FP/SIMD compat HWCAP bits properly
arm64: cpufeature: Fix the type of no FP/SIMD capability
sched/uclamp: Fix a bug in propagating uclamp value in new cgroups
ARM: 8949/1: mm: mark free_memmap as __init
KVM: arm/arm64: vgic-its: Fix restoration of unmapped collections
ARM: at91: pm: use of_device_id array to find the proper shdwc node
ARM: at91: pm: use SAM9X60 PMC's compatible
iommu/arm-smmu-v3: Populate VMID field for CMDQ_OP_TLBI_NH_VA
powerpc/pseries: Allow not having ibm, hypertas-functions::hcall-multi-tce for DDW
powerpc/pseries/vio: Fix iommu_table use-after-free refcount warning
powerpc/papr_scm: Fix leaking 'bus_desc.provider_name' in some paths
powerpc/ptdump: Only enable PPC_CHECK_WX with STRICT_KERNEL_RWX
powerpc/ptdump: Fix W+X verification call in mark_rodata_ro()
Revert "powerpc/pseries/iommu: Don't use dma_iommu_ops on secure guests"
soc: qcom: rpmhpd: Set 'active_only' for active only power domains
tools/power/acpi: fix compilation error
ARM: dts: at91: sama5d3: define clock rate range for tcb1
ARM: dts: at91: sama5d3: fix maximum peripheral clock rates
ARM: dts: meson8b: use the actual frequency for the GPU's 364MHz OPP
ARM: dts: meson8: use the actual frequency for the GPU's 182.1MHz OPP
arm64: dts: marvell: clearfog-gt-8k: fix switch cpu port node
arm64: dts: renesas: r8a77990: ebisu: Remove clkout-lr-synchronous from sound
ARM: dts: am43xx: add support for clkout1 clock
ARM: dts: at91: Reenable UART TX pull-ups
arm64: dts: uDPU: fix broken ethernet
arm64: dts: qcom: msm8998: Fix tcsr syscon size
platform/x86: intel_mid_powerbtn: Take a copy of ddata
ARC: [plat-axs10x]: Add missing multicast filter number to GMAC node
watchdog: qcom: Use platform_get_irq_optional() for bark irq
rtc: cmos: Stop using shared IRQ
rtc: hym8563: Return -EINVAL if the time is known to be invalid
x86/boot: Handle malformed SRAT tables during early ACPI parsing
NFSv4.0: nfs4_do_fsinfo() should not do implicit lease renewals
NFSv4: try lease recovery on NFS4ERR_EXPIRED
NFSv4: pnfs_roc() must use cred_fscmp() to compare creds
NFS: Fix fix of show_nfs_errors
NFS/pnfs: Fix pnfs_generic_prepare_to_resend_writes()
NFS: Revalidate the file size on a fatal write error
nfs: NFS_SWAP should depend on SWAP
bpf, sockmap: Check update requirements after locking
bpf: Improve bucket_log calculation logic
selftests/bpf: Test freeing sockmap/sockhash with a socket in it
bpf, sockhash: Synchronize_rcu before free'ing map
bpf, sockmap: Don't sleep while holding RCU lock on tear-down
bpftool: Don't crash on missing xlated program instructions
iwlwifi: mvm: avoid use after free for pmsr request
PCI/AER: Initialize aer_fifo
PCI: Don't disable bridge BARs when assigning bus resources
PCI: tegra: Fix afi_pex2_ctrl reg offset for Tegra30
PCI/switchtec: Fix vep_vector_number ioread width
PCI/switchtec: Use dma_set_mask_and_coherent()
ath10k: pci: Only dump ATH10K_MEM_REGION_TYPE_IOREG when safe
PCI/IOV: Fix memory leak in pci_iov_add_virtfn()
scsi: ufs: Fix ufshcd_probe_hba() reture value in case ufshcd_scsi_add_wlus() fails
RDMA/umem: Fix ib_umem_find_best_pgsz()
RDMA/cma: Fix unbalanced cm_id reference count during address resolve
RDMA/uverbs: Verify MR access flags
RDMA/core: Fix locking in ib_uverbs_event_read
RDMA/i40iw: fix a potential NULL pointer dereference
RDMA/netlink: Do not always generate an ACK for some netlink operations
IB/mlx4: Fix leak in id_map_find_del
IB/srp: Never use immediate data if it is disabled by a user
IB/mlx4: Fix memory leak in add_gid error flow
hv_sock: Remove the accept port restriction
ASoC: pcm: update FE/BE trigger order based on the command
ANDROID: gki_defconfig: Add CONFIG_UNICODE
ANDROID: added memory initialization tests to cuttlefish config
ANDROID: gki_defconfig: enable CONFIG_RUNTIME_TESTING_MENU
fs-verity: use u64_to_user_ptr()
fs-verity: use mempool for hash requests
fs-verity: implement readahead of Merkle tree pages
fs-verity: implement readahead for FS_IOC_ENABLE_VERITY
fscrypt: improve format of no-key names
ubifs: allow both hash and disk name to be provided in no-key names
ubifs: don't trigger assertion on invalid no-key filename
fscrypt: clarify what is meant by a per-file key
fscrypt: derive dirhash key for casefolded directories
fscrypt: don't allow v1 policies with casefolding
fscrypt: add "fscrypt_" prefix to fname_encrypt()
fscrypt: don't print name of busy file when removing key
ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()
fscrypt: document gfp_flags for bounce page allocation
fscrypt: optimize fscrypt_zeroout_range()
fscrypt: remove redundant bi_status check
fscrypt: Allow modular crypto algorithms
FROMLIST: rename missed uaccess .fixup section
ANDROID: gki_defconfig: enable heap and stack initialization.
ANDROID: ABI/Whitelist: update for db845c
ANDROID: ABI/Whitelist: update for Cuttlefish
ANDROID: update ABI representation and GKI whitelist
ANDROID: f2fs: fix missing blk-crypto changes
fscrypt: include <linux/ioctl.h> in UAPI header
fscrypt: don't check for ENOKEY from fscrypt_get_encryption_info()
fscrypt: remove fscrypt_is_direct_key_policy()
fscrypt: move fscrypt_valid_enc_modes() to policy.c
fscrypt: check for appropriate use of DIRECT_KEY flag earlier
fscrypt: split up fscrypt_supported_policy() by policy version
fscrypt: introduce fscrypt_needs_contents_encryption()
fscrypt: move fscrypt_d_revalidate() to fname.c
fscrypt: constify inode parameter to filename encryption functions
fscrypt: constify struct fscrypt_hkdf parameter to fscrypt_hkdf_expand()
fscrypt: verify that the crypto_skcipher has the correct ivsize
fscrypt: use crypto_skcipher_driver_name()
fscrypt: support passing a keyring key to FS_IOC_ADD_ENCRYPTION_KEY
UPSTREAM: dynamic_debug: allow to work if debugfs is disabled
UPSTREAM: serial: sprd: Add polling IO support
UPSTREAM: dmaengine: sprd: Add wrap address support for link-list mode
UPSTREAM: pinctrl: sprd: Add CM4 sleep mode support
UPSTREAM: pinctrl: sprd: Add PIN_CONFIG_BIAS_DISABLE configuration support
UPSTREAM: spi: sprd: adi: Set BIT_WDG_NEW bit when rebooting
UPSTREAM: nvmem: sprd: Add Spreadtrum SoCs eFuse support
UPSTREAM: dt-bindings: nvmem: Add Spreadtrum eFuse controller documentation
UPSTREAM: scsi: ufs-mediatek: enable low-power mode for hibern8 state
BACKPORT: scsi: ufs: export some functions for vendor usage
UPSTREAM: scsi: ufs-mediatek: add dbg_register_dump implementation
UPSTREAM: scsi: ufs-mediatek: add apply_dev_quirks variant operation
UPSTREAM: scsi: ufs: pass device information to apply_dev_quirks
UPSTREAM: scsi: ufs: add device reset history for vendor implementations
UPSTREAM: scsi: ufs: fix empty check of error history
UPSTREAM: scsi: ufs-mediatek: configure and enable clk-gating
UPSTREAM: scsi: ufs-mediatek: configure customized auto-hibern8 timer
BACKPORT: scsi: ufs: export ufshcd_auto_hibern8_update for vendor usage
UPSTREAM: scsi: ufs-mediatek: introduce reference clock control
UPSTREAM: scsi: ufs-mediatek: add device reset implementation
UPSTREAM: scsi: soc: mediatek: add header for SiP service interface
BACKPORT: scsi: ufs: use ufshcd_vops_dbg_register_dump for vendor specific dumps
BACKPORT: scsi: ufs: unify scsi_block_requests usage
UPSTREAM: scsi: ufs: disable interrupt during clock-gating
UPSTREAM: scsi: ufs: disable irq before disabling clocks
UPSTREAM: scsi: ufs-mediatek: enable auto suspend capability
ANDROID: update ABI for 5.4.19
ANDROID: fix up dummy-cpufreq.c due to api changes
Linux 5.4.19
powerpc/kuap: Fix set direction in allow/prevent_user_access()
regulator fix for "regulator: core: Add regulator_is_equal() helper"
rxrpc: Fix service call disconnection
perf/core: Fix mlock accounting in perf_mmap()
clocksource: Prevent double add_timer_on() for watchdog_timer
x86/apic/msi: Plug non-maskable MSI affinity race
cifs: fail i/o on soft mounts if sessionsetup errors out
KVM: Play nice with read-only memslots when querying host page size
KVM: Use vcpu-specific gva->hva translation when querying host page size
KVM: nVMX: vmread should not set rflags to specify success in case of #PF
KVM: x86: fix overlap between SPTE_MMIO_MASK and generation
KVM: x86: Use gpa_t for cr2/gpa to fix TDP support on 32-bit KVM
KVM: x86: use CPUID to locate host page table reserved bits
KVM: x86/mmu: Apply max PA check for MMIO sptes to 32-bit KVM
drm/dp_mst: Remove VCPI while disabling topology mgr
btrfs: free block groups after free'ing fs trees
btrfs: use bool argument in free_root_pointers()
x86/timer: Don't skip PIT setup when APIC is disabled or in legacy mode
mfd: bd70528: Fix hour register mask
mfd: rn5t618: Mark ADC control register volatile
mfd: da9062: Fix watchdog compatible string
ASoC: Intel: skl_hda_dsp_common: Fix global-out-of-bounds bug
net/mlx5: Deprecate usage of generic TLS HW capability bit
net/mlx5: Fix deadlock in fs_core
drop_monitor: Do not cancel uninitialized work item
qed: Fix timestamping issue for L2 unicast ptp packets.
ipv6/addrconf: fix potential NULL deref in inet6_set_link_af()
taprio: Fix dropping packets when using taprio + ETF offloading
taprio: Use taprio_reset_tc() to reset Traffic Classes configuration
taprio: Add missing policy validation for flags
taprio: Fix still allowing changing the flags during runtime
taprio: Fix enabling offload with wrong number of traffic classes
net: macb: Limit maximum GEM TX length in TSO
net: macb: Remove unnecessary alignment check for TSO
net/mlx5: IPsec, fix memory leak at mlx5_fpga_ipsec_delete_sa_ctx
net/mlx5: IPsec, Fix esp modify function attribute
net: systemport: Avoid RBUF stuck in Wake-on-LAN mode
net: stmmac: fix a possible endless loop
net_sched: fix a resource leak in tcindex_set_parms()
net: mvneta: move rx_dropped and rx_errors in per-cpu stats
net: dsa: microchip: enable module autoprobe
net: dsa: bcm_sf2: Only 7278 supports 2Gb/sec IMP port
net: dsa: b53: Always use dev->vlan_enabled in b53_configure_vlan()
dpaa_eth: support all modes with rate adapting PHYs
devlink: report 0 after hitting end in region read
bonding/alb: properly access headers in bond_alb_xmit()
ASoC: sgtl5000: Fix VDDA and VDDIO comparison
regulator: core: Add regulator_is_equal() helper
ubifs: Fix memory leak from c->sup_node
ubi: Fix an error pointer dereference in error handling code
ubi: fastmap: Fix inverted logic in seen selfcheck
virtio_balloon: Fix memory leaks on errors in virtballoon_probe()
virtio-balloon: Fix memory leak when unloading while hinting is in progress
nfsd: Return the correct number of bytes written to the file
nfsd: fix jiffies/time_t mixup in LRU list
nfsd: fix delay timer on 32-bit architectures
IB/core: Fix ODP get user pages flow
IB/mlx5: Fix outstanding_pi index for GSI qps
net: tulip: Adjust indentation in {dmfe, uli526x}_init_module
net: smc911x: Adjust indentation in smc911x_phy_configure
ppp: Adjust indentation into ppp_async_input
NFC: pn544: Adjust indentation in pn544_hci_check_presence
drm: msm: mdp4: Adjust indentation in mdp4_dsi_encoder_enable
powerpc/44x: Adjust indentation in ibm4xx_denali_fixup_memsize
ext2: Adjust indentation in ext2_fill_super
phy: qualcomm: Adjust indentation in read_poll_timeout
mtd: spi-nor: Split mt25qu512a (n25q512a) entry into two
scsi: ufs: Recheck bkops level if bkops is disabled
scsi: qla4xxx: Adjust indentation in qla4xxx_mem_free
scsi: csiostor: Adjust indentation in csio_device_reset
scsi: qla2xxx: Fix the endianness of the qla82xx_get_fw_size() return type
ASoC: meson: axg-fifo: fix fifo threshold setup
percpu: Separate decrypted varaibles anytime encryption can be enabled
broken ping to ipv6 linklocal addresses on debian buster
fix up iter on short count in fuse_direct_io()
virtio-pci: check name when counting MSI-X vectors
virtio-balloon: initialize all vq callbacks
drm/amd/dm/mst: Ignore payload update failures
clk: tegra: Mark fuse clock as critical
mm/mmu_gather: invalidate TLB correctly on batch allocation failure and flush
arm64: dts: qcom: qcs404-evb: Set vdd_apc regulator in high power mode
mm/page_alloc.c: fix uninitialized memmaps on a partially populated last section
ocfs2: fix oops when writing cloned file
KVM: s390: do not clobber registers during guest reset/store status
KVM: x86: Revert "KVM: X86: Fix fpu state crash in kvm guest"
KVM: x86: Ensure guest's FPU state is loaded when accessing for emulation
KVM: x86: Handle TIF_NEED_FPU_LOAD in kvm_{load,put}_guest_fpu()
KVM: x86: Free wbinvd_dirty_mask if vCPU creation fails
KVM: x86: Don't let userspace set host-reserved cr4 bits
KVM: VMX: Add non-canonical check on writes to RTIT address MSRs
x86/KVM: Clean up host's steal time structure
x86/kvm: Cache gfn to pfn translation
x86/KVM: Make sure KVM_VCPU_FLUSH_TLB flag is not missed
x86/kvm: Introduce kvm_(un)map_gfn()
x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit
kvm/svm: PKU not currently supported
KVM: PPC: Book3S PR: Free shared page if mmu initialization fails
KVM: PPC: Book3S HV: Uninit vCPU if vcore creation fails
KVM: x86: Fix potential put_fpu() w/o load_fpu() on MPX platform
KVM: x86: Protect MSR-based index computations in fixed_msr_to_seg_unit() from Spectre-v1/L1TF attacks
KVM: x86: Protect x86_decode_insn from Spectre-v1/L1TF attacks
KVM: x86: Protect MSR-based index computations from Spectre-v1/L1TF attacks in x86.c
KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks
KVM: x86: Protect MSR-based index computations in pmu.h from Spectre-v1/L1TF attacks
KVM: x86: Protect ioapic_write_indirect() from Spectre-v1/L1TF attacks
KVM: x86: Protect kvm_hv_msr_[get|set]_crash_data() from Spectre-v1/L1TF attacks
KVM: x86: Protect kvm_lapic_reg_write() from Spectre-v1/L1TF attacks
KVM: x86: Protect DR-based index computations from Spectre-v1/L1TF attacks
KVM: x86: Protect pmu_intel.c from Spectre-v1/L1TF attacks
KVM: x86: Refactor prefix decoding to prevent Spectre-v1/L1TF attacks
KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks
aio: prevent potential eventfd recursion on poll
eventfd: track eventfd_signal() recursion depth
bcache: add readahead cache policy options via sysfs interface
watchdog: fix UAF in reboot notifier handling in watchdog core code
xen/balloon: Support xend-based toolstack take two
tools/kvm_stat: Fix kvm_exit filter name
media: rc: ensure lirc is initialized before registering input device
media: iguanair: fix endpoint sanity check
drm/rect: Avoid division by zero
drm: atmel-hlcdc: prefer a lower pixel-clock than requested
drm: atmel-hlcdc: enable clock before configuring timing engine
drm: atmel-hlcdc: use double rate for pixel clock only if supported
gfs2: fix O_SYNC write handling
gfs2: move setting current->backing_dev_info
gfs2: fix gfs2_find_jhead that returns uninitialized jhead with seq 0
sunrpc: expiry_time should be seconds not timeval
mwifiex: fix unbalanced locking in mwifiex_process_country_ie()
iwlwifi: don't throw error when trying to remove IGTK
ARM: tegra: Enable PLLP bypass during Tegra124 LP1
btrfs: Correctly handle empty trees in find_first_clear_extent_bit
btrfs: flush write bio if we loop in extent_write_cache_pages
Btrfs: fix race between adding and putting tree mod seq elements and nodes
btrfs: drop log root for dropped roots
btrfs: set trans->drity in btrfs_commit_transaction
Btrfs: fix infinite loop during fsync after rename operations
Btrfs: make deduplication with range including the last block work
Btrfs: fix missing hole after hole punching and fsync when using NO_HOLES
ext4: fix race conditions in ->d_compare() and ->d_hash()
ext4: fix deadlock allocating crypto bounce page from mempool
jbd2_seq_info_next should increase position index
nfsd: fix filecache lookup
NFS: Directory page cache pages need to be locked when read
NFS: Fix memory leaks and corruption in readdir
scsi: qla2xxx: Fix unbound NVME response length
powerpc/futex: Fix incorrect user access blocking
crypto: picoxcell - adjust the position of tasklet_init and fix missed tasklet_kill
crypto: api - Fix race condition in crypto_spawn_alg
crypto: atmel-aes - Fix counter overflow in CTR mode
crypto: pcrypt - Do not clear MAY_SLEEP flag in original request
crypto: arm64/ghash-neon - bump priority to 150
crypto: ccp - set max RSA modulus size for v3 platform devices as well
crypto: hisilicon - Use the offset fields in sqe to avoid need to split scatterlists
crypto: api - fix unexpectedly getting generic implementation
selftests: bpf: Ignore FIN packets for reuseport tests
selftests: bpf: Use a temporary file in test_sockmap
selftests/bpf: Skip perf hw events test if the setup disabled it
selftests/bpf: Fix test_attach_probe
samples/bpf: Xdp_redirect_cpu fix missing tracepoint attach
samples/bpf: Don't try to remove user's homedir on clean
tc-testing: fix eBPF tests failure on linux fresh clones
libbpf: Fix realloc usage in bpf_core_find_cands
bpf, devmap: Pass lockdep expression to RCU lists
selftests/bpf: Fix perf_buffer test on systems w/ offline CPUs
riscv, bpf: Fix broken BPF tail calls
btrfs: Handle another split brain scenario with metadata uuid feature
btrfs: fix improper setting of scanned for range cyclic write cache pages
crypto: pcrypt - Avoid deadlock by using per-instance padata queues
ftrace: Protect ftrace_graph_hash with ftrace_sync
ftrace: Add comment to why rcu_dereference_sched() is open coded
tracing: Annotate ftrace_graph_notrace_hash pointer with __rcu
tracing: Annotate ftrace_graph_hash pointer with __rcu
ASoC: SOF: core: release resources on errors in probe_continue
ASoC: SOF: Introduce state machine for FW boot
scsi: qla2xxx: Fix stuck login session using prli_pend_timer
dm: fix potential for q->make_request_fn NULL pointer
dm thin metadata: use pool locking at end of dm_pool_metadata_close
dm crypt: fix benbi IV constructor crash if used in authenticated mode
dm crypt: fix GFP flags passed to skcipher_request_alloc()
dm writecache: fix incorrect flush sequence when doing SSD mode commit
dm space map common: fix to ensure new block isn't already in use
dm zoned: support zone sizes smaller than 128MiB
ARM: dma-api: fix max_pfn off-by-one error in __dma_supported()
of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc
cpufreq: Avoid creating excessively large stack frames
PM: core: Fix handling of devices deleted during system-wide resume
f2fs: fix race conditions in ->d_compare() and ->d_hash()
f2fs: fix dcache lookup of !casefolded directories
f2fs: code cleanup for f2fs_statfs_project()
f2fs: fix miscounted block limit in f2fs_statfs_project()
f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project()
ovl: fix lseek overflow on 32bit
ovl: fix wrong WARN_ON() in ovl_cache_update_ino()
power: supply: ltc2941-battery-gauge: fix use-after-free
power: supply: axp20x_ac_power: Fix reporting online status
cpupower: Revert library ABI changes from commit ae2917093f
scsi: qla2xxx: Fix mtcp dump collection failure
scsi: megaraid_sas: Do not initiate OCR if controller is not in ready state
erofs: fix out-of-bound read for shifted uncompressed block
scripts/find-unused-docs: Fix massive false positives
fs: allow deduplication of eof block into the end of the destination file
padata: Remove broken queue flushing
crypto: ccree - fix PM race condition
crypto: ccree - fix FDE descriptor sequence
crypto: ccree - fix pm wrongful error reporting
crypto: ccree - fix AEAD decrypt auth fail
crypto: ccree - fix backlog memory leak
crypto: api - Check spawn->alg under lock in crypto_drop_spawn
nvmem: core: fix memory abort in cleanup path
mfd: axp20x: Mark AXP20X_VBUS_IPSOUT_MGMT as volatile
hv_balloon: Balloon up according to request page number
ASoC: SOF: core: free trace on errors
mmc: sdhci-of-at91: fix memleak on clk_get failure
ubifs: Fix deadlock in concurrent bulk-read and writepage
ubifs: Fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
ubifs: Fix wrong memory allocation
ubifs: don't trigger assertion on invalid no-key filename
fscrypt: don't print name of busy file when removing key
alarmtimer: Unregister wakeup source when module get fails
ACPI / battery: Deal better with neither design nor full capacity not being reported
ACPI / battery: Use design-cap for capacity calculations if full-cap is not available
ACPI / battery: Deal with design or full capacity being reported as -1
ACPI: video: Do not export a non working backlight interface on MSI MS-7721 boards
mmc: spi: Toggle SPI polarity, do not hardcode it
PCI: keystone: Fix error handling when "num-viewport" DT property is not populated
PCI: keystone: Fix link training retries initiation
PCI: keystone: Fix outbound region mapping
PCI: tegra: Fix return value check of pm_runtime_get_sync()
tracing: Fix now invalid var_ref_vals assumption in trace action
powerpc/32s: Fix CPU wake-up from sleep mode
powerpc/32s: Fix bad_kuap_fault()
powerpc/pseries: Advance pfn if section is not present in lmb_is_removable()
powerpc/xmon: don't access ASDR in VMs
powerpc/ptdump: Fix W+X verification
powerpc/mmu_gather: enable RCU_TABLE_FREE even for !SMP case
s390/mm: fix dynamic pagetable upgrade for hugetlbfs
MIPS: boot: fix typo in 'vmlinux.lzma.its' target
MIPS: fix indentation of the 'RELOCS' message
MIPS: syscalls: fix indentation of the 'SYSNR' message
KVM: arm64: Only sign-extend MMIO up to register width
KVM: arm/arm64: Correct AArch32 SPSR on exception entry
KVM: arm/arm64: Correct CPSR on exception entry
KVM: arm64: Correct PSTATE on exception entry
arm64: acpi: fix DAIF manipulation with pNMI
ALSA: hda: Add JasperLake PCI ID and codec vid
ALSA: hda: Add Clevo W65_67SB the power_save blacklist
ALSA: hda: Apply aligned MMIO access only conditionally
platform/x86: intel_scu_ipc: Fix interrupt support
x86/cpu: Update cached HLE state on write to TSX_CTRL_CPUID_CLEAR
irqdomain: Fix a memory leak in irq_domain_push_irq()
lib/test_kasan.c: fix memory leak in kmalloc_oob_krealloc_more()
media: v4l2-rect.h: fix v4l2_rect_map_inside() top/left adjustments
media: v4l2-core: compat: ignore native command codes
media/v4l2-core: set pages dirty upon releasing DMA buffers
mm: move_pages: report the number of non-attempted pages
mm: thp: don't need care deferred split queue in memcg charge move path
mm/memory_hotplug: fix remove_memory() lockdep splat
utimes: Clamp the timestamps in notify_change()
mmc: sdhci-pci: Make function amd_sdhci_reset static
mm/sparse.c: reset section's mem_map when fully deactivated
memcg: fix a crash in wb_workfn when a device disappears
ALSA: dummy: Fix PCM format loop in proc output
ALSA: usb-audio: Annotate endianess in Scarlett gen2 quirk
ALSA: usb-audio: Fix endianess in descriptor validation
usb: gadget: f_ecm: Use atomic_t to track in-flight request
usb: gadget: f_ncm: Use atomic_t to track in-flight request
usb: gadget: legacy: set max_speed to super-speed
usb: gadget: f_fs: set req->num_sgs as 0 for non-sg transfer
objtool: Silence build output
usb: typec: tcpci: mask event interrupts when remove driver
usb: dwc3: gadget: Delay starting transfer
usb: dwc3: gadget: Check END_TRANSFER completion
brcmfmac: Fix memory leak in brcmf_usbdev_qinit
Bluetooth: btusb: Disable runtime suspend on Realtek devices
Bluetooth: btusb: fix memory leak on fw
nvmet: Fix controller use after free
nvmet: Fix error print message at nvmet_install_queue function
rcu: Use READ_ONCE() for ->expmask in rcu_read_unlock_special()
srcu: Apply *_ONCE() to ->srcu_last_gp_end
rcu: Avoid data-race in rcu_gp_fqs_check_wake()
rcu: Use *_ONCE() to protect lockless ->expmask accesses
tracing: Fix sched switch start/stop refcount racy updates
tracing/kprobes: Have uname use __get_str() in print_fmt
ipc/msg.c: consolidate all xxxctl_down() functions
netfilter: ipset: fix suspicious RCU usage in find_set_and_id
mfd: dln2: More sanity checking for endpoints
media: uvcvideo: Avoid cyclic entity chains due to malformed USB descriptors
bnxt_en: Fix logic that disables Bus Master during firmware reset.
netdevsim: fix stack-out-of-bounds in nsim_dev_debugfs_init()
MAINTAINERS: correct entries for ISDN/mISDN section
ionic: fix rxq comp packet type mask
tcp: clear tp->segs_{in|out} in tcp_disconnect()
tcp: clear tp->data_segs{in|out} in tcp_disconnect()
tcp: clear tp->delivered in tcp_disconnect()
tcp: clear tp->total_retrans in tcp_disconnect()
rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect
rxrpc: Fix missing active use pinning of rxrpc_local object
rxrpc: Fix insufficient receive notification generation
rxrpc: Fix use-after-free in rxrpc_put_local()
bnxt_en: Fix TC queue mapping.
net: stmmac: Delete txtimer in suspend()
net_sched: fix an OOB access in cls_tcindex
net: hsr: fix possible NULL deref in hsr_handle_frame()
l2tp: Allow duplicate session creation with UDP
gtp: use __GFP_NOWARN to avoid memalloc warning
cls_rsvp: fix rsvp_policy
bnxt_en: Move devlink_register before registering netdev
sparc32: fix struct ipc64_perm type definition
ANDROID: Revert "ANDROID: gki_defconfig: removed CONFIG_PM_WAKELOCKS"
ANDROID: dm: prevent default-key from being enabled without needed hooks
UPSTREAM: crypto: x86 - Regularize glue function prototypes
ANDROID: gki: x86: Enable PCI_MSI, WATCHDOG, HPET
ANDROID: drm: Add support for DP 1.4 Compliance edid corruption test
ANDROID: drm: Parse Colorimetry data block from EDID
ANDROID: drm: fix HDR static metadata type field numbering
ANDROID: Incremental fs: Make files writeable
UPSTREAM: mfd: syscon: Add arguments support for syscon reference
ANDROID: Incremental fs: Fix crash on failed lookup
UPSTREAM: usb: gadget: f_fs: set req->num_sgs as 0 for non-sg transfer
ANDROID: support GKI image that contains an uncompressed Kernel Image.
ANDROID: update ABI for 5.4.18
Linux 5.4.18
tracing/uprobe: Fix to make trace_uprobe_filter alignment safe
Revert "rsi: fix potential null dereference in rsi_probe()"
ASoC: topology: fix soc_tplg_fe_link_create() - link->dobj initialization order
mm/migrate.c: also overwrite error when it is bigger than zero
perf report: Fix no libunwind compiled warning break s390 issue
dm thin: fix use-after-free in metadata_pre_commit_callback
flow_dissector: Fix to use new variables for port ranges in bpf hook
cpuidle: teo: Avoid using "early hits" incorrectly
btrfs: do not zero f_bavail if we have available space
net: Fix skb->csum update in inet_proto_csum_replace16().
netfilter: nf_tables_offload: fix check the chain offload flag
netfilter: conntrack: sctp: use distinct states for new SCTP connections
l2t_seq_next should increase position index
seq_tab_next() should increase position index
net: fsl/fman: rename IF_MODE_XGMII to IF_MODE_10G
net/fsl: treat fsl,erratum-a011043
powerpc/fsl/dts: add fsl,erratum-a011043
qlcnic: Fix CPU soft lockup while collecting firmware dump
ARM: dts: am43x-epos-evm: set data pin directions for spi0 and spi1
r8152: disable DelayPhyPwrChg
r8152: avoid the MCU to clear the lanwake
r8152: disable test IO for RTL8153B
r8152: Disable PLA MCU clock speed down
r8152: disable U2P3 for RTL8153B
r8152: get default setting of WOL before initializing
tee: optee: Fix compilation issue with nommu
led: max77650: add of_match table
ARM: 8955/1: virt: Relax arch timer version check during early boot
scsi: fnic: do not queue commands during fwreset
Input: max77650-onkey - add of_match table
xfrm: interface: do not confirm neighbor when do pmtu update
xfrm interface: fix packet tx through bpf_redirect()
vti[6]: fix packet tx through bpf_redirect()
ARM: dts: am335x-boneblack-common: fix memory size
Input: evdev - convert kzalloc()/vzalloc() to kvzalloc()
iwlwifi: dbg: force stop the debug monitor HW
iwlwifi: Don't ignore the cap field upon mcc update
iwlwifi: pcie: allocate smaller dev_cmd for TX headers
XArray: Fix xas_pause at ULONG_MAX
riscv: delete temporary files
perf/x86/intel/uncore: Remove PCIe3 unit for SNR
perf/x86/intel/uncore: Add PCI ID of IMC for Xeon E3 V5 Family
wireless: wext: avoid gcc -O3 warning
mac80211: Fix TKIP replay protection immediately after key setup
cfg80211: Fix radar event during another phy CAC
wireless: fix enabling channel 12 for custom regulatory domain
lkdtm/bugs: fix build error in lkdtm_UNSET_SMEP
parisc: Use proper printk format for resource_size_t
qmi_wwan: Add support for Quectel RM500Q
ASoC: sti: fix possible sleep-in-atomic
ASoC: hdac_hda: Fix error in driver removal after failed probe
ASoC: SOF: Intel: fix HDA codec driver probe with multiple controllers
platform/x86: intel_pmc_core: update Comet Lake platform driver
platform/x86: GPD pocket fan: Allow somewhat lower/higher temperature limits
iavf: remove current MAC address filter on VF reset
igb: Fix SGMII SFP module discovery for 100FX/LX.
ixgbe: Fix calculation of queue with VFs and flow director on interface flap
ixgbevf: Remove limit of 10 entries for unicast filter list
i40e: Fix virtchnl_queue_select bitmap validation
s390/zcrypt: move ap device reset from bus to driver code
ASoC: rt5640: Fix NULL dereference on module unload
clk: mmp2: Fix the order of timer mux parents
mac80211: mesh: restrict airtime metric to peered established plinks
clk: sunxi-ng: h6-r: Fix AR100/R_APB2 parent order
clk: sunxi-ng: sun8i-r: Fix divider on APB0 clock
rseq: Unregister rseq for clone CLONE_VM
tools lib traceevent: Fix memory leakage in filter_event
soc: ti: wkup_m3_ipc: Fix race condition with rproc_boot
ARM: dts: beagle-x15-common: Model 5V0 regulator
ARM: dts: am57xx-beagle-x15/am57xx-idk: Remove "gpios" for endpoint dt nodes
ARM: dts: sun8i: a83t: Correct USB3503 GPIOs polarity
arm64: dts: meson-sm1-sei610: add gpio bluetooth interrupt
clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
cgroup: Prevent double killing of css when enabling threaded cgroup
Bluetooth: Fix race condition in hci_release_sock()
ttyprintk: fix a potential deadlock in interrupt context issue
tomoyo: Use atomic_t for statistics counter
media: dvb-usb/dvb-usb-urb.c: initialize actlen to 0
media: gspca: zero usb_buf
media: vp7045: do not read uninitialized values if usb transfer fails
media: af9005: uninitialized variable printked
media: digitv: don't continue if remote control state can't be read
reiserfs: Fix memory leak of journal device string
mm/mempolicy.c: fix out of bounds write in mpol_parse_str()
arm64: kbuild: remove compressed images on 'make ARCH=arm64 (dist)clean'
tools lib: Fix builds when glibc contains strlcpy()
PM / devfreq: Add new name attribute for sysfs
perf c2c: Fix return type for histogram sorting comparision functions
gfs2: Another gfs2_find_jhead fix
e1000e: Revert "e1000e: Make watchdog use delayed work"
e1000e: Drop unnecessary __E1000_DOWN bit twiddling
x86/resctrl: Fix use-after-free due to inaccurate refcount of rdtgroup
x86/resctrl: Fix use-after-free when deleting resource groups
x86/resctrl: Fix a deadlock due to inaccurate reference
cifs: fix soft mounts hanging in the reconnect code
vfs: fix do_last() regression
ANDROID: Incremental fs: Remove C++-style comments
ANDROID: gki_defconfig: Set CONFIG_ANDROID_BINDERFS=y
FROMLIST: selinux: Fix typo in filesystem name
UPSTREAM: drm: Add DisplayPort colorspace property creation function
UPSTREAM: drm: Rename HDMI colorspace property creation function
ANDROID: db845c: Update db845c_gki.fragment to add support for bluetooth modules
UPSTREAM: sched/rt: Make RT capacity-aware
UPSTREAM: sched/fair: Make EAS wakeup placement consider uclamp restrictions
UPSTREAM: sched/fair: Make task_fits_capacity() consider uclamp restrictions
UPSTREAM: sched/uclamp: Rename uclamp_util_with() into uclamp_rq_util_with()
UPSTREAM: sched/uclamp: Make uclamp util helpers use and return UL values
BACKPORT: sched/uclamp: Remove uclamp_util()
Revert "ANDROID: sched/fair: EAS: Add uclamp support to find_energy_efficient_cpu()"
Linux 5.4.17
power/supply: ingenic-battery: Don't change scale if there's only one
Revert "um: Enable CONFIG_CONSTRUCTORS"
KVM: arm64: Write arch.mdcr_el2 changes since last vcpu_load on VHE
crypto: pcrypt - Fix user-after-free on module unload
crypto: caam - do not reset pointer size from MCFGR register
crypto: vmx - reject xts inputs that are too short
crypto: af_alg - Use bh_lock_sock in sk_destruct
rsi: fix non-atomic allocation in completion handler
rsi: fix memory leak on failed URB submission
rsi: fix use-after-free on probe errors
rsi: fix use-after-free on failed probe and unbind
bus: ti-sysc: Fix missing force mstandby quirk handling
Bluetooth: btbcm: Use the BDADDR_PROPERTY quirk
Bluetooth: Allow combination of BDADDR_PROPERTY and INVALID_BDADDR quirks
ALSA: hda/realtek - Move some alc236 pintbls to fallback table
usb-storage: Disable UAS on JMicron SATA enclosure
bus: ti-sysc: Add module enable quirk for audio AESS
mmc: sdhci-pci: Add support for Intel JSL
mmc: sdhci-pci: Quirk for AMD SDHC Device 0x7906
ARM: OMAP2+: SmartReflex: add omap_sr_pdata definition
ARM: config: aspeed-g5: Enable 8250_DW quirks
mfd: intel-lpss: Add Intel Comet Lake PCH-H PCI IDs
perf/imx_ddr: Add enhanced AXI ID filter support
iommu/amd: Support multiple PCI DMA aliases in IRQ Remapping
iommu/amd: Support multiple PCI DMA aliases in device table
spi: pxa2xx: Add support for Intel Comet Lake-H
bus: ti-sysc: Use swsup quirks also for am335x musb
bus: ti-sysc: Handle mstandby quirk and use it for musb
media: dvbsky: add support for eyeTV Geniatech T2 lite
PCI: Add DMA alias quirk for Intel VCA NTB
platform/x86: dell-laptop: disable kbd backlight on Inspiron 10xx
staging: mt7621-pci: add quirks for 'E2' revision using 'soc_device_attribute'
libbpf: Fix BTF-defined map's __type macro handling of arrays
drm/amdgpu/SRIOV: add navi12 pci id for SRIOV (v2)
ASoC: Intel: cht_bsw_rt5645: Add quirk for boards using pmc_plt_clk_0
extcon-intel-cht-wc: Don't reset USB data connection at probe
HID: steam: Fix input device disappearing
atm: eni: fix uninitialized variable warning
stmmac: debugfs entry name is not be changed when udev rename device name.
drm/amd/display: Reduce HDMI pixel encoding if max clock is exceeded
iommu/dma: fix variable 'cookie' set but not used
gpio: max77620: Add missing dependency on GPIOLIB_IRQCHIP
net: wan: sdla: Fix cast from pointer to integer of different size
drivers/net/b44: Change to non-atomic bit operations on pwol_mask
net: Google gve: Remove dma_wmb() before ringing doorbell
spi: spi-dw: Add lock protect dw_spi rx/tx to prevent concurrent calls
can: tcan4x5x: tcan4x5x_parse_config(): reset device before register access
usb: musb: jz4740: Silence error if code is -EPROBE_DEFER
watchdog: orion: fix platform_get_irq() complaints
watchdog: rn5t618_wdt: fix module aliases
watchdog: max77620_wdt: fix potential build errors
HID: intel-ish-hid: ipc: Add Tiger Lake PCI device ID
phy: cpcap-usb: Prevent USB line glitches from waking up modem
ASoC: topology: Prevent use-after-free in snd_soc_get_pcm_runtime()
ASoC: fsl_audmix: add missed pm_runtime_disable
phy: qcom-qmp: Increase PHY ready timeout
drivers/hid/hid-multitouch.c: fix a possible null pointer access.
ASoC: SOF: Intel: hda: hda-dai: fix oops on hda_link .hw_free
ASoC: SOF: fix fault at driver unload after failed probe
HID: wacom: Recognize new MobileStudio Pro PID
HID: intel-ish-hid: ipc: add CMP device id
HID: Add quirk for incorrect input length on Lenovo Y720
HID: asus: Ignore Asus vendor-page usage-code 0xff events
HID: ite: Add USB id match for Acer SW5-012 keyboard dock
HID: Add quirk for Xin-Mo Dual Controller
arc: eznps: fix allmodconfig kconfig warning
HID: multitouch: Add LG MELF0410 I2C touchscreen support
rxrpc: Fix use-after-free in rxrpc_receive_data()
net: include struct nhmsg size in nh nlmsg size
mlxsw: minimal: Fix an error handling path in 'mlxsw_m_port_create()'
udp: segment looped gso packets correctly
net: socionext: fix xdp_result initialization in netsec_process_rx
net: socionext: fix possible user-after-free in netsec_process_rx
net_sched: walk through all child classes in tc_bind_tclass()
net_sched: fix ops->bind_class() implementations
net_sched: ematch: reject invalid TCF_EM_SIMPLE
zd1211rw: fix storage endpoint lookup
rtl8xxxu: fix interface sanity check
brcmfmac: fix interface sanity check
ath9k: fix storage endpoint lookup
cifs: Fix memory allocation in __smb2_handle_cancelled_cmd()
cifs: set correct max-buffer-size for smb2_ioctl_init()
CIFS: Fix task struct use-after-free on reconnect
crypto: chelsio - fix writing tfm flags to wrong place
driver core: Fix test_async_driver_probe if NUMA is disabled
iio: st_gyro: Correct data for LSM9DS0 gyro
iio: adc: stm32-dfsdm: fix single conversion
mei: me: add comet point (lake) H device ids
mei: hdcp: bind only with i915 on the same PCH
binder: fix log spam for existing debugfs file creation.
component: do not dereference opaque pointer in debugfs
debugfs: Return -EPERM when locked down
serial: imx: fix a race condition in receive path
serial: 8250_bcm2835aux: Fix line mismatch on driver unbind
staging: vt6656: Fix false Tx excessive retries reporting.
staging: vt6656: use NULLFUCTION stack on mac80211
staging: vt6656: correct packet types for CTS protect, mode.
staging: wlan-ng: ensure error return is actually returned
staging: most: net: fix buffer overflow
usb: typec: fusb302: fix "op-sink-microwatt" default that was in mW
usb: typec: wcove: fix "op-sink-microwatt" default that was in mW
usb: dwc3: turn off VBUS when leaving host mode
USB: serial: ir-usb: fix IrLAP framing
USB: serial: ir-usb: fix link-speed handling
USB: serial: ir-usb: add missing endpoint sanity check
usb: host: xhci-tegra: set MODULE_FIRMWARE for tegra186
usb: dwc3: pci: add ID for the Intel Comet Lake -V variant
rsi_91x_usb: fix interface sanity check
orinoco_usb: fix interface sanity check
Bluetooth: btusb: fix non-atomic allocation in completion handler
ANDROID: scsi: ufs: fix collision between CRYPTO and RPM_AUTOSUSPEND bits
ANDROID: gki: Removed cf modules from gki_defconfig
ANDROID: Remove default y for VIRTIO_PCI_LEGACY
ANDROID: gki_defconfig: enabled INTERCONNECT
ANDROID: gki_defconfig: Remove SND_8X0
ANDROID: gki: Fixed some typos in Kconfig.gki
ANDROID: gki_defconfig: Enable req modules in GKI
ANDROID: modularize BLK_MQ_VIRTIO
ANDROID: kallsyms: strip hashes from static functions with ThinLTO and CFI
ANDROID: Incremental fs: Remove unneeded compatibility typedef
ANDROID: Incremental fs: Enable incrementalfs in GKI
ANDROID: Incremental fs: Fix sparse errors
ANDROID: Fixing incremental fs style issues
ANDROID: Make incfs selftests pass
ANDROID: Initial commit of Incremental FS
Linux 5.4.16
net/x25: fix nonblocking connect
netfilter: nf_tables: autoload modules from the abort path
netfilter: nf_tables: add __nft_chain_type_get()
netfilter: ipset: use bitmap infrastructure completely
media: v4l2-ioctl.c: zero reserved fields for S/TRY_FMT
libertas: Fix two buffer overflows at parsing bss descriptor
net/sonic: Prevent tx watchdog timeout
net/sonic: Fix CAM initialization
net/sonic: Fix command register usage
net/sonic: Quiesce SONIC before re-initializing descriptor memory
net/sonic: Fix receive buffer replenishment
net/sonic: Improve receive descriptor status flag check
net/sonic: Avoid needless receive descriptor EOL flag updates
net/sonic: Fix receive buffer handling
net/sonic: Fix interface error stats collection
net/sonic: Use MMIO accessors
net/sonic: Clear interrupt flags immediately
net/sonic: Add mutual exclusion for accessing shared state
readdir: be more conservative with directory entry names
do_last(): fetch directory ->i_mode and ->i_uid before it's too late
net, sk_msg: Don't check if sock is locked when tearing down psock
xfrm: support output_mark for offload ESP packets
drm/i915/userptr: fix size calculation
iwlwifi: mvm: fix potential SKB leak on TXQ TX
iwlwifi: mvm: fix SKB leak on invalid queue
tracing: xen: Ordered comparison of function pointers
scsi: RDMA/isert: Fix a recently introduced regression related to logout
hwmon: (nct7802) Fix non-working alarm on voltages
hwmon: (nct7802) Fix voltage limits to wrong registers
hsr: Fix a compilation error
leds: gpio: Fix uninitialized gpio label for fwnode based probe
readdir: make user_access_begin() use the real access range
iommu/amd: Fix IOMMU perf counter clobbering during init
lib: Reduce user_access_begin() boundaries in strncpy_from_user() and strnlen_user()
netfilter: nft_osf: add missing check for DREG attribute
Input: sun4i-ts - add a check for devm_thermal_zone_of_sensor_register
Input: pegasus_notetaker - fix endpoint sanity check
Input: aiptek - fix endpoint sanity check
Input: gtco - fix endpoint sanity check
Input: sur40 - fix interface sanity checks
Input: pm8xxx-vib - fix handling of separate enable register
net/tls: fix async operation
mlxsw: switchx2: Do not modify cloned SKBs during xmit
mmc: sdhci_am654: Reset Command and Data line after tuning
mmc: sdhci_am654: Remove Inverted Write Protect flag
mmc: sdhci: fix minimum clock rate for v3 controller
mmc: tegra: fix SDR50 tuning override
ARM: 8950/1: ftrace/recordmcount: filter relocation types
Revert "Input: synaptics-rmi4 - don't increment rmiaddr for SMBus transfers"
Input: keyspan-remote - fix control-message timeouts
iommu/vt-d: Call __dmar_remove_one_dev_info with valid pointer
pinctrl: sunrisepoint: Add missing Interrupt Status register offset
XArray: Fix xas_find returning too many entries
XArray: Fix xa_find_after with multi-index entries
XArray: Fix infinite loop with entry at ULONG_MAX
iwlwifi: mvm: don't send the IWL_MVM_RXQ_NSSN_SYNC notif to Rx queues
Revert "iwlwifi: mvm: fix scan config command size"
powerpc/xive: Discard ESB load value when interrupt is invalid
powerpc/mm/hash: Fix sharing context ids between kernel & userspace
tracing: Fix histogram code when expression has same var as value
tracing: Do not set trace clock if tracefs lockdown is in effect
tracing/uprobe: Fix double perf_event linking on multiprobe uprobe
tracing: trigger: Replace unneeded RCU-list traversals
PM: hibernate: fix crashes with init_on_free=1
drm/i915: Align engine->uabi_class/instance with i915_drm.h
drm/panfrost: Add the panfrost_gem_mapping concept
PCI: Mark AMD Navi14 GPU rev 0xc5 ATS as broken
ceph: hold extra reference to r_parent over life of request
hwmon: (core) Do not use device managed functions for memory allocations
hwmon: (adt7475) Make volt2reg return same reg as reg2volt input
afs: Fix characters allowed into cell names
Revert "io_uring: only allow submit from owning task"
ipv4: Detect rollover in specific fib table dump
net/mlx5e: kTLS, Do not send decrypted-marked SKBs via non-accel path
net/mlx5e: kTLS, Remove redundant posts in TX resync flow
net/mlx5e: kTLS, Fix corner-case checks in TX resync flow
net/mlx5: DR, use non preemptible call to get the current cpu number
net/mlx5: E-Switch, Prevent ingress rate configuration of uplink rep
net/mlx5: DR, Enable counter on non-fwd-dest objects
net/mlx5: Update the list of the PCI supported devices
net/mlx5: Fix lowest FDB pool size
net: Fix packet reordering caused by GRO and listified RX cooperation
fou: Fix IPv6 netlink policy
mlxsw: spectrum_acl: Fix use-after-free during reload
airo: Add missing CAP_NET_ADMIN check in AIROOLDIOCTL/SIOCDEVPRIVATE
airo: Fix possible info leak in AIROOLDIOCTL/SIOCDEVPRIVATE
tun: add mutex_unlock() call and napi.skb clearing in tun_get_user()
tcp: do not leave dangling pointers in tp->highest_sack
tcp_bbr: improve arithmetic division in bbr_update_bw()
Revert "udp: do rmem bulk free even if the rx sk queue is empty"
net: usb: lan78xx: Add .ndo_features_check
net-sysfs: Fix reference count leak
net_sched: use validated TCA_KIND attribute in tc_new_tfilter()
net_sched: fix datalen for ematch
net: rtnetlink: validate IFLA_MTU attribute in rtnl_create_link()
net, ip_tunnel: fix namespaces move
net, ip6_tunnel: fix namespaces move
net: ip6_gre: fix moving ip6gre between namespaces
net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM
net: bcmgenet: Use netif_tx_napi_add() for TX NAPI
ipv6: sr: remove SKB_GSO_IPXIP6 on End.D* actions
gtp: make sure only SOCK_DGRAM UDP sockets are accepted
firestream: fix memory leaks
can, slip: Protect tty->disc_data in write_wakeup and close with RCU
ANDROID: gki_defconfig: Set IKHEADERS back to =y
ANDROID: gki_defconfig: Enable CONFIG_BTT
f2fs: fix race conditions in ->d_compare() and ->d_hash()
f2fs: fix dcache lookup of !casefolded directories
f2fs: Add f2fs stats to sysfs
f2fs: delete duplicate information on sysfs nodes
f2fs: change to use rwsem for gc_mutex
f2fs: update f2fs document regarding to fsync_mode
f2fs: add a way to turn off ipu bio cache
f2fs: code cleanup for f2fs_statfs_project()
f2fs: fix miscounted block limit in f2fs_statfs_project()
f2fs: show the CP_PAUSE reason in checkpoint traces
f2fs: fix deadlock allocating bio_post_read_ctx from mempool
f2fs: remove unneeded check for error allocating bio_post_read_ctx
f2fs: convert inline_dir early before starting rename
f2fs: fix memleak of kobject
f2fs: fix to add swap extent correctly
f2fs: run fsck when getting bad inode during GC
f2fs: support data compression
f2fs: free sysfs kobject
f2fs: declare nested quota_sem and remove unnecessary sems
f2fs: don't put new_page twice in f2fs_rename
f2fs: set I_LINKABLE early to avoid wrong access by vfs
f2fs: don't keep META_MAPPING pages used for moving verity file blocks
f2fs: introduce private bioset
f2fs: cleanup duplicate stats for atomic files
f2fs: Check write pointer consistency of non-open zones
f2fs: Check write pointer consistency of open zones
f2fs: set GFP_NOFS when moving inline dentries
f2fs: should avoid recursive filesystem ops
f2fs: keep quota data on write_begin failure
f2fs: call f2fs_balance_fs outside of locked page
f2fs: preallocate DIO blocks when forcing buffered_io
FROMGIT: ext4: Add EXT4_IOC_FSGETXATTR/EXT4_IOC_FSSETXATTR to compat_ioctl.
ANDROID: gki_defconfig: Set IKHEADERS back to =m
ANDROID: gki_defconfig: enable NVDIMM/PMEM options
Linux 5.4.15
optee: Fix multi page dynamic shm pool alloc
phy/rockchip: inno-hdmi: round clock rate down to closest 1000 Hz
gpio: aspeed: avoid return type warning
net-sysfs: Call dev_hold always in netdev_queue_add_kobject
s390/qeth: fix dangling IO buffers after halt/clear
block: fix memleak of bio integrity data
platform/chrome: wilco_ec: fix use after free issue
xdp: Fix cleanup on map free for devmap_hash map type
drm/radeon: fix bad DMA from INTERRUPT_CNTL2
dmaengine: ti: edma: fix missed failure handling
afs: Remove set but not used variables 'before', 'after'
dma-direct: don't check swiotlb=force in dma_direct_map_resource
mt76: mt76u: rely on usb_interface instead of usb_dev
sched/cpufreq: Move the cfs_rq_util_change() call to cpufreq_update_util()
SUNRPC: Fix another issue with MIC buffer space
workqueue: Add RCU annotation for pwq list walk
tee: optee: fix device enumeration error handling
tee: optee: Fix dynamic shm pool allocations
mmc: core: fix wl1251 sdio quirks
mmc: sdio: fix wl1251 vendor id
firmware: arm_scmi: Fix doorbell ring logic for !CONFIG_64BIT
kselftests: cgroup: Avoid the reuse of fd after it is deallocated
i2c: stm32f7: report dma error during probe
packet: fix data-race in fanout_flow_is_huge()
rtc: bd70528: fix module alias to autoload module
selftests: gen_kselftest_tar.sh: Do not clobber kselftest/
net: axienet: Fix error return code in axienet_probe()
net: neigh: use long type to store jiffies delta
rt2800: remove errornous duplicate condition
hv_netvsc: flag software created hash value
net: openvswitch: don't unlock mutex when changing the user_features fails
scsi: ufs: delete redundant function ufshcd_def_desc_sizes()
dpaa_eth: avoid timestamp read on error paths
dpaa_eth: perform DMA unmapping before read
rcu: Fix uninitialized variable in nocb_gp_wait()
libbpf: Don't use kernel-side u32 type in xsk.c
firmware: imx: Remove call to devm_of_platform_populate
power: supply: bd70528: Add MODULE_ALIAS to allow module auto loading
drm/amdgpu/vi: silence an uninitialized variable warning
regulator: bd70528: Add MODULE_ALIAS to allow module auto loading
pwm: sun4i: Fix incorrect calculation of duty_cycle/period
ACPI: platform: Unregister stale platform devices
net: netsec: Correct dma sync for XDP_TX frames
drm: rcar_lvds: Fix color mismatches on R-Car H2 ES2.0 and later
PCI: mobiveil: Fix csr_read()/write() build issue
software node: Get reference to parent swnode in get_parent op
drm/rockchip: Round up _before_ giving to the clock framework
dpaa2-eth: Fix minor bug in ethtool stats reporting
hwrng: omap3-rom - Fix missing clock by probing with device tree
drm/amdgpu: remove excess function parameter description
drm: panel-lvds: Potential Oops in probe error handling
drm/panfrost: Add missing check for pfdev->regulator
rtw88: fix error handling when setup efuse info
rtw88: fix beaconing mode rsvd_page memory violation issue
gpiolib: No need to call gpiochip_remove_pin_ranges() twice
sched/core: Further clarify sched_class::set_next_task()
ipmi: Fix memory leak in __ipmi_bmc_register
watchdog: sprd: Fix the incorrect pointer getting from driver data
soc: aspeed: Fix snoop_file_poll()'s return type
soc: renesas: Add missing check for non-zero product register address
soc: qcom: llcc: Name regmaps to avoid collisions
soc/tegra: pmc: Fix crashes for hierarchical interrupts
leds: tlc591xx: update the maximum brightness
perf map: No need to adjust the long name of modules
crypto: sun4i-ss - fix big endian issues
crypto: amcc - restore CRYPTO_AES dependency
nfsd: depend on CRYPTO_MD5 for legacy client tracking
s390/pkey: fix memory leak within _copy_apqns_from_user()
ice: fix stack leakage
mt7601u: fix bbp version check in mt7601u_wait_bbp_ready
mt76: mt76u: fix endpoint definition order
phy: ti: gmii-sel: fix mac tx internal delay for rgmii-rxid
net: phy: broadcom: Fix RGMII delays configuration for BCM54210E
phy: lantiq: vrx200-pcie: fix error return code in ltq_vrx200_pcie_phy_power_on()
net/mlx5e: Fix free peer_flow when refcount is 0
tipc: fix wrong timeout input for tipc_wait_for_cond()
tipc: fix wrong socket reference counter after tipc_sk_timeout() returns
tipc: fix potential memory leak in __tipc_sendmsg()
tipc: update mon's self addr when node addr generated
tipc: reduce sensitive to retransmit failures
powerpc/archrandom: fix arch_get_random_seed_int()
powerpc/kasan: Fix boot failure with RELOCATABLE && FSL_BOOKE
powerpc/pseries: Enable support for ibm,drc-info property
powerpc/security: Fix debugfs data leak on 32-bit
SUNRPC: Fix backchannel latency metrics
SUNRPC: Fix svcauth_gss_proxy_init()
mfd: intel-lpss: Add default I2C device properties for Gemini Lake
i2c: i2c-stm32f7: fix 10-bits check in slave free id search loop
i2c: stm32f7: rework slave_id allocation
xfs: Sanity check flags of Q_XQUOTARM call
ARM: OMAP2+: Add missing put_device() call in omapdss_init_of()
ARM: dts: logicpd-torpedo-37xx-devkit-28: Reference new DRM panel
samples/bpf: Fix broken xdp_rxq_info due to map order assumptions
samples: bpf: update map definition to new syntax BTF-defined map
bpf: Force .BTF section start to zero when dumping from vmlinux
libbpf: Make btf__resolve_size logic always check size error condition
libbpf: Fix another potential overflow issue in bpf_prog_linfo
libbpf: Fix potential overflow issue
libbpf: Fix memory leak/double free issue
libbpf: Fix compatibility for kernels without need_wakeup
drm/i915: Fix pid leak with banned clients
ANDROID: update ABI following inline crypto changes
ANDROID: gki_defconfig: enable dm-default-key
ANDROID: dm: add dm-default-key target for metadata encryption
ANDROID: dm: enable may_passthrough_inline_crypto on some targets
ANDROID: dm: add support for passing through inline crypto support
ANDROID: block: Introduce passthrough keyslot manager
ANDROID: ext4, f2fs: enable direct I/O with inline encryption
FROMLIST: scsi: ufs: add program_key() variant op
ANDROID: block: export symbols needed for modules to use inline crypto
ANDROID: block: fix some inline crypto bugs
UPSTREAM: mm/page_io.c: annotate refault stalls from swap_readpage
FROMLIST: security: selinux: allow per-file labelling for binderfs
Revert "ANDROID: security,perf: Allow further restriction of perf_event_open"
ANDROID: selinux: modify RTM_GETLINK permission
BACKPORT: tracing: Remove unnecessary DEBUG_FS dependency
BACKPORT: debugfs: Fix !DEBUG_FS debugfs_create_automount
Linux 5.4.14
scsi: lpfc: use hdwq assigned cpu for allocation
perf script: Fix --reltime with --time
hwmon: (pmbus/ibm-cffps) Fix LED blink behavior
hwmon: (pmbus/ibm-cffps) Switch LEDs to blocking brightness call
regulator: ab8500: Remove SYSCLKREQ from enum ab8505_regulator_id
clk: imx7ulp: Correct DDR clock mux options
clk: imx7ulp: Correct system clock source option #7
clk: sprd: Use IS_ERR() to validate the return value of syscon_regmap_lookup_by_phandle()
perf script: Allow --time with --reltime
perf probe: Fix wrong address verification
rtw88: fix potential read outside array boundary
scsi: lpfc: Fix a kernel warning triggered by lpfc_get_sgl_per_hdwq()
scsi: lpfc: Fix hdwq sgl locks and irq handling
scsi: lpfc: Fix list corruption detected in lpfc_put_sgl_per_hdwq
scsi: core: scsi_trace: Use get_unaligned_be*()
scsi: qla2xxx: fix rports not being mark as lost in sync fabric scan
scsi: qla2xxx: Fix qla2x00_request_irqs() for MSI
scsi: scsi_transport_sas: Fix memory leak when removing devices
scsi: hisi_sas: Return directly if init hardware failed
scsi: lpfc: fix: Coverity: lpfc_get_scsi_buf_s3(): Null pointer dereferences
scsi: target: core: Fix a pr_debug() argument
scsi: bnx2i: fix potential use after free
scsi: qla4xxx: fix double free bug
scsi: hisi_sas: Set the BIST init value before enabling BIST
scsi: hisi_sas: Don't create debugfs dump folder twice
scsi: esas2r: unlock on error in esas2r_nvram_read_direct()
reiserfs: fix handling of -EOPNOTSUPP in reiserfs_for_each_xattr
um: virtio_uml: Disallow modular build
um: Don't trace irqflags during shutdown
mtd: cfi_cmdset_0002: fix delayed error detection on HyperFlash
mtd: cfi_cmdset_0002: only check errors when ready in cfi_check_err_status()
mtd: devices: fix mchp23k256 read and write
Revert "arm64: dts: juno: add dma-ranges property"
ARM: dts: Fix sgx sysconfig register for omap4
arm64: dts: juno: Fix UART frequency
ARM: dts: dra7: fix cpsw mdio fck clock
arm64: dts: allwinner: a64: Re-add PMU node
ARM: dts: imx6ul-kontron-n6310-s: Disable the snvs-poweroff driver
arm64: dts: qcom: sdm845-cheza: delete zap-shader
arm64: dts: imx8mm-evk: Assigned clocks for audio plls
arm64: dts: renesas: r8a774a1: Remove audio port node
arm64: dts: marvell: Fix CP110 NAND controller node multi-line comment alignment
tick/sched: Annotate lockless access to last_jiffies_update
cfg80211: check for set_wiphy_params
arm64: dts: marvell: Add AP806-dual missing CPU clocks
arm64: dts: renesas: r8a77970: Fix PWM3
arm64: dts: meson-gxl-s905x-khadas-vim: fix gpio-keys-polled node
arm64: dts: meson: g12: fix audio fifo reg size
arm64: dts: meson: axg: fix audio fifo reg size
cw1200: Fix a signedness bug in cw1200_load_firmware()
arm64: dts: qcom: msm8998: Disable coresight by default
irqchip: Place CONFIG_SIFIVE_PLIC into the menu
tcp: refine rule to allow EPOLLOUT generation under mem pressure
dt-bindings: Add missing 'properties' keyword enclosing 'snps,tso'
xen/blkfront: Adjust indentation in xlvbd_alloc_gendisk
devlink: Wait longer before warning about unset port type
net: stmmac: tc: Do not setup flower filtering if RSS is enabled
net: stmmac: selftests: Update status when disabling RSS
selftests: mlxsw: qos_mc_aware: Fix mausezahn invocation
net: stmmac: selftests: Mark as fail when received VLAN ID != expected
net: stmmac: selftests: Make it work in Synopsys AXS101 boards
mlxsw: spectrum_qdisc: Include MC TCs in Qdisc counters
mlxsw: spectrum: Wipe xstats.backlog of down ports
mlxsw: spectrum: Do not modify cloned SKBs during xmit
sh_eth: check sh_eth_cpu_data::dual_port when dumping registers
drm/amdgpu: allow direct upload save restore list for raven2
i40e: prevent memory leak in i40e_setup_macvlans
net: dsa: bcm_sf2: Configure IMP port for 2Gb/sec
net: sched: act_ctinfo: fix memory leak
net: dsa: tag_gswip: fix typo in tagger name
net: dsa: sja1105: Don't error out on disabled ports with no phy-mode
net: systemport: Fixed queue mapping in internal ring map
net: ethernet: ave: Avoid lockdep warning
bnxt_en: Do not treat DSN (Digital Serial Number) read failure as fatal.
bnxt_en: Fix ipv6 RFS filter matching logic.
bnxt_en: Fix NTUPLE firmware command failures.
tcp: fix marked lost packets not being retransmitted
r8152: add missing endpoint sanity check
ptp: free ptp device pin descriptors properly
net/wan/fsl_ucc_hdlc: fix out of bounds write on array utdm_info
net: usb: lan78xx: limit size of local TSO packets
net/sched: act_ife: initalize ife->metalist earlier
net: phy: dp83867: Set FORCE_LINK_GOOD to default after reset
net: hns: fix soft lockup when there is not enough memory
net: hns3: pad the short frame before sending to the hardware
net: dsa: tag_qca: fix doubled Tx statistics
net: avoid updating qdisc_xmit_lock_key in netdev_update_lockdep_key()
hv_netvsc: Fix memory leak when removing rndis device
macvlan: use skb_reset_mac_header() in macvlan_queue_xmit()
batman-adv: Fix DAT candidate selection on little endian systems
bpftool: Fix printing incorrect pointer in btf_dump_ptr
net: bpf: Don't leak time wait and request sockets
NFC: pn533: fix bulk-message timeout
netfilter: nf_tables: fix flowtable list del corruption
netfilter: nf_tables: store transaction list locally while requesting module
netfilter: nf_tables: remove WARN and add NLA_STRING upper limits
netfilter: nft_tunnel: ERSPAN_VERSION must not be null
netfilter: nft_tunnel: fix null-attribute check
netfilter: nat: fix ICMP header corruption on ICMP errors
netfilter: arp_tables: init netns pointer in xt_tgdtor_param struct
netfilter: fix a use-after-free in mtype_destroy()
i2c: iop3xx: Fix memory leak in probe error path
bpf/sockmap: Read psock ingress_msg before sk_receive_queue
cfg80211: fix page refcount issue in A-MSDU decap
cfg80211: fix memory leak in cfg80211_cqm_rssi_update
cfg80211: fix memory leak in nl80211_probe_mesh_link
cfg80211: fix deadlocks in autodisconnect work
i2c: tegra: Properly disable runtime PM on driver's probe error
i2c: tegra: Fix suspending in active runtime PM state
bpf: Sockmap/tls, fix pop data with SK_DROP return code
bpf: Sockmap/tls, skmsg can have wrapped skmsg that needs extra chaining
bpf: Sockmap/tls, tls_sw can create a plaintext buf > encrypt buf
bpf: Sockmap/tls, msg_push_data may leave end mark in place
bpf: Sockmap, skmsg helper overestimates push, pull, and pop bounds
bpf: Sockmap/tls, push write_space updates through ulp updates
bpf: Sockmap, ensure sock lock held during tear down
bpf: Sockmap/tls, during free we may call tcp_bpf_unhash() in loop
bpf: Fix incorrect verifier simulation of ARSH under ALU32
drm/amd/display: Reorder detect_edp_sink_caps before link settings read.
block: Fix the type of 'sts' in bsg_queue_rq()
net: fix kernel-doc warning in <linux/netdevice.h>
tipc: fix retrans failure due to wrong destination
tipc: fix potential hanging after b/rcast changing
reset: Fix {of,devm}_reset_control_array_get kerneldoc return types
net: stmmac: Enable 16KB buffer size
net: stmmac: 16KB buffer must be 16 byte aligned
ARM: dts: imx7: Fix Toradex Colibri iMX7S 256MB NAND flash support
ARM: dts: imx6q-icore-mipi: Use 1.5 version of i.Core MX6DL
ARM: dts: imx6sll-evk: Remove incorrect power supply assignment
ARM: dts: imx6sl-evk: Remove incorrect power supply assignment
ARM: dts: imx6sx-sdb: Remove incorrect power supply assignment
ARM: dts: imx6qdl-sabresd: Remove incorrect power supply assignment
mm: khugepaged: add trace status description for SCAN_PAGE_HAS_PRIVATE
mm/page-writeback.c: avoid potential division by zero in wb_min_max_ratio()
mm/memory_hotplug: don't free usage map when removing a re-added early section
Btrfs: always copy scrub arguments back to user space
btrfs: check rw_devices, not num_devices for balance
btrfs: fix memory leak in qgroup accounting
btrfs: relocation: fix reloc_root lifespan and access
btrfs: do not delete mismatched root refs
btrfs: fix invalid removal of root ref
btrfs: rework arguments of btrfs_unlink_subvol
mm, debug_pagealloc: don't rely on static keys too early
mm: memcg/slab: call flush_memcg_workqueue() only if memcg workqueue is valid
mm: memcg/slab: fix percpu slab vmstats flushing
mm/huge_memory.c: thp: fix conflict of above-47bit hint address and PMD alignment
mm/shmem.c: thp, shmem: fix conflict of above-47bit hint address and PMD alignment
perf report: Fix incorrectly added dimensions as switch perf data file
locking/lockdep: Fix buffer overrun problem in stack_trace[]
perf hists: Fix variable name's inconsistency in hists__for_each() macro
clk: samsung: exynos5420: Keep top G3D clocks enabled
s390/setup: Fix secure ipl message
efi/earlycon: Fix write-combine mapping on x86
x86/resctrl: Fix potential memory leak
drm/i915: Add missing include file <linux/math64.h>
mtd: spi-nor: Fix selection of 4-byte addressing opcodes on Spansion
scsi: storvsc: Correctly set number of hardware queues for IDE disk
s390/zcrypt: Fix CCA cipher key gen with clear key value function
x86/efistub: Disable paging at mixed mode entry
perf/x86/intel/uncore: Fix missing marker for snr_uncore_imc_freerunning_events
locking/rwsem: Fix kernel crash when spinning on RWSEM_OWNER_UNKNOWN
x86/CPU/AMD: Ensure clearing of SME/SEV features is maintained
x86/resctrl: Fix an imbalance in domain_remove_cpu()
cpu/SMT: Fix x86 link error without CONFIG_SYSFS
usb: core: hub: Improved device recognition on remote wakeup
mtd: rawnand: gpmi: Restore nfc timing setup after suspend/resume
mtd: rawnand: gpmi: Fix suspend/resume problem
ptrace: reintroduce usage of subjective credentials in ptrace_has_cap()
scsi: mptfusion: Fix double fetch bug in ioctl
scsi: fnic: fix invalid stack access
staging: comedi: ni_routes: allow partial routing information
staging: comedi: ni_routes: fix null dereference in ni_find_route_source()
USB: serial: quatech2: handle unbound ports
USB: serial: keyspan: handle unbound ports
USB: serial: io_edgeport: add missing active-port sanity check
USB: serial: io_edgeport: handle unbound ports on URB completion
USB: serial: ch341: handle unbound port at reset_resume
USB: serial: suppress driver bind attributes
USB: serial: option: add support for Quectel RM500Q in QDL mode
USB: serial: opticon: fix control-message timeouts
USB: serial: option: Add support for Quectel RM500Q
USB: serial: simple: Add Motorola Solutions TETRA MTP3xxx and MTP85xx
iio: buffer: align the size of scan bytes to size of the largest element
iio: chemical: pms7003: fix unmet triggered buffer dependency
iio: light: vcnl4000: Fix scale for vcnl4040
iio: imu: st_lsm6dsx: Fix selection of ST_LSM6DS3_ID
iio: adc: ad7124: Fix DT channel configuration
perf: Correctly handle failed perf_get_aux_event()
ARM: davinci: select CONFIG_RESET_CONTROLLER
ARM: dts: am571x-idk: Fix gpios property to have the correct gpio number
cpuidle: teo: Fix intervals[] array indexing bug
io_uring: only allow submit from owning task
fuse: fix fuse_send_readpages() in the syncronous read case
block: fix an integer overflow in logical block size
clk: sunxi-ng: r40: Allow setting parent rate for external clock outputs
Fix built-in early-load Intel microcode alignment
arm64: dts: agilex/stratix10: fix pmu interrupt numbers
arm64: dts: allwinner: a64: olinuxino: Fix eMMC supply regulator
arm64: dts: allwinner: a64: olinuxino: Fix SDIO supply regulator
ALSA: usb-audio: fix sync-ep altsetting sanity check
ALSA: firewire-tascam: fix corruption due to spin lock without restoration in SoftIRQ context
ALSA: seq: Fix racy access for queue timer in proc read
ALSA: dice: fix fallback from protocol extension into limited functionality
ASoC: Intel: bytcht_es8316: Fix Irbis NB41 netbook quirk
ARM: dts: imx6q-dhcom: Fix SGTL5000 VDDIO regulator connection
ARM: dts: imx7ulp: fix reg of cpu node
ARM: OMAP2+: Fix ti_sysc_find_one_clockdomain to check for to_clk_hw_omap
ASoC: msm8916-wcd-analog: Fix MIC BIAS Internal1
ASoC: msm8916-wcd-analog: Fix selected events for MIC BIAS External1
ASoC: stm32: dfsdm: fix 16 bits record
ASoC: stm32: sai: fix possible circular locking
ASoC: msm8916-wcd-digital: Reset RX interpolation path after use
arm64: dts: imx8mq-librem5-devkit: use correct interrupt for the magnetometer
Revert "gpio: thunderx: Switch to GPIOLIB_IRQCHIP"
clk: Don't try to enable critical clocks if prepare failed
bus: ti-sysc: Fix iterating over clocks
arm64: dts: imx8mm: Change SDMA1 ahb clock for imx8mm
arm64: dts: ls1028a: fix endian setting for dcfg
ARM: dts: imx6q-dhcom: fix rtc compatible
dt-bindings: reset: meson8b: fix duplicate reset IDs
soc: amlogic: meson-ee-pwrc: propagate errors from pm_genpd_init()
soc: amlogic: meson-ee-pwrc: propagate PD provider registration errors
clk: qcom: gcc-sdm845: Add missing flag to votable GDSCs
ARM: dts: meson8: fix the size of the PMU registers
ANDROID: gki: Make GKI specific modules builtins
ANDROID: virtio-net: Skip set_features on non-cvq devices
ANDROID: fscrypt: add support for hardware-wrapped keys
ANDROID: block: add KSM op to derive software secret from wrapped key
ANDROID: block: provide key size as input to inline crypto APIs
ANDROID: ufshcd-crypto: export cap find API
ANDROID: build config for cuttlefish ramdisk
ANDROID: x86: gki_defconfig: enable LTO and CFI
ANDROID: x86: map CFI jump tables in pti_clone_entry_text
ANDROID: x86, module: Ignore __typeid__ relocations
ANDROID: x86, relocs: Ignore __typeid__ relocations
ANDROID: x86/alternatives: Use C int3 selftest but disable KASAN
ANDROID: x86/extable: Do not mark exception callback as CFI
ANDROID: x86, build: allow LTO_CLANG and THINLTO to be selected
ANDROID: x86: disable UNWINDER_ORC with LTO_CLANG
ANDROID: x86: disable STACK_VALIDATION with LTO_CLANG
ANDROID: x86: disable HAVE_ARCH_PREL32_RELOCATIONS with LTO_CLANG
ANDROID: x86/vdso: disable LTO only for VDSO
FROMLIST: crypto, x86/sha: Eliminate casts on asm implementations
UPSTREAM: x86/vmlinux: Actually use _etext for the end of the text segment
Linux 5.4.13
ocfs2: call journal flush to mark journal as empty after journal recovery when mount
hexagon: work around compiler crash
hexagon: parenthesize registers in asm predicates
kbuild/deb-pkg: annotate libelf-dev dependency as :native
media: intel-ipu3: Align struct ipu3_uapi_awb_fr_config_s to 32 bytes
drm/amdgpu: enable gfxoff for raven1 refresh
ioat: ioat_alloc_ring() failure handling.
s390/qeth: lock the card while changing its hsuid
dmaengine: k3dma: Avoid null pointer traversal
rxrpc: Fix missing security check on incoming calls
rxrpc: Don't take call->user_mutex in rxrpc_new_incoming_call()
rxrpc: Unlock new call in rxrpc_new_incoming_call() rather than the caller
drm/arm/mali: make malidp_mw_connector_helper_funcs static
MIPS: Prevent link failure with kcov instrumentation
tomoyo: Suppress RCU warning at list_for_each_entry_rcu().
mips: Fix gettimeofday() in the vdso library
mips: cacheinfo: report shared CPU map
riscv: export flush_icache_all to modules
rseq/selftests: Turn off timeout setting
selftests: firmware: Fix it to do root uid check and skip
scsi: target/iblock: Fix protection error with blocks greater than 512B
scsi: libcxgbi: fix NULL pointer dereference in cxgbi_device_destroy()
gpio: mpc8xxx: Add platform device to gpiochip->parent
rtc: bd70528: Add MODULE ALIAS to autoload module
rtc: brcmstb-waketimer: add missed clk_disable_unprepare
rtc: msm6242: Fix reading of 10-hour digit
NFSD fixing possible null pointer derefering in copy offload
f2fs: fix potential overflow
sch_cake: Add missing NLA policy entry TCA_CAKE_SPLIT_GSO
iwlwifi: mvm: fix support for single antenna diversity
rtlwifi: Remove unnecessary NULL check in rtl_regd_init
iwlwifi: mvm: consider ieee80211 station max amsdu value
spi: lpspi: fix memory leak in fsl_lpspi_probe
spi: rspi: Use platform_get_irq_byname_optional() for optional irqs
spi: atmel: fix handling of cs_change set on non-last xfer
spi: pxa2xx: Set controller->max_transfer_size in dma mode
mtd: spi-nor: fix silent truncation in spi_nor_read_raw()
mtd: spi-nor: fix silent truncation in spi_nor_read()
spi: sprd: Fix the incorrect SPI register
ubifs: do_kill_orphans: Fix a memory leak bug
ubifs: Fixed missed le64_to_cpu() in journal
Revert "ubifs: Fix memory leak bug in alloc_ubifs_info() error path"
memory: mtk-smi: Add PM suspend and resume ops
iommu/mediatek: Add a new tlb_lock for tlb_flush
iommu/mediatek: Correct the flush_iotlb_all callback
media: hantro: Set H264 FIELDPIC_FLAG_E flag correctly
media: aspeed-video: Fix memory leaks in aspeed_video_probe
media: hantro: Do not reorder H264 scaling list
media: cedrus: Use correct H264 8x8 scaling list
media: coda: fix deadlock between decoder picture run and start command
media: exynos4-is: Fix recursive locking in isp_video_release()
media: v4l: cadence: Fix how unsued lanes are handled in 'csi2rx_start()'
media: hantro: h264: Fix the frame_num wraparound case
media: rcar-vin: Fix incorrect return statement in rvin_try_format()
media: ov6650: Fix default format not applied on device probe
media: ov6650: Fix .get_fmt() V4L2_SUBDEV_FORMAT_TRY support
media: ov6650: Fix some format attributes not under control
media: ov6650: Fix incorrect use of JPEG colorspace
ARM: 8943/1: Fix topology setup in case of CPU hotplug for CONFIG_SCHED_MC
tty: serial: pch_uart: correct usage of dma_unmap_sg
tty: serial: imx: use the sg count from dma_map_sg
MIPS: SGI-IP27: Fix crash, when CPUs are disabled via nr_cpus parameter
MIPS: Loongson: Fix return value of loongson_hwmon_init
MIPS: PCI: remember nasid changed by set interrupt affinity
powerpc/powernv: Disable native PCIe port management
PCI/PTM: Remove spurious "d" from granularity message
tools: PCI: Fix fd leakage
PCI/PM: Clear PCIe PME Status even for legacy power management
PCI: Fix missing bridge dma_ranges resource list cleanup
PCI: dwc: Fix find_next_bit() usage
PCI: aardvark: Fix PCI_EXP_RTCTL register configuration
PCI: aardvark: Use LTSSM state to build link training flag
compat_ioctl: handle SIOCOUTQNSD
af_unix: add compat_ioctl support
gfs2: add compat_ioctl support
arm64: dts: apq8096-db820c: Increase load on l21 for SDCARD
scsi: sd: enable compat ioctls for sed-opal
drm/amdgpu/discovery: reserve discovery data at the top of VRAM
drm/amdgpu: cleanup creating BOs at fixed location (v2)
Revert "drm/virtio: switch virtio_gpu_wait_ioctl() to gem helper."
PCI: pciehp: Do not disable interrupt twice on suspend
pinctrl: lewisburg: Update pin list according to v1.1v6
pinctrl: sh-pfc: Do not use platform_get_irq() to count interrupts
pinctrl: sh-pfc: Fix PINMUX_IPSR_PHYS() to set GPSR
pinctl: ti: iodelay: fix error checking on pinctrl_count_index_with_args call
affs: fix a memory leak in affs_remount
rsi: fix potential null dereference in rsi_probe()
clk: imx: pll14xx: Fix quick switch of S/K parameter
dmaengine: dw: platform: Mark 'hclk' clock optional
clk: Fix memory leak in clk_unregister()
clk: samsung: exynos5420: Preserve CPU clocks configuration during suspend/resume
clk: meson: axg-audio: fix regmap last register
mei: fix modalias documentation
iio: imu: adis16480: assign bias value only if operation succeeded
iio: imu: st_lsm6dsx: fix gyro gain definitions for LSM9DS1
NFSv4.x: Drop the slot if nfs4_delegreturn_prepare waits for layoutreturn
NFSv4.x: Handle bad/dead sessions correctly in nfs41_sequence_process()
nfsd: v4 support requires CRYPTO_SHA256
nfsd: Fix cld_net->cn_tfm initialization
NFSv2: Fix a typo in encode_sattr()
crypto: geode-aes - convert to skcipher API and make thread-safe
crypto: algif_skcipher - Use chunksize instead of blocksize
crypto: virtio - implement missing support for output IVs
crypto: arm64/aes-neonbs - add return value of skcipher_walk_done() in __xts_crypt()
crypto: hisilicon - select NEED_SG_DMA_LENGTH in qm Kconfig
crypto: cavium/nitrox - fix firmware assignment to AE cores
scsi: ufs: Give an unique ID to each ufs-bsg
dm: add dm-clone to the documentation index
xprtrdma: Fix oops in Receive handler after device removal
xprtrdma: Fix completion wait during device removal
xprtrdma: Fix create_qp crash on device unload
Documentation/ABI: Add missed attribute for mlxreg-io sysfs interfaces
Documentation/ABI: Fix documentation inconsistency for mlxreg-io sysfs interfaces
asm-generic/nds32: don't redefine cacheflush primitives
platform/x86: GPD pocket fan: Use default values when wrong modparams are given
platform/x86: asus-wmi: Fix keyboard brightness cannot be set to 0
platform/mellanox: fix potential deadlock in the tmfifo driver
scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI
scsi: enclosure: Fix stale device oops with hot replug
keys: Fix request_key() cache
afs: Fix afs_lookup() to not clobber the version on a new dentry
afs: Fix use-after-loss-of-ref
libbpf: Fix Makefile' libbpf symbol mismatch diagnostic
bpf: Support pre-2.25-binutils objcopy for vmlinux BTF
bpf: skmsg, fix potential psock NULL pointer dereference
bpf: Make use of probe_user_write in probe write helper
uaccess: Add non-pagefault user-space write function
RDMA/srpt: Report the SCSI residual to the initiator
RDMA/mlx5: Return proper error value
rdma: Remove nes ABI header
RDMA/hns: Bugfix for qpc/cqc timer configuration
RDMA/hns: Fix to support 64K page for srq
xprtrdma: Close window between waking RPC senders and posting Receives
xprtrdma: Fix MR list handling
xprtrdma: Connection becomes unstable after a reconnect
xprtrdma: Add unique trace points for posting Local Invalidate WRs
RDMA/hns: Release qp resources when failed to destroy qp
RDMA/hns: Fix build error again
RDMA/siw: Fix port number endianness in a debug message
RDMA/counter: Prevent QP counter manual binding in auto mode
RDMA/hns: Modify return value of restrack functions
RDMA/hns: remove a redundant le16_to_cpu
RDMA/hns: Prevent undefined behavior in hns_roce_set_user_sq_size()
ASoC: rsnd: fix DALIGN register for SSIU
ASoC: core: Fix compile warning with CONFIG_DEBUG_FS=n
ASoC: SOF: Intel: Broadwell: clarify mutual exclusion with legacy driver
ASoC: fsl_esai: Add spin lock to protect reset, stop and start
ASoC: simple_card_utils.h: Add missing include
ASoC: dt-bindings: mt8183: add missing update
netfilter: nft_meta: use 64-bit time arithmetic
netfilter: nf_tables_offload: release flow_rule on error from commit path
btrfs: simplify inode locking for RWF_NOWAIT
hsr: fix slab-out-of-bounds Read in hsr_debugfs_rename()
syscalls/x86: Fix function types in COND_SYSCALL
syscalls/x86: Use the correct function type for sys_ni_syscall
syscalls/x86: Use COMPAT_SYSCALL_DEFINE0 for IA32 (rt_)sigreturn
syscalls/x86: Wire up COMPAT_SYSCALL_DEFINE0
perf vendor events s390: Remove name from L1D_RO_EXCL_WRITES description
afs: Fix missing cell comparison in afs_test_super()
reset: brcmstb: Remove resource checks
dt-bindings: reset: Fix brcmstb-reset example
can: j1939: fix address claim code example
ath9k: use iowrite32 over __raw_writel
MAINTAINERS: Append missed file to the database
scsi: smartpqi: Update attribute name to `driver_version`
cifs: Adjust indentation in smb2_open_file
s390/qeth: fix initialization on old HW
s390/qeth: vnicc Fix init to default
s390/qeth: Fix vnicc_is_in_use if rx_bcast not set
s390/qeth: fix false reporting of VNIC CHAR config failure
s390/qeth: fix qdio teardown after early init error
hsr: reset network header when supervision frame is created
hsr: rename debugfs file when interface name is changed
hsr: add hsr root debugfs directory
drm/tegra: Fix ordering of cleanup code
PCI: amlogic: Fix probed clock names
PM / devfreq: tegra: Add COMMON_CLK dependency
gpio: Fix error message on out-of-range GPIO in lookup table
scsi: mpt3sas: Fix double free in attach error handling
fs: move guard_bio_eod() after bio_set_op_attrs
bpf: cgroup: prevent out-of-order release of cgroup bpf
iommu: Remove device link to group on failure
iommu/vt-d: Unlink device if failed to add to group
selftests: loopback.sh: skip this test if the driver does not support
pinctrl: meson: Fix wrong shift value when get drive-strength
gpio: zynq: Fix for bug in zynq_gpio_restore_context API
mtd: onenand: omap2: Pass correct flags for prep_dma_memcpy
ASoC: SOF: imx8: Fix dsp_box offset
netfilter: nft_flow_offload: fix underflow in flowtable reference counter
pinctrl: lochnagar: select GPIOLIB
ASoC: stm32: spdifrx: fix input pin state management
ASoC: stm32: spdifrx: fix race condition in irq handler
ASoC: stm32: spdifrx: fix inconsistent lock state
ASoC: soc-core: Set dpcm_playback / dpcm_capture
ASoC: SOF: imx8: fix memory allocation failure check on priv->pd_dev
i2c: bcm2835: Store pointer to bus clock
mtd: rawnand: stm32_fmc2: avoid to lock the CPU bus
IB/hfi1: Don't cancel unused work item
RDMA/bnxt_re: Fix Send Work Entry state check while polling completions
RDMA/bnxt_re: Avoid freeing MR resources if dereg fails
phy: mapphone-mdm6600: Fix uninitialized status value regression
rtc: mt6397: fix alarm register overwrite
HID: hidraw, uhid: Always report EPOLLOUT
FROMGIT: drivers/iommu: Initialise module 'owner' field in iommu_device_set_ops()
Revert "drm/virtio: switch virtio_gpu_wait_ioctl() to gem helper."
ANDROID: update kernel ABI for CONFIG_DUMMY
ANDROID: update ABI whitelist
UPSTREAM: dmaengine: k3dma: Avoid null pointer traversal
GKI: enable CONFIG_DUMMY=y
ANDROID: update kernel ABI for f2fs/fscrypt/other changes
ANDROID: db845c: Add build config
ANDROID: db845c: add db845c_gki.fragment
FROMLIST: usb: dwc3: gadget: Correct the logic for finding last SG entry
FROMLIST: usb: xhci: provide a debugfs hook for erasing rom
FROMLIST: usb: renesas-xhci: allow multiple firmware versions
FROMLIST: usb: renesas-xhci: Add ROM loader for uPD720201
FROMLIST: usb: renesas-xhci: Add the renesas xhci driver
FROMLIST: usb: xhci: export few functions
ANDROID: arm64: dts: db845c: Add clocks entry to display to track real clock inputs
ANDROID: arm64: dts: db845c: add Low speed expansion i2c and spi nodes
ANDROID: arm64: dts: qcom: sdm845-db845c: Bring in LT9611
ANDROID: arm64: dts: qcom: db845c: Enable PCIe controllers
ANDROID: arm64: dts: qcom: sdm845: Add second PCIe PHY and controller
ANDROID: arm64: dts: qcom: sdm845: Add first PCIe controller and PHY
ANDROID: arm64: dts/sdm845: Enable FW implemented safe sequence handler on MTP
ANDROID: drm/bridge: Introduce LT9611 DSI to HDMI bridge
FROMLIST: drm: msm: Quiet down plane errors in atomic_check
FROMLIST: reset: qcom-aoss: Allow CONFIG_RESET_QCOM_AOSS to be a tristate
FROMLIST: tty: serial: Kconfig: Allow SERIAL_QCOM_GENI_CONSOLE to be enabled if SERIAL_QCOM_GENI is a module
FROMLIST: lib/list_sort: fix function type mismatches
UPSTREAM: kcov: fix struct layout for kcov_remote_arg
docs: fs-verity: mention statx() support
f2fs: support STATX_ATTR_VERITY
ext4: support STATX_ATTR_VERITY
statx: define STATX_ATTR_VERITY
docs: fs-verity: document first supported kernel version
f2fs: add support for IV_INO_LBLK_64 encryption policies
ext4: add support for IV_INO_LBLK_64 encryption policies
fscrypt: add support for IV_INO_LBLK_64 policies
fscrypt: avoid data race on fscrypt_mode::logged_impl_name
fscrypt: zeroize fscrypt_info before freeing
fscrypt: remove struct fscrypt_ctx
fscrypt: invoke crypto API for ESSIV handling
null_blk: remove unused variable warning on !CONFIG_BLK_DEV_ZONED
block: set the zone size in blk_revalidate_disk_zones atomically
block: don't handle bio based drivers in blk_revalidate_disk_zones
null_blk: cleanup null_gendisk_register
null_blk: fix zone size paramter check
block: allocate the zone bitmaps lazily
block: replace seq_zones_bitmap with conv_zones_bitmap
block: simplify blkdev_nr_zones
block: remove the empty line at the end of blk-zoned.c
scsi: sd_zbc: Improve report zones error printout
scsi: sd_zbc: Remove set but not used variable 'buflen'
block: rework zone reporting
scsi: sd_zbc: Cleanup sd_zbc_alloc_report_buffer()
null_blk: clean up report zones
null_blk: clean up the block device operations
null_blk: return fixed zoned reads > write pointer
scsi: sd_zbc: add zone open, close, and finish support
block: Remove partition support for zoned block devices
block: Simplify report zones execution
block: cleanup the !zoned case in blk_revalidate_disk_zones
block: Enhance blk_revalidate_disk_zones()
block: add zone open, close and finish ioctl support
block: add zone open, close and finish operations
block: Simplify REQ_OP_ZONE_RESET_ALL handling
block: Remove REQ_OP_ZONE_RESET plugging
f2fs: stop GC when the victim becomes fully valid
f2fs: expose main_blkaddr in sysfs
f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project()
f2fs: Fix deadlock in f2fs_gc() context during atomic files handling
f2fs: show f2fs instance in printk_ratelimited
f2fs: fix potential overflow
f2fs: fix to update dir's i_pino during cross_rename
f2fs: support aligned pinned file
f2fs: avoid kernel panic on corruption test
f2fs: fix wrong description in document
f2fs: cache global IPU bio
f2fs: fix to avoid memory leakage in f2fs_listxattr
f2fs: check total_segments from devices in raw_super
f2fs: update multi-dev metadata in resize_fs
f2fs: mark recovery flag correctly in read_raw_super_block()
f2fs: fix to update time in lazytime mode
Conflicts:
Documentation/devicetree/bindings
Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml
Documentation/devicetree/bindings/net/snps,dwmac.yaml
Documentation/devicetree/bindings/reset/brcm,brcmstb-reset.txt
Documentation/devicetree/bindings/sound/mt8183-mt6358-ts3a227-max98357.txt
Makefile
block/keyslot-manager.c
drivers/clk/qcom/clk-rcg2.c
drivers/cpufreq/cpufreq.c
drivers/gpu/drm/drm_connector.c
drivers/hid/hid-quirks.c
drivers/iommu/Makefile
drivers/iommu/arm-smmu.c
drivers/iommu/iova.c
drivers/md/Kconfig
drivers/md/dm.c
drivers/scsi/ufs/ufs.h
drivers/scsi/ufs/ufs_quirks.h
drivers/scsi/ufs/ufshcd-crypto.c
drivers/scsi/ufs/unipro.h
drivers/staging/android/ion/heaps/Kconfig
drivers/staging/android/ion/heaps/Makefile
drivers/tty/serial/Kconfig
drivers/usb/dwc3/gadget.c
fs/crypto/keyring.c
fs/crypto/keysetup.c
include/linux/keyslot-manager.h
include/linux/perf_event.h
kernel/sched/fair.c
kernel/sched/rt.c
Added change 552546366a ("hugetlbfs: hugetlb_fault_mutex_hash()
cleanup") to fix build errors against mm/hugetlb.c
Extra updated files to fit properly imported content
into downstream:
arch/arm64/configs/vendor/genericarmv8-64_defconfig
arch/arm64/configs/vendor/lahaina_QGKI.config
arch/arm64/configs/vendor/lahaina_debug.config
drivers/android/binderfs.c
drivers/regulator/core.c
drivers/scsi/ufs/ufshcd-qti.c
drivers/staging/android/ion/heaps/ion_carveout_heap.c
drivers/staging/android/ion/heaps/msm_ion.c
drivers/usb/dwc3/host.c
drivers/scsi/ufs/ufshcd-crypto-qti.c
fs/hugetlbfs/inode.c
gen_headers_arm.bp
gen_headers_arm64.bp
include/linux/cpufreq.h
include/linux/hugetlb.h
include/uapi/linux/msm_ion.h
include/uapi/linux/msm_ion_ids.h
kernel/sched/cpufreq_schedutil.c
kernel/sched/fair.c
mm/hugetlb.c
mm/userfaultfd.c
Change-Id: I22295df9d7bca3fc7be9587e893cdd59128cc528
Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
5965 lines
144 KiB
C
5965 lines
144 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* SLUB: A slab allocator that limits cache line use instead of queuing
|
|
* objects in per cpu and per node lists.
|
|
*
|
|
* The allocator synchronizes using per slab locks or atomic operatios
|
|
* and only uses a centralized lock to manage a pool of partial slabs.
|
|
*
|
|
* (C) 2007 SGI, Christoph Lameter
|
|
* (C) 2011 Linux Foundation, Christoph Lameter
|
|
*/
|
|
|
|
#include <linux/mm.h>
|
|
#include <linux/swap.h> /* struct reclaim_state */
|
|
#include <linux/module.h>
|
|
#include <linux/bit_spinlock.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/slab.h>
|
|
#include "slab.h"
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/kasan.h>
|
|
#include <linux/cpu.h>
|
|
#include <linux/cpuset.h>
|
|
#include <linux/mempolicy.h>
|
|
#include <linux/ctype.h>
|
|
#include <linux/debugobjects.h>
|
|
#include <linux/kallsyms.h>
|
|
#include <linux/memory.h>
|
|
#include <linux/math64.h>
|
|
#include <linux/fault-inject.h>
|
|
#include <linux/stacktrace.h>
|
|
#include <linux/prefetch.h>
|
|
#include <linux/memcontrol.h>
|
|
#include <linux/random.h>
|
|
|
|
#include <trace/events/kmem.h>
|
|
|
|
#include "internal.h"
|
|
|
|
/*
|
|
* Lock order:
|
|
* 1. slab_mutex (Global Mutex)
|
|
* 2. node->list_lock
|
|
* 3. slab_lock(page) (Only on some arches and for debugging)
|
|
*
|
|
* slab_mutex
|
|
*
|
|
* The role of the slab_mutex is to protect the list of all the slabs
|
|
* and to synchronize major metadata changes to slab cache structures.
|
|
*
|
|
* The slab_lock is only used for debugging and on arches that do not
|
|
* have the ability to do a cmpxchg_double. It only protects:
|
|
* A. page->freelist -> List of object free in a page
|
|
* B. page->inuse -> Number of objects in use
|
|
* C. page->objects -> Number of objects in page
|
|
* D. page->frozen -> frozen state
|
|
*
|
|
* If a slab is frozen then it is exempt from list management. It is not
|
|
* on any list except per cpu partial list. The processor that froze the
|
|
* slab is the one who can perform list operations on the page. Other
|
|
* processors may put objects onto the freelist but the processor that
|
|
* froze the slab is the only one that can retrieve the objects from the
|
|
* page's freelist.
|
|
*
|
|
* The list_lock protects the partial and full list on each node and
|
|
* the partial slab counter. If taken then no new slabs may be added or
|
|
* removed from the lists nor make the number of partial slabs be modified.
|
|
* (Note that the total number of slabs is an atomic value that may be
|
|
* modified without taking the list lock).
|
|
*
|
|
* The list_lock is a centralized lock and thus we avoid taking it as
|
|
* much as possible. As long as SLUB does not have to handle partial
|
|
* slabs, operations can continue without any centralized lock. F.e.
|
|
* allocating a long series of objects that fill up slabs does not require
|
|
* the list lock.
|
|
* Interrupts are disabled during allocation and deallocation in order to
|
|
* make the slab allocator safe to use in the context of an irq. In addition
|
|
* interrupts are disabled to ensure that the processor does not change
|
|
* while handling per_cpu slabs, due to kernel preemption.
|
|
*
|
|
* SLUB assigns one slab for allocation to each processor.
|
|
* Allocations only occur from these slabs called cpu slabs.
|
|
*
|
|
* Slabs with free elements are kept on a partial list and during regular
|
|
* operations no list for full slabs is used. If an object in a full slab is
|
|
* freed then the slab will show up again on the partial lists.
|
|
* We track full slabs for debugging purposes though because otherwise we
|
|
* cannot scan all objects.
|
|
*
|
|
* Slabs are freed when they become empty. Teardown and setup is
|
|
* minimal so we rely on the page allocators per cpu caches for
|
|
* fast frees and allocs.
|
|
*
|
|
* Overloading of page flags that are otherwise used for LRU management.
|
|
*
|
|
* PageActive The slab is frozen and exempt from list processing.
|
|
* This means that the slab is dedicated to a purpose
|
|
* such as satisfying allocations for a specific
|
|
* processor. Objects may be freed in the slab while
|
|
* it is frozen but slab_free will then skip the usual
|
|
* list operations. It is up to the processor holding
|
|
* the slab to integrate the slab into the slab lists
|
|
* when the slab is no longer needed.
|
|
*
|
|
* One use of this flag is to mark slabs that are
|
|
* used for allocations. Then such a slab becomes a cpu
|
|
* slab. The cpu slab may be equipped with an additional
|
|
* freelist that allows lockless access to
|
|
* free objects in addition to the regular freelist
|
|
* that requires the slab lock.
|
|
*
|
|
* PageError Slab requires special handling due to debug
|
|
* options set. This moves slab handling out of
|
|
* the fast path and disables lockless freelists.
|
|
*/
|
|
|
|
static inline int kmem_cache_debug(struct kmem_cache *s)
|
|
{
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
return unlikely(s->flags & SLAB_DEBUG_FLAGS);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
void *fixup_red_left(struct kmem_cache *s, void *p)
|
|
{
|
|
if (kmem_cache_debug(s) && s->flags & SLAB_RED_ZONE)
|
|
p += s->red_left_pad;
|
|
|
|
return p;
|
|
}
|
|
|
|
static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s)
|
|
{
|
|
#ifdef CONFIG_SLUB_CPU_PARTIAL
|
|
return !kmem_cache_debug(s);
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
* Issues still to be resolved:
|
|
*
|
|
* - Support PAGE_ALLOC_DEBUG. Should be easy to do.
|
|
*
|
|
* - Variable sizing of the per node arrays
|
|
*/
|
|
|
|
/* Enable to test recovery from slab corruption on boot */
|
|
#undef SLUB_RESILIENCY_TEST
|
|
|
|
/* Enable to log cmpxchg failures */
|
|
#undef SLUB_DEBUG_CMPXCHG
|
|
|
|
/*
|
|
* Mininum number of partial slabs. These will be left on the partial
|
|
* lists even if they are empty. kmem_cache_shrink may reclaim them.
|
|
*/
|
|
#define MIN_PARTIAL 5
|
|
|
|
/*
|
|
* Maximum number of desirable partial slabs.
|
|
* The existence of more partial slabs makes kmem_cache_shrink
|
|
* sort the partial list by the number of objects in use.
|
|
*/
|
|
#define MAX_PARTIAL 10
|
|
|
|
#define DEBUG_DEFAULT_FLAGS (SLAB_CONSISTENCY_CHECKS | SLAB_RED_ZONE | \
|
|
SLAB_POISON | SLAB_STORE_USER)
|
|
|
|
/*
|
|
* These debug flags cannot use CMPXCHG because there might be consistency
|
|
* issues when checking or reading debug information
|
|
*/
|
|
#define SLAB_NO_CMPXCHG (SLAB_CONSISTENCY_CHECKS | SLAB_STORE_USER | \
|
|
SLAB_TRACE)
|
|
|
|
|
|
/*
|
|
* Debugging flags that require metadata to be stored in the slab. These get
|
|
* disabled when slub_debug=O is used and a cache's min order increases with
|
|
* metadata.
|
|
*/
|
|
#define DEBUG_METADATA_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
|
|
|
|
#define OO_SHIFT 16
|
|
#define OO_MASK ((1 << OO_SHIFT) - 1)
|
|
#define MAX_OBJS_PER_PAGE 32767 /* since page.objects is u15 */
|
|
|
|
/* Internal SLUB flags */
|
|
/* Poison object */
|
|
#define __OBJECT_POISON ((slab_flags_t __force)0x80000000U)
|
|
/* Use cmpxchg_double */
|
|
#define __CMPXCHG_DOUBLE ((slab_flags_t __force)0x40000000U)
|
|
|
|
/*
|
|
* Tracking user of a slab.
|
|
*/
|
|
#define TRACK_ADDRS_COUNT 16
|
|
struct track {
|
|
unsigned long addr; /* Called from address */
|
|
#ifdef CONFIG_STACKTRACE
|
|
unsigned long addrs[TRACK_ADDRS_COUNT]; /* Called from address */
|
|
#endif
|
|
int cpu; /* Was running on cpu */
|
|
int pid; /* Pid context */
|
|
unsigned long when; /* When did the operation occur */
|
|
};
|
|
|
|
enum track_item { TRACK_ALLOC, TRACK_FREE };
|
|
|
|
#ifdef CONFIG_SYSFS
|
|
static int sysfs_slab_add(struct kmem_cache *);
|
|
static int sysfs_slab_alias(struct kmem_cache *, const char *);
|
|
static void memcg_propagate_slab_attrs(struct kmem_cache *s);
|
|
static void sysfs_slab_remove(struct kmem_cache *s);
|
|
#else
|
|
static inline int sysfs_slab_add(struct kmem_cache *s) { return 0; }
|
|
static inline int sysfs_slab_alias(struct kmem_cache *s, const char *p)
|
|
{ return 0; }
|
|
static inline void memcg_propagate_slab_attrs(struct kmem_cache *s) { }
|
|
static inline void sysfs_slab_remove(struct kmem_cache *s) { }
|
|
#endif
|
|
|
|
static inline void stat(const struct kmem_cache *s, enum stat_item si)
|
|
{
|
|
#ifdef CONFIG_SLUB_STATS
|
|
/*
|
|
* The rmw is racy on a preemptible kernel but this is acceptable, so
|
|
* avoid this_cpu_add()'s irq-disable overhead.
|
|
*/
|
|
raw_cpu_inc(s->cpu_slab->stat[si]);
|
|
#endif
|
|
}
|
|
|
|
/********************************************************************
|
|
* Core slab cache functions
|
|
*******************************************************************/
|
|
|
|
/*
|
|
* Returns freelist pointer (ptr). With hardening, this is obfuscated
|
|
* with an XOR of the address where the pointer is held and a per-cache
|
|
* random number.
|
|
*/
|
|
static inline void *freelist_ptr(const struct kmem_cache *s, void *ptr,
|
|
unsigned long ptr_addr)
|
|
{
|
|
#ifdef CONFIG_SLAB_FREELIST_HARDENED
|
|
/*
|
|
* When CONFIG_KASAN_SW_TAGS is enabled, ptr_addr might be tagged.
|
|
* Normally, this doesn't cause any issues, as both set_freepointer()
|
|
* and get_freepointer() are called with a pointer with the same tag.
|
|
* However, there are some issues with CONFIG_SLUB_DEBUG code. For
|
|
* example, when __free_slub() iterates over objects in a cache, it
|
|
* passes untagged pointers to check_object(). check_object() in turns
|
|
* calls get_freepointer() with an untagged pointer, which causes the
|
|
* freepointer to be restored incorrectly.
|
|
*/
|
|
return (void *)((unsigned long)ptr ^ s->random ^
|
|
(unsigned long)kasan_reset_tag((void *)ptr_addr));
|
|
#else
|
|
return ptr;
|
|
#endif
|
|
}
|
|
|
|
/* Returns the freelist pointer recorded at location ptr_addr. */
|
|
static inline void *freelist_dereference(const struct kmem_cache *s,
|
|
void *ptr_addr)
|
|
{
|
|
return freelist_ptr(s, (void *)*(unsigned long *)(ptr_addr),
|
|
(unsigned long)ptr_addr);
|
|
}
|
|
|
|
static inline void *get_freepointer(struct kmem_cache *s, void *object)
|
|
{
|
|
return freelist_dereference(s, object + s->offset);
|
|
}
|
|
|
|
static void prefetch_freepointer(const struct kmem_cache *s, void *object)
|
|
{
|
|
prefetch(object + s->offset);
|
|
}
|
|
|
|
static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)
|
|
{
|
|
unsigned long freepointer_addr;
|
|
void *p;
|
|
|
|
if (!debug_pagealloc_enabled_static())
|
|
return get_freepointer(s, object);
|
|
|
|
freepointer_addr = (unsigned long)object + s->offset;
|
|
probe_kernel_read(&p, (void **)freepointer_addr, sizeof(p));
|
|
return freelist_ptr(s, p, freepointer_addr);
|
|
}
|
|
|
|
static inline void set_freepointer(struct kmem_cache *s, void *object, void *fp)
|
|
{
|
|
unsigned long freeptr_addr = (unsigned long)object + s->offset;
|
|
|
|
#ifdef CONFIG_SLAB_FREELIST_HARDENED
|
|
BUG_ON(object == fp); /* naive detection of double free or corruption */
|
|
#endif
|
|
|
|
*(void **)freeptr_addr = freelist_ptr(s, fp, freeptr_addr);
|
|
}
|
|
|
|
/* Loop over all objects in a slab */
|
|
#define for_each_object(__p, __s, __addr, __objects) \
|
|
for (__p = fixup_red_left(__s, __addr); \
|
|
__p < (__addr) + (__objects) * (__s)->size; \
|
|
__p += (__s)->size)
|
|
|
|
/* Determine object index from a given position */
|
|
static inline unsigned int slab_index(void *p, struct kmem_cache *s, void *addr)
|
|
{
|
|
return (kasan_reset_tag(p) - addr) / s->size;
|
|
}
|
|
|
|
static inline unsigned int order_objects(unsigned int order, unsigned int size)
|
|
{
|
|
return ((unsigned int)PAGE_SIZE << order) / size;
|
|
}
|
|
|
|
static inline struct kmem_cache_order_objects oo_make(unsigned int order,
|
|
unsigned int size)
|
|
{
|
|
struct kmem_cache_order_objects x = {
|
|
(order << OO_SHIFT) + order_objects(order, size)
|
|
};
|
|
|
|
return x;
|
|
}
|
|
|
|
static inline unsigned int oo_order(struct kmem_cache_order_objects x)
|
|
{
|
|
return x.x >> OO_SHIFT;
|
|
}
|
|
|
|
static inline unsigned int oo_objects(struct kmem_cache_order_objects x)
|
|
{
|
|
return x.x & OO_MASK;
|
|
}
|
|
|
|
/*
|
|
* Per slab locking using the pagelock
|
|
*/
|
|
static __always_inline void slab_lock(struct page *page)
|
|
{
|
|
VM_BUG_ON_PAGE(PageTail(page), page);
|
|
bit_spin_lock(PG_locked, &page->flags);
|
|
}
|
|
|
|
static __always_inline void slab_unlock(struct page *page)
|
|
{
|
|
VM_BUG_ON_PAGE(PageTail(page), page);
|
|
__bit_spin_unlock(PG_locked, &page->flags);
|
|
}
|
|
|
|
/* Interrupts must be disabled (for the fallback code to work right) */
|
|
static inline bool __cmpxchg_double_slab(struct kmem_cache *s, struct page *page,
|
|
void *freelist_old, unsigned long counters_old,
|
|
void *freelist_new, unsigned long counters_new,
|
|
const char *n)
|
|
{
|
|
VM_BUG_ON(!irqs_disabled());
|
|
#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \
|
|
defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
|
|
if (s->flags & __CMPXCHG_DOUBLE) {
|
|
if (cmpxchg_double(&page->freelist, &page->counters,
|
|
freelist_old, counters_old,
|
|
freelist_new, counters_new))
|
|
return true;
|
|
} else
|
|
#endif
|
|
{
|
|
slab_lock(page);
|
|
if (page->freelist == freelist_old &&
|
|
page->counters == counters_old) {
|
|
page->freelist = freelist_new;
|
|
page->counters = counters_new;
|
|
slab_unlock(page);
|
|
return true;
|
|
}
|
|
slab_unlock(page);
|
|
}
|
|
|
|
cpu_relax();
|
|
stat(s, CMPXCHG_DOUBLE_FAIL);
|
|
|
|
#ifdef SLUB_DEBUG_CMPXCHG
|
|
pr_info("%s %s: cmpxchg double redo ", n, s->name);
|
|
#endif
|
|
|
|
return false;
|
|
}
|
|
|
|
static inline bool cmpxchg_double_slab(struct kmem_cache *s, struct page *page,
|
|
void *freelist_old, unsigned long counters_old,
|
|
void *freelist_new, unsigned long counters_new,
|
|
const char *n)
|
|
{
|
|
#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \
|
|
defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
|
|
if (s->flags & __CMPXCHG_DOUBLE) {
|
|
if (cmpxchg_double(&page->freelist, &page->counters,
|
|
freelist_old, counters_old,
|
|
freelist_new, counters_new))
|
|
return true;
|
|
} else
|
|
#endif
|
|
{
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
slab_lock(page);
|
|
if (page->freelist == freelist_old &&
|
|
page->counters == counters_old) {
|
|
page->freelist = freelist_new;
|
|
page->counters = counters_new;
|
|
slab_unlock(page);
|
|
local_irq_restore(flags);
|
|
return true;
|
|
}
|
|
slab_unlock(page);
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
cpu_relax();
|
|
stat(s, CMPXCHG_DOUBLE_FAIL);
|
|
|
|
#ifdef SLUB_DEBUG_CMPXCHG
|
|
pr_info("%s %s: cmpxchg double redo ", n, s->name);
|
|
#endif
|
|
|
|
return false;
|
|
}
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
/*
|
|
* Determine a map of object in use on a page.
|
|
*
|
|
* Node listlock must be held to guarantee that the page does
|
|
* not vanish from under us.
|
|
*/
|
|
static void get_map(struct kmem_cache *s, struct page *page, unsigned long *map)
|
|
{
|
|
void *p;
|
|
void *addr = page_address(page);
|
|
|
|
for (p = page->freelist; p; p = get_freepointer(s, p))
|
|
set_bit(slab_index(p, s, addr), map);
|
|
}
|
|
|
|
static inline unsigned int size_from_object(struct kmem_cache *s)
|
|
{
|
|
if (s->flags & SLAB_RED_ZONE)
|
|
return s->size - s->red_left_pad;
|
|
|
|
return s->size;
|
|
}
|
|
|
|
static inline void *restore_red_left(struct kmem_cache *s, void *p)
|
|
{
|
|
if (s->flags & SLAB_RED_ZONE)
|
|
p -= s->red_left_pad;
|
|
|
|
return p;
|
|
}
|
|
|
|
/*
|
|
* Debug settings:
|
|
*/
|
|
#if defined(CONFIG_SLUB_DEBUG_ON)
|
|
static slab_flags_t slub_debug = DEBUG_DEFAULT_FLAGS;
|
|
#else
|
|
static slab_flags_t slub_debug;
|
|
#endif
|
|
|
|
static char *slub_debug_slabs;
|
|
static int disable_higher_order_debug;
|
|
|
|
/*
|
|
* slub is about to manipulate internal object metadata. This memory lies
|
|
* outside the range of the allocated object, so accessing it would normally
|
|
* be reported by kasan as a bounds error. metadata_access_enable() is used
|
|
* to tell kasan that these accesses are OK.
|
|
*/
|
|
static inline void metadata_access_enable(void)
|
|
{
|
|
kasan_disable_current();
|
|
}
|
|
|
|
static inline void metadata_access_disable(void)
|
|
{
|
|
kasan_enable_current();
|
|
}
|
|
|
|
/*
|
|
* Object debugging
|
|
*/
|
|
|
|
/* Verify that a pointer has an address that is valid within a slab page */
|
|
static inline int check_valid_pointer(struct kmem_cache *s,
|
|
struct page *page, void *object)
|
|
{
|
|
void *base;
|
|
|
|
if (!object)
|
|
return 1;
|
|
|
|
base = page_address(page);
|
|
object = kasan_reset_tag(object);
|
|
object = restore_red_left(s, object);
|
|
if (object < base || object >= base + page->objects * s->size ||
|
|
(object - base) % s->size) {
|
|
return 0;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
static void print_section(char *level, char *text, u8 *addr,
|
|
unsigned int length)
|
|
{
|
|
metadata_access_enable();
|
|
print_hex_dump(level, text, DUMP_PREFIX_ADDRESS, 16, 1, addr,
|
|
length, 1);
|
|
metadata_access_disable();
|
|
}
|
|
|
|
static struct track *get_track(struct kmem_cache *s, void *object,
|
|
enum track_item alloc)
|
|
{
|
|
struct track *p;
|
|
|
|
if (s->offset)
|
|
p = object + s->offset + sizeof(void *);
|
|
else
|
|
p = object + s->inuse;
|
|
|
|
return p + alloc;
|
|
}
|
|
|
|
static void set_track(struct kmem_cache *s, void *object,
|
|
enum track_item alloc, unsigned long addr)
|
|
{
|
|
struct track *p = get_track(s, object, alloc);
|
|
|
|
if (addr) {
|
|
#ifdef CONFIG_STACKTRACE
|
|
unsigned int nr_entries;
|
|
|
|
metadata_access_enable();
|
|
nr_entries = stack_trace_save(p->addrs, TRACK_ADDRS_COUNT, 3);
|
|
metadata_access_disable();
|
|
|
|
if (nr_entries < TRACK_ADDRS_COUNT)
|
|
p->addrs[nr_entries] = 0;
|
|
#endif
|
|
p->addr = addr;
|
|
p->cpu = smp_processor_id();
|
|
p->pid = current->pid;
|
|
p->when = jiffies;
|
|
} else {
|
|
memset(p, 0, sizeof(struct track));
|
|
}
|
|
}
|
|
|
|
static void init_tracking(struct kmem_cache *s, void *object)
|
|
{
|
|
if (!(s->flags & SLAB_STORE_USER))
|
|
return;
|
|
|
|
set_track(s, object, TRACK_FREE, 0UL);
|
|
set_track(s, object, TRACK_ALLOC, 0UL);
|
|
}
|
|
|
|
static void print_track(const char *s, struct track *t, unsigned long pr_time)
|
|
{
|
|
if (!t->addr)
|
|
return;
|
|
|
|
pr_err("INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
|
|
s, (void *)t->addr, pr_time - t->when, t->cpu, t->pid);
|
|
#ifdef CONFIG_STACKTRACE
|
|
{
|
|
int i;
|
|
for (i = 0; i < TRACK_ADDRS_COUNT; i++)
|
|
if (t->addrs[i])
|
|
pr_err("\t%pS\n", (void *)t->addrs[i]);
|
|
else
|
|
break;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
static void print_tracking(struct kmem_cache *s, void *object)
|
|
{
|
|
unsigned long pr_time = jiffies;
|
|
if (!(s->flags & SLAB_STORE_USER))
|
|
return;
|
|
|
|
print_track("Allocated", get_track(s, object, TRACK_ALLOC), pr_time);
|
|
print_track("Freed", get_track(s, object, TRACK_FREE), pr_time);
|
|
}
|
|
|
|
static void print_page_info(struct page *page)
|
|
{
|
|
pr_err("INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n",
|
|
page, page->objects, page->inuse, page->freelist, page->flags);
|
|
|
|
}
|
|
|
|
static void slab_bug(struct kmem_cache *s, char *fmt, ...)
|
|
{
|
|
struct va_format vaf;
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
vaf.fmt = fmt;
|
|
vaf.va = &args;
|
|
pr_err("=============================================================================\n");
|
|
pr_err("BUG %s (%s): %pV\n", s->name, print_tainted(), &vaf);
|
|
pr_err("-----------------------------------------------------------------------------\n\n");
|
|
|
|
add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
|
|
va_end(args);
|
|
}
|
|
|
|
static void slab_fix(struct kmem_cache *s, char *fmt, ...)
|
|
{
|
|
struct va_format vaf;
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
vaf.fmt = fmt;
|
|
vaf.va = &args;
|
|
pr_err("FIX %s: %pV\n", s->name, &vaf);
|
|
va_end(args);
|
|
}
|
|
|
|
static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
|
|
{
|
|
unsigned int off; /* Offset of last byte */
|
|
u8 *addr = page_address(page);
|
|
|
|
print_tracking(s, p);
|
|
|
|
print_page_info(page);
|
|
|
|
pr_err("INFO: Object 0x%p @offset=%tu fp=0x%p\n\n",
|
|
p, p - addr, get_freepointer(s, p));
|
|
|
|
if (s->flags & SLAB_RED_ZONE)
|
|
print_section(KERN_ERR, "Redzone ", p - s->red_left_pad,
|
|
s->red_left_pad);
|
|
else if (p > addr + 16)
|
|
print_section(KERN_ERR, "Bytes b4 ", p - 16, 16);
|
|
|
|
print_section(KERN_ERR, "Object ", p,
|
|
min_t(unsigned int, s->object_size, PAGE_SIZE));
|
|
if (s->flags & SLAB_RED_ZONE)
|
|
print_section(KERN_ERR, "Redzone ", p + s->object_size,
|
|
s->inuse - s->object_size);
|
|
|
|
if (s->offset)
|
|
off = s->offset + sizeof(void *);
|
|
else
|
|
off = s->inuse;
|
|
|
|
if (s->flags & SLAB_STORE_USER)
|
|
off += 2 * sizeof(struct track);
|
|
|
|
off += kasan_metadata_size(s);
|
|
|
|
if (off != size_from_object(s))
|
|
/* Beginning of the filler is the free pointer */
|
|
print_section(KERN_ERR, "Padding ", p + off,
|
|
size_from_object(s) - off);
|
|
|
|
dump_stack();
|
|
}
|
|
|
|
static void slab_panic(const char *cause)
|
|
{
|
|
if (IS_ENABLED(CONFIG_SLUB_DEBUG_PANIC_ON))
|
|
panic("%s\n", cause);
|
|
}
|
|
|
|
void object_err(struct kmem_cache *s, struct page *page,
|
|
u8 *object, char *reason)
|
|
{
|
|
slab_bug(s, "%s", reason);
|
|
print_trailer(s, page, object);
|
|
slab_panic(reason);
|
|
}
|
|
|
|
static __printf(3, 4) void slab_err(struct kmem_cache *s, struct page *page,
|
|
const char *fmt, ...)
|
|
{
|
|
va_list args;
|
|
char buf[100];
|
|
|
|
va_start(args, fmt);
|
|
vsnprintf(buf, sizeof(buf), fmt, args);
|
|
va_end(args);
|
|
slab_bug(s, "%s", buf);
|
|
print_page_info(page);
|
|
dump_stack();
|
|
slab_panic("slab error");
|
|
}
|
|
|
|
static void init_object(struct kmem_cache *s, void *object, u8 val)
|
|
{
|
|
u8 *p = object;
|
|
|
|
if (s->flags & SLAB_RED_ZONE)
|
|
memset(p - s->red_left_pad, val, s->red_left_pad);
|
|
|
|
if (s->flags & __OBJECT_POISON) {
|
|
memset(p, POISON_FREE, s->object_size - 1);
|
|
p[s->object_size - 1] = POISON_END;
|
|
}
|
|
|
|
if (s->flags & SLAB_RED_ZONE)
|
|
memset(p + s->object_size, val, s->inuse - s->object_size);
|
|
}
|
|
|
|
static void restore_bytes(struct kmem_cache *s, char *message, u8 data,
|
|
void *from, void *to)
|
|
{
|
|
slab_panic("object poison overwritten");
|
|
slab_fix(s, "Restoring 0x%p-0x%p=0x%x\n", from, to - 1, data);
|
|
memset(from, data, to - from);
|
|
}
|
|
|
|
static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
|
|
u8 *object, char *what,
|
|
u8 *start, unsigned int value, unsigned int bytes)
|
|
{
|
|
u8 *fault;
|
|
u8 *end;
|
|
|
|
metadata_access_enable();
|
|
fault = memchr_inv(start, value, bytes);
|
|
metadata_access_disable();
|
|
if (!fault)
|
|
return 1;
|
|
|
|
end = start + bytes;
|
|
while (end > fault && end[-1] == value)
|
|
end--;
|
|
|
|
slab_bug(s, "%s overwritten", what);
|
|
pr_err("INFO: 0x%p-0x%p. First byte 0x%x instead of 0x%x\n",
|
|
fault, end - 1, fault[0], value);
|
|
print_trailer(s, page, object);
|
|
|
|
restore_bytes(s, what, value, fault, end);
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Object layout:
|
|
*
|
|
* object address
|
|
* Bytes of the object to be managed.
|
|
* If the freepointer may overlay the object then the free
|
|
* pointer is the first word of the object.
|
|
*
|
|
* Poisoning uses 0x6b (POISON_FREE) and the last byte is
|
|
* 0xa5 (POISON_END)
|
|
*
|
|
* object + s->object_size
|
|
* Padding to reach word boundary. This is also used for Redzoning.
|
|
* Padding is extended by another word if Redzoning is enabled and
|
|
* object_size == inuse.
|
|
*
|
|
* We fill with 0xbb (RED_INACTIVE) for inactive objects and with
|
|
* 0xcc (RED_ACTIVE) for objects in use.
|
|
*
|
|
* object + s->inuse
|
|
* Meta data starts here.
|
|
*
|
|
* A. Free pointer (if we cannot overwrite object on free)
|
|
* B. Tracking data for SLAB_STORE_USER
|
|
* C. Padding to reach required alignment boundary or at mininum
|
|
* one word if debugging is on to be able to detect writes
|
|
* before the word boundary.
|
|
*
|
|
* Padding is done using 0x5a (POISON_INUSE)
|
|
*
|
|
* object + s->size
|
|
* Nothing is used beyond s->size.
|
|
*
|
|
* If slabcaches are merged then the object_size and inuse boundaries are mostly
|
|
* ignored. And therefore no slab options that rely on these boundaries
|
|
* may be used with merged slabcaches.
|
|
*/
|
|
|
|
static int check_pad_bytes(struct kmem_cache *s, struct page *page, u8 *p)
|
|
{
|
|
unsigned long off = s->inuse; /* The end of info */
|
|
|
|
if (s->offset)
|
|
/* Freepointer is placed after the object. */
|
|
off += sizeof(void *);
|
|
|
|
if (s->flags & SLAB_STORE_USER)
|
|
/* We also have user information there */
|
|
off += 2 * sizeof(struct track);
|
|
|
|
off += kasan_metadata_size(s);
|
|
|
|
if (size_from_object(s) == off)
|
|
return 1;
|
|
|
|
return check_bytes_and_report(s, page, p, "Object padding",
|
|
p + off, POISON_INUSE, size_from_object(s) - off);
|
|
}
|
|
|
|
/* Check the pad bytes at the end of a slab page */
|
|
static int slab_pad_check(struct kmem_cache *s, struct page *page)
|
|
{
|
|
u8 *start;
|
|
u8 *fault;
|
|
u8 *end;
|
|
u8 *pad;
|
|
int length;
|
|
int remainder;
|
|
|
|
if (!(s->flags & SLAB_POISON))
|
|
return 1;
|
|
|
|
start = page_address(page);
|
|
length = page_size(page);
|
|
end = start + length;
|
|
remainder = length % s->size;
|
|
if (!remainder)
|
|
return 1;
|
|
|
|
pad = end - remainder;
|
|
metadata_access_enable();
|
|
fault = memchr_inv(pad, POISON_INUSE, remainder);
|
|
metadata_access_disable();
|
|
if (!fault)
|
|
return 1;
|
|
while (end > fault && end[-1] == POISON_INUSE)
|
|
end--;
|
|
|
|
slab_err(s, page, "Padding overwritten. 0x%p-0x%p", fault, end - 1);
|
|
print_section(KERN_ERR, "Padding ", pad, remainder);
|
|
|
|
restore_bytes(s, "slab padding", POISON_INUSE, fault, end);
|
|
return 0;
|
|
}
|
|
|
|
static int check_object(struct kmem_cache *s, struct page *page,
|
|
void *object, u8 val)
|
|
{
|
|
u8 *p = object;
|
|
u8 *endobject = object + s->object_size;
|
|
|
|
if (s->flags & SLAB_RED_ZONE) {
|
|
if (!check_bytes_and_report(s, page, object, "Redzone",
|
|
object - s->red_left_pad, val, s->red_left_pad))
|
|
return 0;
|
|
|
|
if (!check_bytes_and_report(s, page, object, "Redzone",
|
|
endobject, val, s->inuse - s->object_size))
|
|
return 0;
|
|
} else {
|
|
if ((s->flags & SLAB_POISON) && s->object_size < s->inuse) {
|
|
check_bytes_and_report(s, page, p, "Alignment padding",
|
|
endobject, POISON_INUSE,
|
|
s->inuse - s->object_size);
|
|
}
|
|
}
|
|
|
|
if (s->flags & SLAB_POISON) {
|
|
if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) &&
|
|
(!check_bytes_and_report(s, page, p, "Poison", p,
|
|
POISON_FREE, s->object_size - 1) ||
|
|
!check_bytes_and_report(s, page, p, "Poison",
|
|
p + s->object_size - 1, POISON_END, 1)))
|
|
return 0;
|
|
/*
|
|
* check_pad_bytes cleans up on its own.
|
|
*/
|
|
check_pad_bytes(s, page, p);
|
|
}
|
|
|
|
if (!s->offset && val == SLUB_RED_ACTIVE)
|
|
/*
|
|
* Object and freepointer overlap. Cannot check
|
|
* freepointer while object is allocated.
|
|
*/
|
|
return 1;
|
|
|
|
/* Check free pointer validity */
|
|
if (!check_valid_pointer(s, page, get_freepointer(s, p))) {
|
|
object_err(s, page, p, "Freepointer corrupt");
|
|
/*
|
|
* No choice but to zap it and thus lose the remainder
|
|
* of the free objects in this slab. May cause
|
|
* another error because the object count is now wrong.
|
|
*/
|
|
set_freepointer(s, p, NULL);
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static int check_slab(struct kmem_cache *s, struct page *page)
|
|
{
|
|
int maxobj;
|
|
|
|
VM_BUG_ON(!irqs_disabled());
|
|
|
|
if (!PageSlab(page)) {
|
|
slab_err(s, page, "Not a valid slab page");
|
|
return 0;
|
|
}
|
|
|
|
maxobj = order_objects(compound_order(page), s->size);
|
|
if (page->objects > maxobj) {
|
|
slab_err(s, page, "objects %u > max %u",
|
|
page->objects, maxobj);
|
|
return 0;
|
|
}
|
|
if (page->inuse > page->objects) {
|
|
slab_err(s, page, "inuse %u > max %u",
|
|
page->inuse, page->objects);
|
|
return 0;
|
|
}
|
|
/* Slab_pad_check fixes things up after itself */
|
|
slab_pad_check(s, page);
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* Determine if a certain object on a page is on the freelist. Must hold the
|
|
* slab lock to guarantee that the chains are in a consistent state.
|
|
*/
|
|
static int on_freelist(struct kmem_cache *s, struct page *page, void *search)
|
|
{
|
|
int nr = 0;
|
|
void *fp;
|
|
void *object = NULL;
|
|
int max_objects;
|
|
|
|
fp = page->freelist;
|
|
while (fp && nr <= page->objects) {
|
|
if (fp == search)
|
|
return 1;
|
|
if (!check_valid_pointer(s, page, fp)) {
|
|
if (object) {
|
|
object_err(s, page, object,
|
|
"Freechain corrupt");
|
|
set_freepointer(s, object, NULL);
|
|
} else {
|
|
slab_err(s, page, "Freepointer corrupt");
|
|
page->freelist = NULL;
|
|
page->inuse = page->objects;
|
|
slab_fix(s, "Freelist cleared");
|
|
return 0;
|
|
}
|
|
break;
|
|
}
|
|
object = fp;
|
|
fp = get_freepointer(s, object);
|
|
nr++;
|
|
}
|
|
|
|
max_objects = order_objects(compound_order(page), s->size);
|
|
if (max_objects > MAX_OBJS_PER_PAGE)
|
|
max_objects = MAX_OBJS_PER_PAGE;
|
|
|
|
if (page->objects != max_objects) {
|
|
slab_err(s, page, "Wrong number of objects. Found %d but should be %d",
|
|
page->objects, max_objects);
|
|
page->objects = max_objects;
|
|
slab_fix(s, "Number of objects adjusted.");
|
|
}
|
|
if (page->inuse != page->objects - nr) {
|
|
slab_err(s, page, "Wrong object count. Counter is %d but counted were %d",
|
|
page->inuse, page->objects - nr);
|
|
page->inuse = page->objects - nr;
|
|
slab_fix(s, "Object count adjusted.");
|
|
}
|
|
return search == NULL;
|
|
}
|
|
|
|
static void trace(struct kmem_cache *s, struct page *page, void *object,
|
|
int alloc)
|
|
{
|
|
if (s->flags & SLAB_TRACE) {
|
|
pr_info("TRACE %s %s 0x%p inuse=%d fp=0x%p\n",
|
|
s->name,
|
|
alloc ? "alloc" : "free",
|
|
object, page->inuse,
|
|
page->freelist);
|
|
|
|
if (!alloc)
|
|
print_section(KERN_INFO, "Object ", (void *)object,
|
|
s->object_size);
|
|
|
|
dump_stack();
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Tracking of fully allocated slabs for debugging purposes.
|
|
*/
|
|
static void add_full(struct kmem_cache *s,
|
|
struct kmem_cache_node *n, struct page *page)
|
|
{
|
|
if (!(s->flags & SLAB_STORE_USER))
|
|
return;
|
|
|
|
lockdep_assert_held(&n->list_lock);
|
|
list_add(&page->slab_list, &n->full);
|
|
}
|
|
|
|
static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page)
|
|
{
|
|
if (!(s->flags & SLAB_STORE_USER))
|
|
return;
|
|
|
|
lockdep_assert_held(&n->list_lock);
|
|
list_del(&page->slab_list);
|
|
}
|
|
|
|
/* Tracking of the number of slabs for debugging purposes */
|
|
static inline unsigned long slabs_node(struct kmem_cache *s, int node)
|
|
{
|
|
struct kmem_cache_node *n = get_node(s, node);
|
|
|
|
return atomic_long_read(&n->nr_slabs);
|
|
}
|
|
|
|
static inline unsigned long node_nr_slabs(struct kmem_cache_node *n)
|
|
{
|
|
return atomic_long_read(&n->nr_slabs);
|
|
}
|
|
|
|
static inline void inc_slabs_node(struct kmem_cache *s, int node, int objects)
|
|
{
|
|
struct kmem_cache_node *n = get_node(s, node);
|
|
|
|
/*
|
|
* May be called early in order to allocate a slab for the
|
|
* kmem_cache_node structure. Solve the chicken-egg
|
|
* dilemma by deferring the increment of the count during
|
|
* bootstrap (see early_kmem_cache_node_alloc).
|
|
*/
|
|
if (likely(n)) {
|
|
atomic_long_inc(&n->nr_slabs);
|
|
atomic_long_add(objects, &n->total_objects);
|
|
}
|
|
}
|
|
static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects)
|
|
{
|
|
struct kmem_cache_node *n = get_node(s, node);
|
|
|
|
atomic_long_dec(&n->nr_slabs);
|
|
atomic_long_sub(objects, &n->total_objects);
|
|
}
|
|
|
|
/* Object debug checks for alloc/free paths */
|
|
static void setup_object_debug(struct kmem_cache *s, struct page *page,
|
|
void *object)
|
|
{
|
|
if (!(s->flags & (SLAB_STORE_USER|SLAB_RED_ZONE|__OBJECT_POISON)))
|
|
return;
|
|
|
|
init_object(s, object, SLUB_RED_INACTIVE);
|
|
init_tracking(s, object);
|
|
}
|
|
|
|
static
|
|
void setup_page_debug(struct kmem_cache *s, struct page *page, void *addr)
|
|
{
|
|
if (!(s->flags & SLAB_POISON))
|
|
return;
|
|
|
|
metadata_access_enable();
|
|
memset(addr, POISON_INUSE, page_size(page));
|
|
metadata_access_disable();
|
|
}
|
|
|
|
static inline int alloc_consistency_checks(struct kmem_cache *s,
|
|
struct page *page, void *object)
|
|
{
|
|
if (!check_slab(s, page))
|
|
return 0;
|
|
|
|
if (!check_valid_pointer(s, page, object)) {
|
|
object_err(s, page, object, "Freelist Pointer check fails");
|
|
return 0;
|
|
}
|
|
|
|
if (!check_object(s, page, object, SLUB_RED_INACTIVE))
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
static noinline int alloc_debug_processing(struct kmem_cache *s,
|
|
struct page *page,
|
|
void *object, unsigned long addr)
|
|
{
|
|
if (s->flags & SLAB_CONSISTENCY_CHECKS) {
|
|
if (!alloc_consistency_checks(s, page, object))
|
|
goto bad;
|
|
}
|
|
|
|
/* Success perform special debug activities for allocs */
|
|
if (s->flags & SLAB_STORE_USER)
|
|
set_track(s, object, TRACK_ALLOC, addr);
|
|
trace(s, page, object, 1);
|
|
init_object(s, object, SLUB_RED_ACTIVE);
|
|
return 1;
|
|
|
|
bad:
|
|
if (PageSlab(page)) {
|
|
/*
|
|
* If this is a slab page then lets do the best we can
|
|
* to avoid issues in the future. Marking all objects
|
|
* as used avoids touching the remaining objects.
|
|
*/
|
|
slab_fix(s, "Marking all objects used");
|
|
page->inuse = page->objects;
|
|
page->freelist = NULL;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static inline int free_consistency_checks(struct kmem_cache *s,
|
|
struct page *page, void *object, unsigned long addr)
|
|
{
|
|
if (!check_valid_pointer(s, page, object)) {
|
|
slab_err(s, page, "Invalid object pointer 0x%p", object);
|
|
return 0;
|
|
}
|
|
|
|
if (on_freelist(s, page, object)) {
|
|
object_err(s, page, object, "Object already free");
|
|
return 0;
|
|
}
|
|
|
|
if (!check_object(s, page, object, SLUB_RED_ACTIVE))
|
|
return 0;
|
|
|
|
if (unlikely(s != page->slab_cache)) {
|
|
if (!PageSlab(page)) {
|
|
slab_err(s, page, "Attempt to free object(0x%p) outside of slab",
|
|
object);
|
|
} else if (!page->slab_cache) {
|
|
pr_err("SLUB <none>: no slab for object 0x%p.\n",
|
|
object);
|
|
dump_stack();
|
|
} else
|
|
object_err(s, page, object,
|
|
"page slab pointer corrupt.");
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
/* Supports checking bulk free of a constructed freelist */
|
|
static noinline int free_debug_processing(
|
|
struct kmem_cache *s, struct page *page,
|
|
void *head, void *tail, int bulk_cnt,
|
|
unsigned long addr)
|
|
{
|
|
struct kmem_cache_node *n = get_node(s, page_to_nid(page));
|
|
void *object = head;
|
|
int cnt = 0;
|
|
unsigned long uninitialized_var(flags);
|
|
int ret = 0;
|
|
|
|
spin_lock_irqsave(&n->list_lock, flags);
|
|
slab_lock(page);
|
|
|
|
if (s->flags & SLAB_CONSISTENCY_CHECKS) {
|
|
if (!check_slab(s, page))
|
|
goto out;
|
|
}
|
|
|
|
next_object:
|
|
cnt++;
|
|
|
|
if (s->flags & SLAB_CONSISTENCY_CHECKS) {
|
|
if (!free_consistency_checks(s, page, object, addr))
|
|
goto out;
|
|
}
|
|
|
|
if (s->flags & SLAB_STORE_USER)
|
|
set_track(s, object, TRACK_FREE, addr);
|
|
trace(s, page, object, 0);
|
|
/* Freepointer not overwritten by init_object(), SLAB_POISON moved it */
|
|
init_object(s, object, SLUB_RED_INACTIVE);
|
|
|
|
/* Reached end of constructed freelist yet? */
|
|
if (object != tail) {
|
|
object = get_freepointer(s, object);
|
|
goto next_object;
|
|
}
|
|
ret = 1;
|
|
|
|
out:
|
|
if (cnt != bulk_cnt)
|
|
slab_err(s, page, "Bulk freelist count(%d) invalid(%d)\n",
|
|
bulk_cnt, cnt);
|
|
|
|
slab_unlock(page);
|
|
spin_unlock_irqrestore(&n->list_lock, flags);
|
|
if (!ret)
|
|
slab_fix(s, "Object at 0x%p not freed", object);
|
|
return ret;
|
|
}
|
|
|
|
static int __init setup_slub_debug(char *str)
|
|
{
|
|
slub_debug = DEBUG_DEFAULT_FLAGS;
|
|
if (*str++ != '=' || !*str)
|
|
/*
|
|
* No options specified. Switch on full debugging.
|
|
*/
|
|
goto out;
|
|
|
|
if (*str == ',')
|
|
/*
|
|
* No options but restriction on slabs. This means full
|
|
* debugging for slabs matching a pattern.
|
|
*/
|
|
goto check_slabs;
|
|
|
|
slub_debug = 0;
|
|
if (*str == '-')
|
|
/*
|
|
* Switch off all debugging measures.
|
|
*/
|
|
goto out;
|
|
|
|
/*
|
|
* Determine which debug features should be switched on
|
|
*/
|
|
for (; *str && *str != ','; str++) {
|
|
switch (tolower(*str)) {
|
|
case 'f':
|
|
slub_debug |= SLAB_CONSISTENCY_CHECKS;
|
|
break;
|
|
case 'z':
|
|
slub_debug |= SLAB_RED_ZONE;
|
|
break;
|
|
case 'p':
|
|
slub_debug |= SLAB_POISON;
|
|
break;
|
|
case 'u':
|
|
slub_debug |= SLAB_STORE_USER;
|
|
break;
|
|
case 't':
|
|
slub_debug |= SLAB_TRACE;
|
|
break;
|
|
case 'a':
|
|
slub_debug |= SLAB_FAILSLAB;
|
|
break;
|
|
case 'o':
|
|
/*
|
|
* Avoid enabling debugging on caches if its minimum
|
|
* order would increase as a result.
|
|
*/
|
|
disable_higher_order_debug = 1;
|
|
break;
|
|
default:
|
|
pr_err("slub_debug option '%c' unknown. skipped\n",
|
|
*str);
|
|
}
|
|
}
|
|
|
|
check_slabs:
|
|
if (*str == ',')
|
|
slub_debug_slabs = str + 1;
|
|
out:
|
|
if ((static_branch_unlikely(&init_on_alloc) ||
|
|
static_branch_unlikely(&init_on_free)) &&
|
|
(slub_debug & SLAB_POISON))
|
|
pr_info("mem auto-init: SLAB_POISON will take precedence over init_on_alloc/init_on_free\n");
|
|
return 1;
|
|
}
|
|
|
|
__setup("slub_debug", setup_slub_debug);
|
|
|
|
/*
|
|
* kmem_cache_flags - apply debugging options to the cache
|
|
* @object_size: the size of an object without meta data
|
|
* @flags: flags to set
|
|
* @name: name of the cache
|
|
* @ctor: constructor function
|
|
*
|
|
* Debug option(s) are applied to @flags. In addition to the debug
|
|
* option(s), if a slab name (or multiple) is specified i.e.
|
|
* slub_debug=<Debug-Options>,<slab name1>,<slab name2> ...
|
|
* then only the select slabs will receive the debug option(s).
|
|
*/
|
|
slab_flags_t kmem_cache_flags(unsigned int object_size,
|
|
slab_flags_t flags, const char *name,
|
|
void (*ctor)(void *))
|
|
{
|
|
char *iter;
|
|
size_t len;
|
|
|
|
/* If slub_debug = 0, it folds into the if conditional. */
|
|
if (!slub_debug_slabs)
|
|
return flags | slub_debug;
|
|
|
|
len = strlen(name);
|
|
iter = slub_debug_slabs;
|
|
while (*iter) {
|
|
char *end, *glob;
|
|
size_t cmplen;
|
|
|
|
end = strchrnul(iter, ',');
|
|
|
|
glob = strnchr(iter, end - iter, '*');
|
|
if (glob)
|
|
cmplen = glob - iter;
|
|
else
|
|
cmplen = max_t(size_t, len, (end - iter));
|
|
|
|
if (!strncmp(name, iter, cmplen)) {
|
|
flags |= slub_debug;
|
|
break;
|
|
}
|
|
|
|
if (!*end)
|
|
break;
|
|
iter = end + 1;
|
|
}
|
|
|
|
return flags;
|
|
}
|
|
#else /* !CONFIG_SLUB_DEBUG */
|
|
static inline void setup_object_debug(struct kmem_cache *s,
|
|
struct page *page, void *object) {}
|
|
static inline
|
|
void setup_page_debug(struct kmem_cache *s, struct page *page, void *addr) {}
|
|
|
|
static inline int alloc_debug_processing(struct kmem_cache *s,
|
|
struct page *page, void *object, unsigned long addr) { return 0; }
|
|
|
|
static inline int free_debug_processing(
|
|
struct kmem_cache *s, struct page *page,
|
|
void *head, void *tail, int bulk_cnt,
|
|
unsigned long addr) { return 0; }
|
|
|
|
static inline int slab_pad_check(struct kmem_cache *s, struct page *page)
|
|
{ return 1; }
|
|
static inline int check_object(struct kmem_cache *s, struct page *page,
|
|
void *object, u8 val) { return 1; }
|
|
static inline void add_full(struct kmem_cache *s, struct kmem_cache_node *n,
|
|
struct page *page) {}
|
|
static inline void remove_full(struct kmem_cache *s, struct kmem_cache_node *n,
|
|
struct page *page) {}
|
|
slab_flags_t kmem_cache_flags(unsigned int object_size,
|
|
slab_flags_t flags, const char *name,
|
|
void (*ctor)(void *))
|
|
{
|
|
return flags;
|
|
}
|
|
#define slub_debug 0
|
|
|
|
#define disable_higher_order_debug 0
|
|
|
|
static inline unsigned long slabs_node(struct kmem_cache *s, int node)
|
|
{ return 0; }
|
|
static inline unsigned long node_nr_slabs(struct kmem_cache_node *n)
|
|
{ return 0; }
|
|
static inline void inc_slabs_node(struct kmem_cache *s, int node,
|
|
int objects) {}
|
|
static inline void dec_slabs_node(struct kmem_cache *s, int node,
|
|
int objects) {}
|
|
|
|
#endif /* CONFIG_SLUB_DEBUG */
|
|
|
|
/*
|
|
* Hooks for other subsystems that check memory allocations. In a typical
|
|
* production configuration these hooks all should produce no code at all.
|
|
*/
|
|
static inline void *kmalloc_large_node_hook(void *ptr, size_t size, gfp_t flags)
|
|
{
|
|
ptr = kasan_kmalloc_large(ptr, size, flags);
|
|
/* As ptr might get tagged, call kmemleak hook after KASAN. */
|
|
kmemleak_alloc(ptr, size, 1, flags);
|
|
return ptr;
|
|
}
|
|
|
|
static __always_inline void kfree_hook(void *x)
|
|
{
|
|
kmemleak_free(x);
|
|
kasan_kfree_large(x, _RET_IP_);
|
|
}
|
|
|
|
static __always_inline bool slab_free_hook(struct kmem_cache *s, void *x)
|
|
{
|
|
kmemleak_free_recursive(x, s->flags);
|
|
|
|
/*
|
|
* Trouble is that we may no longer disable interrupts in the fast path
|
|
* So in order to make the debug calls that expect irqs to be
|
|
* disabled we need to disable interrupts temporarily.
|
|
*/
|
|
#ifdef CONFIG_LOCKDEP
|
|
{
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
debug_check_no_locks_freed(x, s->object_size);
|
|
local_irq_restore(flags);
|
|
}
|
|
#endif
|
|
if (!(s->flags & SLAB_DEBUG_OBJECTS))
|
|
debug_check_no_obj_freed(x, s->object_size);
|
|
|
|
/* KASAN might put x into memory quarantine, delaying its reuse */
|
|
return kasan_slab_free(s, x, _RET_IP_);
|
|
}
|
|
|
|
static inline bool slab_free_freelist_hook(struct kmem_cache *s,
|
|
void **head, void **tail)
|
|
{
|
|
|
|
void *object;
|
|
void *next = *head;
|
|
void *old_tail = *tail ? *tail : *head;
|
|
int rsize;
|
|
|
|
/* Head and tail of the reconstructed freelist */
|
|
*head = NULL;
|
|
*tail = NULL;
|
|
|
|
do {
|
|
object = next;
|
|
next = get_freepointer(s, object);
|
|
|
|
if (slab_want_init_on_free(s)) {
|
|
/*
|
|
* Clear the object and the metadata, but don't touch
|
|
* the redzone.
|
|
*/
|
|
memset(object, 0, s->object_size);
|
|
rsize = (s->flags & SLAB_RED_ZONE) ? s->red_left_pad
|
|
: 0;
|
|
memset((char *)object + s->inuse, 0,
|
|
s->size - s->inuse - rsize);
|
|
|
|
}
|
|
/* If object's reuse doesn't have to be delayed */
|
|
if (!slab_free_hook(s, object)) {
|
|
/* Move object to the new freelist */
|
|
set_freepointer(s, object, *head);
|
|
*head = object;
|
|
if (!*tail)
|
|
*tail = object;
|
|
}
|
|
} while (object != old_tail);
|
|
|
|
if (*head == *tail)
|
|
*tail = NULL;
|
|
|
|
return *head != NULL;
|
|
}
|
|
|
|
static void *setup_object(struct kmem_cache *s, struct page *page,
|
|
void *object)
|
|
{
|
|
setup_object_debug(s, page, object);
|
|
object = kasan_init_slab_obj(s, object);
|
|
if (unlikely(s->ctor)) {
|
|
kasan_unpoison_object_data(s, object);
|
|
s->ctor(object);
|
|
kasan_poison_object_data(s, object);
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/*
|
|
* Slab allocation and freeing
|
|
*/
|
|
static inline struct page *alloc_slab_page(struct kmem_cache *s,
|
|
gfp_t flags, int node, struct kmem_cache_order_objects oo)
|
|
{
|
|
struct page *page;
|
|
unsigned int order = oo_order(oo);
|
|
|
|
if (node == NUMA_NO_NODE)
|
|
page = alloc_pages(flags, order);
|
|
else
|
|
page = __alloc_pages_node(node, flags, order);
|
|
|
|
if (page && charge_slab_page(page, flags, order, s)) {
|
|
__free_pages(page, order);
|
|
page = NULL;
|
|
}
|
|
|
|
return page;
|
|
}
|
|
|
|
#ifdef CONFIG_SLAB_FREELIST_RANDOM
|
|
/* Pre-initialize the random sequence cache */
|
|
static int init_cache_random_seq(struct kmem_cache *s)
|
|
{
|
|
unsigned int count = oo_objects(s->oo);
|
|
int err;
|
|
|
|
/* Bailout if already initialised */
|
|
if (s->random_seq)
|
|
return 0;
|
|
|
|
err = cache_random_seq_create(s, count, GFP_KERNEL);
|
|
if (err) {
|
|
pr_err("SLUB: Unable to initialize free list for %s\n",
|
|
s->name);
|
|
return err;
|
|
}
|
|
|
|
/* Transform to an offset on the set of pages */
|
|
if (s->random_seq) {
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < count; i++)
|
|
s->random_seq[i] *= s->size;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/* re-initialize the random sequence cache */
|
|
static int reinit_cache_random_seq(struct kmem_cache *s)
|
|
{
|
|
int err;
|
|
|
|
if (s->random_seq) {
|
|
cache_random_seq_destroy(s);
|
|
err = init_cache_random_seq(s);
|
|
|
|
if (err) {
|
|
pr_err("SLUB: Unable to re-initialize random sequence cache for %s\n",
|
|
s->name);
|
|
return err;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* Initialize each random sequence freelist per cache */
|
|
static void __init init_freelist_randomization(void)
|
|
{
|
|
struct kmem_cache *s;
|
|
|
|
mutex_lock(&slab_mutex);
|
|
|
|
list_for_each_entry(s, &slab_caches, list)
|
|
init_cache_random_seq(s);
|
|
|
|
mutex_unlock(&slab_mutex);
|
|
}
|
|
|
|
/* Get the next entry on the pre-computed freelist randomized */
|
|
static void *next_freelist_entry(struct kmem_cache *s, struct page *page,
|
|
unsigned long *pos, void *start,
|
|
unsigned long page_limit,
|
|
unsigned long freelist_count)
|
|
{
|
|
unsigned int idx;
|
|
|
|
/*
|
|
* If the target page allocation failed, the number of objects on the
|
|
* page might be smaller than the usual size defined by the cache.
|
|
*/
|
|
do {
|
|
idx = s->random_seq[*pos];
|
|
*pos += 1;
|
|
if (*pos >= freelist_count)
|
|
*pos = 0;
|
|
} while (unlikely(idx >= page_limit));
|
|
|
|
return (char *)start + idx;
|
|
}
|
|
|
|
/* Shuffle the single linked freelist based on a random pre-computed sequence */
|
|
static bool shuffle_freelist(struct kmem_cache *s, struct page *page)
|
|
{
|
|
void *start;
|
|
void *cur;
|
|
void *next;
|
|
unsigned long idx, pos, page_limit, freelist_count;
|
|
|
|
if (page->objects < 2 || !s->random_seq)
|
|
return false;
|
|
|
|
freelist_count = oo_objects(s->oo);
|
|
pos = get_random_int() % freelist_count;
|
|
|
|
page_limit = page->objects * s->size;
|
|
start = fixup_red_left(s, page_address(page));
|
|
|
|
/* First entry is used as the base of the freelist */
|
|
cur = next_freelist_entry(s, page, &pos, start, page_limit,
|
|
freelist_count);
|
|
cur = setup_object(s, page, cur);
|
|
page->freelist = cur;
|
|
|
|
for (idx = 1; idx < page->objects; idx++) {
|
|
next = next_freelist_entry(s, page, &pos, start, page_limit,
|
|
freelist_count);
|
|
next = setup_object(s, page, next);
|
|
set_freepointer(s, cur, next);
|
|
cur = next;
|
|
}
|
|
set_freepointer(s, cur, NULL);
|
|
|
|
return true;
|
|
}
|
|
#else
|
|
static inline int init_cache_random_seq(struct kmem_cache *s)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int reinit_cache_random_seq(struct kmem_cache *s)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline void init_freelist_randomization(void) { }
|
|
static inline bool shuffle_freelist(struct kmem_cache *s, struct page *page)
|
|
{
|
|
return false;
|
|
}
|
|
#endif /* CONFIG_SLAB_FREELIST_RANDOM */
|
|
|
|
static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
|
|
{
|
|
struct page *page;
|
|
struct kmem_cache_order_objects oo = s->oo;
|
|
gfp_t alloc_gfp;
|
|
void *start, *p, *next;
|
|
int idx;
|
|
bool shuffle;
|
|
|
|
flags &= gfp_allowed_mask;
|
|
|
|
if (gfpflags_allow_blocking(flags))
|
|
local_irq_enable();
|
|
|
|
flags |= s->allocflags;
|
|
|
|
/*
|
|
* Let the initial higher-order allocation fail under memory pressure
|
|
* so we fall-back to the minimum order allocation.
|
|
*/
|
|
alloc_gfp = (flags | __GFP_NOWARN | __GFP_NORETRY) & ~__GFP_NOFAIL;
|
|
if ((alloc_gfp & __GFP_DIRECT_RECLAIM) && oo_order(oo) > oo_order(s->min))
|
|
alloc_gfp = (alloc_gfp | __GFP_NOMEMALLOC) & ~(__GFP_RECLAIM|__GFP_NOFAIL);
|
|
|
|
page = alloc_slab_page(s, alloc_gfp, node, oo);
|
|
if (unlikely(!page)) {
|
|
oo = s->min;
|
|
alloc_gfp = flags;
|
|
/*
|
|
* Allocation may have failed due to fragmentation.
|
|
* Try a lower order alloc if possible
|
|
*/
|
|
page = alloc_slab_page(s, alloc_gfp, node, oo);
|
|
if (unlikely(!page))
|
|
goto out;
|
|
stat(s, ORDER_FALLBACK);
|
|
}
|
|
|
|
page->objects = oo_objects(oo);
|
|
|
|
page->slab_cache = s;
|
|
__SetPageSlab(page);
|
|
if (page_is_pfmemalloc(page))
|
|
SetPageSlabPfmemalloc(page);
|
|
|
|
kasan_poison_slab(page);
|
|
|
|
start = page_address(page);
|
|
|
|
setup_page_debug(s, page, start);
|
|
|
|
shuffle = shuffle_freelist(s, page);
|
|
|
|
if (!shuffle) {
|
|
start = fixup_red_left(s, start);
|
|
start = setup_object(s, page, start);
|
|
page->freelist = start;
|
|
for (idx = 0, p = start; idx < page->objects - 1; idx++) {
|
|
next = p + s->size;
|
|
next = setup_object(s, page, next);
|
|
set_freepointer(s, p, next);
|
|
p = next;
|
|
}
|
|
set_freepointer(s, p, NULL);
|
|
}
|
|
|
|
page->inuse = page->objects;
|
|
page->frozen = 1;
|
|
|
|
out:
|
|
if (gfpflags_allow_blocking(flags))
|
|
local_irq_disable();
|
|
if (!page)
|
|
return NULL;
|
|
|
|
inc_slabs_node(s, page_to_nid(page), page->objects);
|
|
|
|
return page;
|
|
}
|
|
|
|
static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
|
|
{
|
|
if (unlikely(flags & GFP_SLAB_BUG_MASK)) {
|
|
gfp_t invalid_mask = flags & GFP_SLAB_BUG_MASK;
|
|
flags &= ~GFP_SLAB_BUG_MASK;
|
|
pr_warn("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n",
|
|
invalid_mask, &invalid_mask, flags, &flags);
|
|
dump_stack();
|
|
}
|
|
|
|
return allocate_slab(s,
|
|
flags & (GFP_RECLAIM_MASK | GFP_CONSTRAINT_MASK), node);
|
|
}
|
|
|
|
static void __free_slab(struct kmem_cache *s, struct page *page)
|
|
{
|
|
int order = compound_order(page);
|
|
int pages = 1 << order;
|
|
|
|
if (s->flags & SLAB_CONSISTENCY_CHECKS) {
|
|
void *p;
|
|
|
|
slab_pad_check(s, page);
|
|
for_each_object(p, s, page_address(page),
|
|
page->objects)
|
|
check_object(s, page, p, SLUB_RED_INACTIVE);
|
|
}
|
|
|
|
__ClearPageSlabPfmemalloc(page);
|
|
__ClearPageSlab(page);
|
|
|
|
page->mapping = NULL;
|
|
if (current->reclaim_state)
|
|
current->reclaim_state->reclaimed_slab += pages;
|
|
uncharge_slab_page(page, order, s);
|
|
__free_pages(page, order);
|
|
}
|
|
|
|
static void rcu_free_slab(struct rcu_head *h)
|
|
{
|
|
struct page *page = container_of(h, struct page, rcu_head);
|
|
|
|
__free_slab(page->slab_cache, page);
|
|
}
|
|
|
|
static void free_slab(struct kmem_cache *s, struct page *page)
|
|
{
|
|
if (unlikely(s->flags & SLAB_TYPESAFE_BY_RCU)) {
|
|
call_rcu(&page->rcu_head, rcu_free_slab);
|
|
} else
|
|
__free_slab(s, page);
|
|
}
|
|
|
|
static void discard_slab(struct kmem_cache *s, struct page *page)
|
|
{
|
|
dec_slabs_node(s, page_to_nid(page), page->objects);
|
|
free_slab(s, page);
|
|
}
|
|
|
|
/*
|
|
* Management of partially allocated slabs.
|
|
*/
|
|
static inline void
|
|
__add_partial(struct kmem_cache_node *n, struct page *page, int tail)
|
|
{
|
|
n->nr_partial++;
|
|
if (tail == DEACTIVATE_TO_TAIL)
|
|
list_add_tail(&page->slab_list, &n->partial);
|
|
else
|
|
list_add(&page->slab_list, &n->partial);
|
|
}
|
|
|
|
static inline void add_partial(struct kmem_cache_node *n,
|
|
struct page *page, int tail)
|
|
{
|
|
lockdep_assert_held(&n->list_lock);
|
|
__add_partial(n, page, tail);
|
|
}
|
|
|
|
static inline void remove_partial(struct kmem_cache_node *n,
|
|
struct page *page)
|
|
{
|
|
lockdep_assert_held(&n->list_lock);
|
|
list_del(&page->slab_list);
|
|
n->nr_partial--;
|
|
}
|
|
|
|
/*
|
|
* Remove slab from the partial list, freeze it and
|
|
* return the pointer to the freelist.
|
|
*
|
|
* Returns a list of objects or NULL if it fails.
|
|
*/
|
|
static inline void *acquire_slab(struct kmem_cache *s,
|
|
struct kmem_cache_node *n, struct page *page,
|
|
int mode, int *objects)
|
|
{
|
|
void *freelist;
|
|
unsigned long counters;
|
|
struct page new;
|
|
|
|
lockdep_assert_held(&n->list_lock);
|
|
|
|
/*
|
|
* Zap the freelist and set the frozen bit.
|
|
* The old freelist is the list of objects for the
|
|
* per cpu allocation list.
|
|
*/
|
|
freelist = page->freelist;
|
|
counters = page->counters;
|
|
new.counters = counters;
|
|
*objects = new.objects - new.inuse;
|
|
if (mode) {
|
|
new.inuse = page->objects;
|
|
new.freelist = NULL;
|
|
} else {
|
|
new.freelist = freelist;
|
|
}
|
|
|
|
VM_BUG_ON(new.frozen);
|
|
new.frozen = 1;
|
|
|
|
if (!__cmpxchg_double_slab(s, page,
|
|
freelist, counters,
|
|
new.freelist, new.counters,
|
|
"acquire_slab"))
|
|
return NULL;
|
|
|
|
remove_partial(n, page);
|
|
WARN_ON(!freelist);
|
|
return freelist;
|
|
}
|
|
|
|
static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain);
|
|
static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags);
|
|
|
|
/*
|
|
* Try to allocate a partial slab from a specific node.
|
|
*/
|
|
static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n,
|
|
struct kmem_cache_cpu *c, gfp_t flags)
|
|
{
|
|
struct page *page, *page2;
|
|
void *object = NULL;
|
|
unsigned int available = 0;
|
|
int objects;
|
|
|
|
/*
|
|
* Racy check. If we mistakenly see no partial slabs then we
|
|
* just allocate an empty slab. If we mistakenly try to get a
|
|
* partial slab and there is none available then get_partials()
|
|
* will return NULL.
|
|
*/
|
|
if (!n || !n->nr_partial)
|
|
return NULL;
|
|
|
|
spin_lock(&n->list_lock);
|
|
list_for_each_entry_safe(page, page2, &n->partial, slab_list) {
|
|
void *t;
|
|
|
|
if (!pfmemalloc_match(page, flags))
|
|
continue;
|
|
|
|
t = acquire_slab(s, n, page, object == NULL, &objects);
|
|
if (!t)
|
|
break;
|
|
|
|
available += objects;
|
|
if (!object) {
|
|
c->page = page;
|
|
stat(s, ALLOC_FROM_PARTIAL);
|
|
object = t;
|
|
} else {
|
|
put_cpu_partial(s, page, 0);
|
|
stat(s, CPU_PARTIAL_NODE);
|
|
}
|
|
if (!kmem_cache_has_cpu_partial(s)
|
|
|| available > slub_cpu_partial(s) / 2)
|
|
break;
|
|
|
|
}
|
|
spin_unlock(&n->list_lock);
|
|
return object;
|
|
}
|
|
|
|
/*
|
|
* Get a page from somewhere. Search in increasing NUMA distances.
|
|
*/
|
|
static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
|
|
struct kmem_cache_cpu *c)
|
|
{
|
|
#ifdef CONFIG_NUMA
|
|
struct zonelist *zonelist;
|
|
struct zoneref *z;
|
|
struct zone *zone;
|
|
enum zone_type high_zoneidx = gfp_zone(flags);
|
|
void *object;
|
|
unsigned int cpuset_mems_cookie;
|
|
|
|
/*
|
|
* The defrag ratio allows a configuration of the tradeoffs between
|
|
* inter node defragmentation and node local allocations. A lower
|
|
* defrag_ratio increases the tendency to do local allocations
|
|
* instead of attempting to obtain partial slabs from other nodes.
|
|
*
|
|
* If the defrag_ratio is set to 0 then kmalloc() always
|
|
* returns node local objects. If the ratio is higher then kmalloc()
|
|
* may return off node objects because partial slabs are obtained
|
|
* from other nodes and filled up.
|
|
*
|
|
* If /sys/kernel/slab/xx/remote_node_defrag_ratio is set to 100
|
|
* (which makes defrag_ratio = 1000) then every (well almost)
|
|
* allocation will first attempt to defrag slab caches on other nodes.
|
|
* This means scanning over all nodes to look for partial slabs which
|
|
* may be expensive if we do it every time we are trying to find a slab
|
|
* with available objects.
|
|
*/
|
|
if (!s->remote_node_defrag_ratio ||
|
|
get_cycles() % 1024 > s->remote_node_defrag_ratio)
|
|
return NULL;
|
|
|
|
do {
|
|
cpuset_mems_cookie = read_mems_allowed_begin();
|
|
zonelist = node_zonelist(mempolicy_slab_node(), flags);
|
|
for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) {
|
|
struct kmem_cache_node *n;
|
|
|
|
n = get_node(s, zone_to_nid(zone));
|
|
|
|
if (n && cpuset_zone_allowed(zone, flags) &&
|
|
n->nr_partial > s->min_partial) {
|
|
object = get_partial_node(s, n, c, flags);
|
|
if (object) {
|
|
/*
|
|
* Don't check read_mems_allowed_retry()
|
|
* here - if mems_allowed was updated in
|
|
* parallel, that was a harmless race
|
|
* between allocation and the cpuset
|
|
* update
|
|
*/
|
|
return object;
|
|
}
|
|
}
|
|
}
|
|
} while (read_mems_allowed_retry(cpuset_mems_cookie));
|
|
#endif /* CONFIG_NUMA */
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* Get a partial page, lock it and return it.
|
|
*/
|
|
static void *get_partial(struct kmem_cache *s, gfp_t flags, int node,
|
|
struct kmem_cache_cpu *c)
|
|
{
|
|
void *object;
|
|
int searchnode = node;
|
|
|
|
if (node == NUMA_NO_NODE)
|
|
searchnode = numa_mem_id();
|
|
else if (!node_present_pages(node))
|
|
searchnode = node_to_mem_node(node);
|
|
|
|
object = get_partial_node(s, get_node(s, searchnode), c, flags);
|
|
if (object || node != NUMA_NO_NODE)
|
|
return object;
|
|
|
|
return get_any_partial(s, flags, c);
|
|
}
|
|
|
|
#ifdef CONFIG_PREEMPT
|
|
/*
|
|
* Calculate the next globally unique transaction for disambiguiation
|
|
* during cmpxchg. The transactions start with the cpu number and are then
|
|
* incremented by CONFIG_NR_CPUS.
|
|
*/
|
|
#define TID_STEP roundup_pow_of_two(CONFIG_NR_CPUS)
|
|
#else
|
|
/*
|
|
* No preemption supported therefore also no need to check for
|
|
* different cpus.
|
|
*/
|
|
#define TID_STEP 1
|
|
#endif
|
|
|
|
static inline unsigned long next_tid(unsigned long tid)
|
|
{
|
|
return tid + TID_STEP;
|
|
}
|
|
|
|
#ifdef SLUB_DEBUG_CMPXCHG
|
|
static inline unsigned int tid_to_cpu(unsigned long tid)
|
|
{
|
|
return tid % TID_STEP;
|
|
}
|
|
|
|
static inline unsigned long tid_to_event(unsigned long tid)
|
|
{
|
|
return tid / TID_STEP;
|
|
}
|
|
#endif
|
|
|
|
static inline unsigned int init_tid(int cpu)
|
|
{
|
|
return cpu;
|
|
}
|
|
|
|
static inline void note_cmpxchg_failure(const char *n,
|
|
const struct kmem_cache *s, unsigned long tid)
|
|
{
|
|
#ifdef SLUB_DEBUG_CMPXCHG
|
|
unsigned long actual_tid = __this_cpu_read(s->cpu_slab->tid);
|
|
|
|
pr_info("%s %s: cmpxchg redo ", n, s->name);
|
|
|
|
#ifdef CONFIG_PREEMPT
|
|
if (tid_to_cpu(tid) != tid_to_cpu(actual_tid))
|
|
pr_warn("due to cpu change %d -> %d\n",
|
|
tid_to_cpu(tid), tid_to_cpu(actual_tid));
|
|
else
|
|
#endif
|
|
if (tid_to_event(tid) != tid_to_event(actual_tid))
|
|
pr_warn("due to cpu running other code. Event %ld->%ld\n",
|
|
tid_to_event(tid), tid_to_event(actual_tid));
|
|
else
|
|
pr_warn("for unknown reason: actual=%lx was=%lx target=%lx\n",
|
|
actual_tid, tid, next_tid(tid));
|
|
#endif
|
|
stat(s, CMPXCHG_DOUBLE_CPU_FAIL);
|
|
}
|
|
|
|
static void init_kmem_cache_cpus(struct kmem_cache *s)
|
|
{
|
|
int cpu;
|
|
|
|
for_each_possible_cpu(cpu)
|
|
per_cpu_ptr(s->cpu_slab, cpu)->tid = init_tid(cpu);
|
|
}
|
|
|
|
/*
|
|
* Remove the cpu slab
|
|
*/
|
|
static void deactivate_slab(struct kmem_cache *s, struct page *page,
|
|
void *freelist, struct kmem_cache_cpu *c)
|
|
{
|
|
enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE };
|
|
struct kmem_cache_node *n = get_node(s, page_to_nid(page));
|
|
int lock = 0;
|
|
enum slab_modes l = M_NONE, m = M_NONE;
|
|
void *nextfree;
|
|
int tail = DEACTIVATE_TO_HEAD;
|
|
struct page new;
|
|
struct page old;
|
|
|
|
if (page->freelist) {
|
|
stat(s, DEACTIVATE_REMOTE_FREES);
|
|
tail = DEACTIVATE_TO_TAIL;
|
|
}
|
|
|
|
/*
|
|
* Stage one: Free all available per cpu objects back
|
|
* to the page freelist while it is still frozen. Leave the
|
|
* last one.
|
|
*
|
|
* There is no need to take the list->lock because the page
|
|
* is still frozen.
|
|
*/
|
|
while (freelist && (nextfree = get_freepointer(s, freelist))) {
|
|
void *prior;
|
|
unsigned long counters;
|
|
|
|
do {
|
|
prior = page->freelist;
|
|
counters = page->counters;
|
|
set_freepointer(s, freelist, prior);
|
|
new.counters = counters;
|
|
new.inuse--;
|
|
VM_BUG_ON(!new.frozen);
|
|
|
|
} while (!__cmpxchg_double_slab(s, page,
|
|
prior, counters,
|
|
freelist, new.counters,
|
|
"drain percpu freelist"));
|
|
|
|
freelist = nextfree;
|
|
}
|
|
|
|
/*
|
|
* Stage two: Ensure that the page is unfrozen while the
|
|
* list presence reflects the actual number of objects
|
|
* during unfreeze.
|
|
*
|
|
* We setup the list membership and then perform a cmpxchg
|
|
* with the count. If there is a mismatch then the page
|
|
* is not unfrozen but the page is on the wrong list.
|
|
*
|
|
* Then we restart the process which may have to remove
|
|
* the page from the list that we just put it on again
|
|
* because the number of objects in the slab may have
|
|
* changed.
|
|
*/
|
|
redo:
|
|
|
|
old.freelist = page->freelist;
|
|
old.counters = page->counters;
|
|
VM_BUG_ON(!old.frozen);
|
|
|
|
/* Determine target state of the slab */
|
|
new.counters = old.counters;
|
|
if (freelist) {
|
|
new.inuse--;
|
|
set_freepointer(s, freelist, old.freelist);
|
|
new.freelist = freelist;
|
|
} else
|
|
new.freelist = old.freelist;
|
|
|
|
new.frozen = 0;
|
|
|
|
if (!new.inuse && n->nr_partial >= s->min_partial)
|
|
m = M_FREE;
|
|
else if (new.freelist) {
|
|
m = M_PARTIAL;
|
|
if (!lock) {
|
|
lock = 1;
|
|
/*
|
|
* Taking the spinlock removes the possibility
|
|
* that acquire_slab() will see a slab page that
|
|
* is frozen
|
|
*/
|
|
spin_lock(&n->list_lock);
|
|
}
|
|
} else {
|
|
m = M_FULL;
|
|
if (kmem_cache_debug(s) && !lock) {
|
|
lock = 1;
|
|
/*
|
|
* This also ensures that the scanning of full
|
|
* slabs from diagnostic functions will not see
|
|
* any frozen slabs.
|
|
*/
|
|
spin_lock(&n->list_lock);
|
|
}
|
|
}
|
|
|
|
if (l != m) {
|
|
if (l == M_PARTIAL)
|
|
remove_partial(n, page);
|
|
else if (l == M_FULL)
|
|
remove_full(s, n, page);
|
|
|
|
if (m == M_PARTIAL)
|
|
add_partial(n, page, tail);
|
|
else if (m == M_FULL)
|
|
add_full(s, n, page);
|
|
}
|
|
|
|
l = m;
|
|
if (!__cmpxchg_double_slab(s, page,
|
|
old.freelist, old.counters,
|
|
new.freelist, new.counters,
|
|
"unfreezing slab"))
|
|
goto redo;
|
|
|
|
if (lock)
|
|
spin_unlock(&n->list_lock);
|
|
|
|
if (m == M_PARTIAL)
|
|
stat(s, tail);
|
|
else if (m == M_FULL)
|
|
stat(s, DEACTIVATE_FULL);
|
|
else if (m == M_FREE) {
|
|
stat(s, DEACTIVATE_EMPTY);
|
|
discard_slab(s, page);
|
|
stat(s, FREE_SLAB);
|
|
}
|
|
|
|
c->page = NULL;
|
|
c->freelist = NULL;
|
|
}
|
|
|
|
/*
|
|
* Unfreeze all the cpu partial slabs.
|
|
*
|
|
* This function must be called with interrupts disabled
|
|
* for the cpu using c (or some other guarantee must be there
|
|
* to guarantee no concurrent accesses).
|
|
*/
|
|
static void unfreeze_partials(struct kmem_cache *s,
|
|
struct kmem_cache_cpu *c)
|
|
{
|
|
#ifdef CONFIG_SLUB_CPU_PARTIAL
|
|
struct kmem_cache_node *n = NULL, *n2 = NULL;
|
|
struct page *page, *discard_page = NULL;
|
|
|
|
while ((page = c->partial)) {
|
|
struct page new;
|
|
struct page old;
|
|
|
|
c->partial = page->next;
|
|
|
|
n2 = get_node(s, page_to_nid(page));
|
|
if (n != n2) {
|
|
if (n)
|
|
spin_unlock(&n->list_lock);
|
|
|
|
n = n2;
|
|
spin_lock(&n->list_lock);
|
|
}
|
|
|
|
do {
|
|
|
|
old.freelist = page->freelist;
|
|
old.counters = page->counters;
|
|
VM_BUG_ON(!old.frozen);
|
|
|
|
new.counters = old.counters;
|
|
new.freelist = old.freelist;
|
|
|
|
new.frozen = 0;
|
|
|
|
} while (!__cmpxchg_double_slab(s, page,
|
|
old.freelist, old.counters,
|
|
new.freelist, new.counters,
|
|
"unfreezing slab"));
|
|
|
|
if (unlikely(!new.inuse && n->nr_partial >= s->min_partial)) {
|
|
page->next = discard_page;
|
|
discard_page = page;
|
|
} else {
|
|
add_partial(n, page, DEACTIVATE_TO_TAIL);
|
|
stat(s, FREE_ADD_PARTIAL);
|
|
}
|
|
}
|
|
|
|
if (n)
|
|
spin_unlock(&n->list_lock);
|
|
|
|
while (discard_page) {
|
|
page = discard_page;
|
|
discard_page = discard_page->next;
|
|
|
|
stat(s, DEACTIVATE_EMPTY);
|
|
discard_slab(s, page);
|
|
stat(s, FREE_SLAB);
|
|
}
|
|
#endif /* CONFIG_SLUB_CPU_PARTIAL */
|
|
}
|
|
|
|
/*
|
|
* Put a page that was just frozen (in __slab_free|get_partial_node) into a
|
|
* partial page slot if available.
|
|
*
|
|
* If we did not find a slot then simply move all the partials to the
|
|
* per node partial list.
|
|
*/
|
|
static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
|
|
{
|
|
#ifdef CONFIG_SLUB_CPU_PARTIAL
|
|
struct page *oldpage;
|
|
int pages;
|
|
int pobjects;
|
|
|
|
preempt_disable();
|
|
do {
|
|
pages = 0;
|
|
pobjects = 0;
|
|
oldpage = this_cpu_read(s->cpu_slab->partial);
|
|
|
|
if (oldpage) {
|
|
pobjects = oldpage->pobjects;
|
|
pages = oldpage->pages;
|
|
if (drain && pobjects > s->cpu_partial) {
|
|
unsigned long flags;
|
|
/*
|
|
* partial array is full. Move the existing
|
|
* set to the per node partial list.
|
|
*/
|
|
local_irq_save(flags);
|
|
unfreeze_partials(s, this_cpu_ptr(s->cpu_slab));
|
|
local_irq_restore(flags);
|
|
oldpage = NULL;
|
|
pobjects = 0;
|
|
pages = 0;
|
|
stat(s, CPU_PARTIAL_DRAIN);
|
|
}
|
|
}
|
|
|
|
pages++;
|
|
pobjects += page->objects - page->inuse;
|
|
|
|
page->pages = pages;
|
|
page->pobjects = pobjects;
|
|
page->next = oldpage;
|
|
|
|
} while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page)
|
|
!= oldpage);
|
|
if (unlikely(!s->cpu_partial)) {
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
unfreeze_partials(s, this_cpu_ptr(s->cpu_slab));
|
|
local_irq_restore(flags);
|
|
}
|
|
preempt_enable();
|
|
#endif /* CONFIG_SLUB_CPU_PARTIAL */
|
|
}
|
|
|
|
static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
|
|
{
|
|
stat(s, CPUSLAB_FLUSH);
|
|
deactivate_slab(s, c->page, c->freelist, c);
|
|
|
|
c->tid = next_tid(c->tid);
|
|
}
|
|
|
|
/*
|
|
* Flush cpu slab.
|
|
*
|
|
* Called from IPI handler with interrupts disabled.
|
|
*/
|
|
static inline void __flush_cpu_slab(struct kmem_cache *s, int cpu)
|
|
{
|
|
struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu);
|
|
|
|
if (c->page)
|
|
flush_slab(s, c);
|
|
|
|
unfreeze_partials(s, c);
|
|
}
|
|
|
|
static void flush_cpu_slab(void *d)
|
|
{
|
|
struct kmem_cache *s = d;
|
|
|
|
__flush_cpu_slab(s, smp_processor_id());
|
|
}
|
|
|
|
static bool has_cpu_slab(int cpu, void *info)
|
|
{
|
|
struct kmem_cache *s = info;
|
|
struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu);
|
|
|
|
return c->page || slub_percpu_partial(c);
|
|
}
|
|
|
|
static void flush_all(struct kmem_cache *s)
|
|
{
|
|
on_each_cpu_cond(has_cpu_slab, flush_cpu_slab, s, 1, GFP_ATOMIC);
|
|
}
|
|
|
|
/*
|
|
* Use the cpu notifier to insure that the cpu slabs are flushed when
|
|
* necessary.
|
|
*/
|
|
static int slub_cpu_dead(unsigned int cpu)
|
|
{
|
|
struct kmem_cache *s;
|
|
unsigned long flags;
|
|
|
|
mutex_lock(&slab_mutex);
|
|
list_for_each_entry(s, &slab_caches, list) {
|
|
local_irq_save(flags);
|
|
__flush_cpu_slab(s, cpu);
|
|
local_irq_restore(flags);
|
|
}
|
|
mutex_unlock(&slab_mutex);
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Check if the objects in a per cpu structure fit numa
|
|
* locality expectations.
|
|
*/
|
|
static inline int node_match(struct page *page, int node)
|
|
{
|
|
#ifdef CONFIG_NUMA
|
|
if (node != NUMA_NO_NODE && page_to_nid(page) != node)
|
|
return 0;
|
|
#endif
|
|
return 1;
|
|
}
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
static int count_free(struct page *page)
|
|
{
|
|
return page->objects - page->inuse;
|
|
}
|
|
|
|
static inline unsigned long node_nr_objs(struct kmem_cache_node *n)
|
|
{
|
|
return atomic_long_read(&n->total_objects);
|
|
}
|
|
#endif /* CONFIG_SLUB_DEBUG */
|
|
|
|
#if defined(CONFIG_SLUB_DEBUG) || defined(CONFIG_SYSFS)
|
|
static unsigned long count_partial(struct kmem_cache_node *n,
|
|
int (*get_count)(struct page *))
|
|
{
|
|
unsigned long flags;
|
|
unsigned long x = 0;
|
|
struct page *page;
|
|
|
|
spin_lock_irqsave(&n->list_lock, flags);
|
|
list_for_each_entry(page, &n->partial, slab_list)
|
|
x += get_count(page);
|
|
spin_unlock_irqrestore(&n->list_lock, flags);
|
|
return x;
|
|
}
|
|
#endif /* CONFIG_SLUB_DEBUG || CONFIG_SYSFS */
|
|
|
|
static noinline void
|
|
slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
|
|
{
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
static DEFINE_RATELIMIT_STATE(slub_oom_rs, DEFAULT_RATELIMIT_INTERVAL,
|
|
DEFAULT_RATELIMIT_BURST);
|
|
int node;
|
|
struct kmem_cache_node *n;
|
|
|
|
if ((gfpflags & __GFP_NOWARN) || !__ratelimit(&slub_oom_rs))
|
|
return;
|
|
|
|
pr_warn("SLUB: Unable to allocate memory on node %d, gfp=%#x(%pGg)\n",
|
|
nid, gfpflags, &gfpflags);
|
|
pr_warn(" cache: %s, object size: %u, buffer size: %u, default order: %u, min order: %u\n",
|
|
s->name, s->object_size, s->size, oo_order(s->oo),
|
|
oo_order(s->min));
|
|
|
|
if (oo_order(s->min) > get_order(s->object_size))
|
|
pr_warn(" %s debugging increased min order, use slub_debug=O to disable.\n",
|
|
s->name);
|
|
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
unsigned long nr_slabs;
|
|
unsigned long nr_objs;
|
|
unsigned long nr_free;
|
|
|
|
nr_free = count_partial(n, count_free);
|
|
nr_slabs = node_nr_slabs(n);
|
|
nr_objs = node_nr_objs(n);
|
|
|
|
pr_warn(" node %d: slabs: %ld, objs: %ld, free: %ld\n",
|
|
node, nr_slabs, nr_objs, nr_free);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
|
|
int node, struct kmem_cache_cpu **pc)
|
|
{
|
|
void *freelist;
|
|
struct kmem_cache_cpu *c = *pc;
|
|
struct page *page;
|
|
|
|
WARN_ON_ONCE(s->ctor && (flags & __GFP_ZERO));
|
|
|
|
freelist = get_partial(s, flags, node, c);
|
|
|
|
if (freelist)
|
|
return freelist;
|
|
|
|
page = new_slab(s, flags, node);
|
|
if (page) {
|
|
c = raw_cpu_ptr(s->cpu_slab);
|
|
if (c->page)
|
|
flush_slab(s, c);
|
|
|
|
/*
|
|
* No other reference to the page yet so we can
|
|
* muck around with it freely without cmpxchg
|
|
*/
|
|
freelist = page->freelist;
|
|
page->freelist = NULL;
|
|
|
|
stat(s, ALLOC_SLAB);
|
|
c->page = page;
|
|
*pc = c;
|
|
}
|
|
|
|
return freelist;
|
|
}
|
|
|
|
static inline bool pfmemalloc_match(struct page *page, gfp_t gfpflags)
|
|
{
|
|
if (unlikely(PageSlabPfmemalloc(page)))
|
|
return gfp_pfmemalloc_allowed(gfpflags);
|
|
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* Check the page->freelist of a page and either transfer the freelist to the
|
|
* per cpu freelist or deactivate the page.
|
|
*
|
|
* The page is still frozen if the return value is not NULL.
|
|
*
|
|
* If this function returns NULL then the page has been unfrozen.
|
|
*
|
|
* This function must be called with interrupt disabled.
|
|
*/
|
|
static inline void *get_freelist(struct kmem_cache *s, struct page *page)
|
|
{
|
|
struct page new;
|
|
unsigned long counters;
|
|
void *freelist;
|
|
|
|
do {
|
|
freelist = page->freelist;
|
|
counters = page->counters;
|
|
|
|
new.counters = counters;
|
|
VM_BUG_ON(!new.frozen);
|
|
|
|
new.inuse = page->objects;
|
|
new.frozen = freelist != NULL;
|
|
|
|
} while (!__cmpxchg_double_slab(s, page,
|
|
freelist, counters,
|
|
NULL, new.counters,
|
|
"get_freelist"));
|
|
|
|
return freelist;
|
|
}
|
|
|
|
/*
|
|
* Slow path. The lockless freelist is empty or we need to perform
|
|
* debugging duties.
|
|
*
|
|
* Processing is still very fast if new objects have been freed to the
|
|
* regular freelist. In that case we simply take over the regular freelist
|
|
* as the lockless freelist and zap the regular freelist.
|
|
*
|
|
* If that is not working then we fall back to the partial lists. We take the
|
|
* first element of the freelist as the object to allocate now and move the
|
|
* rest of the freelist to the lockless freelist.
|
|
*
|
|
* And if we were unable to get a new slab from the partial slab lists then
|
|
* we need to allocate a new slab. This is the slowest path since it involves
|
|
* a call to the page allocator and the setup of a new slab.
|
|
*
|
|
* Version of __slab_alloc to use when we know that interrupts are
|
|
* already disabled (which is the case for bulk allocation).
|
|
*/
|
|
static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
|
|
unsigned long addr, struct kmem_cache_cpu *c)
|
|
{
|
|
void *freelist;
|
|
struct page *page;
|
|
|
|
page = c->page;
|
|
if (!page)
|
|
goto new_slab;
|
|
redo:
|
|
|
|
if (unlikely(!node_match(page, node))) {
|
|
int searchnode = node;
|
|
|
|
if (node != NUMA_NO_NODE && !node_present_pages(node))
|
|
searchnode = node_to_mem_node(node);
|
|
|
|
if (unlikely(!node_match(page, searchnode))) {
|
|
stat(s, ALLOC_NODE_MISMATCH);
|
|
deactivate_slab(s, page, c->freelist, c);
|
|
goto new_slab;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* By rights, we should be searching for a slab page that was
|
|
* PFMEMALLOC but right now, we are losing the pfmemalloc
|
|
* information when the page leaves the per-cpu allocator
|
|
*/
|
|
if (unlikely(!pfmemalloc_match(page, gfpflags))) {
|
|
deactivate_slab(s, page, c->freelist, c);
|
|
goto new_slab;
|
|
}
|
|
|
|
/* must check again c->freelist in case of cpu migration or IRQ */
|
|
freelist = c->freelist;
|
|
if (freelist)
|
|
goto load_freelist;
|
|
|
|
freelist = get_freelist(s, page);
|
|
|
|
if (!freelist) {
|
|
c->page = NULL;
|
|
stat(s, DEACTIVATE_BYPASS);
|
|
goto new_slab;
|
|
}
|
|
|
|
stat(s, ALLOC_REFILL);
|
|
|
|
load_freelist:
|
|
/*
|
|
* freelist is pointing to the list of objects to be used.
|
|
* page is pointing to the page from which the objects are obtained.
|
|
* That page must be frozen for per cpu allocations to work.
|
|
*/
|
|
VM_BUG_ON(!c->page->frozen);
|
|
c->freelist = get_freepointer(s, freelist);
|
|
c->tid = next_tid(c->tid);
|
|
return freelist;
|
|
|
|
new_slab:
|
|
|
|
if (slub_percpu_partial(c)) {
|
|
page = c->page = slub_percpu_partial(c);
|
|
slub_set_percpu_partial(c, page);
|
|
stat(s, CPU_PARTIAL_ALLOC);
|
|
goto redo;
|
|
}
|
|
|
|
freelist = new_slab_objects(s, gfpflags, node, &c);
|
|
|
|
if (unlikely(!freelist)) {
|
|
slab_out_of_memory(s, gfpflags, node);
|
|
return NULL;
|
|
}
|
|
|
|
page = c->page;
|
|
if (likely(!kmem_cache_debug(s) && pfmemalloc_match(page, gfpflags)))
|
|
goto load_freelist;
|
|
|
|
/* Only entered in the debug case */
|
|
if (kmem_cache_debug(s) &&
|
|
!alloc_debug_processing(s, page, freelist, addr))
|
|
goto new_slab; /* Slab failed checks. Next slab needed */
|
|
|
|
deactivate_slab(s, page, get_freepointer(s, freelist), c);
|
|
return freelist;
|
|
}
|
|
|
|
/*
|
|
* Another one that disabled interrupt and compensates for possible
|
|
* cpu changes by refetching the per cpu area pointer.
|
|
*/
|
|
static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
|
|
unsigned long addr, struct kmem_cache_cpu *c)
|
|
{
|
|
void *p;
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
#ifdef CONFIG_PREEMPT
|
|
/*
|
|
* We may have been preempted and rescheduled on a different
|
|
* cpu before disabling interrupts. Need to reload cpu area
|
|
* pointer.
|
|
*/
|
|
c = this_cpu_ptr(s->cpu_slab);
|
|
#endif
|
|
|
|
p = ___slab_alloc(s, gfpflags, node, addr, c);
|
|
local_irq_restore(flags);
|
|
return p;
|
|
}
|
|
|
|
/*
|
|
* If the object has been wiped upon free, make sure it's fully initialized by
|
|
* zeroing out freelist pointer.
|
|
*/
|
|
static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s,
|
|
void *obj)
|
|
{
|
|
if (unlikely(slab_want_init_on_free(s)) && obj)
|
|
memset((void *)((char *)obj + s->offset), 0, sizeof(void *));
|
|
}
|
|
|
|
/*
|
|
* Inlined fastpath so that allocation functions (kmalloc, kmem_cache_alloc)
|
|
* have the fastpath folded into their functions. So no function call
|
|
* overhead for requests that can be satisfied on the fastpath.
|
|
*
|
|
* The fastpath works by first checking if the lockless freelist can be used.
|
|
* If not then __slab_alloc is called for slow processing.
|
|
*
|
|
* Otherwise we can simply pick the next object from the lockless free list.
|
|
*/
|
|
static __always_inline void *slab_alloc_node(struct kmem_cache *s,
|
|
gfp_t gfpflags, int node, unsigned long addr)
|
|
{
|
|
void *object;
|
|
struct kmem_cache_cpu *c;
|
|
struct page *page;
|
|
unsigned long tid;
|
|
|
|
s = slab_pre_alloc_hook(s, gfpflags);
|
|
if (!s)
|
|
return NULL;
|
|
redo:
|
|
/*
|
|
* Must read kmem_cache cpu data via this cpu ptr. Preemption is
|
|
* enabled. We may switch back and forth between cpus while
|
|
* reading from one cpu area. That does not matter as long
|
|
* as we end up on the original cpu again when doing the cmpxchg.
|
|
*
|
|
* We should guarantee that tid and kmem_cache are retrieved on
|
|
* the same cpu. It could be different if CONFIG_PREEMPT so we need
|
|
* to check if it is matched or not.
|
|
*/
|
|
do {
|
|
tid = this_cpu_read(s->cpu_slab->tid);
|
|
c = raw_cpu_ptr(s->cpu_slab);
|
|
} while (IS_ENABLED(CONFIG_PREEMPT) &&
|
|
unlikely(tid != READ_ONCE(c->tid)));
|
|
|
|
/*
|
|
* Irqless object alloc/free algorithm used here depends on sequence
|
|
* of fetching cpu_slab's data. tid should be fetched before anything
|
|
* on c to guarantee that object and page associated with previous tid
|
|
* won't be used with current tid. If we fetch tid first, object and
|
|
* page could be one associated with next tid and our alloc/free
|
|
* request will be failed. In this case, we will retry. So, no problem.
|
|
*/
|
|
barrier();
|
|
|
|
/*
|
|
* The transaction ids are globally unique per cpu and per operation on
|
|
* a per cpu queue. Thus they can be guarantee that the cmpxchg_double
|
|
* occurs on the right processor and that there was no operation on the
|
|
* linked list in between.
|
|
*/
|
|
|
|
object = c->freelist;
|
|
page = c->page;
|
|
if (unlikely(!object || !node_match(page, node))) {
|
|
object = __slab_alloc(s, gfpflags, node, addr, c);
|
|
stat(s, ALLOC_SLOWPATH);
|
|
} else {
|
|
void *next_object = get_freepointer_safe(s, object);
|
|
|
|
/*
|
|
* The cmpxchg will only match if there was no additional
|
|
* operation and if we are on the right processor.
|
|
*
|
|
* The cmpxchg does the following atomically (without lock
|
|
* semantics!)
|
|
* 1. Relocate first pointer to the current per cpu area.
|
|
* 2. Verify that tid and freelist have not been changed
|
|
* 3. If they were not changed replace tid and freelist
|
|
*
|
|
* Since this is without lock semantics the protection is only
|
|
* against code executing on this cpu *not* from access by
|
|
* other cpus.
|
|
*/
|
|
if (unlikely(!this_cpu_cmpxchg_double(
|
|
s->cpu_slab->freelist, s->cpu_slab->tid,
|
|
object, tid,
|
|
next_object, next_tid(tid)))) {
|
|
|
|
note_cmpxchg_failure("slab_alloc", s, tid);
|
|
goto redo;
|
|
}
|
|
prefetch_freepointer(s, next_object);
|
|
stat(s, ALLOC_FASTPATH);
|
|
}
|
|
|
|
maybe_wipe_obj_freeptr(s, object);
|
|
|
|
if (unlikely(slab_want_init_on_alloc(gfpflags, s)) && object)
|
|
memset(object, 0, s->object_size);
|
|
|
|
slab_post_alloc_hook(s, gfpflags, 1, &object);
|
|
|
|
return object;
|
|
}
|
|
|
|
static __always_inline void *slab_alloc(struct kmem_cache *s,
|
|
gfp_t gfpflags, unsigned long addr)
|
|
{
|
|
return slab_alloc_node(s, gfpflags, NUMA_NO_NODE, addr);
|
|
}
|
|
|
|
void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
|
|
{
|
|
void *ret = slab_alloc(s, gfpflags, _RET_IP_);
|
|
|
|
trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size,
|
|
s->size, gfpflags);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(kmem_cache_alloc);
|
|
|
|
#ifdef CONFIG_TRACING
|
|
void *kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size)
|
|
{
|
|
void *ret = slab_alloc(s, gfpflags, _RET_IP_);
|
|
trace_kmalloc(_RET_IP_, ret, size, s->size, gfpflags);
|
|
ret = kasan_kmalloc(s, ret, size, gfpflags);
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(kmem_cache_alloc_trace);
|
|
#endif
|
|
|
|
#ifdef CONFIG_NUMA
|
|
void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)
|
|
{
|
|
void *ret = slab_alloc_node(s, gfpflags, node, _RET_IP_);
|
|
|
|
trace_kmem_cache_alloc_node(_RET_IP_, ret,
|
|
s->object_size, s->size, gfpflags, node);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(kmem_cache_alloc_node);
|
|
|
|
#ifdef CONFIG_TRACING
|
|
void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
|
|
gfp_t gfpflags,
|
|
int node, size_t size)
|
|
{
|
|
void *ret = slab_alloc_node(s, gfpflags, node, _RET_IP_);
|
|
|
|
trace_kmalloc_node(_RET_IP_, ret,
|
|
size, s->size, gfpflags, node);
|
|
|
|
ret = kasan_kmalloc(s, ret, size, gfpflags);
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(kmem_cache_alloc_node_trace);
|
|
#endif
|
|
#endif /* CONFIG_NUMA */
|
|
|
|
/*
|
|
* Slow path handling. This may still be called frequently since objects
|
|
* have a longer lifetime than the cpu slabs in most processing loads.
|
|
*
|
|
* So we still attempt to reduce cache line usage. Just take the slab
|
|
* lock and free the item. If there is no additional partial page
|
|
* handling required then we can return immediately.
|
|
*/
|
|
static void __slab_free(struct kmem_cache *s, struct page *page,
|
|
void *head, void *tail, int cnt,
|
|
unsigned long addr)
|
|
|
|
{
|
|
void *prior;
|
|
int was_frozen;
|
|
struct page new;
|
|
unsigned long counters;
|
|
struct kmem_cache_node *n = NULL;
|
|
unsigned long uninitialized_var(flags);
|
|
|
|
stat(s, FREE_SLOWPATH);
|
|
|
|
if (kmem_cache_debug(s) &&
|
|
!free_debug_processing(s, page, head, tail, cnt, addr))
|
|
return;
|
|
|
|
do {
|
|
if (unlikely(n)) {
|
|
spin_unlock_irqrestore(&n->list_lock, flags);
|
|
n = NULL;
|
|
}
|
|
prior = page->freelist;
|
|
counters = page->counters;
|
|
set_freepointer(s, tail, prior);
|
|
new.counters = counters;
|
|
was_frozen = new.frozen;
|
|
new.inuse -= cnt;
|
|
if ((!new.inuse || !prior) && !was_frozen) {
|
|
|
|
if (kmem_cache_has_cpu_partial(s) && !prior) {
|
|
|
|
/*
|
|
* Slab was on no list before and will be
|
|
* partially empty
|
|
* We can defer the list move and instead
|
|
* freeze it.
|
|
*/
|
|
new.frozen = 1;
|
|
|
|
} else { /* Needs to be taken off a list */
|
|
|
|
n = get_node(s, page_to_nid(page));
|
|
/*
|
|
* Speculatively acquire the list_lock.
|
|
* If the cmpxchg does not succeed then we may
|
|
* drop the list_lock without any processing.
|
|
*
|
|
* Otherwise the list_lock will synchronize with
|
|
* other processors updating the list of slabs.
|
|
*/
|
|
spin_lock_irqsave(&n->list_lock, flags);
|
|
|
|
}
|
|
}
|
|
|
|
} while (!cmpxchg_double_slab(s, page,
|
|
prior, counters,
|
|
head, new.counters,
|
|
"__slab_free"));
|
|
|
|
if (likely(!n)) {
|
|
|
|
/*
|
|
* If we just froze the page then put it onto the
|
|
* per cpu partial list.
|
|
*/
|
|
if (new.frozen && !was_frozen) {
|
|
put_cpu_partial(s, page, 1);
|
|
stat(s, CPU_PARTIAL_FREE);
|
|
}
|
|
/*
|
|
* The list lock was not taken therefore no list
|
|
* activity can be necessary.
|
|
*/
|
|
if (was_frozen)
|
|
stat(s, FREE_FROZEN);
|
|
return;
|
|
}
|
|
|
|
if (unlikely(!new.inuse && n->nr_partial >= s->min_partial))
|
|
goto slab_empty;
|
|
|
|
/*
|
|
* Objects left in the slab. If it was not on the partial list before
|
|
* then add it.
|
|
*/
|
|
if (!kmem_cache_has_cpu_partial(s) && unlikely(!prior)) {
|
|
remove_full(s, n, page);
|
|
add_partial(n, page, DEACTIVATE_TO_TAIL);
|
|
stat(s, FREE_ADD_PARTIAL);
|
|
}
|
|
spin_unlock_irqrestore(&n->list_lock, flags);
|
|
return;
|
|
|
|
slab_empty:
|
|
if (prior) {
|
|
/*
|
|
* Slab on the partial list.
|
|
*/
|
|
remove_partial(n, page);
|
|
stat(s, FREE_REMOVE_PARTIAL);
|
|
} else {
|
|
/* Slab must be on the full list */
|
|
remove_full(s, n, page);
|
|
}
|
|
|
|
spin_unlock_irqrestore(&n->list_lock, flags);
|
|
stat(s, FREE_SLAB);
|
|
discard_slab(s, page);
|
|
}
|
|
|
|
/*
|
|
* Fastpath with forced inlining to produce a kfree and kmem_cache_free that
|
|
* can perform fastpath freeing without additional function calls.
|
|
*
|
|
* The fastpath is only possible if we are freeing to the current cpu slab
|
|
* of this processor. This typically the case if we have just allocated
|
|
* the item before.
|
|
*
|
|
* If fastpath is not possible then fall back to __slab_free where we deal
|
|
* with all sorts of special processing.
|
|
*
|
|
* Bulk free of a freelist with several objects (all pointing to the
|
|
* same page) possible by specifying head and tail ptr, plus objects
|
|
* count (cnt). Bulk free indicated by tail pointer being set.
|
|
*/
|
|
static __always_inline void do_slab_free(struct kmem_cache *s,
|
|
struct page *page, void *head, void *tail,
|
|
int cnt, unsigned long addr)
|
|
{
|
|
void *tail_obj = tail ? : head;
|
|
struct kmem_cache_cpu *c;
|
|
unsigned long tid;
|
|
redo:
|
|
/*
|
|
* Determine the currently cpus per cpu slab.
|
|
* The cpu may change afterward. However that does not matter since
|
|
* data is retrieved via this pointer. If we are on the same cpu
|
|
* during the cmpxchg then the free will succeed.
|
|
*/
|
|
do {
|
|
tid = this_cpu_read(s->cpu_slab->tid);
|
|
c = raw_cpu_ptr(s->cpu_slab);
|
|
} while (IS_ENABLED(CONFIG_PREEMPT) &&
|
|
unlikely(tid != READ_ONCE(c->tid)));
|
|
|
|
/* Same with comment on barrier() in slab_alloc_node() */
|
|
barrier();
|
|
|
|
if (likely(page == c->page)) {
|
|
set_freepointer(s, tail_obj, c->freelist);
|
|
|
|
if (unlikely(!this_cpu_cmpxchg_double(
|
|
s->cpu_slab->freelist, s->cpu_slab->tid,
|
|
c->freelist, tid,
|
|
head, next_tid(tid)))) {
|
|
|
|
note_cmpxchg_failure("slab_free", s, tid);
|
|
goto redo;
|
|
}
|
|
stat(s, FREE_FASTPATH);
|
|
} else
|
|
__slab_free(s, page, head, tail_obj, cnt, addr);
|
|
|
|
}
|
|
|
|
static __always_inline void slab_free(struct kmem_cache *s, struct page *page,
|
|
void *head, void *tail, int cnt,
|
|
unsigned long addr)
|
|
{
|
|
/*
|
|
* With KASAN enabled slab_free_freelist_hook modifies the freelist
|
|
* to remove objects, whose reuse must be delayed.
|
|
*/
|
|
if (slab_free_freelist_hook(s, &head, &tail))
|
|
do_slab_free(s, page, head, tail, cnt, addr);
|
|
}
|
|
|
|
#ifdef CONFIG_KASAN_GENERIC
|
|
void ___cache_free(struct kmem_cache *cache, void *x, unsigned long addr)
|
|
{
|
|
do_slab_free(cache, virt_to_head_page(x), x, NULL, 1, addr);
|
|
}
|
|
#endif
|
|
|
|
void kmem_cache_free(struct kmem_cache *s, void *x)
|
|
{
|
|
s = cache_from_obj(s, x);
|
|
if (!s)
|
|
return;
|
|
slab_free(s, virt_to_head_page(x), x, NULL, 1, _RET_IP_);
|
|
trace_kmem_cache_free(_RET_IP_, x);
|
|
}
|
|
EXPORT_SYMBOL(kmem_cache_free);
|
|
|
|
struct detached_freelist {
|
|
struct page *page;
|
|
void *tail;
|
|
void *freelist;
|
|
int cnt;
|
|
struct kmem_cache *s;
|
|
};
|
|
|
|
/*
|
|
* This function progressively scans the array with free objects (with
|
|
* a limited look ahead) and extract objects belonging to the same
|
|
* page. It builds a detached freelist directly within the given
|
|
* page/objects. This can happen without any need for
|
|
* synchronization, because the objects are owned by running process.
|
|
* The freelist is build up as a single linked list in the objects.
|
|
* The idea is, that this detached freelist can then be bulk
|
|
* transferred to the real freelist(s), but only requiring a single
|
|
* synchronization primitive. Look ahead in the array is limited due
|
|
* to performance reasons.
|
|
*/
|
|
static inline
|
|
int build_detached_freelist(struct kmem_cache *s, size_t size,
|
|
void **p, struct detached_freelist *df)
|
|
{
|
|
size_t first_skipped_index = 0;
|
|
int lookahead = 3;
|
|
void *object;
|
|
struct page *page;
|
|
|
|
/* Always re-init detached_freelist */
|
|
df->page = NULL;
|
|
|
|
do {
|
|
object = p[--size];
|
|
/* Do we need !ZERO_OR_NULL_PTR(object) here? (for kfree) */
|
|
} while (!object && size);
|
|
|
|
if (!object)
|
|
return 0;
|
|
|
|
page = virt_to_head_page(object);
|
|
if (!s) {
|
|
/* Handle kalloc'ed objects */
|
|
if (unlikely(!PageSlab(page))) {
|
|
BUG_ON(!PageCompound(page));
|
|
kfree_hook(object);
|
|
__free_pages(page, compound_order(page));
|
|
p[size] = NULL; /* mark object processed */
|
|
return size;
|
|
}
|
|
/* Derive kmem_cache from object */
|
|
df->s = page->slab_cache;
|
|
} else {
|
|
df->s = cache_from_obj(s, object); /* Support for memcg */
|
|
}
|
|
|
|
/* Start new detached freelist */
|
|
df->page = page;
|
|
set_freepointer(df->s, object, NULL);
|
|
df->tail = object;
|
|
df->freelist = object;
|
|
p[size] = NULL; /* mark object processed */
|
|
df->cnt = 1;
|
|
|
|
while (size) {
|
|
object = p[--size];
|
|
if (!object)
|
|
continue; /* Skip processed objects */
|
|
|
|
/* df->page is always set at this point */
|
|
if (df->page == virt_to_head_page(object)) {
|
|
/* Opportunity build freelist */
|
|
set_freepointer(df->s, object, df->freelist);
|
|
df->freelist = object;
|
|
df->cnt++;
|
|
p[size] = NULL; /* mark object processed */
|
|
|
|
continue;
|
|
}
|
|
|
|
/* Limit look ahead search */
|
|
if (!--lookahead)
|
|
break;
|
|
|
|
if (!first_skipped_index)
|
|
first_skipped_index = size + 1;
|
|
}
|
|
|
|
return first_skipped_index;
|
|
}
|
|
|
|
/* Note that interrupts must be enabled when calling this function. */
|
|
void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p)
|
|
{
|
|
if (WARN_ON(!size))
|
|
return;
|
|
|
|
do {
|
|
struct detached_freelist df;
|
|
|
|
size = build_detached_freelist(s, size, p, &df);
|
|
if (!df.page)
|
|
continue;
|
|
|
|
slab_free(df.s, df.page, df.freelist, df.tail, df.cnt,_RET_IP_);
|
|
} while (likely(size));
|
|
}
|
|
EXPORT_SYMBOL(kmem_cache_free_bulk);
|
|
|
|
/* Note that interrupts must be enabled when calling this function. */
|
|
int kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size,
|
|
void **p)
|
|
{
|
|
struct kmem_cache_cpu *c;
|
|
int i;
|
|
|
|
/* memcg and kmem_cache debug support */
|
|
s = slab_pre_alloc_hook(s, flags);
|
|
if (unlikely(!s))
|
|
return false;
|
|
/*
|
|
* Drain objects in the per cpu slab, while disabling local
|
|
* IRQs, which protects against PREEMPT and interrupts
|
|
* handlers invoking normal fastpath.
|
|
*/
|
|
local_irq_disable();
|
|
c = this_cpu_ptr(s->cpu_slab);
|
|
|
|
for (i = 0; i < size; i++) {
|
|
void *object = c->freelist;
|
|
|
|
if (unlikely(!object)) {
|
|
/*
|
|
* Invoking slow path likely have side-effect
|
|
* of re-populating per CPU c->freelist
|
|
*/
|
|
p[i] = ___slab_alloc(s, flags, NUMA_NO_NODE,
|
|
_RET_IP_, c);
|
|
if (unlikely(!p[i]))
|
|
goto error;
|
|
|
|
c = this_cpu_ptr(s->cpu_slab);
|
|
maybe_wipe_obj_freeptr(s, p[i]);
|
|
|
|
continue; /* goto for-loop */
|
|
}
|
|
c->freelist = get_freepointer(s, object);
|
|
p[i] = object;
|
|
maybe_wipe_obj_freeptr(s, p[i]);
|
|
}
|
|
c->tid = next_tid(c->tid);
|
|
local_irq_enable();
|
|
|
|
/* Clear memory outside IRQ disabled fastpath loop */
|
|
if (unlikely(slab_want_init_on_alloc(flags, s))) {
|
|
int j;
|
|
|
|
for (j = 0; j < i; j++)
|
|
memset(p[j], 0, s->object_size);
|
|
}
|
|
|
|
/* memcg and kmem_cache debug support */
|
|
slab_post_alloc_hook(s, flags, size, p);
|
|
return i;
|
|
error:
|
|
local_irq_enable();
|
|
slab_post_alloc_hook(s, flags, i, p);
|
|
__kmem_cache_free_bulk(s, i, p);
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(kmem_cache_alloc_bulk);
|
|
|
|
|
|
/*
|
|
* Object placement in a slab is made very easy because we always start at
|
|
* offset 0. If we tune the size of the object to the alignment then we can
|
|
* get the required alignment by putting one properly sized object after
|
|
* another.
|
|
*
|
|
* Notice that the allocation order determines the sizes of the per cpu
|
|
* caches. Each processor has always one slab available for allocations.
|
|
* Increasing the allocation order reduces the number of times that slabs
|
|
* must be moved on and off the partial lists and is therefore a factor in
|
|
* locking overhead.
|
|
*/
|
|
|
|
/*
|
|
* Mininum / Maximum order of slab pages. This influences locking overhead
|
|
* and slab fragmentation. A higher order reduces the number of partial slabs
|
|
* and increases the number of allocations possible without having to
|
|
* take the list_lock.
|
|
*/
|
|
static unsigned int slub_min_order;
|
|
static unsigned int slub_max_order = PAGE_ALLOC_COSTLY_ORDER;
|
|
static unsigned int slub_min_objects;
|
|
|
|
/*
|
|
* Calculate the order of allocation given an slab object size.
|
|
*
|
|
* The order of allocation has significant impact on performance and other
|
|
* system components. Generally order 0 allocations should be preferred since
|
|
* order 0 does not cause fragmentation in the page allocator. Larger objects
|
|
* be problematic to put into order 0 slabs because there may be too much
|
|
* unused space left. We go to a higher order if more than 1/16th of the slab
|
|
* would be wasted.
|
|
*
|
|
* In order to reach satisfactory performance we must ensure that a minimum
|
|
* number of objects is in one slab. Otherwise we may generate too much
|
|
* activity on the partial lists which requires taking the list_lock. This is
|
|
* less a concern for large slabs though which are rarely used.
|
|
*
|
|
* slub_max_order specifies the order where we begin to stop considering the
|
|
* number of objects in a slab as critical. If we reach slub_max_order then
|
|
* we try to keep the page order as low as possible. So we accept more waste
|
|
* of space in favor of a small page order.
|
|
*
|
|
* Higher order allocations also allow the placement of more objects in a
|
|
* slab and thereby reduce object handling overhead. If the user has
|
|
* requested a higher mininum order then we start with that one instead of
|
|
* the smallest order which will fit the object.
|
|
*/
|
|
static inline unsigned int slab_order(unsigned int size,
|
|
unsigned int min_objects, unsigned int max_order,
|
|
unsigned int fract_leftover)
|
|
{
|
|
unsigned int min_order = slub_min_order;
|
|
unsigned int order;
|
|
|
|
if (order_objects(min_order, size) > MAX_OBJS_PER_PAGE)
|
|
return get_order(size * MAX_OBJS_PER_PAGE) - 1;
|
|
|
|
for (order = max(min_order, (unsigned int)get_order(min_objects * size));
|
|
order <= max_order; order++) {
|
|
|
|
unsigned int slab_size = (unsigned int)PAGE_SIZE << order;
|
|
unsigned int rem;
|
|
|
|
rem = slab_size % size;
|
|
|
|
if (rem <= slab_size / fract_leftover)
|
|
break;
|
|
}
|
|
|
|
return order;
|
|
}
|
|
|
|
static inline int calculate_order(unsigned int size)
|
|
{
|
|
unsigned int order;
|
|
unsigned int min_objects;
|
|
unsigned int max_objects;
|
|
|
|
/*
|
|
* Attempt to find best configuration for a slab. This
|
|
* works by first attempting to generate a layout with
|
|
* the best configuration and backing off gradually.
|
|
*
|
|
* First we increase the acceptable waste in a slab. Then
|
|
* we reduce the minimum objects required in a slab.
|
|
*/
|
|
min_objects = slub_min_objects;
|
|
if (!min_objects)
|
|
min_objects = 4 * (fls(nr_cpu_ids) + 1);
|
|
max_objects = order_objects(slub_max_order, size);
|
|
min_objects = min(min_objects, max_objects);
|
|
|
|
while (min_objects > 1) {
|
|
unsigned int fraction;
|
|
|
|
fraction = 16;
|
|
while (fraction >= 4) {
|
|
order = slab_order(size, min_objects,
|
|
slub_max_order, fraction);
|
|
if (order <= slub_max_order)
|
|
return order;
|
|
fraction /= 2;
|
|
}
|
|
min_objects--;
|
|
}
|
|
|
|
/*
|
|
* We were unable to place multiple objects in a slab. Now
|
|
* lets see if we can place a single object there.
|
|
*/
|
|
order = slab_order(size, 1, slub_max_order, 1);
|
|
if (order <= slub_max_order)
|
|
return order;
|
|
|
|
/*
|
|
* Doh this slab cannot be placed using slub_max_order.
|
|
*/
|
|
order = slab_order(size, 1, MAX_ORDER, 1);
|
|
if (order < MAX_ORDER)
|
|
return order;
|
|
return -ENOSYS;
|
|
}
|
|
|
|
static void
|
|
init_kmem_cache_node(struct kmem_cache_node *n)
|
|
{
|
|
n->nr_partial = 0;
|
|
spin_lock_init(&n->list_lock);
|
|
INIT_LIST_HEAD(&n->partial);
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
atomic_long_set(&n->nr_slabs, 0);
|
|
atomic_long_set(&n->total_objects, 0);
|
|
INIT_LIST_HEAD(&n->full);
|
|
#endif
|
|
}
|
|
|
|
static inline int alloc_kmem_cache_cpus(struct kmem_cache *s)
|
|
{
|
|
BUILD_BUG_ON(PERCPU_DYNAMIC_EARLY_SIZE <
|
|
KMALLOC_SHIFT_HIGH * sizeof(struct kmem_cache_cpu));
|
|
|
|
/*
|
|
* Must align to double word boundary for the double cmpxchg
|
|
* instructions to work; see __pcpu_double_call_return_bool().
|
|
*/
|
|
s->cpu_slab = __alloc_percpu(sizeof(struct kmem_cache_cpu),
|
|
2 * sizeof(void *));
|
|
|
|
if (!s->cpu_slab)
|
|
return 0;
|
|
|
|
init_kmem_cache_cpus(s);
|
|
|
|
return 1;
|
|
}
|
|
|
|
static struct kmem_cache *kmem_cache_node;
|
|
|
|
/*
|
|
* No kmalloc_node yet so do it by hand. We know that this is the first
|
|
* slab on the node for this slabcache. There are no concurrent accesses
|
|
* possible.
|
|
*
|
|
* Note that this function only works on the kmem_cache_node
|
|
* when allocating for the kmem_cache_node. This is used for bootstrapping
|
|
* memory on a fresh node that has no slab structures yet.
|
|
*/
|
|
static void early_kmem_cache_node_alloc(int node)
|
|
{
|
|
struct page *page;
|
|
struct kmem_cache_node *n;
|
|
|
|
BUG_ON(kmem_cache_node->size < sizeof(struct kmem_cache_node));
|
|
|
|
page = new_slab(kmem_cache_node, GFP_NOWAIT, node);
|
|
|
|
BUG_ON(!page);
|
|
if (page_to_nid(page) != node) {
|
|
pr_err("SLUB: Unable to allocate memory from node %d\n", node);
|
|
pr_err("SLUB: Allocating a useless per node structure in order to be able to continue\n");
|
|
}
|
|
|
|
n = page->freelist;
|
|
BUG_ON(!n);
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
init_object(kmem_cache_node, n, SLUB_RED_ACTIVE);
|
|
init_tracking(kmem_cache_node, n);
|
|
#endif
|
|
n = kasan_kmalloc(kmem_cache_node, n, sizeof(struct kmem_cache_node),
|
|
GFP_KERNEL);
|
|
page->freelist = get_freepointer(kmem_cache_node, n);
|
|
page->inuse = 1;
|
|
page->frozen = 0;
|
|
kmem_cache_node->node[node] = n;
|
|
init_kmem_cache_node(n);
|
|
inc_slabs_node(kmem_cache_node, node, page->objects);
|
|
|
|
/*
|
|
* No locks need to be taken here as it has just been
|
|
* initialized and there is no concurrent access.
|
|
*/
|
|
__add_partial(n, page, DEACTIVATE_TO_HEAD);
|
|
}
|
|
|
|
static void free_kmem_cache_nodes(struct kmem_cache *s)
|
|
{
|
|
int node;
|
|
struct kmem_cache_node *n;
|
|
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
s->node[node] = NULL;
|
|
kmem_cache_free(kmem_cache_node, n);
|
|
}
|
|
}
|
|
|
|
void __kmem_cache_release(struct kmem_cache *s)
|
|
{
|
|
cache_random_seq_destroy(s);
|
|
free_percpu(s->cpu_slab);
|
|
free_kmem_cache_nodes(s);
|
|
}
|
|
|
|
static int init_kmem_cache_nodes(struct kmem_cache *s)
|
|
{
|
|
int node;
|
|
|
|
for_each_node_state(node, N_NORMAL_MEMORY) {
|
|
struct kmem_cache_node *n;
|
|
|
|
if (slab_state == DOWN) {
|
|
early_kmem_cache_node_alloc(node);
|
|
continue;
|
|
}
|
|
n = kmem_cache_alloc_node(kmem_cache_node,
|
|
GFP_KERNEL, node);
|
|
|
|
if (!n) {
|
|
free_kmem_cache_nodes(s);
|
|
return 0;
|
|
}
|
|
|
|
init_kmem_cache_node(n);
|
|
s->node[node] = n;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static void set_min_partial(struct kmem_cache *s, unsigned long min)
|
|
{
|
|
if (min < MIN_PARTIAL)
|
|
min = MIN_PARTIAL;
|
|
else if (min > MAX_PARTIAL)
|
|
min = MAX_PARTIAL;
|
|
s->min_partial = min;
|
|
}
|
|
|
|
static void set_cpu_partial(struct kmem_cache *s)
|
|
{
|
|
#ifdef CONFIG_SLUB_CPU_PARTIAL
|
|
/*
|
|
* cpu_partial determined the maximum number of objects kept in the
|
|
* per cpu partial lists of a processor.
|
|
*
|
|
* Per cpu partial lists mainly contain slabs that just have one
|
|
* object freed. If they are used for allocation then they can be
|
|
* filled up again with minimal effort. The slab will never hit the
|
|
* per node partial lists and therefore no locking will be required.
|
|
*
|
|
* This setting also determines
|
|
*
|
|
* A) The number of objects from per cpu partial slabs dumped to the
|
|
* per node list when we reach the limit.
|
|
* B) The number of objects in cpu partial slabs to extract from the
|
|
* per node list when we run out of per cpu objects. We only fetch
|
|
* 50% to keep some capacity around for frees.
|
|
*/
|
|
if (!kmem_cache_has_cpu_partial(s))
|
|
s->cpu_partial = 0;
|
|
else if (s->size >= PAGE_SIZE)
|
|
s->cpu_partial = 2;
|
|
else if (s->size >= 1024)
|
|
s->cpu_partial = 6;
|
|
else if (s->size >= 256)
|
|
s->cpu_partial = 13;
|
|
else
|
|
s->cpu_partial = 30;
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
* calculate_sizes() determines the order and the distribution of data within
|
|
* a slab object.
|
|
*/
|
|
static int calculate_sizes(struct kmem_cache *s, int forced_order)
|
|
{
|
|
slab_flags_t flags = s->flags;
|
|
unsigned int size = s->object_size;
|
|
unsigned int order;
|
|
|
|
/*
|
|
* Round up object size to the next word boundary. We can only
|
|
* place the free pointer at word boundaries and this determines
|
|
* the possible location of the free pointer.
|
|
*/
|
|
size = ALIGN(size, sizeof(void *));
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
/*
|
|
* Determine if we can poison the object itself. If the user of
|
|
* the slab may touch the object after free or before allocation
|
|
* then we should never poison the object itself.
|
|
*/
|
|
if ((flags & SLAB_POISON) && !(flags & SLAB_TYPESAFE_BY_RCU) &&
|
|
!s->ctor)
|
|
s->flags |= __OBJECT_POISON;
|
|
else
|
|
s->flags &= ~__OBJECT_POISON;
|
|
|
|
|
|
/*
|
|
* If we are Redzoning then check if there is some space between the
|
|
* end of the object and the free pointer. If not then add an
|
|
* additional word to have some bytes to store Redzone information.
|
|
*/
|
|
if ((flags & SLAB_RED_ZONE) && size == s->object_size)
|
|
size += sizeof(void *);
|
|
#endif
|
|
|
|
/*
|
|
* With that we have determined the number of bytes in actual use
|
|
* by the object. This is the potential offset to the free pointer.
|
|
*/
|
|
s->inuse = size;
|
|
|
|
if (((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) ||
|
|
s->ctor)) {
|
|
/*
|
|
* Relocate free pointer after the object if it is not
|
|
* permitted to overwrite the first word of the object on
|
|
* kmem_cache_free.
|
|
*
|
|
* This is the case if we do RCU, have a constructor or
|
|
* destructor or are poisoning the objects.
|
|
*/
|
|
s->offset = size;
|
|
size += sizeof(void *);
|
|
}
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
if (flags & SLAB_STORE_USER)
|
|
/*
|
|
* Need to store information about allocs and frees after
|
|
* the object.
|
|
*/
|
|
size += 2 * sizeof(struct track);
|
|
#endif
|
|
|
|
kasan_cache_create(s, &size, &s->flags);
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
if (flags & SLAB_RED_ZONE) {
|
|
/*
|
|
* Add some empty padding so that we can catch
|
|
* overwrites from earlier objects rather than let
|
|
* tracking information or the free pointer be
|
|
* corrupted if a user writes before the start
|
|
* of the object.
|
|
*/
|
|
size += sizeof(void *);
|
|
|
|
s->red_left_pad = sizeof(void *);
|
|
s->red_left_pad = ALIGN(s->red_left_pad, s->align);
|
|
size += s->red_left_pad;
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* SLUB stores one object immediately after another beginning from
|
|
* offset 0. In order to align the objects we have to simply size
|
|
* each object to conform to the alignment.
|
|
*/
|
|
size = ALIGN(size, s->align);
|
|
s->size = size;
|
|
if (forced_order >= 0)
|
|
order = forced_order;
|
|
else
|
|
order = calculate_order(size);
|
|
|
|
if ((int)order < 0)
|
|
return 0;
|
|
|
|
s->allocflags = 0;
|
|
if (order)
|
|
s->allocflags |= __GFP_COMP;
|
|
|
|
if (s->flags & SLAB_CACHE_DMA)
|
|
s->allocflags |= GFP_DMA;
|
|
|
|
if (s->flags & SLAB_CACHE_DMA32)
|
|
s->allocflags |= GFP_DMA32;
|
|
|
|
if (s->flags & SLAB_RECLAIM_ACCOUNT)
|
|
s->allocflags |= __GFP_RECLAIMABLE;
|
|
|
|
/*
|
|
* Determine the number of objects per slab
|
|
*/
|
|
s->oo = oo_make(order, size);
|
|
s->min = oo_make(get_order(size), size);
|
|
if (oo_objects(s->oo) > oo_objects(s->max))
|
|
s->max = s->oo;
|
|
|
|
return !!oo_objects(s->oo);
|
|
}
|
|
|
|
static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags)
|
|
{
|
|
s->flags = kmem_cache_flags(s->size, flags, s->name, s->ctor);
|
|
#ifdef CONFIG_SLAB_FREELIST_HARDENED
|
|
s->random = get_random_long();
|
|
#endif
|
|
|
|
if (!calculate_sizes(s, -1))
|
|
goto error;
|
|
if (disable_higher_order_debug) {
|
|
/*
|
|
* Disable debugging flags that store metadata if the min slab
|
|
* order increased.
|
|
*/
|
|
if (get_order(s->size) > get_order(s->object_size)) {
|
|
s->flags &= ~DEBUG_METADATA_FLAGS;
|
|
s->offset = 0;
|
|
if (!calculate_sizes(s, -1))
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \
|
|
defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
|
|
if (system_has_cmpxchg_double() && (s->flags & SLAB_NO_CMPXCHG) == 0)
|
|
/* Enable fast mode */
|
|
s->flags |= __CMPXCHG_DOUBLE;
|
|
#endif
|
|
|
|
/*
|
|
* The larger the object size is, the more pages we want on the partial
|
|
* list to avoid pounding the page allocator excessively.
|
|
*/
|
|
set_min_partial(s, ilog2(s->size) / 2);
|
|
|
|
set_cpu_partial(s);
|
|
|
|
#ifdef CONFIG_NUMA
|
|
s->remote_node_defrag_ratio = 1000;
|
|
#endif
|
|
|
|
/* Initialize the pre-computed randomized freelist if slab is up */
|
|
if (slab_state >= UP) {
|
|
if (init_cache_random_seq(s))
|
|
goto error;
|
|
}
|
|
|
|
if (!init_kmem_cache_nodes(s))
|
|
goto error;
|
|
|
|
if (alloc_kmem_cache_cpus(s))
|
|
return 0;
|
|
|
|
free_kmem_cache_nodes(s);
|
|
error:
|
|
return -EINVAL;
|
|
}
|
|
|
|
static void list_slab_objects(struct kmem_cache *s, struct page *page,
|
|
const char *text)
|
|
{
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
void *addr = page_address(page);
|
|
void *p;
|
|
unsigned long *map = bitmap_zalloc(page->objects, GFP_ATOMIC);
|
|
if (!map)
|
|
return;
|
|
slab_err(s, page, text, s->name);
|
|
slab_lock(page);
|
|
|
|
get_map(s, page, map);
|
|
for_each_object(p, s, addr, page->objects) {
|
|
|
|
if (!test_bit(slab_index(p, s, addr), map)) {
|
|
pr_err("INFO: Object 0x%p @offset=%tu\n", p, p - addr);
|
|
print_tracking(s, p);
|
|
}
|
|
}
|
|
slab_unlock(page);
|
|
bitmap_free(map);
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
* Attempt to free all partial slabs on a node.
|
|
* This is called from __kmem_cache_shutdown(). We must take list_lock
|
|
* because sysfs file might still access partial list after the shutdowning.
|
|
*/
|
|
static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
|
|
{
|
|
LIST_HEAD(discard);
|
|
struct page *page, *h;
|
|
|
|
BUG_ON(irqs_disabled());
|
|
spin_lock_irq(&n->list_lock);
|
|
list_for_each_entry_safe(page, h, &n->partial, slab_list) {
|
|
if (!page->inuse) {
|
|
remove_partial(n, page);
|
|
list_add(&page->slab_list, &discard);
|
|
} else {
|
|
list_slab_objects(s, page,
|
|
"Objects remaining in %s on __kmem_cache_shutdown()");
|
|
}
|
|
}
|
|
spin_unlock_irq(&n->list_lock);
|
|
|
|
list_for_each_entry_safe(page, h, &discard, slab_list)
|
|
discard_slab(s, page);
|
|
}
|
|
|
|
bool __kmem_cache_empty(struct kmem_cache *s)
|
|
{
|
|
int node;
|
|
struct kmem_cache_node *n;
|
|
|
|
for_each_kmem_cache_node(s, node, n)
|
|
if (n->nr_partial || slabs_node(s, node))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* Release all resources used by a slab cache.
|
|
*/
|
|
int __kmem_cache_shutdown(struct kmem_cache *s)
|
|
{
|
|
int node;
|
|
struct kmem_cache_node *n;
|
|
|
|
flush_all(s);
|
|
/* Attempt to free all objects */
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
free_partial(s, n);
|
|
if (n->nr_partial || slabs_node(s, node))
|
|
return 1;
|
|
}
|
|
sysfs_slab_remove(s);
|
|
return 0;
|
|
}
|
|
|
|
/********************************************************************
|
|
* Kmalloc subsystem
|
|
*******************************************************************/
|
|
|
|
static int __init setup_slub_min_order(char *str)
|
|
{
|
|
get_option(&str, (int *)&slub_min_order);
|
|
|
|
return 1;
|
|
}
|
|
|
|
__setup("slub_min_order=", setup_slub_min_order);
|
|
|
|
static int __init setup_slub_max_order(char *str)
|
|
{
|
|
get_option(&str, (int *)&slub_max_order);
|
|
slub_max_order = min(slub_max_order, (unsigned int)MAX_ORDER - 1);
|
|
|
|
return 1;
|
|
}
|
|
|
|
__setup("slub_max_order=", setup_slub_max_order);
|
|
|
|
static int __init setup_slub_min_objects(char *str)
|
|
{
|
|
get_option(&str, (int *)&slub_min_objects);
|
|
|
|
return 1;
|
|
}
|
|
|
|
__setup("slub_min_objects=", setup_slub_min_objects);
|
|
|
|
void *__kmalloc(size_t size, gfp_t flags)
|
|
{
|
|
struct kmem_cache *s;
|
|
void *ret;
|
|
|
|
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
|
|
return kmalloc_large(size, flags);
|
|
|
|
s = kmalloc_slab(size, flags);
|
|
|
|
if (unlikely(ZERO_OR_NULL_PTR(s)))
|
|
return s;
|
|
|
|
ret = slab_alloc(s, flags, _RET_IP_);
|
|
|
|
trace_kmalloc(_RET_IP_, ret, size, s->size, flags);
|
|
|
|
ret = kasan_kmalloc(s, ret, size, flags);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(__kmalloc);
|
|
|
|
#ifdef CONFIG_NUMA
|
|
static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
|
|
{
|
|
struct page *page;
|
|
void *ptr = NULL;
|
|
unsigned int order = get_order(size);
|
|
|
|
flags |= __GFP_COMP;
|
|
page = alloc_pages_node(node, flags, order);
|
|
if (page) {
|
|
ptr = page_address(page);
|
|
mod_node_page_state(page_pgdat(page), NR_SLAB_UNRECLAIMABLE,
|
|
1 << order);
|
|
}
|
|
|
|
return kmalloc_large_node_hook(ptr, size, flags);
|
|
}
|
|
|
|
void *__kmalloc_node(size_t size, gfp_t flags, int node)
|
|
{
|
|
struct kmem_cache *s;
|
|
void *ret;
|
|
|
|
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
|
|
ret = kmalloc_large_node(size, flags, node);
|
|
|
|
trace_kmalloc_node(_RET_IP_, ret,
|
|
size, PAGE_SIZE << get_order(size),
|
|
flags, node);
|
|
|
|
return ret;
|
|
}
|
|
|
|
s = kmalloc_slab(size, flags);
|
|
|
|
if (unlikely(ZERO_OR_NULL_PTR(s)))
|
|
return s;
|
|
|
|
ret = slab_alloc_node(s, flags, node, _RET_IP_);
|
|
|
|
trace_kmalloc_node(_RET_IP_, ret, size, s->size, flags, node);
|
|
|
|
ret = kasan_kmalloc(s, ret, size, flags);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(__kmalloc_node);
|
|
#endif /* CONFIG_NUMA */
|
|
|
|
#ifdef CONFIG_HARDENED_USERCOPY
|
|
/*
|
|
* Rejects incorrectly sized objects and objects that are to be copied
|
|
* to/from userspace but do not fall entirely within the containing slab
|
|
* cache's usercopy region.
|
|
*
|
|
* Returns NULL if check passes, otherwise const char * to name of cache
|
|
* to indicate an error.
|
|
*/
|
|
void __check_heap_object(const void *ptr, unsigned long n, struct page *page,
|
|
bool to_user)
|
|
{
|
|
struct kmem_cache *s;
|
|
unsigned int offset;
|
|
size_t object_size;
|
|
|
|
ptr = kasan_reset_tag(ptr);
|
|
|
|
/* Find object and usable object size. */
|
|
s = page->slab_cache;
|
|
|
|
/* Reject impossible pointers. */
|
|
if (ptr < page_address(page))
|
|
usercopy_abort("SLUB object not in SLUB page?!", NULL,
|
|
to_user, 0, n);
|
|
|
|
/* Find offset within object. */
|
|
offset = (ptr - page_address(page)) % s->size;
|
|
|
|
/* Adjust for redzone and reject if within the redzone. */
|
|
if (kmem_cache_debug(s) && s->flags & SLAB_RED_ZONE) {
|
|
if (offset < s->red_left_pad)
|
|
usercopy_abort("SLUB object in left red zone",
|
|
s->name, to_user, offset, n);
|
|
offset -= s->red_left_pad;
|
|
}
|
|
|
|
/* Allow address range falling entirely within usercopy region. */
|
|
if (offset >= s->useroffset &&
|
|
offset - s->useroffset <= s->usersize &&
|
|
n <= s->useroffset - offset + s->usersize)
|
|
return;
|
|
|
|
/*
|
|
* If the copy is still within the allocated object, produce
|
|
* a warning instead of rejecting the copy. This is intended
|
|
* to be a temporary method to find any missing usercopy
|
|
* whitelists.
|
|
*/
|
|
object_size = slab_ksize(s);
|
|
if (usercopy_fallback &&
|
|
offset <= object_size && n <= object_size - offset) {
|
|
usercopy_warn("SLUB object", s->name, to_user, offset, n);
|
|
return;
|
|
}
|
|
|
|
usercopy_abort("SLUB object", s->name, to_user, offset, n);
|
|
}
|
|
#endif /* CONFIG_HARDENED_USERCOPY */
|
|
|
|
size_t __ksize(const void *object)
|
|
{
|
|
struct page *page;
|
|
|
|
if (unlikely(object == ZERO_SIZE_PTR))
|
|
return 0;
|
|
|
|
page = virt_to_head_page(object);
|
|
|
|
if (unlikely(!PageSlab(page))) {
|
|
WARN_ON(!PageCompound(page));
|
|
return page_size(page);
|
|
}
|
|
|
|
return slab_ksize(page->slab_cache);
|
|
}
|
|
EXPORT_SYMBOL(__ksize);
|
|
|
|
void kfree(const void *x)
|
|
{
|
|
struct page *page;
|
|
void *object = (void *)x;
|
|
|
|
trace_kfree(_RET_IP_, x);
|
|
|
|
if (unlikely(ZERO_OR_NULL_PTR(x)))
|
|
return;
|
|
|
|
page = virt_to_head_page(x);
|
|
if (unlikely(!PageSlab(page))) {
|
|
unsigned int order = compound_order(page);
|
|
|
|
BUG_ON(!PageCompound(page));
|
|
kfree_hook(object);
|
|
mod_node_page_state(page_pgdat(page), NR_SLAB_UNRECLAIMABLE,
|
|
-(1 << order));
|
|
__free_pages(page, order);
|
|
return;
|
|
}
|
|
slab_free(page->slab_cache, page, object, NULL, 1, _RET_IP_);
|
|
}
|
|
EXPORT_SYMBOL(kfree);
|
|
|
|
#define SHRINK_PROMOTE_MAX 32
|
|
|
|
/*
|
|
* kmem_cache_shrink discards empty slabs and promotes the slabs filled
|
|
* up most to the head of the partial lists. New allocations will then
|
|
* fill those up and thus they can be removed from the partial lists.
|
|
*
|
|
* The slabs with the least items are placed last. This results in them
|
|
* being allocated from last increasing the chance that the last objects
|
|
* are freed in them.
|
|
*/
|
|
int __kmem_cache_shrink(struct kmem_cache *s)
|
|
{
|
|
int node;
|
|
int i;
|
|
struct kmem_cache_node *n;
|
|
struct page *page;
|
|
struct page *t;
|
|
struct list_head discard;
|
|
struct list_head promote[SHRINK_PROMOTE_MAX];
|
|
unsigned long flags;
|
|
int ret = 0;
|
|
|
|
flush_all(s);
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
INIT_LIST_HEAD(&discard);
|
|
for (i = 0; i < SHRINK_PROMOTE_MAX; i++)
|
|
INIT_LIST_HEAD(promote + i);
|
|
|
|
spin_lock_irqsave(&n->list_lock, flags);
|
|
|
|
/*
|
|
* Build lists of slabs to discard or promote.
|
|
*
|
|
* Note that concurrent frees may occur while we hold the
|
|
* list_lock. page->inuse here is the upper limit.
|
|
*/
|
|
list_for_each_entry_safe(page, t, &n->partial, slab_list) {
|
|
int free = page->objects - page->inuse;
|
|
|
|
/* Do not reread page->inuse */
|
|
barrier();
|
|
|
|
/* We do not keep full slabs on the list */
|
|
BUG_ON(free <= 0);
|
|
|
|
if (free == page->objects) {
|
|
list_move(&page->slab_list, &discard);
|
|
n->nr_partial--;
|
|
} else if (free <= SHRINK_PROMOTE_MAX)
|
|
list_move(&page->slab_list, promote + free - 1);
|
|
}
|
|
|
|
/*
|
|
* Promote the slabs filled up most to the head of the
|
|
* partial list.
|
|
*/
|
|
for (i = SHRINK_PROMOTE_MAX - 1; i >= 0; i--)
|
|
list_splice(promote + i, &n->partial);
|
|
|
|
spin_unlock_irqrestore(&n->list_lock, flags);
|
|
|
|
/* Release empty slabs */
|
|
list_for_each_entry_safe(page, t, &discard, slab_list)
|
|
discard_slab(s, page);
|
|
|
|
if (slabs_node(s, node))
|
|
ret = 1;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
#ifdef CONFIG_MEMCG
|
|
void __kmemcg_cache_deactivate_after_rcu(struct kmem_cache *s)
|
|
{
|
|
/*
|
|
* Called with all the locks held after a sched RCU grace period.
|
|
* Even if @s becomes empty after shrinking, we can't know that @s
|
|
* doesn't have allocations already in-flight and thus can't
|
|
* destroy @s until the associated memcg is released.
|
|
*
|
|
* However, let's remove the sysfs files for empty caches here.
|
|
* Each cache has a lot of interface files which aren't
|
|
* particularly useful for empty draining caches; otherwise, we can
|
|
* easily end up with millions of unnecessary sysfs files on
|
|
* systems which have a lot of memory and transient cgroups.
|
|
*/
|
|
if (!__kmem_cache_shrink(s))
|
|
sysfs_slab_remove(s);
|
|
}
|
|
|
|
void __kmemcg_cache_deactivate(struct kmem_cache *s)
|
|
{
|
|
/*
|
|
* Disable empty slabs caching. Used to avoid pinning offline
|
|
* memory cgroups by kmem pages that can be freed.
|
|
*/
|
|
slub_set_cpu_partial(s, 0);
|
|
s->min_partial = 0;
|
|
}
|
|
#endif /* CONFIG_MEMCG */
|
|
|
|
static int slab_mem_going_offline_callback(void *arg)
|
|
{
|
|
struct kmem_cache *s;
|
|
|
|
mutex_lock(&slab_mutex);
|
|
list_for_each_entry(s, &slab_caches, list)
|
|
__kmem_cache_shrink(s);
|
|
mutex_unlock(&slab_mutex);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void slab_mem_offline_callback(void *arg)
|
|
{
|
|
struct kmem_cache_node *n;
|
|
struct kmem_cache *s;
|
|
struct memory_notify *marg = arg;
|
|
int offline_node;
|
|
|
|
offline_node = marg->status_change_nid_normal;
|
|
|
|
/*
|
|
* If the node still has available memory. we need kmem_cache_node
|
|
* for it yet.
|
|
*/
|
|
if (offline_node < 0)
|
|
return;
|
|
|
|
mutex_lock(&slab_mutex);
|
|
list_for_each_entry(s, &slab_caches, list) {
|
|
n = get_node(s, offline_node);
|
|
if (n) {
|
|
/*
|
|
* if n->nr_slabs > 0, slabs still exist on the node
|
|
* that is going down. We were unable to free them,
|
|
* and offline_pages() function shouldn't call this
|
|
* callback. So, we must fail.
|
|
*/
|
|
BUG_ON(slabs_node(s, offline_node));
|
|
|
|
s->node[offline_node] = NULL;
|
|
kmem_cache_free(kmem_cache_node, n);
|
|
}
|
|
}
|
|
mutex_unlock(&slab_mutex);
|
|
}
|
|
|
|
static int slab_mem_going_online_callback(void *arg)
|
|
{
|
|
struct kmem_cache_node *n;
|
|
struct kmem_cache *s;
|
|
struct memory_notify *marg = arg;
|
|
int nid = marg->status_change_nid_normal;
|
|
int ret = 0;
|
|
|
|
/*
|
|
* If the node's memory is already available, then kmem_cache_node is
|
|
* already created. Nothing to do.
|
|
*/
|
|
if (nid < 0)
|
|
return 0;
|
|
|
|
/*
|
|
* We are bringing a node online. No memory is available yet. We must
|
|
* allocate a kmem_cache_node structure in order to bring the node
|
|
* online.
|
|
*/
|
|
mutex_lock(&slab_mutex);
|
|
list_for_each_entry(s, &slab_caches, list) {
|
|
/*
|
|
* XXX: kmem_cache_alloc_node will fallback to other nodes
|
|
* since memory is not yet available from the node that
|
|
* is brought up.
|
|
*/
|
|
n = kmem_cache_alloc(kmem_cache_node, GFP_KERNEL);
|
|
if (!n) {
|
|
ret = -ENOMEM;
|
|
goto out;
|
|
}
|
|
init_kmem_cache_node(n);
|
|
s->node[nid] = n;
|
|
}
|
|
out:
|
|
mutex_unlock(&slab_mutex);
|
|
return ret;
|
|
}
|
|
|
|
static int slab_memory_callback(struct notifier_block *self,
|
|
unsigned long action, void *arg)
|
|
{
|
|
int ret = 0;
|
|
|
|
switch (action) {
|
|
case MEM_GOING_ONLINE:
|
|
ret = slab_mem_going_online_callback(arg);
|
|
break;
|
|
case MEM_GOING_OFFLINE:
|
|
ret = slab_mem_going_offline_callback(arg);
|
|
break;
|
|
case MEM_OFFLINE:
|
|
case MEM_CANCEL_ONLINE:
|
|
slab_mem_offline_callback(arg);
|
|
break;
|
|
case MEM_ONLINE:
|
|
case MEM_CANCEL_OFFLINE:
|
|
break;
|
|
}
|
|
if (ret)
|
|
ret = notifier_from_errno(ret);
|
|
else
|
|
ret = NOTIFY_OK;
|
|
return ret;
|
|
}
|
|
|
|
static struct notifier_block slab_memory_callback_nb = {
|
|
.notifier_call = slab_memory_callback,
|
|
.priority = SLAB_CALLBACK_PRI,
|
|
};
|
|
|
|
/********************************************************************
|
|
* Basic setup of slabs
|
|
*******************************************************************/
|
|
|
|
/*
|
|
* Used for early kmem_cache structures that were allocated using
|
|
* the page allocator. Allocate them properly then fix up the pointers
|
|
* that may be pointing to the wrong kmem_cache structure.
|
|
*/
|
|
|
|
static struct kmem_cache * __init bootstrap(struct kmem_cache *static_cache)
|
|
{
|
|
int node;
|
|
struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT);
|
|
struct kmem_cache_node *n;
|
|
|
|
memcpy(s, static_cache, kmem_cache->object_size);
|
|
|
|
/*
|
|
* This runs very early, and only the boot processor is supposed to be
|
|
* up. Even if it weren't true, IRQs are not up so we couldn't fire
|
|
* IPIs around.
|
|
*/
|
|
__flush_cpu_slab(s, smp_processor_id());
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
struct page *p;
|
|
|
|
list_for_each_entry(p, &n->partial, slab_list)
|
|
p->slab_cache = s;
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
list_for_each_entry(p, &n->full, slab_list)
|
|
p->slab_cache = s;
|
|
#endif
|
|
}
|
|
slab_init_memcg_params(s);
|
|
list_add(&s->list, &slab_caches);
|
|
memcg_link_cache(s, NULL);
|
|
return s;
|
|
}
|
|
|
|
void __init kmem_cache_init(void)
|
|
{
|
|
static __initdata struct kmem_cache boot_kmem_cache,
|
|
boot_kmem_cache_node;
|
|
|
|
if (debug_guardpage_minorder())
|
|
slub_max_order = 0;
|
|
|
|
kmem_cache_node = &boot_kmem_cache_node;
|
|
kmem_cache = &boot_kmem_cache;
|
|
|
|
create_boot_cache(kmem_cache_node, "kmem_cache_node",
|
|
sizeof(struct kmem_cache_node), SLAB_HWCACHE_ALIGN, 0, 0);
|
|
|
|
register_hotmemory_notifier(&slab_memory_callback_nb);
|
|
|
|
/* Able to allocate the per node structures */
|
|
slab_state = PARTIAL;
|
|
|
|
create_boot_cache(kmem_cache, "kmem_cache",
|
|
offsetof(struct kmem_cache, node) +
|
|
nr_node_ids * sizeof(struct kmem_cache_node *),
|
|
SLAB_HWCACHE_ALIGN, 0, 0);
|
|
|
|
kmem_cache = bootstrap(&boot_kmem_cache);
|
|
kmem_cache_node = bootstrap(&boot_kmem_cache_node);
|
|
|
|
/* Now we can use the kmem_cache to allocate kmalloc slabs */
|
|
setup_kmalloc_cache_index_table();
|
|
create_kmalloc_caches(0);
|
|
|
|
/* Setup random freelists for each cache */
|
|
init_freelist_randomization();
|
|
|
|
cpuhp_setup_state_nocalls(CPUHP_SLUB_DEAD, "slub:dead", NULL,
|
|
slub_cpu_dead);
|
|
|
|
pr_info("SLUB: HWalign=%d, Order=%u-%u, MinObjects=%u, CPUs=%u, Nodes=%u\n",
|
|
cache_line_size(),
|
|
slub_min_order, slub_max_order, slub_min_objects,
|
|
nr_cpu_ids, nr_node_ids);
|
|
}
|
|
|
|
void __init kmem_cache_init_late(void)
|
|
{
|
|
}
|
|
|
|
struct kmem_cache *
|
|
__kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
|
|
slab_flags_t flags, void (*ctor)(void *))
|
|
{
|
|
struct kmem_cache *s, *c;
|
|
|
|
s = find_mergeable(size, align, flags, name, ctor);
|
|
if (s) {
|
|
s->refcount++;
|
|
|
|
/*
|
|
* Adjust the object sizes so that we clear
|
|
* the complete object on kzalloc.
|
|
*/
|
|
s->object_size = max(s->object_size, size);
|
|
s->inuse = max(s->inuse, ALIGN(size, sizeof(void *)));
|
|
|
|
for_each_memcg_cache(c, s) {
|
|
c->object_size = s->object_size;
|
|
c->inuse = max(c->inuse, ALIGN(size, sizeof(void *)));
|
|
}
|
|
|
|
if (sysfs_slab_alias(s, name)) {
|
|
s->refcount--;
|
|
s = NULL;
|
|
}
|
|
}
|
|
|
|
return s;
|
|
}
|
|
|
|
int __kmem_cache_create(struct kmem_cache *s, slab_flags_t flags)
|
|
{
|
|
int err;
|
|
|
|
err = kmem_cache_open(s, flags);
|
|
if (err)
|
|
return err;
|
|
|
|
/* Mutex is not taken during early boot */
|
|
if (slab_state <= UP)
|
|
return 0;
|
|
|
|
memcg_propagate_slab_attrs(s);
|
|
err = sysfs_slab_add(s);
|
|
if (err)
|
|
__kmem_cache_release(s);
|
|
|
|
return err;
|
|
}
|
|
|
|
void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller)
|
|
{
|
|
struct kmem_cache *s;
|
|
void *ret;
|
|
|
|
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
|
|
return kmalloc_large(size, gfpflags);
|
|
|
|
s = kmalloc_slab(size, gfpflags);
|
|
|
|
if (unlikely(ZERO_OR_NULL_PTR(s)))
|
|
return s;
|
|
|
|
ret = slab_alloc(s, gfpflags, caller);
|
|
|
|
/* Honor the call site pointer we received. */
|
|
trace_kmalloc(caller, ret, size, s->size, gfpflags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
#ifdef CONFIG_NUMA
|
|
void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
|
|
int node, unsigned long caller)
|
|
{
|
|
struct kmem_cache *s;
|
|
void *ret;
|
|
|
|
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
|
|
ret = kmalloc_large_node(size, gfpflags, node);
|
|
|
|
trace_kmalloc_node(caller, ret,
|
|
size, PAGE_SIZE << get_order(size),
|
|
gfpflags, node);
|
|
|
|
return ret;
|
|
}
|
|
|
|
s = kmalloc_slab(size, gfpflags);
|
|
|
|
if (unlikely(ZERO_OR_NULL_PTR(s)))
|
|
return s;
|
|
|
|
ret = slab_alloc_node(s, gfpflags, node, caller);
|
|
|
|
/* Honor the call site pointer we received. */
|
|
trace_kmalloc_node(caller, ret, size, s->size, gfpflags, node);
|
|
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_SYSFS
|
|
static int count_inuse(struct page *page)
|
|
{
|
|
return page->inuse;
|
|
}
|
|
|
|
static int count_total(struct page *page)
|
|
{
|
|
return page->objects;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
static int validate_slab(struct kmem_cache *s, struct page *page,
|
|
unsigned long *map)
|
|
{
|
|
void *p;
|
|
void *addr = page_address(page);
|
|
|
|
if (!check_slab(s, page) ||
|
|
!on_freelist(s, page, NULL))
|
|
return 0;
|
|
|
|
/* Now we know that a valid freelist exists */
|
|
bitmap_zero(map, page->objects);
|
|
|
|
get_map(s, page, map);
|
|
for_each_object(p, s, addr, page->objects) {
|
|
if (test_bit(slab_index(p, s, addr), map))
|
|
if (!check_object(s, page, p, SLUB_RED_INACTIVE))
|
|
return 0;
|
|
}
|
|
|
|
for_each_object(p, s, addr, page->objects)
|
|
if (!test_bit(slab_index(p, s, addr), map))
|
|
if (!check_object(s, page, p, SLUB_RED_ACTIVE))
|
|
return 0;
|
|
return 1;
|
|
}
|
|
|
|
static void validate_slab_slab(struct kmem_cache *s, struct page *page,
|
|
unsigned long *map)
|
|
{
|
|
slab_lock(page);
|
|
validate_slab(s, page, map);
|
|
slab_unlock(page);
|
|
}
|
|
|
|
static int validate_slab_node(struct kmem_cache *s,
|
|
struct kmem_cache_node *n, unsigned long *map)
|
|
{
|
|
unsigned long count = 0;
|
|
struct page *page;
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&n->list_lock, flags);
|
|
|
|
list_for_each_entry(page, &n->partial, slab_list) {
|
|
validate_slab_slab(s, page, map);
|
|
count++;
|
|
}
|
|
if (count != n->nr_partial)
|
|
pr_err("SLUB %s: %ld partial slabs counted but counter=%ld\n",
|
|
s->name, count, n->nr_partial);
|
|
|
|
if (!(s->flags & SLAB_STORE_USER))
|
|
goto out;
|
|
|
|
list_for_each_entry(page, &n->full, slab_list) {
|
|
validate_slab_slab(s, page, map);
|
|
count++;
|
|
}
|
|
if (count != atomic_long_read(&n->nr_slabs))
|
|
pr_err("SLUB: %s %ld slabs counted but counter=%ld\n",
|
|
s->name, count, atomic_long_read(&n->nr_slabs));
|
|
|
|
out:
|
|
spin_unlock_irqrestore(&n->list_lock, flags);
|
|
return count;
|
|
}
|
|
|
|
static long validate_slab_cache(struct kmem_cache *s)
|
|
{
|
|
int node;
|
|
unsigned long count = 0;
|
|
struct kmem_cache_node *n;
|
|
unsigned long *map = bitmap_alloc(oo_objects(s->max), GFP_KERNEL);
|
|
|
|
if (!map)
|
|
return -ENOMEM;
|
|
|
|
flush_all(s);
|
|
for_each_kmem_cache_node(s, node, n)
|
|
count += validate_slab_node(s, n, map);
|
|
bitmap_free(map);
|
|
return count;
|
|
}
|
|
/*
|
|
* Generate lists of code addresses where slabcache objects are allocated
|
|
* and freed.
|
|
*/
|
|
|
|
struct location {
|
|
unsigned long count;
|
|
unsigned long addr;
|
|
long long sum_time;
|
|
long min_time;
|
|
long max_time;
|
|
long min_pid;
|
|
long max_pid;
|
|
DECLARE_BITMAP(cpus, NR_CPUS);
|
|
nodemask_t nodes;
|
|
};
|
|
|
|
struct loc_track {
|
|
unsigned long max;
|
|
unsigned long count;
|
|
struct location *loc;
|
|
};
|
|
|
|
static void free_loc_track(struct loc_track *t)
|
|
{
|
|
if (t->max)
|
|
free_pages((unsigned long)t->loc,
|
|
get_order(sizeof(struct location) * t->max));
|
|
}
|
|
|
|
static int alloc_loc_track(struct loc_track *t, unsigned long max, gfp_t flags)
|
|
{
|
|
struct location *l;
|
|
int order;
|
|
|
|
order = get_order(sizeof(struct location) * max);
|
|
|
|
l = (void *)__get_free_pages(flags, order);
|
|
if (!l)
|
|
return 0;
|
|
|
|
if (t->count) {
|
|
memcpy(l, t->loc, sizeof(struct location) * t->count);
|
|
free_loc_track(t);
|
|
}
|
|
t->max = max;
|
|
t->loc = l;
|
|
return 1;
|
|
}
|
|
|
|
static int add_location(struct loc_track *t, struct kmem_cache *s,
|
|
const struct track *track)
|
|
{
|
|
long start, end, pos;
|
|
struct location *l;
|
|
unsigned long caddr;
|
|
unsigned long age = jiffies - track->when;
|
|
|
|
start = -1;
|
|
end = t->count;
|
|
|
|
for ( ; ; ) {
|
|
pos = start + (end - start + 1) / 2;
|
|
|
|
/*
|
|
* There is nothing at "end". If we end up there
|
|
* we need to add something to before end.
|
|
*/
|
|
if (pos == end)
|
|
break;
|
|
|
|
caddr = t->loc[pos].addr;
|
|
if (track->addr == caddr) {
|
|
|
|
l = &t->loc[pos];
|
|
l->count++;
|
|
if (track->when) {
|
|
l->sum_time += age;
|
|
if (age < l->min_time)
|
|
l->min_time = age;
|
|
if (age > l->max_time)
|
|
l->max_time = age;
|
|
|
|
if (track->pid < l->min_pid)
|
|
l->min_pid = track->pid;
|
|
if (track->pid > l->max_pid)
|
|
l->max_pid = track->pid;
|
|
|
|
cpumask_set_cpu(track->cpu,
|
|
to_cpumask(l->cpus));
|
|
}
|
|
node_set(page_to_nid(virt_to_page(track)), l->nodes);
|
|
return 1;
|
|
}
|
|
|
|
if (track->addr < caddr)
|
|
end = pos;
|
|
else
|
|
start = pos;
|
|
}
|
|
|
|
/*
|
|
* Not found. Insert new tracking element.
|
|
*/
|
|
if (t->count >= t->max && !alloc_loc_track(t, 2 * t->max, GFP_ATOMIC))
|
|
return 0;
|
|
|
|
l = t->loc + pos;
|
|
if (pos < t->count)
|
|
memmove(l + 1, l,
|
|
(t->count - pos) * sizeof(struct location));
|
|
t->count++;
|
|
l->count = 1;
|
|
l->addr = track->addr;
|
|
l->sum_time = age;
|
|
l->min_time = age;
|
|
l->max_time = age;
|
|
l->min_pid = track->pid;
|
|
l->max_pid = track->pid;
|
|
cpumask_clear(to_cpumask(l->cpus));
|
|
cpumask_set_cpu(track->cpu, to_cpumask(l->cpus));
|
|
nodes_clear(l->nodes);
|
|
node_set(page_to_nid(virt_to_page(track)), l->nodes);
|
|
return 1;
|
|
}
|
|
|
|
static void process_slab(struct loc_track *t, struct kmem_cache *s,
|
|
struct page *page, enum track_item alloc,
|
|
unsigned long *map)
|
|
{
|
|
void *addr = page_address(page);
|
|
void *p;
|
|
|
|
bitmap_zero(map, page->objects);
|
|
get_map(s, page, map);
|
|
|
|
for_each_object(p, s, addr, page->objects)
|
|
if (!test_bit(slab_index(p, s, addr), map))
|
|
add_location(t, s, get_track(s, p, alloc));
|
|
}
|
|
|
|
static int list_locations(struct kmem_cache *s, char *buf,
|
|
enum track_item alloc)
|
|
{
|
|
int len = 0;
|
|
unsigned long i;
|
|
struct loc_track t = { 0, 0, NULL };
|
|
int node;
|
|
struct kmem_cache_node *n;
|
|
unsigned long *map = bitmap_alloc(oo_objects(s->max), GFP_KERNEL);
|
|
|
|
if (!map || !alloc_loc_track(&t, PAGE_SIZE / sizeof(struct location),
|
|
GFP_KERNEL)) {
|
|
bitmap_free(map);
|
|
return sprintf(buf, "Out of memory\n");
|
|
}
|
|
/* Push back cpu slabs */
|
|
flush_all(s);
|
|
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
unsigned long flags;
|
|
struct page *page;
|
|
|
|
if (!atomic_long_read(&n->nr_slabs))
|
|
continue;
|
|
|
|
spin_lock_irqsave(&n->list_lock, flags);
|
|
list_for_each_entry(page, &n->partial, slab_list)
|
|
process_slab(&t, s, page, alloc, map);
|
|
list_for_each_entry(page, &n->full, slab_list)
|
|
process_slab(&t, s, page, alloc, map);
|
|
spin_unlock_irqrestore(&n->list_lock, flags);
|
|
}
|
|
|
|
for (i = 0; i < t.count; i++) {
|
|
struct location *l = &t.loc[i];
|
|
|
|
if (len > PAGE_SIZE - KSYM_SYMBOL_LEN - 100)
|
|
break;
|
|
len += sprintf(buf + len, "%7ld ", l->count);
|
|
|
|
if (l->addr)
|
|
len += sprintf(buf + len, "%pS", (void *)l->addr);
|
|
else
|
|
len += sprintf(buf + len, "<not-available>");
|
|
|
|
if (l->sum_time != l->min_time) {
|
|
len += sprintf(buf + len, " age=%ld/%ld/%ld",
|
|
l->min_time,
|
|
(long)div_u64(l->sum_time, l->count),
|
|
l->max_time);
|
|
} else
|
|
len += sprintf(buf + len, " age=%ld",
|
|
l->min_time);
|
|
|
|
if (l->min_pid != l->max_pid)
|
|
len += sprintf(buf + len, " pid=%ld-%ld",
|
|
l->min_pid, l->max_pid);
|
|
else
|
|
len += sprintf(buf + len, " pid=%ld",
|
|
l->min_pid);
|
|
|
|
if (num_online_cpus() > 1 &&
|
|
!cpumask_empty(to_cpumask(l->cpus)) &&
|
|
len < PAGE_SIZE - 60)
|
|
len += scnprintf(buf + len, PAGE_SIZE - len - 50,
|
|
" cpus=%*pbl",
|
|
cpumask_pr_args(to_cpumask(l->cpus)));
|
|
|
|
if (nr_online_nodes > 1 && !nodes_empty(l->nodes) &&
|
|
len < PAGE_SIZE - 60)
|
|
len += scnprintf(buf + len, PAGE_SIZE - len - 50,
|
|
" nodes=%*pbl",
|
|
nodemask_pr_args(&l->nodes));
|
|
|
|
len += sprintf(buf + len, "\n");
|
|
}
|
|
|
|
free_loc_track(&t);
|
|
bitmap_free(map);
|
|
if (!t.count)
|
|
len += sprintf(buf, "No data\n");
|
|
return len;
|
|
}
|
|
#endif /* CONFIG_SLUB_DEBUG */
|
|
|
|
#ifdef SLUB_RESILIENCY_TEST
|
|
static void __init resiliency_test(void)
|
|
{
|
|
u8 *p;
|
|
int type = KMALLOC_NORMAL;
|
|
|
|
BUILD_BUG_ON(KMALLOC_MIN_SIZE > 16 || KMALLOC_SHIFT_HIGH < 10);
|
|
|
|
pr_err("SLUB resiliency testing\n");
|
|
pr_err("-----------------------\n");
|
|
pr_err("A. Corruption after allocation\n");
|
|
|
|
p = kzalloc(16, GFP_KERNEL);
|
|
p[16] = 0x12;
|
|
pr_err("\n1. kmalloc-16: Clobber Redzone/next pointer 0x12->0x%p\n\n",
|
|
p + 16);
|
|
|
|
validate_slab_cache(kmalloc_caches[type][4]);
|
|
|
|
/* Hmmm... The next two are dangerous */
|
|
p = kzalloc(32, GFP_KERNEL);
|
|
p[32 + sizeof(void *)] = 0x34;
|
|
pr_err("\n2. kmalloc-32: Clobber next pointer/next slab 0x34 -> -0x%p\n",
|
|
p);
|
|
pr_err("If allocated object is overwritten then not detectable\n\n");
|
|
|
|
validate_slab_cache(kmalloc_caches[type][5]);
|
|
p = kzalloc(64, GFP_KERNEL);
|
|
p += 64 + (get_cycles() & 0xff) * sizeof(void *);
|
|
*p = 0x56;
|
|
pr_err("\n3. kmalloc-64: corrupting random byte 0x56->0x%p\n",
|
|
p);
|
|
pr_err("If allocated object is overwritten then not detectable\n\n");
|
|
validate_slab_cache(kmalloc_caches[type][6]);
|
|
|
|
pr_err("\nB. Corruption after free\n");
|
|
p = kzalloc(128, GFP_KERNEL);
|
|
kfree(p);
|
|
*p = 0x78;
|
|
pr_err("1. kmalloc-128: Clobber first word 0x78->0x%p\n\n", p);
|
|
validate_slab_cache(kmalloc_caches[type][7]);
|
|
|
|
p = kzalloc(256, GFP_KERNEL);
|
|
kfree(p);
|
|
p[50] = 0x9a;
|
|
pr_err("\n2. kmalloc-256: Clobber 50th byte 0x9a->0x%p\n\n", p);
|
|
validate_slab_cache(kmalloc_caches[type][8]);
|
|
|
|
p = kzalloc(512, GFP_KERNEL);
|
|
kfree(p);
|
|
p[512] = 0xab;
|
|
pr_err("\n3. kmalloc-512: Clobber redzone 0xab->0x%p\n\n", p);
|
|
validate_slab_cache(kmalloc_caches[type][9]);
|
|
}
|
|
#else
|
|
#ifdef CONFIG_SYSFS
|
|
static void resiliency_test(void) {};
|
|
#endif
|
|
#endif /* SLUB_RESILIENCY_TEST */
|
|
|
|
#ifdef CONFIG_SYSFS
|
|
enum slab_stat_type {
|
|
SL_ALL, /* All slabs */
|
|
SL_PARTIAL, /* Only partially allocated slabs */
|
|
SL_CPU, /* Only slabs used for cpu caches */
|
|
SL_OBJECTS, /* Determine allocated objects not slabs */
|
|
SL_TOTAL /* Determine object capacity not slabs */
|
|
};
|
|
|
|
#define SO_ALL (1 << SL_ALL)
|
|
#define SO_PARTIAL (1 << SL_PARTIAL)
|
|
#define SO_CPU (1 << SL_CPU)
|
|
#define SO_OBJECTS (1 << SL_OBJECTS)
|
|
#define SO_TOTAL (1 << SL_TOTAL)
|
|
|
|
#ifdef CONFIG_MEMCG
|
|
static bool memcg_sysfs_enabled = IS_ENABLED(CONFIG_SLUB_MEMCG_SYSFS_ON);
|
|
|
|
static int __init setup_slub_memcg_sysfs(char *str)
|
|
{
|
|
int v;
|
|
|
|
if (get_option(&str, &v) > 0)
|
|
memcg_sysfs_enabled = v;
|
|
|
|
return 1;
|
|
}
|
|
|
|
__setup("slub_memcg_sysfs=", setup_slub_memcg_sysfs);
|
|
#endif
|
|
|
|
static ssize_t show_slab_objects(struct kmem_cache *s,
|
|
char *buf, unsigned long flags)
|
|
{
|
|
unsigned long total = 0;
|
|
int node;
|
|
int x;
|
|
unsigned long *nodes;
|
|
|
|
nodes = kcalloc(nr_node_ids, sizeof(unsigned long), GFP_KERNEL);
|
|
if (!nodes)
|
|
return -ENOMEM;
|
|
|
|
if (flags & SO_CPU) {
|
|
int cpu;
|
|
|
|
for_each_possible_cpu(cpu) {
|
|
struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab,
|
|
cpu);
|
|
int node;
|
|
struct page *page;
|
|
|
|
page = READ_ONCE(c->page);
|
|
if (!page)
|
|
continue;
|
|
|
|
node = page_to_nid(page);
|
|
if (flags & SO_TOTAL)
|
|
x = page->objects;
|
|
else if (flags & SO_OBJECTS)
|
|
x = page->inuse;
|
|
else
|
|
x = 1;
|
|
|
|
total += x;
|
|
nodes[node] += x;
|
|
|
|
page = slub_percpu_partial_read_once(c);
|
|
if (page) {
|
|
node = page_to_nid(page);
|
|
if (flags & SO_TOTAL)
|
|
WARN_ON_ONCE(1);
|
|
else if (flags & SO_OBJECTS)
|
|
WARN_ON_ONCE(1);
|
|
else
|
|
x = page->pages;
|
|
total += x;
|
|
nodes[node] += x;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
* It is impossible to take "mem_hotplug_lock" here with "kernfs_mutex"
|
|
* already held which will conflict with an existing lock order:
|
|
*
|
|
* mem_hotplug_lock->slab_mutex->kernfs_mutex
|
|
*
|
|
* We don't really need mem_hotplug_lock (to hold off
|
|
* slab_mem_going_offline_callback) here because slab's memory hot
|
|
* unplug code doesn't destroy the kmem_cache->node[] data.
|
|
*/
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
if (flags & SO_ALL) {
|
|
struct kmem_cache_node *n;
|
|
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
|
|
if (flags & SO_TOTAL)
|
|
x = atomic_long_read(&n->total_objects);
|
|
else if (flags & SO_OBJECTS)
|
|
x = atomic_long_read(&n->total_objects) -
|
|
count_partial(n, count_free);
|
|
else
|
|
x = atomic_long_read(&n->nr_slabs);
|
|
total += x;
|
|
nodes[node] += x;
|
|
}
|
|
|
|
} else
|
|
#endif
|
|
if (flags & SO_PARTIAL) {
|
|
struct kmem_cache_node *n;
|
|
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
if (flags & SO_TOTAL)
|
|
x = count_partial(n, count_total);
|
|
else if (flags & SO_OBJECTS)
|
|
x = count_partial(n, count_inuse);
|
|
else
|
|
x = n->nr_partial;
|
|
total += x;
|
|
nodes[node] += x;
|
|
}
|
|
}
|
|
x = sprintf(buf, "%lu", total);
|
|
#ifdef CONFIG_NUMA
|
|
for (node = 0; node < nr_node_ids; node++)
|
|
if (nodes[node])
|
|
x += sprintf(buf + x, " N%d=%lu",
|
|
node, nodes[node]);
|
|
#endif
|
|
kfree(nodes);
|
|
return x + sprintf(buf + x, "\n");
|
|
}
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
static int any_slab_objects(struct kmem_cache *s)
|
|
{
|
|
int node;
|
|
struct kmem_cache_node *n;
|
|
|
|
for_each_kmem_cache_node(s, node, n)
|
|
if (atomic_long_read(&n->total_objects))
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#define to_slab_attr(n) container_of(n, struct slab_attribute, attr)
|
|
#define to_slab(n) container_of(n, struct kmem_cache, kobj)
|
|
|
|
struct slab_attribute {
|
|
struct attribute attr;
|
|
ssize_t (*show)(struct kmem_cache *s, char *buf);
|
|
ssize_t (*store)(struct kmem_cache *s, const char *x, size_t count);
|
|
};
|
|
|
|
#define SLAB_ATTR_RO(_name) \
|
|
static struct slab_attribute _name##_attr = \
|
|
__ATTR(_name, 0400, _name##_show, NULL)
|
|
|
|
#define SLAB_ATTR(_name) \
|
|
static struct slab_attribute _name##_attr = \
|
|
__ATTR(_name, 0600, _name##_show, _name##_store)
|
|
|
|
static ssize_t slab_size_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", s->size);
|
|
}
|
|
SLAB_ATTR_RO(slab_size);
|
|
|
|
static ssize_t align_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", s->align);
|
|
}
|
|
SLAB_ATTR_RO(align);
|
|
|
|
static ssize_t object_size_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", s->object_size);
|
|
}
|
|
SLAB_ATTR_RO(object_size);
|
|
|
|
static ssize_t objs_per_slab_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", oo_objects(s->oo));
|
|
}
|
|
SLAB_ATTR_RO(objs_per_slab);
|
|
|
|
static ssize_t order_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
unsigned int order;
|
|
int err;
|
|
|
|
err = kstrtouint(buf, 10, &order);
|
|
if (err)
|
|
return err;
|
|
|
|
if (order > slub_max_order || order < slub_min_order)
|
|
return -EINVAL;
|
|
|
|
calculate_sizes(s, order);
|
|
reinit_cache_random_seq(s);
|
|
return length;
|
|
}
|
|
|
|
static ssize_t order_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", oo_order(s->oo));
|
|
}
|
|
SLAB_ATTR(order);
|
|
|
|
static ssize_t min_partial_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%lu\n", s->min_partial);
|
|
}
|
|
|
|
static ssize_t min_partial_store(struct kmem_cache *s, const char *buf,
|
|
size_t length)
|
|
{
|
|
unsigned long min;
|
|
int err;
|
|
|
|
err = kstrtoul(buf, 10, &min);
|
|
if (err)
|
|
return err;
|
|
|
|
set_min_partial(s, min);
|
|
return length;
|
|
}
|
|
SLAB_ATTR(min_partial);
|
|
|
|
static ssize_t cpu_partial_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", slub_cpu_partial(s));
|
|
}
|
|
|
|
static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf,
|
|
size_t length)
|
|
{
|
|
unsigned int objects;
|
|
int err;
|
|
|
|
err = kstrtouint(buf, 10, &objects);
|
|
if (err)
|
|
return err;
|
|
if (objects && !kmem_cache_has_cpu_partial(s))
|
|
return -EINVAL;
|
|
|
|
slub_set_cpu_partial(s, objects);
|
|
flush_all(s);
|
|
return length;
|
|
}
|
|
SLAB_ATTR(cpu_partial);
|
|
|
|
static ssize_t ctor_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
if (!s->ctor)
|
|
return 0;
|
|
return sprintf(buf, "%pS\n", s->ctor);
|
|
}
|
|
SLAB_ATTR_RO(ctor);
|
|
|
|
static ssize_t aliases_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", s->refcount < 0 ? 0 : s->refcount - 1);
|
|
}
|
|
SLAB_ATTR_RO(aliases);
|
|
|
|
static ssize_t partial_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return show_slab_objects(s, buf, SO_PARTIAL);
|
|
}
|
|
SLAB_ATTR_RO(partial);
|
|
|
|
static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return show_slab_objects(s, buf, SO_CPU);
|
|
}
|
|
SLAB_ATTR_RO(cpu_slabs);
|
|
|
|
static ssize_t objects_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return show_slab_objects(s, buf, SO_ALL|SO_OBJECTS);
|
|
}
|
|
SLAB_ATTR_RO(objects);
|
|
|
|
static ssize_t objects_partial_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return show_slab_objects(s, buf, SO_PARTIAL|SO_OBJECTS);
|
|
}
|
|
SLAB_ATTR_RO(objects_partial);
|
|
|
|
static ssize_t slabs_cpu_partial_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
int objects = 0;
|
|
int pages = 0;
|
|
int cpu;
|
|
int len;
|
|
|
|
for_each_online_cpu(cpu) {
|
|
struct page *page;
|
|
|
|
page = slub_percpu_partial(per_cpu_ptr(s->cpu_slab, cpu));
|
|
|
|
if (page) {
|
|
pages += page->pages;
|
|
objects += page->pobjects;
|
|
}
|
|
}
|
|
|
|
len = sprintf(buf, "%d(%d)", objects, pages);
|
|
|
|
#ifdef CONFIG_SMP
|
|
for_each_online_cpu(cpu) {
|
|
struct page *page;
|
|
|
|
page = slub_percpu_partial(per_cpu_ptr(s->cpu_slab, cpu));
|
|
|
|
if (page && len < PAGE_SIZE - 20)
|
|
len += sprintf(buf + len, " C%d=%d(%d)", cpu,
|
|
page->pobjects, page->pages);
|
|
}
|
|
#endif
|
|
return len + sprintf(buf + len, "\n");
|
|
}
|
|
SLAB_ATTR_RO(slabs_cpu_partial);
|
|
|
|
static ssize_t reclaim_account_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_RECLAIM_ACCOUNT));
|
|
}
|
|
|
|
static ssize_t reclaim_account_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
s->flags &= ~SLAB_RECLAIM_ACCOUNT;
|
|
if (buf[0] == '1')
|
|
s->flags |= SLAB_RECLAIM_ACCOUNT;
|
|
return length;
|
|
}
|
|
SLAB_ATTR(reclaim_account);
|
|
|
|
static ssize_t hwcache_align_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_HWCACHE_ALIGN));
|
|
}
|
|
SLAB_ATTR_RO(hwcache_align);
|
|
|
|
#ifdef CONFIG_ZONE_DMA
|
|
static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_CACHE_DMA));
|
|
}
|
|
SLAB_ATTR_RO(cache_dma);
|
|
#endif
|
|
|
|
static ssize_t usersize_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", s->usersize);
|
|
}
|
|
SLAB_ATTR_RO(usersize);
|
|
|
|
static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_TYPESAFE_BY_RCU));
|
|
}
|
|
SLAB_ATTR_RO(destroy_by_rcu);
|
|
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
static ssize_t slabs_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return show_slab_objects(s, buf, SO_ALL);
|
|
}
|
|
SLAB_ATTR_RO(slabs);
|
|
|
|
static ssize_t total_objects_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return show_slab_objects(s, buf, SO_ALL|SO_TOTAL);
|
|
}
|
|
SLAB_ATTR_RO(total_objects);
|
|
|
|
static ssize_t sanity_checks_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_CONSISTENCY_CHECKS));
|
|
}
|
|
|
|
static ssize_t sanity_checks_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
s->flags &= ~SLAB_CONSISTENCY_CHECKS;
|
|
if (buf[0] == '1') {
|
|
s->flags &= ~__CMPXCHG_DOUBLE;
|
|
s->flags |= SLAB_CONSISTENCY_CHECKS;
|
|
}
|
|
return length;
|
|
}
|
|
SLAB_ATTR(sanity_checks);
|
|
|
|
static ssize_t trace_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_TRACE));
|
|
}
|
|
|
|
static ssize_t trace_store(struct kmem_cache *s, const char *buf,
|
|
size_t length)
|
|
{
|
|
/*
|
|
* Tracing a merged cache is going to give confusing results
|
|
* as well as cause other issues like converting a mergeable
|
|
* cache into an umergeable one.
|
|
*/
|
|
if (s->refcount > 1)
|
|
return -EINVAL;
|
|
|
|
s->flags &= ~SLAB_TRACE;
|
|
if (buf[0] == '1') {
|
|
s->flags &= ~__CMPXCHG_DOUBLE;
|
|
s->flags |= SLAB_TRACE;
|
|
}
|
|
return length;
|
|
}
|
|
SLAB_ATTR(trace);
|
|
|
|
static ssize_t red_zone_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_RED_ZONE));
|
|
}
|
|
|
|
static ssize_t red_zone_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
if (any_slab_objects(s))
|
|
return -EBUSY;
|
|
|
|
s->flags &= ~SLAB_RED_ZONE;
|
|
if (buf[0] == '1') {
|
|
s->flags |= SLAB_RED_ZONE;
|
|
}
|
|
calculate_sizes(s, -1);
|
|
reinit_cache_random_seq(s);
|
|
return length;
|
|
}
|
|
SLAB_ATTR(red_zone);
|
|
|
|
static ssize_t poison_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_POISON));
|
|
}
|
|
|
|
static ssize_t poison_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
if (any_slab_objects(s))
|
|
return -EBUSY;
|
|
|
|
s->flags &= ~SLAB_POISON;
|
|
if (buf[0] == '1') {
|
|
s->flags |= SLAB_POISON;
|
|
}
|
|
calculate_sizes(s, -1);
|
|
reinit_cache_random_seq(s);
|
|
return length;
|
|
}
|
|
SLAB_ATTR(poison);
|
|
|
|
static ssize_t store_user_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_STORE_USER));
|
|
}
|
|
|
|
static ssize_t store_user_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
if (any_slab_objects(s))
|
|
return -EBUSY;
|
|
|
|
s->flags &= ~SLAB_STORE_USER;
|
|
if (buf[0] == '1') {
|
|
s->flags &= ~__CMPXCHG_DOUBLE;
|
|
s->flags |= SLAB_STORE_USER;
|
|
}
|
|
calculate_sizes(s, -1);
|
|
reinit_cache_random_seq(s);
|
|
return length;
|
|
}
|
|
SLAB_ATTR(store_user);
|
|
|
|
static ssize_t validate_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t validate_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
int ret = -EINVAL;
|
|
|
|
if (buf[0] == '1') {
|
|
ret = validate_slab_cache(s);
|
|
if (ret >= 0)
|
|
ret = length;
|
|
}
|
|
return ret;
|
|
}
|
|
SLAB_ATTR(validate);
|
|
|
|
static ssize_t alloc_calls_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
if (!(s->flags & SLAB_STORE_USER))
|
|
return -ENOSYS;
|
|
return list_locations(s, buf, TRACK_ALLOC);
|
|
}
|
|
SLAB_ATTR_RO(alloc_calls);
|
|
|
|
static ssize_t free_calls_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
if (!(s->flags & SLAB_STORE_USER))
|
|
return -ENOSYS;
|
|
return list_locations(s, buf, TRACK_FREE);
|
|
}
|
|
SLAB_ATTR_RO(free_calls);
|
|
#endif /* CONFIG_SLUB_DEBUG */
|
|
|
|
#ifdef CONFIG_FAILSLAB
|
|
static ssize_t failslab_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%d\n", !!(s->flags & SLAB_FAILSLAB));
|
|
}
|
|
|
|
static ssize_t failslab_store(struct kmem_cache *s, const char *buf,
|
|
size_t length)
|
|
{
|
|
if (s->refcount > 1)
|
|
return -EINVAL;
|
|
|
|
s->flags &= ~SLAB_FAILSLAB;
|
|
if (buf[0] == '1')
|
|
s->flags |= SLAB_FAILSLAB;
|
|
return length;
|
|
}
|
|
SLAB_ATTR(failslab);
|
|
#endif
|
|
|
|
static ssize_t shrink_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t shrink_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
if (buf[0] == '1')
|
|
kmem_cache_shrink_all(s);
|
|
else
|
|
return -EINVAL;
|
|
return length;
|
|
}
|
|
SLAB_ATTR(shrink);
|
|
|
|
#ifdef CONFIG_NUMA
|
|
static ssize_t remote_node_defrag_ratio_show(struct kmem_cache *s, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", s->remote_node_defrag_ratio / 10);
|
|
}
|
|
|
|
static ssize_t remote_node_defrag_ratio_store(struct kmem_cache *s,
|
|
const char *buf, size_t length)
|
|
{
|
|
unsigned int ratio;
|
|
int err;
|
|
|
|
err = kstrtouint(buf, 10, &ratio);
|
|
if (err)
|
|
return err;
|
|
if (ratio > 100)
|
|
return -ERANGE;
|
|
|
|
s->remote_node_defrag_ratio = ratio * 10;
|
|
|
|
return length;
|
|
}
|
|
SLAB_ATTR(remote_node_defrag_ratio);
|
|
#endif
|
|
|
|
#ifdef CONFIG_SLUB_STATS
|
|
static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si)
|
|
{
|
|
unsigned long sum = 0;
|
|
int cpu;
|
|
int len;
|
|
int *data = kmalloc_array(nr_cpu_ids, sizeof(int), GFP_KERNEL);
|
|
|
|
if (!data)
|
|
return -ENOMEM;
|
|
|
|
for_each_online_cpu(cpu) {
|
|
unsigned x = per_cpu_ptr(s->cpu_slab, cpu)->stat[si];
|
|
|
|
data[cpu] = x;
|
|
sum += x;
|
|
}
|
|
|
|
len = sprintf(buf, "%lu", sum);
|
|
|
|
#ifdef CONFIG_SMP
|
|
for_each_online_cpu(cpu) {
|
|
if (data[cpu] && len < PAGE_SIZE - 20)
|
|
len += sprintf(buf + len, " C%d=%u", cpu, data[cpu]);
|
|
}
|
|
#endif
|
|
kfree(data);
|
|
return len + sprintf(buf + len, "\n");
|
|
}
|
|
|
|
static void clear_stat(struct kmem_cache *s, enum stat_item si)
|
|
{
|
|
int cpu;
|
|
|
|
for_each_online_cpu(cpu)
|
|
per_cpu_ptr(s->cpu_slab, cpu)->stat[si] = 0;
|
|
}
|
|
|
|
#define STAT_ATTR(si, text) \
|
|
static ssize_t text##_show(struct kmem_cache *s, char *buf) \
|
|
{ \
|
|
return show_stat(s, buf, si); \
|
|
} \
|
|
static ssize_t text##_store(struct kmem_cache *s, \
|
|
const char *buf, size_t length) \
|
|
{ \
|
|
if (buf[0] != '0') \
|
|
return -EINVAL; \
|
|
clear_stat(s, si); \
|
|
return length; \
|
|
} \
|
|
SLAB_ATTR(text); \
|
|
|
|
STAT_ATTR(ALLOC_FASTPATH, alloc_fastpath);
|
|
STAT_ATTR(ALLOC_SLOWPATH, alloc_slowpath);
|
|
STAT_ATTR(FREE_FASTPATH, free_fastpath);
|
|
STAT_ATTR(FREE_SLOWPATH, free_slowpath);
|
|
STAT_ATTR(FREE_FROZEN, free_frozen);
|
|
STAT_ATTR(FREE_ADD_PARTIAL, free_add_partial);
|
|
STAT_ATTR(FREE_REMOVE_PARTIAL, free_remove_partial);
|
|
STAT_ATTR(ALLOC_FROM_PARTIAL, alloc_from_partial);
|
|
STAT_ATTR(ALLOC_SLAB, alloc_slab);
|
|
STAT_ATTR(ALLOC_REFILL, alloc_refill);
|
|
STAT_ATTR(ALLOC_NODE_MISMATCH, alloc_node_mismatch);
|
|
STAT_ATTR(FREE_SLAB, free_slab);
|
|
STAT_ATTR(CPUSLAB_FLUSH, cpuslab_flush);
|
|
STAT_ATTR(DEACTIVATE_FULL, deactivate_full);
|
|
STAT_ATTR(DEACTIVATE_EMPTY, deactivate_empty);
|
|
STAT_ATTR(DEACTIVATE_TO_HEAD, deactivate_to_head);
|
|
STAT_ATTR(DEACTIVATE_TO_TAIL, deactivate_to_tail);
|
|
STAT_ATTR(DEACTIVATE_REMOTE_FREES, deactivate_remote_frees);
|
|
STAT_ATTR(DEACTIVATE_BYPASS, deactivate_bypass);
|
|
STAT_ATTR(ORDER_FALLBACK, order_fallback);
|
|
STAT_ATTR(CMPXCHG_DOUBLE_CPU_FAIL, cmpxchg_double_cpu_fail);
|
|
STAT_ATTR(CMPXCHG_DOUBLE_FAIL, cmpxchg_double_fail);
|
|
STAT_ATTR(CPU_PARTIAL_ALLOC, cpu_partial_alloc);
|
|
STAT_ATTR(CPU_PARTIAL_FREE, cpu_partial_free);
|
|
STAT_ATTR(CPU_PARTIAL_NODE, cpu_partial_node);
|
|
STAT_ATTR(CPU_PARTIAL_DRAIN, cpu_partial_drain);
|
|
#endif /* CONFIG_SLUB_STATS */
|
|
|
|
static struct attribute *slab_attrs[] = {
|
|
&slab_size_attr.attr,
|
|
&object_size_attr.attr,
|
|
&objs_per_slab_attr.attr,
|
|
&order_attr.attr,
|
|
&min_partial_attr.attr,
|
|
&cpu_partial_attr.attr,
|
|
&objects_attr.attr,
|
|
&objects_partial_attr.attr,
|
|
&partial_attr.attr,
|
|
&cpu_slabs_attr.attr,
|
|
&ctor_attr.attr,
|
|
&aliases_attr.attr,
|
|
&align_attr.attr,
|
|
&hwcache_align_attr.attr,
|
|
&reclaim_account_attr.attr,
|
|
&destroy_by_rcu_attr.attr,
|
|
&shrink_attr.attr,
|
|
&slabs_cpu_partial_attr.attr,
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
&total_objects_attr.attr,
|
|
&slabs_attr.attr,
|
|
&sanity_checks_attr.attr,
|
|
&trace_attr.attr,
|
|
&red_zone_attr.attr,
|
|
&poison_attr.attr,
|
|
&store_user_attr.attr,
|
|
&validate_attr.attr,
|
|
&alloc_calls_attr.attr,
|
|
&free_calls_attr.attr,
|
|
#endif
|
|
#ifdef CONFIG_ZONE_DMA
|
|
&cache_dma_attr.attr,
|
|
#endif
|
|
#ifdef CONFIG_NUMA
|
|
&remote_node_defrag_ratio_attr.attr,
|
|
#endif
|
|
#ifdef CONFIG_SLUB_STATS
|
|
&alloc_fastpath_attr.attr,
|
|
&alloc_slowpath_attr.attr,
|
|
&free_fastpath_attr.attr,
|
|
&free_slowpath_attr.attr,
|
|
&free_frozen_attr.attr,
|
|
&free_add_partial_attr.attr,
|
|
&free_remove_partial_attr.attr,
|
|
&alloc_from_partial_attr.attr,
|
|
&alloc_slab_attr.attr,
|
|
&alloc_refill_attr.attr,
|
|
&alloc_node_mismatch_attr.attr,
|
|
&free_slab_attr.attr,
|
|
&cpuslab_flush_attr.attr,
|
|
&deactivate_full_attr.attr,
|
|
&deactivate_empty_attr.attr,
|
|
&deactivate_to_head_attr.attr,
|
|
&deactivate_to_tail_attr.attr,
|
|
&deactivate_remote_frees_attr.attr,
|
|
&deactivate_bypass_attr.attr,
|
|
&order_fallback_attr.attr,
|
|
&cmpxchg_double_fail_attr.attr,
|
|
&cmpxchg_double_cpu_fail_attr.attr,
|
|
&cpu_partial_alloc_attr.attr,
|
|
&cpu_partial_free_attr.attr,
|
|
&cpu_partial_node_attr.attr,
|
|
&cpu_partial_drain_attr.attr,
|
|
#endif
|
|
#ifdef CONFIG_FAILSLAB
|
|
&failslab_attr.attr,
|
|
#endif
|
|
&usersize_attr.attr,
|
|
|
|
NULL
|
|
};
|
|
|
|
static const struct attribute_group slab_attr_group = {
|
|
.attrs = slab_attrs,
|
|
};
|
|
|
|
static ssize_t slab_attr_show(struct kobject *kobj,
|
|
struct attribute *attr,
|
|
char *buf)
|
|
{
|
|
struct slab_attribute *attribute;
|
|
struct kmem_cache *s;
|
|
int err;
|
|
|
|
attribute = to_slab_attr(attr);
|
|
s = to_slab(kobj);
|
|
|
|
if (!attribute->show)
|
|
return -EIO;
|
|
|
|
err = attribute->show(s, buf);
|
|
|
|
return err;
|
|
}
|
|
|
|
static ssize_t slab_attr_store(struct kobject *kobj,
|
|
struct attribute *attr,
|
|
const char *buf, size_t len)
|
|
{
|
|
struct slab_attribute *attribute;
|
|
struct kmem_cache *s;
|
|
int err;
|
|
|
|
attribute = to_slab_attr(attr);
|
|
s = to_slab(kobj);
|
|
|
|
if (!attribute->store)
|
|
return -EIO;
|
|
|
|
err = attribute->store(s, buf, len);
|
|
#ifdef CONFIG_MEMCG
|
|
if (slab_state >= FULL && err >= 0 && is_root_cache(s)) {
|
|
struct kmem_cache *c;
|
|
|
|
mutex_lock(&slab_mutex);
|
|
if (s->max_attr_size < len)
|
|
s->max_attr_size = len;
|
|
|
|
/*
|
|
* This is a best effort propagation, so this function's return
|
|
* value will be determined by the parent cache only. This is
|
|
* basically because not all attributes will have a well
|
|
* defined semantics for rollbacks - most of the actions will
|
|
* have permanent effects.
|
|
*
|
|
* Returning the error value of any of the children that fail
|
|
* is not 100 % defined, in the sense that users seeing the
|
|
* error code won't be able to know anything about the state of
|
|
* the cache.
|
|
*
|
|
* Only returning the error code for the parent cache at least
|
|
* has well defined semantics. The cache being written to
|
|
* directly either failed or succeeded, in which case we loop
|
|
* through the descendants with best-effort propagation.
|
|
*/
|
|
for_each_memcg_cache(c, s)
|
|
attribute->store(c, buf, len);
|
|
mutex_unlock(&slab_mutex);
|
|
}
|
|
#endif
|
|
return err;
|
|
}
|
|
|
|
static void memcg_propagate_slab_attrs(struct kmem_cache *s)
|
|
{
|
|
#ifdef CONFIG_MEMCG
|
|
int i;
|
|
char *buffer = NULL;
|
|
struct kmem_cache *root_cache;
|
|
|
|
if (is_root_cache(s))
|
|
return;
|
|
|
|
root_cache = s->memcg_params.root_cache;
|
|
|
|
/*
|
|
* This mean this cache had no attribute written. Therefore, no point
|
|
* in copying default values around
|
|
*/
|
|
if (!root_cache->max_attr_size)
|
|
return;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(slab_attrs); i++) {
|
|
char mbuf[64];
|
|
char *buf;
|
|
struct slab_attribute *attr = to_slab_attr(slab_attrs[i]);
|
|
ssize_t len;
|
|
|
|
if (!attr || !attr->store || !attr->show)
|
|
continue;
|
|
|
|
/*
|
|
* It is really bad that we have to allocate here, so we will
|
|
* do it only as a fallback. If we actually allocate, though,
|
|
* we can just use the allocated buffer until the end.
|
|
*
|
|
* Most of the slub attributes will tend to be very small in
|
|
* size, but sysfs allows buffers up to a page, so they can
|
|
* theoretically happen.
|
|
*/
|
|
if (buffer)
|
|
buf = buffer;
|
|
else if (root_cache->max_attr_size < ARRAY_SIZE(mbuf))
|
|
buf = mbuf;
|
|
else {
|
|
buffer = (char *) get_zeroed_page(GFP_KERNEL);
|
|
if (WARN_ON(!buffer))
|
|
continue;
|
|
buf = buffer;
|
|
}
|
|
|
|
len = attr->show(root_cache, buf);
|
|
if (len > 0)
|
|
attr->store(s, buf, len);
|
|
}
|
|
|
|
if (buffer)
|
|
free_page((unsigned long)buffer);
|
|
#endif /* CONFIG_MEMCG */
|
|
}
|
|
|
|
static void kmem_cache_release(struct kobject *k)
|
|
{
|
|
slab_kmem_cache_release(to_slab(k));
|
|
}
|
|
|
|
static const struct sysfs_ops slab_sysfs_ops = {
|
|
.show = slab_attr_show,
|
|
.store = slab_attr_store,
|
|
};
|
|
|
|
static struct kobj_type slab_ktype = {
|
|
.sysfs_ops = &slab_sysfs_ops,
|
|
.release = kmem_cache_release,
|
|
};
|
|
|
|
static int uevent_filter(struct kset *kset, struct kobject *kobj)
|
|
{
|
|
struct kobj_type *ktype = get_ktype(kobj);
|
|
|
|
if (ktype == &slab_ktype)
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
static const struct kset_uevent_ops slab_uevent_ops = {
|
|
.filter = uevent_filter,
|
|
};
|
|
|
|
static struct kset *slab_kset;
|
|
|
|
static inline struct kset *cache_kset(struct kmem_cache *s)
|
|
{
|
|
#ifdef CONFIG_MEMCG
|
|
if (!is_root_cache(s))
|
|
return s->memcg_params.root_cache->memcg_kset;
|
|
#endif
|
|
return slab_kset;
|
|
}
|
|
|
|
#define ID_STR_LENGTH 64
|
|
|
|
/* Create a unique string id for a slab cache:
|
|
*
|
|
* Format :[flags-]size
|
|
*/
|
|
static char *create_unique_id(struct kmem_cache *s)
|
|
{
|
|
char *name = kmalloc(ID_STR_LENGTH, GFP_KERNEL);
|
|
char *p = name;
|
|
|
|
BUG_ON(!name);
|
|
|
|
*p++ = ':';
|
|
/*
|
|
* First flags affecting slabcache operations. We will only
|
|
* get here for aliasable slabs so we do not need to support
|
|
* too many flags. The flags here must cover all flags that
|
|
* are matched during merging to guarantee that the id is
|
|
* unique.
|
|
*/
|
|
if (s->flags & SLAB_CACHE_DMA)
|
|
*p++ = 'd';
|
|
if (s->flags & SLAB_CACHE_DMA32)
|
|
*p++ = 'D';
|
|
if (s->flags & SLAB_RECLAIM_ACCOUNT)
|
|
*p++ = 'a';
|
|
if (s->flags & SLAB_CONSISTENCY_CHECKS)
|
|
*p++ = 'F';
|
|
if (s->flags & SLAB_ACCOUNT)
|
|
*p++ = 'A';
|
|
if (p != name + 1)
|
|
*p++ = '-';
|
|
p += sprintf(p, "%07u", s->size);
|
|
|
|
BUG_ON(p > name + ID_STR_LENGTH - 1);
|
|
return name;
|
|
}
|
|
|
|
static void sysfs_slab_remove_workfn(struct work_struct *work)
|
|
{
|
|
struct kmem_cache *s =
|
|
container_of(work, struct kmem_cache, kobj_remove_work);
|
|
|
|
if (!s->kobj.state_in_sysfs)
|
|
/*
|
|
* For a memcg cache, this may be called during
|
|
* deactivation and again on shutdown. Remove only once.
|
|
* A cache is never shut down before deactivation is
|
|
* complete, so no need to worry about synchronization.
|
|
*/
|
|
goto out;
|
|
|
|
#ifdef CONFIG_MEMCG
|
|
kset_unregister(s->memcg_kset);
|
|
#endif
|
|
kobject_uevent(&s->kobj, KOBJ_REMOVE);
|
|
out:
|
|
kobject_put(&s->kobj);
|
|
}
|
|
|
|
static int sysfs_slab_add(struct kmem_cache *s)
|
|
{
|
|
int err;
|
|
const char *name;
|
|
struct kset *kset = cache_kset(s);
|
|
int unmergeable = slab_unmergeable(s);
|
|
|
|
INIT_WORK(&s->kobj_remove_work, sysfs_slab_remove_workfn);
|
|
|
|
if (!kset) {
|
|
kobject_init(&s->kobj, &slab_ktype);
|
|
return 0;
|
|
}
|
|
|
|
if (!unmergeable && disable_higher_order_debug &&
|
|
(slub_debug & DEBUG_METADATA_FLAGS))
|
|
unmergeable = 1;
|
|
|
|
if (unmergeable) {
|
|
/*
|
|
* Slabcache can never be merged so we can use the name proper.
|
|
* This is typically the case for debug situations. In that
|
|
* case we can catch duplicate names easily.
|
|
*/
|
|
sysfs_remove_link(&slab_kset->kobj, s->name);
|
|
name = s->name;
|
|
} else {
|
|
/*
|
|
* Create a unique name for the slab as a target
|
|
* for the symlinks.
|
|
*/
|
|
name = create_unique_id(s);
|
|
}
|
|
|
|
s->kobj.kset = kset;
|
|
err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
|
|
if (err)
|
|
goto out;
|
|
|
|
err = sysfs_create_group(&s->kobj, &slab_attr_group);
|
|
if (err)
|
|
goto out_del_kobj;
|
|
|
|
#ifdef CONFIG_MEMCG
|
|
if (is_root_cache(s) && memcg_sysfs_enabled) {
|
|
s->memcg_kset = kset_create_and_add("cgroup", NULL, &s->kobj);
|
|
if (!s->memcg_kset) {
|
|
err = -ENOMEM;
|
|
goto out_del_kobj;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
kobject_uevent(&s->kobj, KOBJ_ADD);
|
|
if (!unmergeable) {
|
|
/* Setup first alias */
|
|
sysfs_slab_alias(s, s->name);
|
|
}
|
|
out:
|
|
if (!unmergeable)
|
|
kfree(name);
|
|
return err;
|
|
out_del_kobj:
|
|
kobject_del(&s->kobj);
|
|
goto out;
|
|
}
|
|
|
|
static void sysfs_slab_remove(struct kmem_cache *s)
|
|
{
|
|
if (slab_state < FULL)
|
|
/*
|
|
* Sysfs has not been setup yet so no need to remove the
|
|
* cache from sysfs.
|
|
*/
|
|
return;
|
|
|
|
kobject_get(&s->kobj);
|
|
schedule_work(&s->kobj_remove_work);
|
|
}
|
|
|
|
void sysfs_slab_unlink(struct kmem_cache *s)
|
|
{
|
|
if (slab_state >= FULL)
|
|
kobject_del(&s->kobj);
|
|
}
|
|
|
|
void sysfs_slab_release(struct kmem_cache *s)
|
|
{
|
|
if (slab_state >= FULL)
|
|
kobject_put(&s->kobj);
|
|
}
|
|
|
|
/*
|
|
* Need to buffer aliases during bootup until sysfs becomes
|
|
* available lest we lose that information.
|
|
*/
|
|
struct saved_alias {
|
|
struct kmem_cache *s;
|
|
const char *name;
|
|
struct saved_alias *next;
|
|
};
|
|
|
|
static struct saved_alias *alias_list;
|
|
|
|
static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
|
|
{
|
|
struct saved_alias *al;
|
|
|
|
if (slab_state == FULL) {
|
|
/*
|
|
* If we have a leftover link then remove it.
|
|
*/
|
|
sysfs_remove_link(&slab_kset->kobj, name);
|
|
return sysfs_create_link(&slab_kset->kobj, &s->kobj, name);
|
|
}
|
|
|
|
al = kmalloc(sizeof(struct saved_alias), GFP_KERNEL);
|
|
if (!al)
|
|
return -ENOMEM;
|
|
|
|
al->s = s;
|
|
al->name = name;
|
|
al->next = alias_list;
|
|
alias_list = al;
|
|
return 0;
|
|
}
|
|
|
|
static int __init slab_sysfs_init(void)
|
|
{
|
|
struct kmem_cache *s;
|
|
int err;
|
|
|
|
mutex_lock(&slab_mutex);
|
|
|
|
slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj);
|
|
if (!slab_kset) {
|
|
mutex_unlock(&slab_mutex);
|
|
pr_err("Cannot register slab subsystem.\n");
|
|
return -ENOSYS;
|
|
}
|
|
|
|
slab_state = FULL;
|
|
|
|
list_for_each_entry(s, &slab_caches, list) {
|
|
err = sysfs_slab_add(s);
|
|
if (err)
|
|
pr_err("SLUB: Unable to add boot slab %s to sysfs\n",
|
|
s->name);
|
|
}
|
|
|
|
while (alias_list) {
|
|
struct saved_alias *al = alias_list;
|
|
|
|
alias_list = alias_list->next;
|
|
err = sysfs_slab_alias(al->s, al->name);
|
|
if (err)
|
|
pr_err("SLUB: Unable to add boot slab alias %s to sysfs\n",
|
|
al->name);
|
|
kfree(al);
|
|
}
|
|
|
|
mutex_unlock(&slab_mutex);
|
|
resiliency_test();
|
|
return 0;
|
|
}
|
|
|
|
__initcall(slab_sysfs_init);
|
|
#endif /* CONFIG_SYSFS */
|
|
|
|
/*
|
|
* The /proc/slabinfo ABI
|
|
*/
|
|
#ifdef CONFIG_SLUB_DEBUG
|
|
void get_slabinfo(struct kmem_cache *s, struct slabinfo *sinfo)
|
|
{
|
|
unsigned long nr_slabs = 0;
|
|
unsigned long nr_objs = 0;
|
|
unsigned long nr_free = 0;
|
|
int node;
|
|
struct kmem_cache_node *n;
|
|
|
|
for_each_kmem_cache_node(s, node, n) {
|
|
nr_slabs += node_nr_slabs(n);
|
|
nr_objs += node_nr_objs(n);
|
|
nr_free += count_partial(n, count_free);
|
|
}
|
|
|
|
sinfo->active_objs = nr_objs - nr_free;
|
|
sinfo->num_objs = nr_objs;
|
|
sinfo->active_slabs = nr_slabs;
|
|
sinfo->num_slabs = nr_slabs;
|
|
sinfo->objects_per_slab = oo_objects(s->oo);
|
|
sinfo->cache_order = oo_order(s->oo);
|
|
}
|
|
|
|
void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *s)
|
|
{
|
|
}
|
|
|
|
ssize_t slabinfo_write(struct file *file, const char __user *buffer,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
return -EIO;
|
|
}
|
|
#endif /* CONFIG_SLUB_DEBUG */
|