
Changes in 5.10.65 locking/mutex: Fix HANDOFF condition regmap: fix the offset of register error log regulator: tps65910: Silence deferred probe error crypto: mxs-dcp - Check for DMA mapping errors sched/deadline: Fix reset_on_fork reporting of DL tasks power: supply: axp288_fuel_gauge: Report register-address on readb / writeb errors crypto: omap-sham - clear dma flags only after omap_sham_update_dma_stop() sched/deadline: Fix missing clock update in migrate_task_rq_dl() rcu/tree: Handle VM stoppage in stall detection EDAC/mce_amd: Do not load edac_mce_amd module on guests posix-cpu-timers: Force next expiration recalc after itimer reset hrtimer: Avoid double reprogramming in __hrtimer_start_range_ns() hrtimer: Ensure timerfd notification for HIGHRES=n udf: Check LVID earlier udf: Fix iocharset=utf8 mount option isofs: joliet: Fix iocharset=utf8 mount option bcache: add proper error unwinding in bcache_device_init blk-throtl: optimize IOPS throttle for large IO scenarios nvme-tcp: don't update queue count when failing to set io queues nvme-rdma: don't update queue count when failing to set io queues nvmet: pass back cntlid on successful completion power: supply: smb347-charger: Add missing pin control activation power: supply: max17042_battery: fix typo in MAx17042_TOFF s390/cio: add dev_busid sysfs entry for each subchannel s390/zcrypt: fix wrong offset index for APKA master key valid state libata: fix ata_host_start() crypto: omap - Fix inconsistent locking of device lists crypto: qat - do not ignore errors from enable_vf2pf_comms() crypto: qat - handle both source of interrupt in VF ISR crypto: qat - fix reuse of completion variable crypto: qat - fix naming for init/shutdown VF to PF notifications crypto: qat - do not export adf_iov_putmsg() fcntl: fix potential deadlock for &fasync_struct.fa_lock udf_get_extendedattr() had no boundary checks. s390/kasan: fix large PMD pages address alignment check s390/pci: fix misleading rc in clp_set_pci_fn() s390/debug: keep debug data on resize s390/debug: fix debug area life cycle s390/ap: fix state machine hang after failure to enable irq power: supply: cw2015: use dev_err_probe to allow deferred probe m68k: emu: Fix invalid free in nfeth_cleanup() sched/numa: Fix is_core_idle() sched: Fix UCLAMP_FLAG_IDLE setting rcu: Fix to include first blocked task in stall warning rcu: Add lockdep_assert_irqs_disabled() to rcu_sched_clock_irq() and callees rcu: Fix stall-warning deadlock due to non-release of rcu_node ->lock m68k: Fix invalid RMW_INSNS on CPUs that lack CAS block: return ELEVATOR_DISCARD_MERGE if possible spi: spi-fsl-dspi: Fix issue with uninitialized dma_slave_config spi: spi-pic32: Fix issue with uninitialized dma_slave_config genirq/timings: Fix error return code in irq_timings_test_irqs() irqchip/loongson-pch-pic: Improve edge triggered interrupt support lib/mpi: use kcalloc in mpi_resize clocksource/drivers/sh_cmt: Fix wrong setting if don't request IRQ for clock source channel block: nbd: add sanity check for first_minor spi: coldfire-qspi: Use clk_disable_unprepare in the remove function irqchip/gic-v3: Fix priority comparison when non-secure priorities are used crypto: qat - use proper type for vf_mask certs: Trigger creation of RSA module signing key if it's not an RSA key tpm: ibmvtpm: Avoid error message when process gets signal while waiting x86/mce: Defer processing of early errors spi: davinci: invoke chipselect callback blk-crypto: fix check for too-large dun_bytes regulator: vctrl: Use locked regulator_get_voltage in probe path regulator: vctrl: Avoid lockdep warning in enable/disable ops spi: sprd: Fix the wrong WDG_LOAD_VAL spi: spi-zynq-qspi: use wait_for_completion_timeout to make zynq_qspi_exec_mem_op not interruptible EDAC/i10nm: Fix NVDIMM detection drm/panfrost: Fix missing clk_disable_unprepare() on error in panfrost_clk_init() drm/gma500: Fix end of loop tests for list_for_each_entry ASoC: mediatek: mt8183: Fix Unbalanced pm_runtime_enable in mt8183_afe_pcm_dev_probe media: TDA1997x: enable EDID support leds: is31fl32xx: Fix missing error code in is31fl32xx_parse_dt() soc: rockchip: ROCKCHIP_GRF should not default to y, unconditionally media: cxd2880-spi: Fix an error handling path drm/of: free the right object bpf: Fix a typo of reuseport map in bpf.h. bpf: Fix potential memleak and UAF in the verifier. drm/of: free the iterator object on failure gve: fix the wrong AdminQ buffer overflow check libbpf: Fix the possible memory leak on error ARM: dts: aspeed-g6: Fix HVI3C function-group in pinctrl dtsi arm64: dts: renesas: r8a77995: draak: Remove bogus adv7511w properties i40e: improve locking of mac_filter_hash soc: qcom: rpmhpd: Use corner in power_off libbpf: Fix removal of inner map in bpf_object__create_map gfs2: Fix memory leak of object lsi on error return path firmware: fix theoretical UAF race with firmware cache and resume driver core: Fix error return code in really_probe() ionic: cleanly release devlink instance media: dvb-usb: fix uninit-value in dvb_usb_adapter_dvb_init media: dvb-usb: fix uninit-value in vp702x_read_mac_addr media: dvb-usb: Fix error handling in dvb_usb_i2c_init media: go7007: fix memory leak in go7007_usb_probe media: go7007: remove redundant initialization media: rockchip/rga: use pm_runtime_resume_and_get() media: rockchip/rga: fix error handling in probe media: coda: fix frame_mem_ctrl for YUV420 and YVU420 formats media: atomisp: fix the uninitialized use and rename "retvalue" Bluetooth: sco: prevent information leak in sco_conn_defer_accept() 6lowpan: iphc: Fix an off-by-one check of array index drm/amdgpu/acp: Make PM domain really work tcp: seq_file: Avoid skipping sk during tcp_seek_last_pos ARM: dts: meson8: Use a higher default GPU clock frequency ARM: dts: meson8b: odroidc1: Fix the pwm regulator supply properties ARM: dts: meson8b: mxq: Fix the pwm regulator supply properties ARM: dts: meson8b: ec100: Fix the pwm regulator supply properties net/mlx5e: Prohibit inner indir TIRs in IPoIB net/mlx5e: Block LRO if firmware asks for tunneled LRO cgroup/cpuset: Fix a partition bug with hotplug drm: mxsfb: Enable recovery on underflow drm: mxsfb: Increase number of outstanding requests on V4 and newer HW drm: mxsfb: Clear FIFO_CLEAR bit net: cipso: fix warnings in netlbl_cipsov4_add_std Bluetooth: mgmt: Fix wrong opcode in the response for add_adv cmd arm64: dts: renesas: rzg2: Convert EtherAVB to explicit delay handling arm64: dts: renesas: hihope-rzg2-ex: Add EtherAVB internal rx delay devlink: Break parameter notification sequence to be before/after unload/load driver net/mlx5: Fix missing return value in mlx5_devlink_eswitch_inline_mode_set() i2c: highlander: add IRQ check leds: lt3593: Put fwnode in any case during ->probe() leds: trigger: audio: Add an activate callback to ensure the initial brightness is set media: em28xx-input: fix refcount bug in em28xx_usb_disconnect media: venus: venc: Fix potential null pointer dereference on pointer fmt PCI: PM: Avoid forcing PCI_D0 for wakeup reasons inconsistently PCI: PM: Enable PME if it can be signaled from D3cold bpf, samples: Add missing mprog-disable to xdp_redirect_cpu's optstring soc: qcom: smsm: Fix missed interrupts if state changes while masked debugfs: Return error during {full/open}_proxy_open() on rmmod Bluetooth: increase BTNAMSIZ to 21 chars to fix potential buffer overflow PM: EM: Increase energy calculation precision selftests/bpf: Fix bpf-iter-tcp4 test to print correctly the dest IP drm/msm/mdp4: refactor HW revision detection into read_mdp_hw_revision drm/msm/mdp4: move HW revision detection to earlier phase drm/msm/dpu: make dpu_hw_ctl_clear_all_blendstages clear necessary LMs arm64: dts: exynos: correct GIC CPU interfaces address range on Exynos7 counter: 104-quad-8: Return error when invalid mode during ceiling_write cgroup/cpuset: Miscellaneous code cleanup cgroup/cpuset: Fix violation of cpuset locking rule ASoC: Intel: Fix platform ID matching Bluetooth: fix repeated calls to sco_sock_kill drm/msm/dsi: Fix some reference counted resource leaks net/mlx5: Register to devlink ingress VLAN filter trap net/mlx5: Fix unpublish devlink parameters ASoC: rt5682: Implement remove callback ASoC: rt5682: Properly turn off regulators if wrong device ID usb: dwc3: meson-g12a: add IRQ check usb: dwc3: qcom: add IRQ check usb: gadget: udc: at91: add IRQ check usb: gadget: udc: s3c2410: add IRQ check usb: phy: fsl-usb: add IRQ check usb: phy: twl6030: add IRQ checks usb: gadget: udc: renesas_usb3: Fix soc_device_match() abuse selftests/bpf: Fix test_core_autosize on big-endian machines devlink: Clear whole devlink_flash_notify struct samples: pktgen: add missing IPv6 option to pktgen scripts Bluetooth: Move shutdown callback before flushing tx and rx queue PM: cpu: Make notifier chain use a raw_spinlock_t usb: host: ohci-tmio: add IRQ check usb: phy: tahvo: add IRQ check libbpf: Re-build libbpf.so when libbpf.map changes mac80211: Fix insufficient headroom issue for AMSDU locking/lockdep: Mark local_lock_t locking/local_lock: Add missing owner initialization lockd: Fix invalid lockowner cast after vfs_test_lock nfsd4: Fix forced-expiry locking arm64: dts: marvell: armada-37xx: Extend PCIe MEM space clk: staging: correct reference to config IOMEM to config HAS_IOMEM i2c: synquacer: fix deferred probing firmware: raspberrypi: Keep count of all consumers firmware: raspberrypi: Fix a leak in 'rpi_firmware_get()' usb: gadget: mv_u3d: request_irq() after initializing UDC mm/swap: consider max pages in iomap_swapfile_add_extent lkdtm: replace SCSI_DISPATCH_CMD with SCSI_QUEUE_RQ Bluetooth: add timeout sanity check to hci_inquiry i2c: iop3xx: fix deferred probing i2c: s3c2410: fix IRQ check i2c: fix platform_get_irq.cocci warnings i2c: hix5hd2: fix IRQ check gfs2: init system threads before freeze lock rsi: fix error code in rsi_load_9116_firmware() rsi: fix an error code in rsi_probe() ASoC: Intel: kbl_da7219_max98927: Fix format selection for max98373 ASoC: Intel: Skylake: Leave data as is when invoking TLV IPCs ASoC: Intel: Skylake: Fix module resource and format selection mmc: sdhci: Fix issue with uninitialized dma_slave_config mmc: dw_mmc: Fix issue with uninitialized dma_slave_config mmc: moxart: Fix issue with uninitialized dma_slave_config bpf: Fix possible out of bound write in narrow load handling CIFS: Fix a potencially linear read overflow i2c: mt65xx: fix IRQ check i2c: xlp9xx: fix main IRQ check usb: ehci-orion: Handle errors of clk_prepare_enable() in probe usb: bdc: Fix an error handling path in 'bdc_probe()' when no suitable DMA config is available usb: bdc: Fix a resource leak in the error handling path of 'bdc_probe()' tty: serial: fsl_lpuart: fix the wrong mapbase value ASoC: wcd9335: Fix a double irq free in the remove function ASoC: wcd9335: Fix a memory leak in the error handling path of the probe function ASoC: wcd9335: Disable irq on slave ports in the remove function iwlwifi: follow the new inclusive terminology iwlwifi: skip first element in the WTAS ACPI table ice: Only lock to update netdev dev_addr ath6kl: wmi: fix an error code in ath6kl_wmi_sync_point() atlantic: Fix driver resume flow. bcma: Fix memory leak for internally-handled cores brcmfmac: pcie: fix oops on failure to resume and reprobe ipv6: make exception cache less predictible ipv4: make exception cache less predictible net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed net: qualcomm: fix QCA7000 checksum handling octeontx2-af: Fix loop in free and unmap counter octeontx2-af: Fix static code analyzer reported issues octeontx2-af: Set proper errorcode for IPv4 checksum errors ipv4: fix endianness issue in inet_rtm_getroute_build_skb() ASoC: rt5682: Remove unused variable in rt5682_i2c_remove() iwlwifi Add support for ax201 in Samsung Galaxy Book Flex2 Alpha f2fs: guarantee to write dirty data when enabling checkpoint back time: Handle negative seconds correctly in timespec64_to_ns() io_uring: IORING_OP_WRITE needs hash_reg_file set bio: fix page leak bio_add_hw_page failure tty: Fix data race between tiocsti() and flush_to_ldisc() perf/x86/amd/ibs: Extend PERF_PMU_CAP_NO_EXCLUDE to IBS Op x86/resctrl: Fix a maybe-uninitialized build warning treated as error Revert "KVM: x86: mmu: Add guest physical address check in translate_gpa()" KVM: s390: index kvm->arch.idle_mask by vcpu_idx KVM: x86: Update vCPU's hv_clock before back to guest when tsc_offset is adjusted KVM: VMX: avoid running vmx_handle_exit_irqoff in case of emulation KVM: nVMX: Unconditionally clear nested.pi_pending on nested VM-Enter ARM: dts: at91: add pinctrl-{names, 0} for all gpios fuse: truncate pagecache on atomic_o_trunc fuse: flush extending writes IMA: remove -Wmissing-prototypes warning IMA: remove the dependency on CRYPTO_MD5 fbmem: don't allow too huge resolutions backlight: pwm_bl: Improve bootloader/kernel device handover clk: kirkwood: Fix a clocking boot regression Linux 5.10.65 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: Ie0b9306ba6ee4193de3200df7cdacaeba152b83e
867 lines
26 KiB
C
867 lines
26 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* RCU CPU stall warnings for normal RCU grace periods
|
|
*
|
|
* Copyright IBM Corporation, 2019
|
|
*
|
|
* Author: Paul E. McKenney <paulmck@linux.ibm.com>
|
|
*/
|
|
|
|
#include <linux/kvm_para.h>
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Controlling CPU stall warnings, including delay calculation.
|
|
|
|
/* panic() on RCU Stall sysctl. */
|
|
int sysctl_panic_on_rcu_stall __read_mostly;
|
|
|
|
#ifdef CONFIG_PROVE_RCU
|
|
#define RCU_STALL_DELAY_DELTA (5 * HZ)
|
|
#else
|
|
#define RCU_STALL_DELAY_DELTA 0
|
|
#endif
|
|
#define RCU_STALL_MIGHT_DIV 8
|
|
#define RCU_STALL_MIGHT_MIN (2 * HZ)
|
|
|
|
/* Limit-check stall timeouts specified at boottime and runtime. */
|
|
int rcu_jiffies_till_stall_check(void)
|
|
{
|
|
int till_stall_check = READ_ONCE(rcu_cpu_stall_timeout);
|
|
|
|
/*
|
|
* Limit check must be consistent with the Kconfig limits
|
|
* for CONFIG_RCU_CPU_STALL_TIMEOUT.
|
|
*/
|
|
if (till_stall_check < 3) {
|
|
WRITE_ONCE(rcu_cpu_stall_timeout, 3);
|
|
till_stall_check = 3;
|
|
} else if (till_stall_check > 300) {
|
|
WRITE_ONCE(rcu_cpu_stall_timeout, 300);
|
|
till_stall_check = 300;
|
|
}
|
|
return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
|
|
}
|
|
EXPORT_SYMBOL_GPL(rcu_jiffies_till_stall_check);
|
|
|
|
/**
|
|
* rcu_gp_might_be_stalled - Is it likely that the grace period is stalled?
|
|
*
|
|
* Returns @true if the current grace period is sufficiently old that
|
|
* it is reasonable to assume that it might be stalled. This can be
|
|
* useful when deciding whether to allocate memory to enable RCU-mediated
|
|
* freeing on the one hand or just invoking synchronize_rcu() on the other.
|
|
* The latter is preferable when the grace period is stalled.
|
|
*
|
|
* Note that sampling of the .gp_start and .gp_seq fields must be done
|
|
* carefully to avoid false positives at the beginnings and ends of
|
|
* grace periods.
|
|
*/
|
|
bool rcu_gp_might_be_stalled(void)
|
|
{
|
|
unsigned long d = rcu_jiffies_till_stall_check() / RCU_STALL_MIGHT_DIV;
|
|
unsigned long j = jiffies;
|
|
|
|
if (d < RCU_STALL_MIGHT_MIN)
|
|
d = RCU_STALL_MIGHT_MIN;
|
|
smp_mb(); // jiffies before .gp_seq to avoid false positives.
|
|
if (!rcu_gp_in_progress())
|
|
return false;
|
|
// Long delays at this point avoids false positive, but a delay
|
|
// of ULONG_MAX/4 jiffies voids your no-false-positive warranty.
|
|
smp_mb(); // .gp_seq before second .gp_start
|
|
// And ditto here.
|
|
return !time_before(j, READ_ONCE(rcu_state.gp_start) + d);
|
|
}
|
|
|
|
/* Don't do RCU CPU stall warnings during long sysrq printouts. */
|
|
void rcu_sysrq_start(void)
|
|
{
|
|
if (!rcu_cpu_stall_suppress)
|
|
rcu_cpu_stall_suppress = 2;
|
|
}
|
|
|
|
void rcu_sysrq_end(void)
|
|
{
|
|
if (rcu_cpu_stall_suppress == 2)
|
|
rcu_cpu_stall_suppress = 0;
|
|
}
|
|
|
|
/* Don't print RCU CPU stall warnings during a kernel panic. */
|
|
static int rcu_panic(struct notifier_block *this, unsigned long ev, void *ptr)
|
|
{
|
|
rcu_cpu_stall_suppress = 1;
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
static struct notifier_block rcu_panic_block = {
|
|
.notifier_call = rcu_panic,
|
|
};
|
|
|
|
static int __init check_cpu_stall_init(void)
|
|
{
|
|
atomic_notifier_chain_register(&panic_notifier_list, &rcu_panic_block);
|
|
return 0;
|
|
}
|
|
early_initcall(check_cpu_stall_init);
|
|
|
|
/* If so specified via sysctl, panic, yielding cleaner stall-warning output. */
|
|
static void panic_on_rcu_stall(void)
|
|
{
|
|
if (sysctl_panic_on_rcu_stall)
|
|
panic("RCU Stall\n");
|
|
}
|
|
|
|
/**
|
|
* rcu_cpu_stall_reset - prevent further stall warnings in current grace period
|
|
*
|
|
* Set the stall-warning timeout way off into the future, thus preventing
|
|
* any RCU CPU stall-warning messages from appearing in the current set of
|
|
* RCU grace periods.
|
|
*
|
|
* The caller must disable hard irqs.
|
|
*/
|
|
void rcu_cpu_stall_reset(void)
|
|
{
|
|
WRITE_ONCE(rcu_state.jiffies_stall, jiffies + ULONG_MAX / 2);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Interaction with RCU grace periods
|
|
|
|
/* Start of new grace period, so record stall time (and forcing times). */
|
|
static void record_gp_stall_check_time(void)
|
|
{
|
|
unsigned long j = jiffies;
|
|
unsigned long j1;
|
|
|
|
WRITE_ONCE(rcu_state.gp_start, j);
|
|
j1 = rcu_jiffies_till_stall_check();
|
|
smp_mb(); // ->gp_start before ->jiffies_stall and caller's ->gp_seq.
|
|
WRITE_ONCE(rcu_state.jiffies_stall, j + j1);
|
|
rcu_state.jiffies_resched = j + j1 / 2;
|
|
rcu_state.n_force_qs_gpstart = READ_ONCE(rcu_state.n_force_qs);
|
|
}
|
|
|
|
/* Zero ->ticks_this_gp and snapshot the number of RCU softirq handlers. */
|
|
static void zero_cpu_stall_ticks(struct rcu_data *rdp)
|
|
{
|
|
rdp->ticks_this_gp = 0;
|
|
rdp->softirq_snap = kstat_softirqs_cpu(RCU_SOFTIRQ, smp_processor_id());
|
|
WRITE_ONCE(rdp->last_fqs_resched, jiffies);
|
|
}
|
|
|
|
/*
|
|
* If too much time has passed in the current grace period, and if
|
|
* so configured, go kick the relevant kthreads.
|
|
*/
|
|
static void rcu_stall_kick_kthreads(void)
|
|
{
|
|
unsigned long j;
|
|
|
|
if (!READ_ONCE(rcu_kick_kthreads))
|
|
return;
|
|
j = READ_ONCE(rcu_state.jiffies_kick_kthreads);
|
|
if (time_after(jiffies, j) && rcu_state.gp_kthread &&
|
|
(rcu_gp_in_progress() || READ_ONCE(rcu_state.gp_flags))) {
|
|
WARN_ONCE(1, "Kicking %s grace-period kthread\n",
|
|
rcu_state.name);
|
|
rcu_ftrace_dump(DUMP_ALL);
|
|
wake_up_process(rcu_state.gp_kthread);
|
|
WRITE_ONCE(rcu_state.jiffies_kick_kthreads, j + HZ);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Handler for the irq_work request posted about halfway into the RCU CPU
|
|
* stall timeout, and used to detect excessive irq disabling. Set state
|
|
* appropriately, but just complain if there is unexpected state on entry.
|
|
*/
|
|
static void rcu_iw_handler(struct irq_work *iwp)
|
|
{
|
|
struct rcu_data *rdp;
|
|
struct rcu_node *rnp;
|
|
|
|
rdp = container_of(iwp, struct rcu_data, rcu_iw);
|
|
rnp = rdp->mynode;
|
|
raw_spin_lock_rcu_node(rnp);
|
|
if (!WARN_ON_ONCE(!rdp->rcu_iw_pending)) {
|
|
rdp->rcu_iw_gp_seq = rnp->gp_seq;
|
|
rdp->rcu_iw_pending = false;
|
|
}
|
|
raw_spin_unlock_rcu_node(rnp);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Printing RCU CPU stall warnings
|
|
|
|
#ifdef CONFIG_PREEMPT_RCU
|
|
|
|
/*
|
|
* Dump detailed information for all tasks blocking the current RCU
|
|
* grace period on the specified rcu_node structure.
|
|
*/
|
|
static void rcu_print_detail_task_stall_rnp(struct rcu_node *rnp)
|
|
{
|
|
unsigned long flags;
|
|
struct task_struct *t;
|
|
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
if (!rcu_preempt_blocked_readers_cgp(rnp)) {
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
return;
|
|
}
|
|
t = list_entry(rnp->gp_tasks->prev,
|
|
struct task_struct, rcu_node_entry);
|
|
list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) {
|
|
/*
|
|
* We could be printing a lot while holding a spinlock.
|
|
* Avoid triggering hard lockup.
|
|
*/
|
|
touch_nmi_watchdog();
|
|
sched_show_task(t);
|
|
}
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
}
|
|
|
|
// Communicate task state back to the RCU CPU stall warning request.
|
|
struct rcu_stall_chk_rdr {
|
|
int nesting;
|
|
union rcu_special rs;
|
|
bool on_blkd_list;
|
|
};
|
|
|
|
/*
|
|
* Report out the state of a not-running task that is stalling the
|
|
* current RCU grace period.
|
|
*/
|
|
static bool check_slow_task(struct task_struct *t, void *arg)
|
|
{
|
|
struct rcu_stall_chk_rdr *rscrp = arg;
|
|
|
|
if (task_curr(t))
|
|
return false; // It is running, so decline to inspect it.
|
|
rscrp->nesting = t->rcu_read_lock_nesting;
|
|
rscrp->rs = t->rcu_read_unlock_special;
|
|
rscrp->on_blkd_list = !list_empty(&t->rcu_node_entry);
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* Scan the current list of tasks blocked within RCU read-side critical
|
|
* sections, printing out the tid of each of the first few of them.
|
|
*/
|
|
static int rcu_print_task_stall(struct rcu_node *rnp, unsigned long flags)
|
|
__releases(rnp->lock)
|
|
{
|
|
int i = 0;
|
|
int ndetected = 0;
|
|
struct rcu_stall_chk_rdr rscr;
|
|
struct task_struct *t;
|
|
struct task_struct *ts[8];
|
|
|
|
lockdep_assert_irqs_disabled();
|
|
if (!rcu_preempt_blocked_readers_cgp(rnp)) {
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
return 0;
|
|
}
|
|
pr_err("\tTasks blocked on level-%d rcu_node (CPUs %d-%d):",
|
|
rnp->level, rnp->grplo, rnp->grphi);
|
|
t = list_entry(rnp->gp_tasks->prev,
|
|
struct task_struct, rcu_node_entry);
|
|
list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) {
|
|
get_task_struct(t);
|
|
ts[i++] = t;
|
|
if (i >= ARRAY_SIZE(ts))
|
|
break;
|
|
}
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
while (i) {
|
|
t = ts[--i];
|
|
if (!try_invoke_on_locked_down_task(t, check_slow_task, &rscr))
|
|
pr_cont(" P%d", t->pid);
|
|
else
|
|
pr_cont(" P%d/%d:%c%c%c%c",
|
|
t->pid, rscr.nesting,
|
|
".b"[rscr.rs.b.blocked],
|
|
".q"[rscr.rs.b.need_qs],
|
|
".e"[rscr.rs.b.exp_hint],
|
|
".l"[rscr.on_blkd_list]);
|
|
lockdep_assert_irqs_disabled();
|
|
put_task_struct(t);
|
|
ndetected++;
|
|
}
|
|
pr_cont("\n");
|
|
return ndetected;
|
|
}
|
|
|
|
#else /* #ifdef CONFIG_PREEMPT_RCU */
|
|
|
|
/*
|
|
* Because preemptible RCU does not exist, we never have to check for
|
|
* tasks blocked within RCU read-side critical sections.
|
|
*/
|
|
static void rcu_print_detail_task_stall_rnp(struct rcu_node *rnp)
|
|
{
|
|
}
|
|
|
|
/*
|
|
* Because preemptible RCU does not exist, we never have to check for
|
|
* tasks blocked within RCU read-side critical sections.
|
|
*/
|
|
static int rcu_print_task_stall(struct rcu_node *rnp, unsigned long flags)
|
|
{
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
return 0;
|
|
}
|
|
#endif /* #else #ifdef CONFIG_PREEMPT_RCU */
|
|
|
|
/*
|
|
* Dump stacks of all tasks running on stalled CPUs. First try using
|
|
* NMIs, but fall back to manual remote stack tracing on architectures
|
|
* that don't support NMI-based stack dumps. The NMI-triggered stack
|
|
* traces are more accurate because they are printed by the target CPU.
|
|
*/
|
|
static void rcu_dump_cpu_stacks(void)
|
|
{
|
|
int cpu;
|
|
unsigned long flags;
|
|
struct rcu_node *rnp;
|
|
|
|
rcu_for_each_leaf_node(rnp) {
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
for_each_leaf_node_possible_cpu(rnp, cpu)
|
|
if (rnp->qsmask & leaf_node_cpu_bit(rnp, cpu))
|
|
if (!trigger_single_cpu_backtrace(cpu))
|
|
dump_cpu_task(cpu);
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
}
|
|
}
|
|
|
|
#ifdef CONFIG_RCU_FAST_NO_HZ
|
|
|
|
static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
|
|
{
|
|
struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
|
|
|
|
sprintf(cp, "last_accelerate: %04lx/%04lx dyntick_enabled: %d",
|
|
rdp->last_accelerate & 0xffff, jiffies & 0xffff,
|
|
!!rdp->tick_nohz_enabled_snap);
|
|
}
|
|
|
|
#else /* #ifdef CONFIG_RCU_FAST_NO_HZ */
|
|
|
|
static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
|
|
{
|
|
*cp = '\0';
|
|
}
|
|
|
|
#endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */
|
|
|
|
static const char * const gp_state_names[] = {
|
|
[RCU_GP_IDLE] = "RCU_GP_IDLE",
|
|
[RCU_GP_WAIT_GPS] = "RCU_GP_WAIT_GPS",
|
|
[RCU_GP_DONE_GPS] = "RCU_GP_DONE_GPS",
|
|
[RCU_GP_ONOFF] = "RCU_GP_ONOFF",
|
|
[RCU_GP_INIT] = "RCU_GP_INIT",
|
|
[RCU_GP_WAIT_FQS] = "RCU_GP_WAIT_FQS",
|
|
[RCU_GP_DOING_FQS] = "RCU_GP_DOING_FQS",
|
|
[RCU_GP_CLEANUP] = "RCU_GP_CLEANUP",
|
|
[RCU_GP_CLEANED] = "RCU_GP_CLEANED",
|
|
};
|
|
|
|
/*
|
|
* Convert a ->gp_state value to a character string.
|
|
*/
|
|
static const char *gp_state_getname(short gs)
|
|
{
|
|
if (gs < 0 || gs >= ARRAY_SIZE(gp_state_names))
|
|
return "???";
|
|
return gp_state_names[gs];
|
|
}
|
|
|
|
/* Is the RCU grace-period kthread being starved of CPU time? */
|
|
static bool rcu_is_gp_kthread_starving(unsigned long *jp)
|
|
{
|
|
unsigned long j = jiffies - READ_ONCE(rcu_state.gp_activity);
|
|
|
|
if (jp)
|
|
*jp = j;
|
|
return j > 2 * HZ;
|
|
}
|
|
|
|
/*
|
|
* Print out diagnostic information for the specified stalled CPU.
|
|
*
|
|
* If the specified CPU is aware of the current RCU grace period, then
|
|
* print the number of scheduling clock interrupts the CPU has taken
|
|
* during the time that it has been aware. Otherwise, print the number
|
|
* of RCU grace periods that this CPU is ignorant of, for example, "1"
|
|
* if the CPU was aware of the previous grace period.
|
|
*
|
|
* Also print out idle and (if CONFIG_RCU_FAST_NO_HZ) idle-entry info.
|
|
*/
|
|
static void print_cpu_stall_info(int cpu)
|
|
{
|
|
unsigned long delta;
|
|
bool falsepositive;
|
|
char fast_no_hz[72];
|
|
struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
|
|
char *ticks_title;
|
|
unsigned long ticks_value;
|
|
|
|
/*
|
|
* We could be printing a lot while holding a spinlock. Avoid
|
|
* triggering hard lockup.
|
|
*/
|
|
touch_nmi_watchdog();
|
|
|
|
ticks_value = rcu_seq_ctr(rcu_state.gp_seq - rdp->gp_seq);
|
|
if (ticks_value) {
|
|
ticks_title = "GPs behind";
|
|
} else {
|
|
ticks_title = "ticks this GP";
|
|
ticks_value = rdp->ticks_this_gp;
|
|
}
|
|
print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
|
|
delta = rcu_seq_ctr(rdp->mynode->gp_seq - rdp->rcu_iw_gp_seq);
|
|
falsepositive = rcu_is_gp_kthread_starving(NULL) &&
|
|
rcu_dynticks_in_eqs(rcu_dynticks_snap(rdp));
|
|
pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld %s%s\n",
|
|
cpu,
|
|
"O."[!!cpu_online(cpu)],
|
|
"o."[!!(rdp->grpmask & rdp->mynode->qsmaskinit)],
|
|
"N."[!!(rdp->grpmask & rdp->mynode->qsmaskinitnext)],
|
|
!IS_ENABLED(CONFIG_IRQ_WORK) ? '?' :
|
|
rdp->rcu_iw_pending ? (int)min(delta, 9UL) + '0' :
|
|
"!."[!delta],
|
|
ticks_value, ticks_title,
|
|
rcu_dynticks_snap(rdp) & 0xfff,
|
|
rdp->dynticks_nesting, rdp->dynticks_nmi_nesting,
|
|
rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
|
|
data_race(rcu_state.n_force_qs) - rcu_state.n_force_qs_gpstart,
|
|
fast_no_hz,
|
|
falsepositive ? " (false positive?)" : "");
|
|
}
|
|
|
|
/* Complain about starvation of grace-period kthread. */
|
|
static void rcu_check_gp_kthread_starvation(void)
|
|
{
|
|
struct task_struct *gpk = rcu_state.gp_kthread;
|
|
unsigned long j;
|
|
|
|
if (rcu_is_gp_kthread_starving(&j)) {
|
|
pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=%#lx ->cpu=%d\n",
|
|
rcu_state.name, j,
|
|
(long)rcu_seq_current(&rcu_state.gp_seq),
|
|
data_race(rcu_state.gp_flags),
|
|
gp_state_getname(rcu_state.gp_state), rcu_state.gp_state,
|
|
gpk ? gpk->state : ~0, gpk ? task_cpu(gpk) : -1);
|
|
if (gpk) {
|
|
pr_err("\tUnless %s kthread gets sufficient CPU time, OOM is now expected behavior.\n", rcu_state.name);
|
|
pr_err("RCU grace-period kthread stack dump:\n");
|
|
sched_show_task(gpk);
|
|
wake_up_process(gpk);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void print_other_cpu_stall(unsigned long gp_seq, unsigned long gps)
|
|
{
|
|
int cpu;
|
|
unsigned long flags;
|
|
unsigned long gpa;
|
|
unsigned long j;
|
|
int ndetected = 0;
|
|
struct rcu_node *rnp;
|
|
long totqlen = 0;
|
|
|
|
lockdep_assert_irqs_disabled();
|
|
|
|
/* Kick and suppress, if so configured. */
|
|
rcu_stall_kick_kthreads();
|
|
if (rcu_stall_is_suppressed())
|
|
return;
|
|
|
|
/*
|
|
* OK, time to rat on our buddy...
|
|
* See Documentation/RCU/stallwarn.rst for info on how to debug
|
|
* RCU CPU stall warnings.
|
|
*/
|
|
trace_rcu_stall_warning(rcu_state.name, TPS("StallDetected"));
|
|
pr_err("INFO: %s detected stalls on CPUs/tasks:\n", rcu_state.name);
|
|
rcu_for_each_leaf_node(rnp) {
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
if (rnp->qsmask != 0) {
|
|
for_each_leaf_node_possible_cpu(rnp, cpu)
|
|
if (rnp->qsmask & leaf_node_cpu_bit(rnp, cpu)) {
|
|
print_cpu_stall_info(cpu);
|
|
ndetected++;
|
|
}
|
|
}
|
|
ndetected += rcu_print_task_stall(rnp, flags); // Releases rnp->lock.
|
|
lockdep_assert_irqs_disabled();
|
|
}
|
|
|
|
for_each_possible_cpu(cpu)
|
|
totqlen += rcu_get_n_cbs_cpu(cpu);
|
|
pr_cont("\t(detected by %d, t=%ld jiffies, g=%ld, q=%lu)\n",
|
|
smp_processor_id(), (long)(jiffies - gps),
|
|
(long)rcu_seq_current(&rcu_state.gp_seq), totqlen);
|
|
if (ndetected) {
|
|
rcu_dump_cpu_stacks();
|
|
|
|
/* Complain about tasks blocking the grace period. */
|
|
rcu_for_each_leaf_node(rnp)
|
|
rcu_print_detail_task_stall_rnp(rnp);
|
|
} else {
|
|
if (rcu_seq_current(&rcu_state.gp_seq) != gp_seq) {
|
|
pr_err("INFO: Stall ended before state dump start\n");
|
|
} else {
|
|
j = jiffies;
|
|
gpa = data_race(rcu_state.gp_activity);
|
|
pr_err("All QSes seen, last %s kthread activity %ld (%ld-%ld), jiffies_till_next_fqs=%ld, root ->qsmask %#lx\n",
|
|
rcu_state.name, j - gpa, j, gpa,
|
|
data_race(jiffies_till_next_fqs),
|
|
rcu_get_root()->qsmask);
|
|
}
|
|
}
|
|
/* Rewrite if needed in case of slow consoles. */
|
|
if (ULONG_CMP_GE(jiffies, READ_ONCE(rcu_state.jiffies_stall)))
|
|
WRITE_ONCE(rcu_state.jiffies_stall,
|
|
jiffies + 3 * rcu_jiffies_till_stall_check() + 3);
|
|
|
|
rcu_check_gp_kthread_starvation();
|
|
|
|
panic_on_rcu_stall();
|
|
|
|
rcu_force_quiescent_state(); /* Kick them all. */
|
|
}
|
|
|
|
static void print_cpu_stall(unsigned long gps)
|
|
{
|
|
int cpu;
|
|
unsigned long flags;
|
|
struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
|
|
struct rcu_node *rnp = rcu_get_root();
|
|
long totqlen = 0;
|
|
|
|
lockdep_assert_irqs_disabled();
|
|
|
|
/* Kick and suppress, if so configured. */
|
|
rcu_stall_kick_kthreads();
|
|
if (rcu_stall_is_suppressed())
|
|
return;
|
|
|
|
/*
|
|
* OK, time to rat on ourselves...
|
|
* See Documentation/RCU/stallwarn.rst for info on how to debug
|
|
* RCU CPU stall warnings.
|
|
*/
|
|
trace_rcu_stall_warning(rcu_state.name, TPS("SelfDetected"));
|
|
pr_err("INFO: %s self-detected stall on CPU\n", rcu_state.name);
|
|
raw_spin_lock_irqsave_rcu_node(rdp->mynode, flags);
|
|
print_cpu_stall_info(smp_processor_id());
|
|
raw_spin_unlock_irqrestore_rcu_node(rdp->mynode, flags);
|
|
for_each_possible_cpu(cpu)
|
|
totqlen += rcu_get_n_cbs_cpu(cpu);
|
|
pr_cont("\t(t=%lu jiffies g=%ld q=%lu)\n",
|
|
jiffies - gps,
|
|
(long)rcu_seq_current(&rcu_state.gp_seq), totqlen);
|
|
|
|
rcu_check_gp_kthread_starvation();
|
|
|
|
rcu_dump_cpu_stacks();
|
|
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
/* Rewrite if needed in case of slow consoles. */
|
|
if (ULONG_CMP_GE(jiffies, READ_ONCE(rcu_state.jiffies_stall)))
|
|
WRITE_ONCE(rcu_state.jiffies_stall,
|
|
jiffies + 3 * rcu_jiffies_till_stall_check() + 3);
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
|
|
panic_on_rcu_stall();
|
|
|
|
/*
|
|
* Attempt to revive the RCU machinery by forcing a context switch.
|
|
*
|
|
* A context switch would normally allow the RCU state machine to make
|
|
* progress and it could be we're stuck in kernel space without context
|
|
* switches for an entirely unreasonable amount of time.
|
|
*/
|
|
set_tsk_need_resched(current);
|
|
set_preempt_need_resched();
|
|
}
|
|
|
|
static void check_cpu_stall(struct rcu_data *rdp)
|
|
{
|
|
unsigned long gs1;
|
|
unsigned long gs2;
|
|
unsigned long gps;
|
|
unsigned long j;
|
|
unsigned long jn;
|
|
unsigned long js;
|
|
struct rcu_node *rnp;
|
|
|
|
lockdep_assert_irqs_disabled();
|
|
if ((rcu_stall_is_suppressed() && !READ_ONCE(rcu_kick_kthreads)) ||
|
|
!rcu_gp_in_progress())
|
|
return;
|
|
rcu_stall_kick_kthreads();
|
|
j = jiffies;
|
|
|
|
/*
|
|
* Lots of memory barriers to reject false positives.
|
|
*
|
|
* The idea is to pick up rcu_state.gp_seq, then
|
|
* rcu_state.jiffies_stall, then rcu_state.gp_start, and finally
|
|
* another copy of rcu_state.gp_seq. These values are updated in
|
|
* the opposite order with memory barriers (or equivalent) during
|
|
* grace-period initialization and cleanup. Now, a false positive
|
|
* can occur if we get an new value of rcu_state.gp_start and a old
|
|
* value of rcu_state.jiffies_stall. But given the memory barriers,
|
|
* the only way that this can happen is if one grace period ends
|
|
* and another starts between these two fetches. This is detected
|
|
* by comparing the second fetch of rcu_state.gp_seq with the
|
|
* previous fetch from rcu_state.gp_seq.
|
|
*
|
|
* Given this check, comparisons of jiffies, rcu_state.jiffies_stall,
|
|
* and rcu_state.gp_start suffice to forestall false positives.
|
|
*/
|
|
gs1 = READ_ONCE(rcu_state.gp_seq);
|
|
smp_rmb(); /* Pick up ->gp_seq first... */
|
|
js = READ_ONCE(rcu_state.jiffies_stall);
|
|
smp_rmb(); /* ...then ->jiffies_stall before the rest... */
|
|
gps = READ_ONCE(rcu_state.gp_start);
|
|
smp_rmb(); /* ...and finally ->gp_start before ->gp_seq again. */
|
|
gs2 = READ_ONCE(rcu_state.gp_seq);
|
|
if (gs1 != gs2 ||
|
|
ULONG_CMP_LT(j, js) ||
|
|
ULONG_CMP_GE(gps, js))
|
|
return; /* No stall or GP completed since entering function. */
|
|
rnp = rdp->mynode;
|
|
jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
|
|
if (rcu_gp_in_progress() &&
|
|
(READ_ONCE(rnp->qsmask) & rdp->grpmask) &&
|
|
cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
|
|
|
|
/*
|
|
* If a virtual machine is stopped by the host it can look to
|
|
* the watchdog like an RCU stall. Check to see if the host
|
|
* stopped the vm.
|
|
*/
|
|
if (kvm_check_and_clear_guest_paused())
|
|
return;
|
|
|
|
/* We haven't checked in, so go dump stack. */
|
|
print_cpu_stall(gps);
|
|
if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
|
|
rcu_ftrace_dump(DUMP_ALL);
|
|
|
|
} else if (rcu_gp_in_progress() &&
|
|
ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) &&
|
|
cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
|
|
|
|
/*
|
|
* If a virtual machine is stopped by the host it can look to
|
|
* the watchdog like an RCU stall. Check to see if the host
|
|
* stopped the vm.
|
|
*/
|
|
if (kvm_check_and_clear_guest_paused())
|
|
return;
|
|
|
|
/* They had a few time units to dump stack, so complain. */
|
|
print_other_cpu_stall(gs2, gps);
|
|
if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
|
|
rcu_ftrace_dump(DUMP_ALL);
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// RCU forward-progress mechanisms, including of callback invocation.
|
|
|
|
|
|
/*
|
|
* Show the state of the grace-period kthreads.
|
|
*/
|
|
void show_rcu_gp_kthreads(void)
|
|
{
|
|
unsigned long cbs = 0;
|
|
int cpu;
|
|
unsigned long j;
|
|
unsigned long ja;
|
|
unsigned long jr;
|
|
unsigned long jw;
|
|
struct rcu_data *rdp;
|
|
struct rcu_node *rnp;
|
|
struct task_struct *t = READ_ONCE(rcu_state.gp_kthread);
|
|
|
|
j = jiffies;
|
|
ja = j - data_race(rcu_state.gp_activity);
|
|
jr = j - data_race(rcu_state.gp_req_activity);
|
|
jw = j - data_race(rcu_state.gp_wake_time);
|
|
pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_flags %#x\n",
|
|
rcu_state.name, gp_state_getname(rcu_state.gp_state),
|
|
rcu_state.gp_state, t ? t->state : 0x1ffffL,
|
|
ja, jr, jw, (long)data_race(rcu_state.gp_wake_seq),
|
|
(long)data_race(rcu_state.gp_seq),
|
|
(long)data_race(rcu_get_root()->gp_seq_needed),
|
|
data_race(rcu_state.gp_flags));
|
|
rcu_for_each_node_breadth_first(rnp) {
|
|
if (ULONG_CMP_GE(READ_ONCE(rcu_state.gp_seq),
|
|
READ_ONCE(rnp->gp_seq_needed)))
|
|
continue;
|
|
pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld\n",
|
|
rnp->grplo, rnp->grphi, (long)data_race(rnp->gp_seq),
|
|
(long)data_race(rnp->gp_seq_needed));
|
|
if (!rcu_is_leaf_node(rnp))
|
|
continue;
|
|
for_each_leaf_node_possible_cpu(rnp, cpu) {
|
|
rdp = per_cpu_ptr(&rcu_data, cpu);
|
|
if (READ_ONCE(rdp->gpwrap) ||
|
|
ULONG_CMP_GE(READ_ONCE(rcu_state.gp_seq),
|
|
READ_ONCE(rdp->gp_seq_needed)))
|
|
continue;
|
|
pr_info("\tcpu %d ->gp_seq_needed %ld\n",
|
|
cpu, (long)data_race(rdp->gp_seq_needed));
|
|
}
|
|
}
|
|
for_each_possible_cpu(cpu) {
|
|
rdp = per_cpu_ptr(&rcu_data, cpu);
|
|
cbs += data_race(rdp->n_cbs_invoked);
|
|
if (rcu_segcblist_is_offloaded(&rdp->cblist))
|
|
show_rcu_nocb_state(rdp);
|
|
}
|
|
pr_info("RCU callbacks invoked since boot: %lu\n", cbs);
|
|
show_rcu_tasks_gp_kthreads();
|
|
}
|
|
EXPORT_SYMBOL_GPL(show_rcu_gp_kthreads);
|
|
|
|
/*
|
|
* This function checks for grace-period requests that fail to motivate
|
|
* RCU to come out of its idle mode.
|
|
*/
|
|
static void rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp,
|
|
const unsigned long gpssdelay)
|
|
{
|
|
unsigned long flags;
|
|
unsigned long j;
|
|
struct rcu_node *rnp_root = rcu_get_root();
|
|
static atomic_t warned = ATOMIC_INIT(0);
|
|
|
|
if (!IS_ENABLED(CONFIG_PROVE_RCU) || rcu_gp_in_progress() ||
|
|
ULONG_CMP_GE(READ_ONCE(rnp_root->gp_seq),
|
|
READ_ONCE(rnp_root->gp_seq_needed)) ||
|
|
!smp_load_acquire(&rcu_state.gp_kthread)) // Get stable kthread.
|
|
return;
|
|
j = jiffies; /* Expensive access, and in common case don't get here. */
|
|
if (time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) ||
|
|
time_before(j, READ_ONCE(rcu_state.gp_activity) + gpssdelay) ||
|
|
atomic_read(&warned))
|
|
return;
|
|
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
j = jiffies;
|
|
if (rcu_gp_in_progress() ||
|
|
ULONG_CMP_GE(READ_ONCE(rnp_root->gp_seq),
|
|
READ_ONCE(rnp_root->gp_seq_needed)) ||
|
|
time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) ||
|
|
time_before(j, READ_ONCE(rcu_state.gp_activity) + gpssdelay) ||
|
|
atomic_read(&warned)) {
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
return;
|
|
}
|
|
/* Hold onto the leaf lock to make others see warned==1. */
|
|
|
|
if (rnp_root != rnp)
|
|
raw_spin_lock_rcu_node(rnp_root); /* irqs already disabled. */
|
|
j = jiffies;
|
|
if (rcu_gp_in_progress() ||
|
|
ULONG_CMP_GE(READ_ONCE(rnp_root->gp_seq),
|
|
READ_ONCE(rnp_root->gp_seq_needed)) ||
|
|
time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) ||
|
|
time_before(j, READ_ONCE(rcu_state.gp_activity) + gpssdelay) ||
|
|
atomic_xchg(&warned, 1)) {
|
|
if (rnp_root != rnp)
|
|
/* irqs remain disabled. */
|
|
raw_spin_unlock_rcu_node(rnp_root);
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
return;
|
|
}
|
|
WARN_ON(1);
|
|
if (rnp_root != rnp)
|
|
raw_spin_unlock_rcu_node(rnp_root);
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
show_rcu_gp_kthreads();
|
|
}
|
|
|
|
/*
|
|
* Do a forward-progress check for rcutorture. This is normally invoked
|
|
* due to an OOM event. The argument "j" gives the time period during
|
|
* which rcutorture would like progress to have been made.
|
|
*/
|
|
void rcu_fwd_progress_check(unsigned long j)
|
|
{
|
|
unsigned long cbs;
|
|
int cpu;
|
|
unsigned long max_cbs = 0;
|
|
int max_cpu = -1;
|
|
struct rcu_data *rdp;
|
|
|
|
if (rcu_gp_in_progress()) {
|
|
pr_info("%s: GP age %lu jiffies\n",
|
|
__func__, jiffies - rcu_state.gp_start);
|
|
show_rcu_gp_kthreads();
|
|
} else {
|
|
pr_info("%s: Last GP end %lu jiffies ago\n",
|
|
__func__, jiffies - rcu_state.gp_end);
|
|
preempt_disable();
|
|
rdp = this_cpu_ptr(&rcu_data);
|
|
rcu_check_gp_start_stall(rdp->mynode, rdp, j);
|
|
preempt_enable();
|
|
}
|
|
for_each_possible_cpu(cpu) {
|
|
cbs = rcu_get_n_cbs_cpu(cpu);
|
|
if (!cbs)
|
|
continue;
|
|
if (max_cpu < 0)
|
|
pr_info("%s: callbacks", __func__);
|
|
pr_cont(" %d: %lu", cpu, cbs);
|
|
if (cbs <= max_cbs)
|
|
continue;
|
|
max_cbs = cbs;
|
|
max_cpu = cpu;
|
|
}
|
|
if (max_cpu >= 0)
|
|
pr_cont("\n");
|
|
}
|
|
EXPORT_SYMBOL_GPL(rcu_fwd_progress_check);
|
|
|
|
/* Commandeer a sysrq key to dump RCU's tree. */
|
|
static bool sysrq_rcu;
|
|
module_param(sysrq_rcu, bool, 0444);
|
|
|
|
/* Dump grace-period-request information due to commandeered sysrq. */
|
|
static void sysrq_show_rcu(int key)
|
|
{
|
|
show_rcu_gp_kthreads();
|
|
}
|
|
|
|
static const struct sysrq_key_op sysrq_rcudump_op = {
|
|
.handler = sysrq_show_rcu,
|
|
.help_msg = "show-rcu(y)",
|
|
.action_msg = "Show RCU tree",
|
|
.enable_mask = SYSRQ_ENABLE_DUMP,
|
|
};
|
|
|
|
static int __init rcu_sysrq_init(void)
|
|
{
|
|
if (sysrq_rcu)
|
|
return register_sysrq_key('y', &sysrq_rcudump_op);
|
|
return 0;
|
|
}
|
|
early_initcall(rcu_sysrq_init);
|