Files
ack-tegra/kernel/watchdog.c
Greg Kroah-Hartman 8cb2595f93 Merge 6.12.35 into android16-6.12-lts
GKI (arm64) relevant 87 out of 414 changes, affecting 112 files +738/-352
  bdb71ee651 configfs: Do not override creating attribute file failure in populate_attrs() [1 file, +1/-1]
  ba789be63d io_uring: account drain memory to cgroup [1 file, +1/-1]
  c58b577cf7 io_uring/kbuf: account ring io_buffer_list memory [1 file, +1/-1]
  f78b38af35 jbd2: fix data-race and null-ptr-deref in jbd2_journal_dirty_metadata() [1 file, +3/-2]
  2429bb9fad media: v4l2-dev: fix error handling in __video_register_device() [1 file, +7/-7]
  5d8b057ed7 media: videobuf2: use sgtable-based scatterlist wrappers [1 file, +2/-2]
  b52dc88361 media: uvcvideo: Return the number of processed controls [1 file, +10/-1]
  6d2b12e7c5 media: uvcvideo: Send control events for partial succeeds [1 file, +9/-3]
  aac91ae06c media: uvcvideo: Fix deferred probing error [1 file, +19/-8]
  86d9837e46 arm64/mm: Close theoretical race where stale TLB entry remains valid [1 file, +5/-4]
  5538af3843 block: use plug request list tail for one-shot backmerge attempt [1 file, +13/-13]
  943801c380 block: Clear BIO_EMULATES_ZONE_APPEND flag on BIO completion [1 file, +1/-0]
  1c71f3cf5f cgroup,freezer: fix incomplete freezing when attaching tasks [1 file, +1/-2]
  a0890b7805 bus: firewall: Fix missing static inline annotations for stubs [1 file, +9/-6]
  5766da2237 ext4: inline: fix len overflow in ext4_prepare_inline_data [1 file, +1/-1]
  796632e6f8 ext4: fix calculation of credits for extent tree modification [1 file, +6/-5]
  4b36399711 ext4: ensure i_size is smaller than maxbytes [1 file, +2/-1]
  be5f3061a6 ext4: only dirty folios when data journaling regular files [1 file, +6/-1]
  a0b1c91ada Input: gpio-keys - fix possible concurrent access in gpio_keys_irq_timer() [1 file, +2/-0]
  fed611bd8c f2fs: fix to do sanity check on ino and xnid [1 file, +6/-0]
  aaa644e7ff f2fs: prevent kernel warning due to negative i_nlink from corrupted image [1 file, +9/-0]
  ee1b421c46 f2fs: fix to do sanity check on sit_bitmap_size [1 file, +8/-0]
  f16a797dce watchdog: fix watchdog may detect false positive of softlockup [1 file, +27/-14]
  02137179ff mm: fix ratelimit_pages update error in dirty_ratio_handler() [1 file, +1/-1]
  462eee6d42 firmware: arm_scmi: Ensure that the message-id supports fastchannel [2 files, +45/-33]
  e3cf1ef571 dm-verity: fix a memory leak if some arguments are specified multiple times [3 files, +24/-5]
  f2986bccf2 dm: lock limits when reading them [1 file, +7/-1]
  ec5f0b4412 ovl: Fix nested backing file paths [1 file, +2/-2]
  92776ca0cc remoteproc: core: Cleanup acquired resources when rproc_handle_resources() fails in rproc_attach() [1 file, +2/-3]
  f4ef928ca5 remoteproc: core: Release rproc->clean_table after rproc_attach() fails [1 file, +1/-0]
  68e58f5791 PCI: dwc: ep: Correct PBA offset in .set_msix() callback [1 file, +3/-2]
  b20701d594 PCI: Add ACS quirk for Loongson PCIe [1 file, +23/-0]
  be0cf75cbd PCI: Fix lock symmetry in pci_slot_unlock() [1 file, +2/-1]
  7b45d2401d clocksource: Fix the CPUs' choice in the watchdog per CPU verification [1 file, +1/-1]
  c05aba32a9 ACPICA: Avoid sequence overread in call to strncmp() [1 file, +1/-1]
  66613b13cd ACPI: Add missing prototype for non CONFIG_SUSPEND/CONFIG_X86 case [1 file, +8/-1]
  33cd650d38 pmdomain: core: Reset genpd->states to avoid freeing invalid data [1 file, +3/-1]
  f34e0c1556 platform-msi: Add msi_remove_device_irq_domain() in platform_device_msi_free_irqs_all() [1 file, +1/-0]
  c519f81e9c gpiolib: of: Add polarity quirk for s5m8767 [1 file, +9/-0]
  1f152ae557 PM: runtime: fix denying of auto suspend in pm_suspend_timer_fn() [1 file, +1/-1]
  6c1151d53c tipc: use kfree_sensitive() for aead cleanup [1 file, +1/-1]
  b0e647442c f2fs: use vmalloc instead of kvmalloc in .init_{,de}compress_ctx [2 files, +15/-13]
  2d834477bb bpf: Check rcu_read_lock_trace_held() in bpf_map_lookup_percpu_elem() [1 file, +2/-1]
  77ff6aec7c cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs [1 file, +35/-1]
  0a8446058c tcp: always seek for minimal rtt in tcp_rcv_rtt_update() [1 file, +8/-14]
  f97085d365 tcp: remove zero TCP TS samples for autotuning [1 file, +5/-5]
  89b20c406e tcp: fix initial tp->rcvq_space.space value for passive TS enabled flows [1 file, +3/-3]
  84c156a351 tcp: add receive queue awareness in tcp_rcv_space_adjust() [2 files, +5/-3]
  3a9e74d158 ipv4/route: Use this_cpu_inc() for stats on PREEMPT_RT [1 file, +4/-0]
  5eb9c50e0c net: page_pool: Don't recycle into cache on PREEMPT_RT [1 file, +4/-0]
  8b0741b167 xfrm: validate assignment of maximal possible SEQ number [1 file, +42/-10]
  8fdf2f79eb bpf: Pass the same orig_call value to trampoline functions [1 file, +1/-1]
  f0023d7a2a f2fs: fix to bail out in get_new_segment() [2 files, +6/-1]
  448dc45eea bpf: Use proper type to calculate bpf_raw_tp_null_args.mask index [1 file, +2/-2]
  78f768e36c net: bridge: mcast: re-implement br_multicast_{enable, disable}_port functions [1 file, +69/-8]
  4b3383110b software node: Correct a OOB check in software_node_get_reference_args() [1 file, +1/-1]
  b7129ef57d sock: Correct error checking condition for (assign|release)_proto_idx() [1 file, +2/-2]
  a58f0a0e99 f2fs: fix to set atomic write status more clear [3 files, +12/-2]
  b8b4b8bb34 bpf, sockmap: Fix data lost during EAGAIN retries [1 file, +2/-1]
  7c41f73b64 fs/xattr.c: fix simple_xattr_list() [1 file, +1/-0]
  2e10dc9c2a io_uring/kbuf: don't truncate end buffer for multiple buffer peeks [1 file, +4/-1]
  1a4254ab06 io_uring: fix task leak issue in io_wq_create() [1 file, +3/-1]
  4220cc0b98 nvme: always punt polled uring_cmd end_io work to task_work [1 file, +7/-14]
  f9b97d466e net_sched: sch_sfq: reject invalid perturb period [1 file, +8/-2]
  2a3ad42a57 net: clear the dst when changing skb protocol [1 file, +13/-6]
  510a29d776 mm: close theoretical race where stale TLB entries could linger [1 file, +2/-0]
  57ec081869 sched_ext, sched/core: Don't call scx_group_set_weight() prematurely from sched_create_group() [3 files, +9/-2]
  3d828519bd atm: Revert atm_account_tx() if copy_from_iter_full() fails. [3 files, +8/-1]
  47f34289d1 arm64: Restrict pagetable teardown to avoid false warning [1 file, +2/-1]
  9cf5b2a3b7 mm/hugetlb: unshare page tables during VMA split, not before [5 files, +57/-16]
  dc5f0aef9e net: Fix checksum update for ILA adj-transport [4 files, +7/-7]
  2516299184 bpf: Fix L4 csum update on IPv6 in CHECKSUM_COMPLETE [3 files, +7/-2]
  50189d9c5e erofs: remove unused trace event erofs_destroy_inode [1 file, +0/-18]
  348e541fef ipv6: remove leftover ip6 cookie initializer [1 file, +0/-2]
  3c44ebad5a ipv6: replace ipcm6_init calls with ipcm6_init_sk [4 files, +3/-29]
  6b358b3adf io_uring/sqpoll: don't put task_struct on tctx setup failure [1 file, +1/-4]
  8873080b88 workqueue: Initialize wq_isolated_cpumask in workqueue_init_early() [1 file, +2/-1]
  ac462a75fd net: netmem: fix skb_ensure_writable with unreadable skbs [1 file, +0/-3]
  61b39e189d ptp: allow reading of currently dialed frequency to succeed on free-running clocks [1 file, +2/-1]
  397c1faf8f tcp: fix tcp_packet_delayed() for tcp_is_non_sack_preventing_reopen() behavior [1 file, +25/-12]
  0d3d91c350 tipc: fix null-ptr-deref when acquiring remote ip of ethernet bearer [1 file, +2/-2]
  31d50dfe9c tcp: fix passive TFO socket having invalid NAPI ID [1 file, +3/-0]
  0f8df5d6f2 ublk: santizize the arguments from userspace when adding a device [1 file, +3/-0]
  456019adaa perf: Fix sample vs do_exit() [2 files, +16/-8]
  7335c33d62 perf: Fix cgroup state vs ERROR [1 file, +30/-21]
  fd199366bf perf/core: Fix WARN in perf_cgroup_switch() [1 file, +20/-2]
  22f935bc86 arm64/ptrace: Fix stack-out-of-bounds read in regs_get_kernel_stack_nth() [1 file, +1/-1]

Changes in 6.12.35
	configfs: Do not override creating attribute file failure in populate_attrs()
	crypto: marvell/cesa - Do not chain submitted requests
	gfs2: move msleep to sleepable context
	crypto: qat - add shutdown handler to qat_c3xxx
	crypto: qat - add shutdown handler to qat_420xx
	crypto: qat - add shutdown handler to qat_4xxx
	crypto: qat - add shutdown handler to qat_c62x
	crypto: qat - add shutdown handler to qat_dh895xcc
	ASoC: qcom: sdm845: Add error handling in sdm845_slim_snd_hw_params()
	ASoC: meson: meson-card-utils: use of_property_present() for DT parsing
	ASoC: amd: sof_amd_sdw: Fix unlikely uninitialized variable use in create_sdw_dailinks()
	io_uring: account drain memory to cgroup
	io_uring/kbuf: account ring io_buffer_list memory
	powerpc/pseries/msi: Avoid reading PCI device registers in reduced power states
	s390/pci: Remove redundant bus removal and disable from zpci_release_device()
	s390/pci: Prevent self deletion in disable_slot()
	s390/pci: Allow re-add of a reserved but not yet removed device
	s390/pci: Serialize device addition and removal
	regulator: max20086: Fix MAX200086 chip id
	regulator: max20086: Change enable gpio to optional
	net/mlx5_core: Add error handling inmlx5_query_nic_vport_qkey_viol_cntr()
	net/mlx5: Add error handling in mlx5_query_nic_vport_node_guid()
	wifi: p54: prevent buffer-overflow in p54_rx_eeprom_readback()
	wifi: mt76: mt7925: fix host interrupt register initialization
	wifi: ath11k: fix rx completion meta data corruption
	wifi: rtw88: usb: Upload the firmware in bigger chunks
	wifi: ath11k: fix ring-buffer corruption
	NFSD: unregister filesystem in case genl_register_family() fails
	NFSD: fix race between nfsd registration and exports_proc
	NFSD: Implement FATTR4_CLONE_BLKSIZE attribute
	nfsd: nfsd4_spo_must_allow() must check this is a v4 compound request
	nfsd: Initialize ssc before laundromat_work to prevent NULL dereference
	SUNRPC: Prevent hang on NFS mount with xprtsec=[m]tls
	NFSv4: Don't check for OPEN feature support in v4.1
	fs/nfs/read: fix double-unlock bug in nfs_return_empty_folio()
	wifi: ath12k: fix ring-buffer corruption
	jbd2: fix data-race and null-ptr-deref in jbd2_journal_dirty_metadata()
	svcrdma: Unregister the device if svc_rdma_accept() fails
	wifi: rtw88: usb: Reduce control message timeout to 500 ms
	wifi: rtlwifi: disable ASPM for RTL8723BE with subsystem ID 11ad:1723
	media: ov8856: suppress probe deferral errors
	media: ov5675: suppress probe deferral errors
	media: imx335: Use correct register width for HNUM
	media: nxp: imx8-isi: better handle the m2m usage_count
	media: i2c: ds90ub913: Fix returned fmt from .set_fmt()
	media: ccs-pll: Start VT pre-PLL multiplier search from correct value
	media: ov2740: Move pm-runtime cleanup on probe-errors to proper place
	media: ccs-pll: Start OP pre-PLL multiplier search from correct value
	media: ccs-pll: Correct the upper limit of maximum op_pre_pll_clk_div
	media: ccs-pll: Check for too high VT PLL multiplier in dual PLL case
	media: cxusb: no longer judge rbuf when the write fails
	media: davinci: vpif: Fix memory leak in probe error path
	media: gspca: Add error handling for stv06xx_read_sensor()
	media: i2c: imx335: Fix frame size enumeration
	media: imagination: fix a potential memory leak in e5010_probe()
	media: intel/ipu6: Fix dma mask for non-secure mode
	media: ipu6: Remove workaround for Meteor Lake ES2
	media: mediatek: vcodec: Correct vsi_core framebuffer size
	media: omap3isp: use sgtable-based scatterlist wrappers
	media: v4l2-dev: fix error handling in __video_register_device()
	media: venus: Fix probe error handling
	media: videobuf2: use sgtable-based scatterlist wrappers
	media: vidtv: Terminating the subsequent process of initialization failure
	media: vivid: Change the siize of the composing
	media: imx-jpeg: Drop the first error frames
	media: imx-jpeg: Move mxc_jpeg_free_slot_data() ahead
	media: imx-jpeg: Reset slot data pointers when freed
	media: imx-jpeg: Cleanup after an allocation error
	media: uvcvideo: Return the number of processed controls
	media: uvcvideo: Send control events for partial succeeds
	media: uvcvideo: Fix deferred probing error
	arm64/mm: Close theoretical race where stale TLB entry remains valid
	ARM: 9447/1: arm/memremap: fix arch_memremap_can_ram_remap()
	ARM: omap: pmic-cpcap: do not mess around without CPCAP or OMAP4
	ASoC: codecs: wcd9375: Fix double free of regulator supplies
	ASoC: codecs: wcd937x: Drop unused buck_supply
	block: use plug request list tail for one-shot backmerge attempt
	block: Clear BIO_EMULATES_ZONE_APPEND flag on BIO completion
	bus: mhi: ep: Update read pointer only after buffer is written
	bus: mhi: host: Fix conflict between power_up and SYSERR
	can: kvaser_pciefd: refine error prone echo_skb_max handling logic
	can: tcan4x5x: fix power regulator retrieval during probe
	ceph: avoid kernel BUG for encrypted inode with unaligned file size
	ceph: set superblock s_magic for IMA fsmagic matching
	cgroup,freezer: fix incomplete freezing when attaching tasks
	bus: firewall: Fix missing static inline annotations for stubs
	ata: pata_via: Force PIO for ATAPI devices on VT6415/VT6330
	ata: ahci: Disallow LPM for ASUSPRO-D840SA motherboard
	ata: ahci: Disallow LPM for Asus B550-F motherboard
	bus: fsl-mc: do not add a device-link for the UAPI used DPMCP device
	bus: fsl-mc: fix GET/SET_TAILDROP command ids
	ext4: inline: fix len overflow in ext4_prepare_inline_data
	ext4: fix calculation of credits for extent tree modification
	ext4: factor out ext4_get_maxbytes()
	ext4: ensure i_size is smaller than maxbytes
	ext4: only dirty folios when data journaling regular files
	Input: ims-pcu - check record size in ims_pcu_flash_firmware()
	Input: gpio-keys - fix possible concurrent access in gpio_keys_irq_timer()
	f2fs: fix to do sanity check on ino and xnid
	f2fs: prevent kernel warning due to negative i_nlink from corrupted image
	f2fs: fix to do sanity check on sit_bitmap_size
	hwmon: (ftsteutates) Fix TOCTOU race in fts_read()
	NFC: nci: uart: Set tty->disc_data only in success path
	net/sched: fix use-after-free in taprio_dev_notifier
	net: ftgmac100: select FIXED_PHY
	iommu/vt-d: Restore context entry setup order for aliased devices
	fbdev: Fix do_register_framebuffer to prevent null-ptr-deref in fb_videomode_to_var
	EDAC/altera: Use correct write width with the INTTEST register
	fbdev: Fix fb_set_var to prevent null-ptr-deref in fb_videomode_to_var
	parisc/unaligned: Fix hex output to show 8 hex chars
	vgacon: Add check for vc_origin address range in vgacon_scroll()
	parisc: fix building with gcc-15
	clk: meson-g12a: add missing fclk_div2 to spicc
	ipc: fix to protect IPCS lookups using RCU
	watchdog: fix watchdog may detect false positive of softlockup
	RDMA/iwcm: Fix use-after-free of work objects after cm_id destruction
	mm: fix ratelimit_pages update error in dirty_ratio_handler()
	soc: qcom: pmic_glink_altmode: fix spurious DP hotplug events
	configfs-tsm-report: Fix NULL dereference of tsm_ops
	firmware: arm_scmi: Ensure that the message-id supports fastchannel
	mtd: rawnand: sunxi: Add randomizer configuration in sunxi_nfc_hw_ecc_write_chunk
	mtd: nand: sunxi: Add randomizer configuration before randomizer enable
	KVM: SVM: Clear current_vmcb during vCPU free for all *possible* CPUs
	KVM: VMX: Flush shadow VMCS on emergency reboot
	dm-mirror: fix a tiny race condition
	dm-verity: fix a memory leak if some arguments are specified multiple times
	mtd: rawnand: qcom: Fix read len for onfi param page
	ftrace: Fix UAF when lookup kallsym after ftrace disabled
	dm: lock limits when reading them
	phy: fsl-imx8mq-usb: fix phy_tx_vboost_level_from_property()
	net: ch9200: fix uninitialised access during mii_nway_restart
	KVM: s390: rename PROT_NONE to PROT_TYPE_DUMMY
	sysfb: Fix screen_info type check for VGA
	video: screen_info: Relocate framebuffers behind PCI bridges
	pwm: axi-pwmgen: fix missing separate external clock
	staging: iio: ad5933: Correct settling cycles encoding per datasheet
	mips: Add -std= flag specified in KBUILD_CFLAGS to vdso CFLAGS
	ovl: Fix nested backing file paths
	regulator: max14577: Add error check for max14577_read_reg()
	remoteproc: core: Cleanup acquired resources when rproc_handle_resources() fails in rproc_attach()
	remoteproc: core: Release rproc->clean_table after rproc_attach() fails
	remoteproc: k3-m4: Don't assert reset in detach routine
	cifs: reset connections for all channels when reconnect requested
	cifs: update dstaddr whenever channel iface is updated
	cifs: dns resolution is needed only for primary channel
	smb: client: add NULL check in automount_fullpath
	Drivers: hv: Allocate interrupt and monitor pages aligned to system page boundary
	uio_hv_generic: Use correct size for interrupt and monitor pages
	uio_hv_generic: Align ring size to system page
	PCI: cadence-ep: Correct PBA offset in .set_msix() callback
	PCI: dwc: ep: Correct PBA offset in .set_msix() callback
	PCI: Add ACS quirk for Loongson PCIe
	PCI: Fix lock symmetry in pci_slot_unlock()
	PCI: dw-rockchip: Remove PCIE_L0S_ENTRY check from rockchip_pcie_link_up()
	PCI: dw-rockchip: Fix PHY function call sequence in rockchip_pcie_phy_deinit()
	iio: accel: fxls8962af: Fix temperature scan element sign
	accel/ivpu: Improve buffer object logging
	accel/ivpu: Use firmware names from upstream repo
	accel/ivpu: Use dma_resv_lock() instead of a custom mutex
	accel/ivpu: Fix warning in ivpu_gem_bo_free()
	dummycon: Trigger redraw when switching consoles with deferred takeover
	mm/hugetlb: fix huge_pmd_unshare() vs GUP-fast race
	iio: imu: inv_icm42600: Fix temperature calculation
	iio: adc: ad7944: mask high bits on direct read
	iio: adc: ti-ads1298: Kconfig: add kfifo dependency to fix module build
	iio: adc: ad7606_spi: fix reg write value mask
	ACPICA: fix acpi operand cache leak in dswstate.c
	ASoC: amd: yc: Add quirk for Lenovo Yoga Pro 7 14ASP9
	clocksource: Fix the CPUs' choice in the watchdog per CPU verification
	power: supply: collie: Fix wakeup source leaks on device unbind
	mmc: Add quirk to disable DDR50 tuning
	ACPICA: Avoid sequence overread in call to strncmp()
	ASoC: tas2770: Power cycle amp on ISENSE/VSENSE change
	ASoC: intel/sdw_utils: Assign initial value in asoc_sdw_rt_amp_spk_rtd_init()
	ACPI: bus: Bail out if acpi_kobj registration fails
	ACPI: Add missing prototype for non CONFIG_SUSPEND/CONFIG_X86 case
	ACPICA: fix acpi parse and parseext cache leaks
	ACPICA: Apply pack(1) to union aml_resource
	ALSA: hda: cs35l41: Fix swapped l/r audio channels for Acer Helios laptops
	power: supply: bq27xxx: Retrieve again when busy
	pmdomain: core: Reset genpd->states to avoid freeing invalid data
	ACPICA: utilities: Fix overflow check in vsnprintf()
	platform-msi: Add msi_remove_device_irq_domain() in platform_device_msi_free_irqs_all()
	ASoC: tegra210_ahub: Add check to of_device_get_match_data()
	Make 'cc-option' work correctly for the -Wno-xyzzy pattern
	gpiolib: of: Add polarity quirk for s5m8767
	PM: runtime: fix denying of auto suspend in pm_suspend_timer_fn()
	power: supply: max17040: adjust thermal channel scaling
	ACPI: battery: negate current when discharging
	net: macb: Check return value of dma_set_mask_and_coherent()
	net: lan743x: Modify the EEPROM and OTP size for PCI1xxxx devices
	tipc: use kfree_sensitive() for aead cleanup
	f2fs: use vmalloc instead of kvmalloc in .init_{,de}compress_ctx
	bpf: Check rcu_read_lock_trace_held() in bpf_map_lookup_percpu_elem()
	Bluetooth: btusb: Add new VID/PID 13d3/3584 for MT7922
	i2c: designware: Invoke runtime suspend on quick slave re-registration
	wifi: mt76: mt7996: drop fragments with multicast or broadcast RA
	emulex/benet: correct command version selection in be_cmd_get_stats()
	Bluetooth: btusb: Add new VID/PID 13d3/3630 for MT7925
	wifi: mt76: mt76x2: Add support for LiteOn WN4516R,WN4519R
	wifi: mt76: mt7921: add 160 MHz AP for mt7922 device
	wifi: mt76: mt7925: introduce thermal protection
	wifi: mac80211: validate SCAN_FLAG_AP in scan request during MLO
	sctp: Do not wake readers in __sctp_write_space()
	libbpf/btf: Fix string handling to support multi-split BTF
	cpufreq: scmi: Skip SCMI devices that aren't used by the CPUs
	i2c: tegra: check msg length in SMBUS block read
	i2c: npcm: Add clock toggle recovery
	clk: qcom: gcc-x1e80100: Set FORCE MEM CORE for UFS clocks
	net: dlink: add synchronization for stats update
	wifi: ath12k: fix macro definition HAL_RX_MSDU_PKT_LENGTH_GET
	wifi: ath12k: fix a possible dead lock caused by ab->base_lock
	wifi: ath11k: Fix QMI memory reuse logic
	iommu/amd: Allow matching ACPI HID devices without matching UIDs
	wifi: rtw89: leave idle mode when setting WEP encryption for AP mode
	tcp: always seek for minimal rtt in tcp_rcv_rtt_update()
	tcp: remove zero TCP TS samples for autotuning
	tcp: fix initial tp->rcvq_space.space value for passive TS enabled flows
	tcp: add receive queue awareness in tcp_rcv_space_adjust()
	x86/sgx: Prevent attempts to reclaim poisoned pages
	ipv4/route: Use this_cpu_inc() for stats on PREEMPT_RT
	net: page_pool: Don't recycle into cache on PREEMPT_RT
	xfrm: validate assignment of maximal possible SEQ number
	net: atlantic: generate software timestamp just before the doorbell
	pinctrl: armada-37xx: propagate error from armada_37xx_pmx_set_by_name()
	pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get_direction()
	bpf: Pass the same orig_call value to trampoline functions
	net: stmmac: generate software timestamp just before the doorbell
	pinctrl: armada-37xx: propagate error from armada_37xx_pmx_gpio_set_direction()
	libbpf: Check bpf_map_skeleton link for NULL
	pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get()
	net: mlx4: add SOF_TIMESTAMPING_TX_SOFTWARE flag when getting ts info
	net: vertexcom: mse102x: Return code for mse102x_rx_pkt_spi
	wireless: purelifi: plfxlc: fix memory leak in plfxlc_usb_wreq_asyn()
	wifi: mac80211: do not offer a mesh path if forwarding is disabled
	clk: rockchip: rk3036: mark ddrphy as critical
	hid-asus: check ROG Ally MCU version and warn
	wifi: iwlwifi: mvm: fix beacon CCK flag
	f2fs: fix to bail out in get_new_segment()
	netfilter: nft_set_pipapo: clamp maximum map bucket size to INT_MAX
	libbpf: Add identical pointer detection to btf_dedup_is_equiv()
	scsi: lpfc: Fix lpfc_check_sli_ndlp() handling for GEN_REQUEST64 commands
	scsi: smartpqi: Add new PCI IDs
	iommu/amd: Ensure GA log notifier callbacks finish running before module unload
	wifi: iwlwifi: pcie: make sure to lock rxq->read
	wifi: rtw89: 8922a: fix TX fail with wrong VCO setting
	wifi: mac80211_hwsim: Prevent tsf from setting if beacon is disabled
	netdevsim: Mark NAPI ID on skb in nsim_rcv
	net/mlx5: HWS, Fix IP version decision
	bpf: Use proper type to calculate bpf_raw_tp_null_args.mask index
	wifi: mac80211: VLAN traffic in multicast path
	Revert "mac80211: Dynamically set CoDel parameters per station"
	wifi: iwlwifi: Add missing MODULE_FIRMWARE for Qu-c0-jf-b0
	net: bridge: mcast: update multicast contex when vlan state is changed
	net: bridge: mcast: re-implement br_multicast_{enable, disable}_port functions
	vxlan: Do not treat dst cache initialization errors as fatal
	bnxt_en: Remove unused field "ref_count" in struct bnxt_ulp
	wifi: ath12k: using msdu end descriptor to check for rx multicast packets
	net: ethernet: ti: am65-cpsw: handle -EPROBE_DEFER
	software node: Correct a OOB check in software_node_get_reference_args()
	isofs: fix Y2038 and Y2156 issues in Rock Ridge TF entry
	pinctrl: mcp23s08: Reset all pins to input at probe
	wifi: ath12k: fix failed to set mhi state error during reboot with hardware grouping
	scsi: lpfc: Use memcpy() for BIOS version
	sock: Correct error checking condition for (assign|release)_proto_idx()
	i40e: fix MMIO write access to an invalid page in i40e_clear_hw
	ixgbe: Fix unreachable retry logic in combined and byte I2C write functions
	RDMA/hns: initialize db in update_srq_db()
	ice: fix check for existing switch rule
	usbnet: asix AX88772: leave the carrier control to phylink
	f2fs: fix to set atomic write status more clear
	bpf, sockmap: Fix data lost during EAGAIN retries
	net: ethernet: cortina: Use TOE/TSO on all TCP
	octeontx2-pf: Add error log forcn10k_map_unmap_rq_policer()
	wifi: ath11k: determine PM policy based on machine model
	wifi: ath12k: fix link valid field initialization in the monitor Rx
	wifi: ath12k: fix incorrect CE addresses
	wifi: ath12k: Pass correct values of center freq1 and center freq2 for 160 MHz
	net/mlx5: HWS, Harden IP version definer checks
	fbcon: Make sure modelist not set on unregistered console
	watchdog: da9052_wdt: respect TWDMIN
	bus: fsl-mc: increase MC_CMD_COMPLETION_TIMEOUT_MS value
	ARM: OMAP2+: Fix l4ls clk domain handling in STANDBY
	tee: Prevent size calculation wraparound on 32-bit kernels
	Revert "bus: ti-sysc: Probe for l4_wkup and l4_cfg interconnect devices first"
	fs/xattr.c: fix simple_xattr_list()
	platform/x86/amd: pmc: Clear metrics table at start of cycle
	platform/x86/amd: pmf: Prevent amd_pmf_tee_deinit() from running twice
	platform/x86: dell_rbu: Fix list usage
	platform/x86: dell_rbu: Stop overwriting data buffer
	powerpc/vdso: Fix build of VDSO32 with pcrel
	powerpc/eeh: Fix missing PE bridge reconfiguration during VFIO EEH recovery
	io_uring/kbuf: don't truncate end buffer for multiple buffer peeks
	io_uring: fix task leak issue in io_wq_create()
	drivers/rapidio/rio_cm.c: prevent possible heap overwrite
	platform/loongarch: laptop: Get brightness setting from EC on probe
	platform/loongarch: laptop: Unregister generic_sub_drivers on exit
	platform/loongarch: laptop: Add backlight power control support
	LoongArch: vDSO: Correctly use asm parameters in syscall wrappers
	LoongArch: Avoid using $r0/$r1 as "mask" for csrxchg
	LoongArch: Fix panic caused by NULL-PMD in huge_pte_offset()
	jffs2: check that raw node were preallocated before writing summary
	jffs2: check jffs2_prealloc_raw_node_refs() result in few other places
	cifs: deal with the channel loading lag while picking channels
	cifs: serialize other channels when query server interfaces is pending
	cifs: do not disable interface polling on failure
	smb: improve directory cache reuse for readdir operations
	scsi: storvsc: Increase the timeouts to storvsc_timeout
	scsi: s390: zfcp: Ensure synchronous unit_add
	nvme: always punt polled uring_cmd end_io work to task_work
	net_sched: sch_sfq: reject invalid perturb period
	net: clear the dst when changing skb protocol
	mm: close theoretical race where stale TLB entries could linger
	udmabuf: use sgtable-based scatterlist wrappers
	x86/virt/tdx: Avoid indirect calls to TDX assembly functions
	selftests/x86: Add a test to detect infinite SIGTRAP handler loop
	ksmbd: fix null pointer dereference in destroy_previous_session
	platform/x86: ideapad-laptop: use usleep_range() for EC polling
	selinux: fix selinux_xfrm_alloc_user() to set correct ctx_len
	platform/x86/intel-uncore-freq: Fail module load when plat_info is NULL
	sched_ext, sched/core: Don't call scx_group_set_weight() prematurely from sched_create_group()
	atm: Revert atm_account_tx() if copy_from_iter_full() fails.
	wifi: rtw89: phy: add dummy C2H event handler for report of TAS power
	cpufreq/amd-pstate: Add missing NULL ptr check in amd_pstate_update
	Input: sparcspkr - avoid unannotated fall-through
	wifi: ath12k: Clear affinity hint before calling ath12k_pci_free_irq() in error path
	wifi: cfg80211: init wiphy_work before allocating rfkill fails
	arm64: Restrict pagetable teardown to avoid false warning
	ALSA: usb-audio: Rename ALSA kcontrol PCM and PCM1 for the KTMicro sound card
	ALSA: hda/intel: Add Thinkpad E15 to PM deny list
	ALSA: hda/realtek - Add mute LED support for HP Victus 16-s1xxx and HP Victus 15-fa1xxx
	ALSA: hda/realtek: enable headset mic on Latitude 5420 Rugged
	ALSA: hda/realtek: Fix built-in mic on ASUS VivoBook X513EA
	ALSA: hda/realtek: Add quirk for Asus GU605C
	iio: accel: fxls8962af: Fix temperature calculation
	mm/hugetlb: unshare page tables during VMA split, not before
	drm/amdgpu: read back register after written for VCN v4.0.5
	kbuild: rust: add rustc-min-version support function
	rust: compile libcore with edition 2024 for 1.87+
	net: Fix checksum update for ILA adj-transport
	bpf: Fix L4 csum update on IPv6 in CHECKSUM_COMPLETE
	erofs: remove unused trace event erofs_destroy_inode
	nfsd: use threads array as-is in netlink interface
	sunrpc: handle SVC_GARBAGE during svc auth processing as auth error
	drm/v3d: Avoid NULL pointer dereference in `v3d_job_update_stats()`
	Kunit to check the longest symbol length
	x86/tools: Drop duplicate unlikely() definition in insn_decoder_test.c
	ipv6: remove leftover ip6 cookie initializer
	ipv6: replace ipcm6_init calls with ipcm6_init_sk
	smb: fix secondary channel creation issue with kerberos by populating hostname when adding channels
	drm/msm/disp: Correct porch timing for SDM845
	drm/msm/dsi/dsi_phy_10nm: Fix missing initial VCO rate
	drm/msm: Fix CP_RESET_CONTEXT_STATE bitfield names
	drm/msm/a7xx: Call CP_RESET_CONTEXT_STATE
	drm/ssd130x: fix ssd132x_clear_screen() columns
	ionic: Prevent driver/fw getting out of sync on devcmd(s)
	drm/nouveau/bl: increase buffer size to avoid truncate warning
	drm/i915/pmu: Fix build error with GCOV and AutoFDO enabled
	hwmon: (occ) Rework attribute registration for stack usage
	hwmon: (occ) fix unaligned accesses
	hwmon: (ltc4282) avoid repeated register write
	pldmfw: Select CRC32 when PLDMFW is selected
	aoe: clean device rq_list in aoedev_downdev()
	io_uring/sqpoll: don't put task_struct on tctx setup failure
	net: ice: Perform accurate aRFS flow match
	ice: fix eswitch code memory leak in reset scenario
	e1000e: set fixed clock frequency indication for Nahum 11 and Nahum 13
	workqueue: Initialize wq_isolated_cpumask in workqueue_init_early()
	ksmbd: add free_transport ops in ksmbd connection
	net: netmem: fix skb_ensure_writable with unreadable skbs
	bnxt_en: Fix double invocation of bnxt_ulp_stop()/bnxt_ulp_start()
	eth: bnxt: fix out-of-range access of vnic_info array
	bnxt_en: Add a helper function to configure MRU and RSS
	bnxt_en: Update MRU and RSS table of RSS contexts on queue reset
	ptp: fix breakage after ptp_vclock_in_use() rework
	ptp: allow reading of currently dialed frequency to succeed on free-running clocks
	wifi: carl9170: do not ping device which has failed to load firmware
	mpls: Use rcu_dereference_rtnl() in mpls_route_input_rcu().
	atm: atmtcp: Free invalid length skb in atmtcp_c_send().
	tcp: fix tcp_packet_delayed() for tcp_is_non_sack_preventing_reopen() behavior
	tipc: fix null-ptr-deref when acquiring remote ip of ethernet bearer
	tcp: fix passive TFO socket having invalid NAPI ID
	eth: fbnic: avoid double free when failing to DMA-map FW msg
	net: lan743x: fix potential out-of-bounds write in lan743x_ptp_io_event_clock_get()
	ublk: santizize the arguments from userspace when adding a device
	drm/xe: Wire up device shutdown handler
	drm/xe/gt: Update handling of xe_force_wake_get return
	drm/xe/bmg: Update Wa_16023588340
	calipso: Fix null-ptr-deref in calipso_req_{set,del}attr().
	mlxbf_gige: return EPROBE_DEFER if PHY IRQ is not available
	net: atm: add lec_mutex
	net: atm: fix /proc/net/atm/lec handling
	EDAC/amd64: Correct number of UMCs for family 19h models 70h-7fh
	dt-bindings: i2c: nvidia,tegra20-i2c: Specify the required properties
	smb: Log an error when close_all_cached_dirs fails
	serial: sh-sci: Clean sci_ports[0] after at earlycon exit
	serial: sh-sci: Increment the runtime usage counter for the earlycon device
	smb: client: fix first command failure during re-negotiation
	smb: client: fix max_sge overflow in smb_extract_folioq_to_rdma()
	s390/pci: Fix __pcilg_mio_inuser() inline assembly
	perf: Fix sample vs do_exit()
	perf: Fix cgroup state vs ERROR
	perf/core: Fix WARN in perf_cgroup_switch()
	arm64/ptrace: Fix stack-out-of-bounds read in regs_get_kernel_stack_nth()
	scsi: elx: efct: Fix memory leak in efct_hw_parse_filter()
	RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls
	RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs
	gpio: pca953x: fix wrong error probe return value
	perf evsel: Missed close() when probing hybrid core PMUs
	perf test: Directory file descriptor leak
	gpio: mlxbf3: only get IRQ for device instance 0
	cifs: Remove duplicate fattr->cf_dtype assignment from wsl_to_fattr() function
	bpftool: Fix cgroup command to only show cgroup bpf programs
	Linux 6.12.35

Change-Id: Ida57d269272a624bedb979bfad0b3c5e7df7e846
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2025-07-10 16:01:38 +00:00

1261 lines
34 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Detect hard and soft lockups on a system
*
* started by Don Zickus, Copyright (C) 2010 Red Hat, Inc.
*
* Note: Most of this code is borrowed heavily from the original softlockup
* detector, so thanks to Ingo for the initial implementation.
* Some chunks also taken from the old x86-specific nmi watchdog code, thanks
* to those contributors as well.
*/
#define pr_fmt(fmt) "watchdog: " fmt
#include <linux/cpu.h>
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/irqdesc.h>
#include <linux/kernel_stat.h>
#include <linux/kvm_para.h>
#include <linux/math64.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/nmi.h>
#include <linux/stop_machine.h>
#include <linux/sysctl.h>
#include <linux/tick.h>
#include <linux/sched/clock.h>
#include <linux/sched/debug.h>
#include <linux/sched/isolation.h>
#include <asm/irq_regs.h>
#include <trace/hooks/softlockup.h>
static DEFINE_MUTEX(watchdog_mutex);
#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64)
# define WATCHDOG_HARDLOCKUP_DEFAULT 1
#else
# define WATCHDOG_HARDLOCKUP_DEFAULT 0
#endif
#define NUM_SAMPLE_PERIODS 5
unsigned long __read_mostly watchdog_enabled;
int __read_mostly watchdog_user_enabled = 1;
static int __read_mostly watchdog_hardlockup_user_enabled = WATCHDOG_HARDLOCKUP_DEFAULT;
static int __read_mostly watchdog_softlockup_user_enabled = 1;
int __read_mostly watchdog_thresh = 10;
static int __read_mostly watchdog_thresh_next;
static int __read_mostly watchdog_hardlockup_available;
struct cpumask watchdog_cpumask __read_mostly;
unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
#ifdef CONFIG_HARDLOCKUP_DETECTOR
# ifdef CONFIG_SMP
int __read_mostly sysctl_hardlockup_all_cpu_backtrace;
# endif /* CONFIG_SMP */
/*
* Should we panic when a soft-lockup or hard-lockup occurs:
*/
unsigned int __read_mostly hardlockup_panic =
IS_ENABLED(CONFIG_BOOTPARAM_HARDLOCKUP_PANIC);
/*
* We may not want to enable hard lockup detection by default in all cases,
* for example when running the kernel as a guest on a hypervisor. In these
* cases this function can be called to disable hard lockup detection. This
* function should only be executed once by the boot processor before the
* kernel command line parameters are parsed, because otherwise it is not
* possible to override this in hardlockup_panic_setup().
*/
void __init hardlockup_detector_disable(void)
{
watchdog_hardlockup_user_enabled = 0;
}
static int __init hardlockup_panic_setup(char *str)
{
next:
if (!strncmp(str, "panic", 5))
hardlockup_panic = 1;
else if (!strncmp(str, "nopanic", 7))
hardlockup_panic = 0;
else if (!strncmp(str, "0", 1))
watchdog_hardlockup_user_enabled = 0;
else if (!strncmp(str, "1", 1))
watchdog_hardlockup_user_enabled = 1;
else if (!strncmp(str, "r", 1))
hardlockup_config_perf_event(str + 1);
while (*(str++)) {
if (*str == ',') {
str++;
goto next;
}
}
return 1;
}
__setup("nmi_watchdog=", hardlockup_panic_setup);
#endif /* CONFIG_HARDLOCKUP_DETECTOR */
#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER)
static DEFINE_PER_CPU(atomic_t, hrtimer_interrupts);
static DEFINE_PER_CPU(int, hrtimer_interrupts_saved);
static DEFINE_PER_CPU(bool, watchdog_hardlockup_warned);
static DEFINE_PER_CPU(bool, watchdog_hardlockup_touched);
static unsigned long hard_lockup_nmi_warn;
notrace void arch_touch_nmi_watchdog(void)
{
/*
* Using __raw here because some code paths have
* preemption enabled. If preemption is enabled
* then interrupts should be enabled too, in which
* case we shouldn't have to worry about the watchdog
* going off.
*/
raw_cpu_write(watchdog_hardlockup_touched, true);
}
EXPORT_SYMBOL(arch_touch_nmi_watchdog);
void watchdog_hardlockup_touch_cpu(unsigned int cpu)
{
per_cpu(watchdog_hardlockup_touched, cpu) = true;
}
static bool is_hardlockup(unsigned int cpu)
{
int hrint = atomic_read(&per_cpu(hrtimer_interrupts, cpu));
if (per_cpu(hrtimer_interrupts_saved, cpu) == hrint)
return true;
/*
* NOTE: we don't need any fancy atomic_t or READ_ONCE/WRITE_ONCE
* for hrtimer_interrupts_saved. hrtimer_interrupts_saved is
* written/read by a single CPU.
*/
per_cpu(hrtimer_interrupts_saved, cpu) = hrint;
return false;
}
static void watchdog_hardlockup_kick(void)
{
int new_interrupts;
new_interrupts = atomic_inc_return(this_cpu_ptr(&hrtimer_interrupts));
watchdog_buddy_check_hardlockup(new_interrupts);
}
void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
{
if (per_cpu(watchdog_hardlockup_touched, cpu)) {
per_cpu(watchdog_hardlockup_touched, cpu) = false;
return;
}
/*
* Check for a hardlockup by making sure the CPU's timer
* interrupt is incrementing. The timer interrupt should have
* fired multiple times before we overflow'd. If it hasn't
* then this is a good indication the cpu is stuck
*/
if (is_hardlockup(cpu)) {
unsigned int this_cpu = smp_processor_id();
unsigned long flags;
/* Only print hardlockups once. */
if (per_cpu(watchdog_hardlockup_warned, cpu))
return;
/*
* Prevent multiple hard-lockup reports if one cpu is already
* engaged in dumping all cpu back traces.
*/
if (sysctl_hardlockup_all_cpu_backtrace) {
if (test_and_set_bit_lock(0, &hard_lockup_nmi_warn))
return;
}
/*
* NOTE: we call printk_cpu_sync_get_irqsave() after printing
* the lockup message. While it would be nice to serialize
* that printout, we really want to make sure that if some
* other CPU somehow locked up while holding the lock associated
* with printk_cpu_sync_get_irqsave() that we can still at least
* get the message about the lockup out.
*/
pr_emerg("Watchdog detected hard LOCKUP on cpu %d\n", cpu);
printk_cpu_sync_get_irqsave(flags);
print_modules();
print_irqtrace_events(current);
if (cpu == this_cpu) {
if (regs)
show_regs(regs);
else
dump_stack();
printk_cpu_sync_put_irqrestore(flags);
} else {
printk_cpu_sync_put_irqrestore(flags);
trigger_single_cpu_backtrace(cpu);
}
if (sysctl_hardlockup_all_cpu_backtrace) {
trigger_allbutcpu_cpu_backtrace(cpu);
if (!hardlockup_panic)
clear_bit_unlock(0, &hard_lockup_nmi_warn);
}
if (hardlockup_panic)
nmi_panic(regs, "Hard LOCKUP");
per_cpu(watchdog_hardlockup_warned, cpu) = true;
} else {
per_cpu(watchdog_hardlockup_warned, cpu) = false;
}
}
#else /* CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER */
static inline void watchdog_hardlockup_kick(void) { }
#endif /* !CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER */
/*
* These functions can be overridden based on the configured hardlockdup detector.
*
* watchdog_hardlockup_enable/disable can be implemented to start and stop when
* softlockup watchdog start and stop. The detector must select the
* SOFTLOCKUP_DETECTOR Kconfig.
*/
void __weak watchdog_hardlockup_enable(unsigned int cpu) { }
void __weak watchdog_hardlockup_disable(unsigned int cpu) { }
/*
* Watchdog-detector specific API.
*
* Return 0 when hardlockup watchdog is available, negative value otherwise.
* Note that the negative value means that a delayed probe might
* succeed later.
*/
int __weak __init watchdog_hardlockup_probe(void)
{
return -ENODEV;
}
/**
* watchdog_hardlockup_stop - Stop the watchdog for reconfiguration
*
* The reconfiguration steps are:
* watchdog_hardlockup_stop();
* update_variables();
* watchdog_hardlockup_start();
*/
void __weak watchdog_hardlockup_stop(void) { }
/**
* watchdog_hardlockup_start - Start the watchdog after reconfiguration
*
* Counterpart to watchdog_hardlockup_stop().
*
* The following variables have been updated in update_variables() and
* contain the currently valid configuration:
* - watchdog_enabled
* - watchdog_thresh
* - watchdog_cpumask
*/
void __weak watchdog_hardlockup_start(void) { }
/**
* lockup_detector_update_enable - Update the sysctl enable bit
*
* Caller needs to make sure that the hard watchdogs are off, so this
* can't race with watchdog_hardlockup_disable().
*/
static void lockup_detector_update_enable(void)
{
watchdog_enabled = 0;
if (!watchdog_user_enabled)
return;
if (watchdog_hardlockup_available && watchdog_hardlockup_user_enabled)
watchdog_enabled |= WATCHDOG_HARDLOCKUP_ENABLED;
if (watchdog_softlockup_user_enabled)
watchdog_enabled |= WATCHDOG_SOFTOCKUP_ENABLED;
}
#ifdef CONFIG_SOFTLOCKUP_DETECTOR
/*
* Delay the soflockup report when running a known slow code.
* It does _not_ affect the timestamp of the last successdul reschedule.
*/
#define SOFTLOCKUP_DELAY_REPORT ULONG_MAX
#ifdef CONFIG_SMP
int __read_mostly sysctl_softlockup_all_cpu_backtrace;
#endif
static struct cpumask watchdog_allowed_mask __read_mostly;
/* Global variables, exported for sysctl */
unsigned int __read_mostly softlockup_panic =
IS_ENABLED(CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC);
static bool softlockup_initialized __read_mostly;
static u64 __read_mostly sample_period;
/* Timestamp taken after the last successful reschedule. */
static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts);
/* Timestamp of the last softlockup report. */
static DEFINE_PER_CPU(unsigned long, watchdog_report_ts);
static DEFINE_PER_CPU(struct hrtimer, watchdog_hrtimer);
static DEFINE_PER_CPU(bool, softlockup_touch_sync);
static unsigned long soft_lockup_nmi_warn;
static int __init softlockup_panic_setup(char *str)
{
softlockup_panic = simple_strtoul(str, NULL, 0);
return 1;
}
__setup("softlockup_panic=", softlockup_panic_setup);
static int __init nowatchdog_setup(char *str)
{
watchdog_user_enabled = 0;
return 1;
}
__setup("nowatchdog", nowatchdog_setup);
static int __init nosoftlockup_setup(char *str)
{
watchdog_softlockup_user_enabled = 0;
return 1;
}
__setup("nosoftlockup", nosoftlockup_setup);
static int __init watchdog_thresh_setup(char *str)
{
get_option(&str, &watchdog_thresh);
return 1;
}
__setup("watchdog_thresh=", watchdog_thresh_setup);
#ifdef CONFIG_SOFTLOCKUP_DETECTOR_INTR_STORM
enum stats_per_group {
STATS_SYSTEM,
STATS_SOFTIRQ,
STATS_HARDIRQ,
STATS_IDLE,
NUM_STATS_PER_GROUP,
};
static const enum cpu_usage_stat tracked_stats[NUM_STATS_PER_GROUP] = {
CPUTIME_SYSTEM,
CPUTIME_SOFTIRQ,
CPUTIME_IRQ,
CPUTIME_IDLE,
};
static DEFINE_PER_CPU(u16, cpustat_old[NUM_STATS_PER_GROUP]);
static DEFINE_PER_CPU(u8, cpustat_util[NUM_SAMPLE_PERIODS][NUM_STATS_PER_GROUP]);
static DEFINE_PER_CPU(u8, cpustat_tail);
/*
* We don't need nanosecond resolution. A granularity of 16ms is
* sufficient for our precision, allowing us to use u16 to store
* cpustats, which will roll over roughly every ~1000 seconds.
* 2^24 ~= 16 * 10^6
*/
static u16 get_16bit_precision(u64 data_ns)
{
return data_ns >> 24LL; /* 2^24ns ~= 16.8ms */
}
static void update_cpustat(void)
{
int i;
u8 util;
u16 old_stat, new_stat;
struct kernel_cpustat kcpustat;
u64 *cpustat = kcpustat.cpustat;
u8 tail = __this_cpu_read(cpustat_tail);
u16 sample_period_16 = get_16bit_precision(sample_period);
kcpustat_cpu_fetch(&kcpustat, smp_processor_id());
for (i = 0; i < NUM_STATS_PER_GROUP; i++) {
old_stat = __this_cpu_read(cpustat_old[i]);
new_stat = get_16bit_precision(cpustat[tracked_stats[i]]);
util = DIV_ROUND_UP(100 * (new_stat - old_stat), sample_period_16);
__this_cpu_write(cpustat_util[tail][i], util);
__this_cpu_write(cpustat_old[i], new_stat);
}
__this_cpu_write(cpustat_tail, (tail + 1) % NUM_SAMPLE_PERIODS);
}
static void print_cpustat(void)
{
int i, group;
u8 tail = __this_cpu_read(cpustat_tail);
u64 sample_period_second = sample_period;
do_div(sample_period_second, NSEC_PER_SEC);
/*
* Outputting the "watchdog" prefix on every line is redundant and not
* concise, and the original alarm information is sufficient for
* positioning in logs, hence here printk() is used instead of pr_crit().
*/
printk(KERN_CRIT "CPU#%d Utilization every %llus during lockup:\n",
smp_processor_id(), sample_period_second);
for (i = 0; i < NUM_SAMPLE_PERIODS; i++) {
group = (tail + i) % NUM_SAMPLE_PERIODS;
printk(KERN_CRIT "\t#%d: %3u%% system,\t%3u%% softirq,\t"
"%3u%% hardirq,\t%3u%% idle\n", i + 1,
__this_cpu_read(cpustat_util[group][STATS_SYSTEM]),
__this_cpu_read(cpustat_util[group][STATS_SOFTIRQ]),
__this_cpu_read(cpustat_util[group][STATS_HARDIRQ]),
__this_cpu_read(cpustat_util[group][STATS_IDLE]));
}
}
#define HARDIRQ_PERCENT_THRESH 50
#define NUM_HARDIRQ_REPORT 5
struct irq_counts {
int irq;
u32 counts;
};
static DEFINE_PER_CPU(bool, snapshot_taken);
/* Tabulate the most frequent interrupts. */
static void tabulate_irq_count(struct irq_counts *irq_counts, int irq, u32 counts, int rank)
{
int i;
struct irq_counts new_count = {irq, counts};
for (i = 0; i < rank; i++) {
if (counts > irq_counts[i].counts)
swap(new_count, irq_counts[i]);
}
}
/*
* If the hardirq time exceeds HARDIRQ_PERCENT_THRESH% of the sample_period,
* then the cause of softlockup might be interrupt storm. In this case, it
* would be useful to start interrupt counting.
*/
static bool need_counting_irqs(void)
{
u8 util;
int tail = __this_cpu_read(cpustat_tail);
tail = (tail + NUM_HARDIRQ_REPORT - 1) % NUM_HARDIRQ_REPORT;
util = __this_cpu_read(cpustat_util[tail][STATS_HARDIRQ]);
return util > HARDIRQ_PERCENT_THRESH;
}
static void start_counting_irqs(void)
{
if (!__this_cpu_read(snapshot_taken)) {
kstat_snapshot_irqs();
__this_cpu_write(snapshot_taken, true);
}
}
static void stop_counting_irqs(void)
{
__this_cpu_write(snapshot_taken, false);
}
static void print_irq_counts(void)
{
unsigned int i, count;
struct irq_counts irq_counts_sorted[NUM_HARDIRQ_REPORT] = {
{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}
};
if (__this_cpu_read(snapshot_taken)) {
for_each_active_irq(i) {
count = kstat_get_irq_since_snapshot(i);
tabulate_irq_count(irq_counts_sorted, i, count, NUM_HARDIRQ_REPORT);
}
/*
* Outputting the "watchdog" prefix on every line is redundant and not
* concise, and the original alarm information is sufficient for
* positioning in logs, hence here printk() is used instead of pr_crit().
*/
printk(KERN_CRIT "CPU#%d Detect HardIRQ Time exceeds %d%%. Most frequent HardIRQs:\n",
smp_processor_id(), HARDIRQ_PERCENT_THRESH);
for (i = 0; i < NUM_HARDIRQ_REPORT; i++) {
if (irq_counts_sorted[i].irq == -1)
break;
printk(KERN_CRIT "\t#%u: %-10u\tirq#%d\n",
i + 1, irq_counts_sorted[i].counts,
irq_counts_sorted[i].irq);
}
/*
* If the hardirq time is less than HARDIRQ_PERCENT_THRESH% in the last
* sample_period, then we suspect the interrupt storm might be subsiding.
*/
if (!need_counting_irqs())
stop_counting_irqs();
}
}
static void report_cpu_status(void)
{
print_cpustat();
print_irq_counts();
}
#else
static inline void update_cpustat(void) { }
static inline void report_cpu_status(void) { }
static inline bool need_counting_irqs(void) { return false; }
static inline void start_counting_irqs(void) { }
static inline void stop_counting_irqs(void) { }
#endif
/*
* Hard-lockup warnings should be triggered after just a few seconds. Soft-
* lockups can have false positives under extreme conditions. So we generally
* want a higher threshold for soft lockups than for hard lockups. So we couple
* the thresholds with a factor: we make the soft threshold twice the amount of
* time the hard threshold is.
*/
static int get_softlockup_thresh(void)
{
return watchdog_thresh * 2;
}
/*
* Returns seconds, approximately. We don't need nanosecond
* resolution, and we don't need to waste time with a big divide when
* 2^30ns == 1.074s.
*/
static unsigned long get_timestamp(void)
{
return running_clock() >> 30LL; /* 2^30 ~= 10^9 */
}
static void set_sample_period(void)
{
/*
* convert watchdog_thresh from seconds to ns
* the divide by 5 is to give hrtimer several chances (two
* or three with the current relation between the soft
* and hard thresholds) to increment before the
* hardlockup detector generates a warning
*/
sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / NUM_SAMPLE_PERIODS);
watchdog_update_hrtimer_threshold(sample_period);
}
static void update_report_ts(void)
{
__this_cpu_write(watchdog_report_ts, get_timestamp());
}
/* Commands for resetting the watchdog */
static void update_touch_ts(void)
{
__this_cpu_write(watchdog_touch_ts, get_timestamp());
update_report_ts();
}
/**
* touch_softlockup_watchdog_sched - touch watchdog on scheduler stalls
*
* Call when the scheduler may have stalled for legitimate reasons
* preventing the watchdog task from executing - e.g. the scheduler
* entering idle state. This should only be used for scheduler events.
* Use touch_softlockup_watchdog() for everything else.
*/
notrace void touch_softlockup_watchdog_sched(void)
{
/*
* Preemption can be enabled. It doesn't matter which CPU's watchdog
* report period gets restarted here, so use the raw_ operation.
*/
raw_cpu_write(watchdog_report_ts, SOFTLOCKUP_DELAY_REPORT);
}
notrace void touch_softlockup_watchdog(void)
{
touch_softlockup_watchdog_sched();
wq_watchdog_touch(raw_smp_processor_id());
}
EXPORT_SYMBOL(touch_softlockup_watchdog);
void touch_all_softlockup_watchdogs(void)
{
int cpu;
/*
* watchdog_mutex cannpt be taken here, as this might be called
* from (soft)interrupt context, so the access to
* watchdog_allowed_cpumask might race with a concurrent update.
*
* The watchdog time stamp can race against a concurrent real
* update as well, the only side effect might be a cycle delay for
* the softlockup check.
*/
for_each_cpu(cpu, &watchdog_allowed_mask) {
per_cpu(watchdog_report_ts, cpu) = SOFTLOCKUP_DELAY_REPORT;
wq_watchdog_touch(cpu);
}
}
void touch_softlockup_watchdog_sync(void)
{
__this_cpu_write(softlockup_touch_sync, true);
__this_cpu_write(watchdog_report_ts, SOFTLOCKUP_DELAY_REPORT);
}
static int is_softlockup(unsigned long touch_ts,
unsigned long period_ts,
unsigned long now)
{
if ((watchdog_enabled & WATCHDOG_SOFTOCKUP_ENABLED) && watchdog_thresh) {
/*
* If period_ts has not been updated during a sample_period, then
* in the subsequent few sample_periods, period_ts might also not
* be updated, which could indicate a potential softlockup. In
* this case, if we suspect the cause of the potential softlockup
* might be interrupt storm, then we need to count the interrupts
* to find which interrupt is storming.
*/
if (time_after_eq(now, period_ts + get_softlockup_thresh() / NUM_SAMPLE_PERIODS) &&
need_counting_irqs())
start_counting_irqs();
/* Warn about unreasonable delays. */
if (time_after(now, period_ts + get_softlockup_thresh()))
return now - touch_ts;
}
return 0;
}
/* watchdog detector functions */
static DEFINE_PER_CPU(struct completion, softlockup_completion);
static DEFINE_PER_CPU(struct cpu_stop_work, softlockup_stop_work);
/*
* The watchdog feed function - touches the timestamp.
*
* It only runs once every sample_period seconds (4 seconds by
* default) to reset the softlockup timestamp. If this gets delayed
* for more than 2*watchdog_thresh seconds then the debug-printout
* triggers in watchdog_timer_fn().
*/
static int softlockup_fn(void *data)
{
update_touch_ts();
stop_counting_irqs();
complete(this_cpu_ptr(&softlockup_completion));
return 0;
}
/* watchdog kicker functions */
static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
{
unsigned long touch_ts, period_ts, now;
struct pt_regs *regs = get_irq_regs();
int duration;
int softlockup_all_cpu_backtrace = sysctl_softlockup_all_cpu_backtrace;
unsigned long flags;
if (!watchdog_enabled)
return HRTIMER_NORESTART;
watchdog_hardlockup_kick();
/* kick the softlockup detector */
if (completion_done(this_cpu_ptr(&softlockup_completion))) {
reinit_completion(this_cpu_ptr(&softlockup_completion));
stop_one_cpu_nowait(smp_processor_id(),
softlockup_fn, NULL,
this_cpu_ptr(&softlockup_stop_work));
}
/* .. and repeat */
hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period));
/*
* Read the current timestamp first. It might become invalid anytime
* when a virtual machine is stopped by the host or when the watchog
* is touched from NMI.
*/
now = get_timestamp();
/*
* If a virtual machine is stopped by the host it can look to
* the watchdog like a soft lockup. This function touches the watchdog.
*/
kvm_check_and_clear_guest_paused();
/*
* The stored timestamp is comparable with @now only when not touched.
* It might get touched anytime from NMI. Make sure that is_softlockup()
* uses the same (valid) value.
*/
period_ts = READ_ONCE(*this_cpu_ptr(&watchdog_report_ts));
update_cpustat();
/* Reset the interval when touched by known problematic code. */
if (period_ts == SOFTLOCKUP_DELAY_REPORT) {
if (unlikely(__this_cpu_read(softlockup_touch_sync))) {
/*
* If the time stamp was touched atomically
* make sure the scheduler tick is up to date.
*/
__this_cpu_write(softlockup_touch_sync, false);
sched_clock_tick();
}
update_report_ts();
return HRTIMER_RESTART;
}
/* Check for a softlockup. */
touch_ts = __this_cpu_read(watchdog_touch_ts);
duration = is_softlockup(touch_ts, period_ts, now);
if (unlikely(duration)) {
/*
* Prevent multiple soft-lockup reports if one cpu is already
* engaged in dumping all cpu back traces.
*/
if (softlockup_all_cpu_backtrace) {
if (test_and_set_bit_lock(0, &soft_lockup_nmi_warn))
return HRTIMER_RESTART;
}
/* Start period for the next softlockup warning. */
update_report_ts();
printk_cpu_sync_get_irqsave(flags);
pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
smp_processor_id(), duration,
current->comm, task_pid_nr(current));
report_cpu_status();
print_modules();
print_irqtrace_events(current);
if (regs)
show_regs(regs);
else
dump_stack();
printk_cpu_sync_put_irqrestore(flags);
if (softlockup_all_cpu_backtrace) {
trigger_allbutcpu_cpu_backtrace(smp_processor_id());
if (!softlockup_panic)
clear_bit_unlock(0, &soft_lockup_nmi_warn);
}
trace_android_vh_watchdog_timer_softlockup(duration, regs, !!softlockup_panic);
add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
if (softlockup_panic)
panic("softlockup: hung tasks");
}
return HRTIMER_RESTART;
}
static void watchdog_enable(unsigned int cpu)
{
struct hrtimer *hrtimer = this_cpu_ptr(&watchdog_hrtimer);
struct completion *done = this_cpu_ptr(&softlockup_completion);
WARN_ON_ONCE(cpu != smp_processor_id());
init_completion(done);
complete(done);
/*
* Start the timer first to prevent the hardlockup watchdog triggering
* before the timer has a chance to fire.
*/
hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
hrtimer->function = watchdog_timer_fn;
hrtimer_start(hrtimer, ns_to_ktime(sample_period),
HRTIMER_MODE_REL_PINNED_HARD);
/* Initialize timestamp */
update_touch_ts();
/* Enable the hardlockup detector */
if (watchdog_enabled & WATCHDOG_HARDLOCKUP_ENABLED)
watchdog_hardlockup_enable(cpu);
}
static void watchdog_disable(unsigned int cpu)
{
struct hrtimer *hrtimer = this_cpu_ptr(&watchdog_hrtimer);
WARN_ON_ONCE(cpu != smp_processor_id());
/*
* Disable the hardlockup detector first. That prevents that a large
* delay between disabling the timer and disabling the hardlockup
* detector causes a false positive.
*/
watchdog_hardlockup_disable(cpu);
hrtimer_cancel(hrtimer);
wait_for_completion(this_cpu_ptr(&softlockup_completion));
}
static int softlockup_stop_fn(void *data)
{
watchdog_disable(smp_processor_id());
return 0;
}
static void softlockup_stop_all(void)
{
int cpu;
if (!softlockup_initialized)
return;
for_each_cpu(cpu, &watchdog_allowed_mask)
smp_call_on_cpu(cpu, softlockup_stop_fn, NULL, false);
cpumask_clear(&watchdog_allowed_mask);
}
static int softlockup_start_fn(void *data)
{
watchdog_enable(smp_processor_id());
return 0;
}
static void softlockup_start_all(void)
{
int cpu;
cpumask_copy(&watchdog_allowed_mask, &watchdog_cpumask);
for_each_cpu(cpu, &watchdog_allowed_mask)
smp_call_on_cpu(cpu, softlockup_start_fn, NULL, false);
}
int lockup_detector_online_cpu(unsigned int cpu)
{
if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
watchdog_enable(cpu);
return 0;
}
int lockup_detector_offline_cpu(unsigned int cpu)
{
if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
watchdog_disable(cpu);
return 0;
}
static void __lockup_detector_reconfigure(bool thresh_changed)
{
cpus_read_lock();
watchdog_hardlockup_stop();
softlockup_stop_all();
/*
* To prevent watchdog_timer_fn from using the old interval and
* the new watchdog_thresh at the same time, which could lead to
* false softlockup reports, it is necessary to update the
* watchdog_thresh after the softlockup is completed.
*/
if (thresh_changed)
watchdog_thresh = READ_ONCE(watchdog_thresh_next);
set_sample_period();
lockup_detector_update_enable();
if (watchdog_enabled && watchdog_thresh)
softlockup_start_all();
watchdog_hardlockup_start();
cpus_read_unlock();
}
void lockup_detector_reconfigure(void)
{
mutex_lock(&watchdog_mutex);
__lockup_detector_reconfigure(false);
mutex_unlock(&watchdog_mutex);
}
/*
* Create the watchdog infrastructure and configure the detector(s).
*/
static __init void lockup_detector_setup(void)
{
/*
* If sysctl is off and watchdog got disabled on the command line,
* nothing to do here.
*/
lockup_detector_update_enable();
if (!IS_ENABLED(CONFIG_SYSCTL) &&
!(watchdog_enabled && watchdog_thresh))
return;
mutex_lock(&watchdog_mutex);
__lockup_detector_reconfigure(false);
softlockup_initialized = true;
mutex_unlock(&watchdog_mutex);
}
#else /* CONFIG_SOFTLOCKUP_DETECTOR */
static void __lockup_detector_reconfigure(bool thresh_changed)
{
cpus_read_lock();
watchdog_hardlockup_stop();
if (thresh_changed)
watchdog_thresh = READ_ONCE(watchdog_thresh_next);
lockup_detector_update_enable();
watchdog_hardlockup_start();
cpus_read_unlock();
}
void lockup_detector_reconfigure(void)
{
__lockup_detector_reconfigure(false);
}
static inline void lockup_detector_setup(void)
{
__lockup_detector_reconfigure(false);
}
#endif /* !CONFIG_SOFTLOCKUP_DETECTOR */
/**
* lockup_detector_soft_poweroff - Interface to stop lockup detector(s)
*
* Special interface for parisc. It prevents lockup detector warnings from
* the default pm_poweroff() function which busy loops forever.
*/
void lockup_detector_soft_poweroff(void)
{
watchdog_enabled = 0;
}
#ifdef CONFIG_SYSCTL
/* Propagate any changes to the watchdog infrastructure */
static void proc_watchdog_update(bool thresh_changed)
{
/* Remove impossible cpus to keep sysctl output clean. */
cpumask_and(&watchdog_cpumask, &watchdog_cpumask, cpu_possible_mask);
__lockup_detector_reconfigure(thresh_changed);
}
/*
* common function for watchdog, nmi_watchdog and soft_watchdog parameter
*
* caller | table->data points to | 'which'
* -------------------|----------------------------------|-------------------------------
* proc_watchdog | watchdog_user_enabled | WATCHDOG_HARDLOCKUP_ENABLED |
* | | WATCHDOG_SOFTOCKUP_ENABLED
* -------------------|----------------------------------|-------------------------------
* proc_nmi_watchdog | watchdog_hardlockup_user_enabled | WATCHDOG_HARDLOCKUP_ENABLED
* -------------------|----------------------------------|-------------------------------
* proc_soft_watchdog | watchdog_softlockup_user_enabled | WATCHDOG_SOFTOCKUP_ENABLED
*/
static int proc_watchdog_common(int which, const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int err, old, *param = table->data;
mutex_lock(&watchdog_mutex);
if (!write) {
/*
* On read synchronize the userspace interface. This is a
* racy snapshot.
*/
*param = (watchdog_enabled & which) != 0;
err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
} else {
old = READ_ONCE(*param);
err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (!err && old != READ_ONCE(*param))
proc_watchdog_update(false);
}
mutex_unlock(&watchdog_mutex);
return err;
}
/*
* /proc/sys/kernel/watchdog
*/
static int proc_watchdog(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
return proc_watchdog_common(WATCHDOG_HARDLOCKUP_ENABLED |
WATCHDOG_SOFTOCKUP_ENABLED,
table, write, buffer, lenp, ppos);
}
/*
* /proc/sys/kernel/nmi_watchdog
*/
static int proc_nmi_watchdog(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
if (!watchdog_hardlockup_available && write)
return -ENOTSUPP;
return proc_watchdog_common(WATCHDOG_HARDLOCKUP_ENABLED,
table, write, buffer, lenp, ppos);
}
#ifdef CONFIG_SOFTLOCKUP_DETECTOR
/*
* /proc/sys/kernel/soft_watchdog
*/
static int proc_soft_watchdog(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
return proc_watchdog_common(WATCHDOG_SOFTOCKUP_ENABLED,
table, write, buffer, lenp, ppos);
}
#endif
/*
* /proc/sys/kernel/watchdog_thresh
*/
static int proc_watchdog_thresh(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int err, old;
mutex_lock(&watchdog_mutex);
watchdog_thresh_next = READ_ONCE(watchdog_thresh);
old = watchdog_thresh_next;
err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
if (!err && write && old != READ_ONCE(watchdog_thresh_next))
proc_watchdog_update(true);
mutex_unlock(&watchdog_mutex);
return err;
}
/*
* The cpumask is the mask of possible cpus that the watchdog can run
* on, not the mask of cpus it is actually running on. This allows the
* user to specify a mask that will include cpus that have not yet
* been brought online, if desired.
*/
static int proc_watchdog_cpumask(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int err;
mutex_lock(&watchdog_mutex);
err = proc_do_large_bitmap(table, write, buffer, lenp, ppos);
if (!err && write)
proc_watchdog_update(false);
mutex_unlock(&watchdog_mutex);
return err;
}
static const int sixty = 60;
static struct ctl_table watchdog_sysctls[] = {
{
.procname = "watchdog",
.data = &watchdog_user_enabled,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_watchdog,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
{
.procname = "watchdog_thresh",
.data = &watchdog_thresh_next,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_watchdog_thresh,
.extra1 = SYSCTL_ZERO,
.extra2 = (void *)&sixty,
},
{
.procname = "watchdog_cpumask",
.data = &watchdog_cpumask_bits,
.maxlen = NR_CPUS,
.mode = 0644,
.proc_handler = proc_watchdog_cpumask,
},
#ifdef CONFIG_SOFTLOCKUP_DETECTOR
{
.procname = "soft_watchdog",
.data = &watchdog_softlockup_user_enabled,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_soft_watchdog,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
{
.procname = "softlockup_panic",
.data = &softlockup_panic,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
#ifdef CONFIG_SMP
{
.procname = "softlockup_all_cpu_backtrace",
.data = &sysctl_softlockup_all_cpu_backtrace,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
#endif /* CONFIG_SMP */
#endif
#ifdef CONFIG_HARDLOCKUP_DETECTOR
{
.procname = "hardlockup_panic",
.data = &hardlockup_panic,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
#ifdef CONFIG_SMP
{
.procname = "hardlockup_all_cpu_backtrace",
.data = &sysctl_hardlockup_all_cpu_backtrace,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
#endif /* CONFIG_SMP */
#endif
};
static struct ctl_table watchdog_hardlockup_sysctl[] = {
{
.procname = "nmi_watchdog",
.data = &watchdog_hardlockup_user_enabled,
.maxlen = sizeof(int),
.mode = 0444,
.proc_handler = proc_nmi_watchdog,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
};
static void __init watchdog_sysctl_init(void)
{
register_sysctl_init("kernel", watchdog_sysctls);
if (watchdog_hardlockup_available)
watchdog_hardlockup_sysctl[0].mode = 0644;
register_sysctl_init("kernel", watchdog_hardlockup_sysctl);
}
#else
#define watchdog_sysctl_init() do { } while (0)
#endif /* CONFIG_SYSCTL */
static void __init lockup_detector_delay_init(struct work_struct *work);
static bool allow_lockup_detector_init_retry __initdata;
static struct work_struct detector_work __initdata =
__WORK_INITIALIZER(detector_work, lockup_detector_delay_init);
static void __init lockup_detector_delay_init(struct work_struct *work)
{
int ret;
ret = watchdog_hardlockup_probe();
if (ret) {
if (ret == -ENODEV)
pr_info("NMI not fully supported\n");
else
pr_info("Delayed init of the lockup detector failed: %d\n", ret);
pr_info("Hard watchdog permanently disabled\n");
return;
}
allow_lockup_detector_init_retry = false;
watchdog_hardlockup_available = true;
lockup_detector_setup();
}
/*
* lockup_detector_retry_init - retry init lockup detector if possible.
*
* Retry hardlockup detector init. It is useful when it requires some
* functionality that has to be initialized later on a particular
* platform.
*/
void __init lockup_detector_retry_init(void)
{
/* Must be called before late init calls */
if (!allow_lockup_detector_init_retry)
return;
schedule_work(&detector_work);
}
/*
* Ensure that optional delayed hardlockup init is proceed before
* the init code and memory is freed.
*/
static int __init lockup_detector_check(void)
{
/* Prevent any later retry. */
allow_lockup_detector_init_retry = false;
/* Make sure no work is pending. */
flush_work(&detector_work);
watchdog_sysctl_init();
return 0;
}
late_initcall_sync(lockup_detector_check);
void __init lockup_detector_init(void)
{
if (tick_nohz_full_enabled())
pr_info("Disabling watchdog on nohz_full cores by default\n");
cpumask_copy(&watchdog_cpumask,
housekeeping_cpumask(HK_TYPE_TIMER));
if (!watchdog_hardlockup_probe())
watchdog_hardlockup_available = true;
else
allow_lockup_detector_init_retry = true;
lockup_detector_setup();
}