https://source.android.com/docs/security/bulletin/2023-04-01 CVE-2022-4696 CVE-2023-20941 * tag 'ASB-2023-04-05_4.19-stable' of https://android.googlesource.com/kernel/common: UPSTREAM: ext4: fix kernel BUG in 'ext4_write_inline_data_end()' UPSTREAM: fsverity: don't drop pagecache at end of FS_IOC_ENABLE_VERITY UPSTREAM: fsverity: Remove WQ_UNBOUND from fsverity read workqueue BACKPORT: blk-mq: clear stale request in tags->rq[] before freeing one request pool Linux 4.19.279 HID: uhid: Over-ride the default maximum data buffer value with our own HID: core: Provide new max_buffer_size attribute to over-ride the default serial: 8250_em: Fix UART port type drm/i915: Don't use stolen memory for ring buffers with LLC x86/mm: Fix use of uninitialized buffer in sme_enable() fbdev: stifb: Provide valid pixelclock and add fb_check_var() checks ftrace: Fix invalid address access in lookup_rec() when index is 0 tracing: Make tracepoint lockdep check actually test something tracing: Check field value in hist_field_name() sh: intc: Avoid spurious sizeof-pointer-div warning drm/amdkfd: Fix an illegal memory access ext4: fix task hung in ext4_xattr_delete_inode ext4: fail ext4_iget if special inode unallocated jffs2: correct logic when creating a hole in jffs2_write_begin mmc: atmel-mci: fix race between stop command and start of next command media: m5mols: fix off-by-one loop termination error hwmon: (xgene) Fix use after free bug in xgene_hwmon_remove due to race condition hwmon: (adt7475) Fix masking of hysteresis registers hwmon: (adt7475) Display smoothing attributes in correct order ethernet: sun: add check for the mdesc_grab() net/iucv: Fix size of interrupt data net: usb: smsc75xx: Move packet length check to prevent kernel panic in skb_pull ipv4: Fix incorrect table ID in IOCTL path block: sunvdc: add check for mdesc_grab() returning NULL nvmet: avoid potential UAF in nvmet_req_complete() net: usb: smsc75xx: Limit packet length to skb->len nfc: st-nci: Fix use after free bug in ndlc_remove due to race condition net: phy: smsc: bail out in lan87xx_read_status if genphy_read_status fails net: tunnels: annotate lockless accesses to dev->needed_headroom qed/qed_dev: guard against a possible division by zero nfc: pn533: initialize struct pn533_out_arg properly tcp: tcp_make_synack() can be called from process context clk: HI655X: select REGMAP instead of depending on it fs: sysfs_emit_at: Remove PAGE_SIZE alignment check ext4: fix cgroup writeback accounting with fs-layer encryption UPSTREAM: ext4: fix another off-by-one fsmap error on 1k block filesystems Linux 4.19.278 ila: do not generate empty messages in ila_xlat_nl_cmd_get_mapping() nfc: fdp: add null check of devm_kmalloc_array in fdp_nci_i2c_read_device_properties net: caif: Fix use-after-free in cfusbl_device_notify() drm/i915: Don't use BAR mappings for ring buffers with LLC tipc: improve function tipc_wait_for_cond() media: ov5640: Fix analogue gain control PCI: Add SolidRun vendor ID macintosh: windfarm: Use unsigned type for 1-bit bitfields alpha: fix R_ALPHA_LITERAL reloc for large modules MIPS: Fix a compilation issue Revert "spi: mt7621: Fix an error message in mt7621_spi_probe()" scsi: core: Remove the /proc/scsi/${proc_name} directory earlier kbuild: generate modules.order only in directories visited by obj-y/m kbuild: fix false-positive need-builtin calculation udf: Detect system inodes linked into directory hierarchy udf: Preserve link count of system files udf: Remove pointless union in udf_inode_info udf: reduce leakage of blocks related to named streams udf: Explain handling of load_nls() failure nfc: change order inside nfc_se_io error path ext4: zero i_disksize when initializing the bootloader inode ext4: fix WARNING in ext4_update_inline_data ext4: move where set the MAY_INLINE_DATA flag is set ext4: fix another off-by-one fsmap error on 1k block filesystems ext4: fix RENAME_WHITEOUT handling for inline directories x86/CPU/AMD: Disable XSAVES on AMD family 0x17 fs: prevent out-of-bounds array speculation when closing a file descriptor Linux 4.19.277 staging: rtl8192e: Remove call_usermodehelper starting RadioPower.sh staging: rtl8192e: Remove function ..dm_check_ac_dc_power calling a script wifi: cfg80211: Partial revert "wifi: cfg80211: Fix use after free for wext" Linux 4.19.276 thermal: intel: powerclamp: Fix cur_state for multi package system f2fs: fix cgroup writeback accounting with fs-layer encryption media: uvcvideo: Fix race condition with usb_kill_urb media: uvcvideo: Provide sync and async uvc_ctrl_status_event tcp: Fix listen() regression in 4.19.270 s390/setup: init jump labels before command line parsing s390/maccess: add no DAT mode to kernel_write Bluetooth: hci_sock: purge socket queues in the destruct() callback phy: rockchip-typec: Fix unsigned comparison with less than zero usb: uvc: Enumerate valid values for color matching USB: ene_usb6250: Allocate enough memory for full object usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_config_word() iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_status_word() tools/iio/iio_utils:fix memory leak mei: bus-fixup:upon error print return values of send and receive tty: serial: fsl_lpuart: disable the CTS when send break signal tty: fix out-of-bounds access in tty_driver_lookup_tty() media: uvcvideo: Silence memcpy() run-time false positive warnings media: uvcvideo: Handle errors from calls to usb_string media: uvcvideo: Handle cameras with invalid descriptors firmware/efi sysfb_efi: Add quirk for Lenovo IdeaPad Duet 3 tracing: Add NULL checks for buffer in ring_buffer_free_read_page() thermal: intel: quark_dts: fix error pointer dereference scsi: ipr: Work around fortify-string warning vc_screen: modify vcs_size() handling in vcs_read() tcp: tcp_check_req() can be called from process context ARM: dts: spear320-hmi: correct STMPE GPIO compatible nfc: fix memory leak of se_io context in nfc_genl_se_io 9p/rdma: unmap receive dma buffer in rdma_request()/post_recv() 9p/xen: fix connection sequence 9p/xen: fix version parsing net: fix __dev_kfree_skb_any() vs drop monitor netfilter: ctnetlink: fix possible refcount leak in ctnetlink_create_conntrack() watchdog: pcwd_usb: Fix attempting to access uninitialized memory watchdog: Fix kmemleak in watchdog_cdev_register watchdog: at91sam9_wdt: use devm_request_irq to avoid missing free_irq() in error path x86: um: vdso: Add '%rcx' and '%r11' to the syscall clobber list ubi: ubi_wl_put_peb: Fix infinite loop when wear-leveling work failed ubi: Fix UAF wear-leveling entry in eraseblk_count_seq_show() ubifs: ubifs_writepage: Mark page dirty after writing inode failed ubifs: dirty_cow_znode: Fix memleak in error handling path ubifs: Re-statistic cleaned znode count if commit failed ubi: Fix possible null-ptr-deref in ubi_free_volume() ubi: Fix unreferenced object reported by kmemleak in ubi_resize_volume() ubi: Fix use-after-free when volume resizing failed ubifs: Reserve one leb for each journal head while doing budget ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1 ubifs: Fix wrong dirty space budget for dirty inode ubifs: Rectify space budget for ubifs_xrename() ubifs: Rectify space budget for ubifs_symlink() if symlink is encrypted ubi: ensure that VID header offset + VID header size <= alloc, size um: vector: Fix memory leak in vector_config pwm: stm32-lp: fix the check on arr and cmp registers update fs/jfs: fix shift exponent db_agl2size negative net/sched: Retire tcindex classifier kbuild: Port silent mode detection to future gnu make. wifi: ath9k: use proper statements in conditionals drm/radeon: Fix eDP for single-display iMac11,2 PCI: Avoid FLR for AMD FCH AHCI adapters scsi: ses: Fix slab-out-of-bounds in ses_intf_remove() scsi: ses: Fix possible desc_ptr out-of-bounds accesses scsi: ses: Fix possible addl_desc_ptr out-of-bounds accesses scsi: ses: Fix slab-out-of-bounds in ses_enclosure_data_process() scsi: ses: Don't attach if enclosure has no components scsi: qla2xxx: Fix erroneous link down scsi: qla2xxx: Fix link failure in NPIV environment ktest.pl: Add RUN_TIMEOUT option with default unlimited ktest.pl: Fix missing "end_monitor" when machine check fails ktest.pl: Give back console on Ctrt^C on monitor media: ipu3-cio2: Fix PM runtime usage_count in driver unbind mips: fix syscall_get_nr alpha: fix FEN fault handling rbd: avoid use-after-free in do_rbd_add() when rbd_dev_create() fails ARM: dts: exynos: correct TMU phandle in Odroid XU ARM: dts: exynos: correct TMU phandle in Exynos4 dm flakey: don't corrupt the zero page dm flakey: fix logic when corrupting a bio wifi: cfg80211: Fix use after free for wext wifi: rtl8xxxu: Use a longer retry limit of 48 ext4: refuse to create ea block when umounted ext4: optimize ea_inode block expansion ALSA: ice1712: Do not left ice->gpio_mutex locked in aureon_add_controls() irqdomain: Drop bogus fwspec-mapping error handling irqdomain: Fix disassociation race irqdomain: Fix association race ima: Align ima_file_mmap() parameters with mmap_file LSM hook Documentation/hw-vuln: Document the interaction between IBRS and STIBP x86/speculation: Allow enabling STIBP with legacy IBRS x86/microcode/AMD: Fix mixed steppings support x86/microcode/AMD: Add a @cpu parameter to the reloading functions x86/microcode/amd: Remove load_microcode_amd()'s bsp parameter x86/kprobes: Fix arch_check_optimized_kprobe check within optimized_kprobe range x86/kprobes: Fix __recover_optprobed_insn check optimizing logic x86/reboot: Disable SVM, not just VMX, when stopping CPUs x86/reboot: Disable virtualization in an emergency if SVM is supported x86/crash: Disable virt in core NMI crash handler to avoid double shootdown x86/virt: Force GIF=1 prior to disabling SVM (for reboot flows) udf: Fix file corruption when appending just after end of preallocated extent udf: Do not update file length for failed writes to inline files udf: Do not bother merging very long extents udf: Truncate added extents on failed expansion ocfs2: fix non-auto defrag path not working issue ocfs2: fix defrag path triggering jbd2 ASSERT f2fs: fix information leak in f2fs_move_inline_dirents() fs: hfsplus: fix UAF issue in hfsplus_put_super hfs: fix missing hfs_bnode_get() in __hfs_bnode_create ARM: dts: exynos: correct HDMI phy compatible in Exynos4 s390/kprobes: fix current_kprobe never cleared after kprobes reenter s390/kprobes: fix irq mask clobbering on kprobe reenter from post_handler s390: discard .interp section rtc: pm8xxx: fix set-alarm race firmware: coreboot: framebuffer: Ignore reserved pixel color bits wifi: rtl8xxxu: fixing transmisison failure for rtl8192eu dm cache: add cond_resched() to various workqueue loops dm thin: add cond_resched() to various workqueue loops pinctrl: at91: use devm_kasprintf() to avoid potential leaks regulator: s5m8767: Bounds check id indexing into arrays regulator: max77802: Bounds check regulator id against opmode ASoC: kirkwood: Iterate over array indexes instead of using pointer math docs/scripts/gdb: add necessary make scripts_gdb step drm/msm/dsi: Add missing check for alloc_ordered_workqueue drm/radeon: free iio for atombios when driver shutdown drm/amd/display: Fix potential null-deref in dm_resume net/mlx5: fw_tracer: Fix debug print ACPI: video: Fix Lenovo Ideapad Z570 DMI match m68k: Check syscall_trace_enter() return code net: bcmgenet: Add a check for oversized packets ACPI: Don't build ACPICA with '-Os' inet: fix fast path in __inet_hash_connect() wifi: brcmfmac: ensure CLM version is null-terminated to prevent stack-out-of-bounds x86/bugs: Reset speculation control settings on init timers: Prevent union confusion from unexpected restart_syscall() thermal: intel: Fix unsigned comparison with less than zero rcu: Suppress smp_processor_id() complaint in synchronize_rcu_expedited_wait() wifi: brcmfmac: Fix potential stack-out-of-bounds in brcmf_c_preinit_dcmds() ARM: dts: exynos: Use Exynos5420 compatible for the MIPI video phy udf: Define EFSCORRUPTED error code rpmsg: glink: Avoid infinite loop on intent for missing channel media: usb: siano: Fix use after free bugs caused by do_submit_urb media: i2c: ov7670: 0 instead of -EINVAL was returned media: rc: Fix use-after-free bugs caused by ene_tx_irqsim() media: i2c: ov772x: Fix memleak in ov772x_probe() powerpc: Remove linker flag from KBUILD_AFLAGS media: platform: ti: Add missing check for devm_regulator_get MIPS: vpe-mt: drop physical_memsize powerpc/rtas: ensure 4KB alignment for rtas_data_buf powerpc/rtas: make all exports GPL powerpc/pseries/lparcfg: add missing RTAS retry status handling clk: Honor CLK_OPS_PARENT_ENABLE in clk_core_is_enabled() powerpc/powernv/ioda: Skip unallocated resources when mapping to PE Input: ads7846 - don't check penirq immediately for 7845 Input: ads7846 - don't report pressure for ads7845 mtd: rawnand: sunxi: Fix the size of the last OOB region mfd: pcf50633-adc: Fix potential memleak in pcf50633_adc_async_read() selftests/ftrace: Fix bash specific "==" operator sparc: allow PM configs for sparc32 COMPILE_TEST perf tools: Fix auto-complete on aarch64 perf llvm: Fix inadvertent file creation gfs2: jdata writepage fix cifs: Fix warning and UAF when destroy the MR list cifs: Fix lost destroy smbd connection when MR allocate failed nfsd: fix race to check ls_layouts dm: remove flush_scheduled_work() during local_exit() hwmon: (mlxreg-fan) Return zero speed for broken fan spi: bcm63xx-hsspi: Fix multi-bit mode setting spi: bcm63xx-hsspi: fix pm_runtime scsi: aic94xx: Add missing check for dma_map_single() hwmon: (ltc2945) Handle error case in ltc2945_value_store gpio: vf610: connect GPIO label to dev name ASoC: soc-compress.c: fixup private_data on snd_soc_new_compress() drm/mediatek: Clean dangling pointer on bind error path drm/mediatek: Drop unbalanced obj unref gpu: host1x: Don't skip assigning syncpoints to channels drm/msm/dpu: Add check for pstates drm/msm: use strscpy instead of strncpy drm/mipi-dsi: Fix byte order of 16-bit DCS set/get brightness ALSA: hda/ca0132: minor fix for allocation size pinctrl: rockchip: Fix refcount leak in rockchip_pinctrl_parse_groups pinctrl: pinctrl-rockchip: Fix a bunch of kerneldoc misdemeanours drm/msm/hdmi: Add missing check for alloc_ordered_workqueue gpu: ipu-v3: common: Add of_node_put() for reference returned by of_graph_get_port_by_id() drm/vc4: dpi: Fix format mapping for RGB565 drm/vc4: dpi: Add option for inverting pixel clock and output enable drm: Clarify definition of the DRM_BUS_FLAG_(PIXDATA|SYNC)_* macros drm/bridge: megachips: Fix error handling in i2c_register_driver() drm: mxsfb: DRM_MXSFB should depend on ARCH_MXS || ARCH_MXC selftest: fib_tests: Always cleanup before exit irqchip/irq-bcm7120-l2: Set IRQ_LEVEL for level triggered interrupts irqchip/irq-brcmstb-l2: Set IRQ_LEVEL for level triggered interrupts can: esd_usb: Move mislocated storage of SJA1000_ECC_SEG bits in case of a bus error wifi: mac80211: make rate u32 in sta_set_rate_info_rx() crypto: crypto4xx - Call dma_unmap_page when done wifi: mwifiex: fix loop iterator in mwifiex_update_ampdu_txwinsize() wifi: iwl4965: Add missing check for create_singlethread_workqueue() wifi: iwl3945: Add missing check for create_singlethread_workqueue RISC-V: time: initialize hrtimer based broadcast clock event device m68k: /proc/hardware should depend on PROC_FS crypto: rsa-pkcs1pad - Use akcipher_request_complete rds: rds_rm_zerocopy_callback() correct order for list_add_tail() libbpf: Fix alen calculation in libbpf_nla_dump_errormsg() Bluetooth: L2CAP: Fix potential user-after-free irqchip/irq-mvebu-gicp: Fix refcount leak in mvebu_gicp_probe irqchip/alpine-msi: Fix refcount leak in alpine_msix_init_domains net/mlx5: Enhance debug print in page allocation failure powercap: fix possible name leak in powercap_register_zone() crypto: seqiv - Handle EBUSY correctly ACPI: battery: Fix missing NUL-termination with large strings wifi: ath9k: Fix potential stack-out-of-bounds write in ath9k_wmi_rsp_callback() wifi: ath9k: hif_usb: clean up skbs if ath9k_hif_usb_rx_stream() fails ath9k: htc: clean up statistics macros ath9k: hif_usb: simplify if-if to if-else wifi: ath9k: htc_hst: free skb in ath9k_htc_rx_msg() if there is no callback function wifi: orinoco: check return value of hermes_write_wordrec() ACPICA: nsrepair: handle cases without a return value correctly lib/mpi: Fix buffer overrun when SG is too long genirq: Fix the return type of kstat_cpu_irqs_sum() ACPICA: Drop port I/O validation for some regions wifi: wl3501_cs: don't call kfree_skb() under spin_lock_irqsave() wifi: libertas: cmdresp: don't call kfree_skb() under spin_lock_irqsave() wifi: libertas: main: don't call kfree_skb() under spin_lock_irqsave() wifi: libertas: if_usb: don't call kfree_skb() under spin_lock_irqsave() wifi: libertas_tf: don't call kfree_skb() under spin_lock_irqsave() wifi: brcmfmac: unmap dma buffer in brcmf_msgbuf_alloc_pktid() wifi: brcmfmac: fix potential memory leak in brcmf_netdev_start_xmit() wifi: ipw2200: fix memory leak in ipw_wdev_init() wifi: ipw2x00: don't call dev_kfree_skb() under spin_lock_irqsave() ipw2x00: switch from 'pci_' to 'dma_' API wifi: rtlwifi: Fix global-out-of-bounds bug in _rtl8812ae_phy_set_txpower_limit() rtlwifi: fix -Wpointer-sign warning wifi: rtl8xxxu: don't call dev_kfree_skb() under spin_lock_irqsave() wifi: libertas: fix memory leak in lbs_init_adapter() wifi: rsi: Fix memory leak in rsi_coex_attach() block: bio-integrity: Copy flags when bio_integrity_payload is cloned blk-mq: remove stale comment for blk_mq_sched_mark_restart_hctx arm64: dts: mediatek: mt7622: Add missing pwm-cells to pwm node arm64: dts: amlogic: meson-gxl: add missing unit address to eth-phy-mux node name arm64: dts: amlogic: meson-gx: add missing unit address to rng node name arm64: dts: amlogic: meson-gx: add missing SCPI sensors compatible arm64: dts: amlogic: meson-axg: fix SCPI clock dvfs node name arm64: dts: meson-axg: enable SCPI arm64: dts: amlogic: meson-gx: fix SCPI clock dvfs node name ARM: imx: Call ida_simple_remove() for ida_simple_get ARM: dts: exynos: correct wr-active property in Exynos3250 Rinato ARM: OMAP1: call platform_device_put() in error case in omap1_dm_timer_init() arm64: dts: meson-gx: Fix the SCPI DVFS node name and unit address arm64: dts: meson-gx: Fix Ethernet MAC address unit name ARM: zynq: Fix refcount leak in zynq_early_slcr_init ARM: OMAP2+: Fix memory leak in realtime_counter_init() HID: asus: use spinlock to safely schedule workers HID: asus: use spinlock to protect concurrent accesses HID: asus: Remove check for same LED brightness on set Change-Id: Ie09175b59aef5de140e476316d94097cac7a3031
814 lines
25 KiB
C
814 lines
25 KiB
C
/*
|
|
* RCU expedited grace periods
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, you can access it online at
|
|
* http://www.gnu.org/licenses/gpl-2.0.html.
|
|
*
|
|
* Copyright IBM Corporation, 2016
|
|
*
|
|
* Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
|
|
*/
|
|
|
|
#include <linux/lockdep.h>
|
|
|
|
/*
|
|
* Record the start of an expedited grace period.
|
|
*/
|
|
static void rcu_exp_gp_seq_start(struct rcu_state *rsp)
|
|
{
|
|
rcu_seq_start(&rsp->expedited_sequence);
|
|
}
|
|
|
|
/*
|
|
* Return then value that expedited-grace-period counter will have
|
|
* at the end of the current grace period.
|
|
*/
|
|
static __maybe_unused unsigned long rcu_exp_gp_seq_endval(struct rcu_state *rsp)
|
|
{
|
|
return rcu_seq_endval(&rsp->expedited_sequence);
|
|
}
|
|
|
|
/*
|
|
* Record the end of an expedited grace period.
|
|
*/
|
|
static void rcu_exp_gp_seq_end(struct rcu_state *rsp)
|
|
{
|
|
rcu_seq_end(&rsp->expedited_sequence);
|
|
smp_mb(); /* Ensure that consecutive grace periods serialize. */
|
|
}
|
|
|
|
/*
|
|
* Take a snapshot of the expedited-grace-period counter.
|
|
*/
|
|
static unsigned long rcu_exp_gp_seq_snap(struct rcu_state *rsp)
|
|
{
|
|
unsigned long s;
|
|
|
|
smp_mb(); /* Caller's modifications seen first by other CPUs. */
|
|
s = rcu_seq_snap(&rsp->expedited_sequence);
|
|
trace_rcu_exp_grace_period(rsp->name, s, TPS("snap"));
|
|
return s;
|
|
}
|
|
|
|
/*
|
|
* Given a counter snapshot from rcu_exp_gp_seq_snap(), return true
|
|
* if a full expedited grace period has elapsed since that snapshot
|
|
* was taken.
|
|
*/
|
|
static bool rcu_exp_gp_seq_done(struct rcu_state *rsp, unsigned long s)
|
|
{
|
|
return rcu_seq_done(&rsp->expedited_sequence, s);
|
|
}
|
|
|
|
/*
|
|
* Reset the ->expmaskinit values in the rcu_node tree to reflect any
|
|
* recent CPU-online activity. Note that these masks are not cleared
|
|
* when CPUs go offline, so they reflect the union of all CPUs that have
|
|
* ever been online. This means that this function normally takes its
|
|
* no-work-to-do fastpath.
|
|
*/
|
|
static void sync_exp_reset_tree_hotplug(struct rcu_state *rsp)
|
|
{
|
|
bool done;
|
|
unsigned long flags;
|
|
unsigned long mask;
|
|
unsigned long oldmask;
|
|
int ncpus = smp_load_acquire(&rsp->ncpus); /* Order against locking. */
|
|
struct rcu_node *rnp;
|
|
struct rcu_node *rnp_up;
|
|
|
|
/* If no new CPUs onlined since last time, nothing to do. */
|
|
if (likely(ncpus == rsp->ncpus_snap))
|
|
return;
|
|
rsp->ncpus_snap = ncpus;
|
|
|
|
/*
|
|
* Each pass through the following loop propagates newly onlined
|
|
* CPUs for the current rcu_node structure up the rcu_node tree.
|
|
*/
|
|
rcu_for_each_leaf_node(rsp, rnp) {
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
if (rnp->expmaskinit == rnp->expmaskinitnext) {
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
continue; /* No new CPUs, nothing to do. */
|
|
}
|
|
|
|
/* Update this node's mask, track old value for propagation. */
|
|
oldmask = rnp->expmaskinit;
|
|
rnp->expmaskinit = rnp->expmaskinitnext;
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
|
|
/* If was already nonzero, nothing to propagate. */
|
|
if (oldmask)
|
|
continue;
|
|
|
|
/* Propagate the new CPU up the tree. */
|
|
mask = rnp->grpmask;
|
|
rnp_up = rnp->parent;
|
|
done = false;
|
|
while (rnp_up) {
|
|
raw_spin_lock_irqsave_rcu_node(rnp_up, flags);
|
|
if (rnp_up->expmaskinit)
|
|
done = true;
|
|
rnp_up->expmaskinit |= mask;
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp_up, flags);
|
|
if (done)
|
|
break;
|
|
mask = rnp_up->grpmask;
|
|
rnp_up = rnp_up->parent;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Reset the ->expmask values in the rcu_node tree in preparation for
|
|
* a new expedited grace period.
|
|
*/
|
|
static void __maybe_unused sync_exp_reset_tree(struct rcu_state *rsp)
|
|
{
|
|
unsigned long flags;
|
|
struct rcu_node *rnp;
|
|
|
|
sync_exp_reset_tree_hotplug(rsp);
|
|
rcu_for_each_node_breadth_first(rsp, rnp) {
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
WARN_ON_ONCE(rnp->expmask);
|
|
rnp->expmask = rnp->expmaskinit;
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Return non-zero if there is no RCU expedited grace period in progress
|
|
* for the specified rcu_node structure, in other words, if all CPUs and
|
|
* tasks covered by the specified rcu_node structure have done their bit
|
|
* for the current expedited grace period. Works only for preemptible
|
|
* RCU -- other RCU implementation use other means.
|
|
*
|
|
* Caller must hold the specificed rcu_node structure's ->lock
|
|
*/
|
|
static bool sync_rcu_preempt_exp_done(struct rcu_node *rnp)
|
|
{
|
|
raw_lockdep_assert_held_rcu_node(rnp);
|
|
|
|
return rnp->exp_tasks == NULL &&
|
|
READ_ONCE(rnp->expmask) == 0;
|
|
}
|
|
|
|
/*
|
|
* Like sync_rcu_preempt_exp_done(), but this function assumes the caller
|
|
* doesn't hold the rcu_node's ->lock, and will acquire and release the lock
|
|
* itself
|
|
*/
|
|
static bool sync_rcu_preempt_exp_done_unlocked(struct rcu_node *rnp)
|
|
{
|
|
unsigned long flags;
|
|
bool ret;
|
|
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
ret = sync_rcu_preempt_exp_done(rnp);
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
/*
|
|
* Report the exit from RCU read-side critical section for the last task
|
|
* that queued itself during or before the current expedited preemptible-RCU
|
|
* grace period. This event is reported either to the rcu_node structure on
|
|
* which the task was queued or to one of that rcu_node structure's ancestors,
|
|
* recursively up the tree. (Calm down, calm down, we do the recursion
|
|
* iteratively!)
|
|
*
|
|
* Caller must hold the specified rcu_node structure's ->lock.
|
|
*/
|
|
static void __rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp,
|
|
bool wake, unsigned long flags)
|
|
__releases(rnp->lock)
|
|
{
|
|
unsigned long mask;
|
|
|
|
for (;;) {
|
|
if (!sync_rcu_preempt_exp_done(rnp)) {
|
|
if (!rnp->expmask)
|
|
rcu_initiate_boost(rnp, flags);
|
|
else
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
break;
|
|
}
|
|
if (rnp->parent == NULL) {
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
if (wake) {
|
|
smp_mb(); /* EGP done before wake_up(). */
|
|
swake_up_one(&rsp->expedited_wq);
|
|
}
|
|
break;
|
|
}
|
|
mask = rnp->grpmask;
|
|
raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled */
|
|
rnp = rnp->parent;
|
|
raw_spin_lock_rcu_node(rnp); /* irqs already disabled */
|
|
WARN_ON_ONCE(!(rnp->expmask & mask));
|
|
rnp->expmask &= ~mask;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Report expedited quiescent state for specified node. This is a
|
|
* lock-acquisition wrapper function for __rcu_report_exp_rnp().
|
|
*/
|
|
static void __maybe_unused rcu_report_exp_rnp(struct rcu_state *rsp,
|
|
struct rcu_node *rnp, bool wake)
|
|
{
|
|
unsigned long flags;
|
|
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
__rcu_report_exp_rnp(rsp, rnp, wake, flags);
|
|
}
|
|
|
|
/*
|
|
* Report expedited quiescent state for multiple CPUs, all covered by the
|
|
* specified leaf rcu_node structure.
|
|
*/
|
|
static void rcu_report_exp_cpu_mult(struct rcu_state *rsp, struct rcu_node *rnp,
|
|
unsigned long mask, bool wake)
|
|
{
|
|
unsigned long flags;
|
|
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
if (!(rnp->expmask & mask)) {
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
return;
|
|
}
|
|
rnp->expmask &= ~mask;
|
|
__rcu_report_exp_rnp(rsp, rnp, wake, flags); /* Releases rnp->lock. */
|
|
}
|
|
|
|
/*
|
|
* Report expedited quiescent state for specified rcu_data (CPU).
|
|
*/
|
|
static void rcu_report_exp_rdp(struct rcu_state *rsp, struct rcu_data *rdp,
|
|
bool wake)
|
|
{
|
|
rcu_report_exp_cpu_mult(rsp, rdp->mynode, rdp->grpmask, wake);
|
|
}
|
|
|
|
/* Common code for synchronize_{rcu,sched}_expedited() work-done checking. */
|
|
static bool sync_exp_work_done(struct rcu_state *rsp, unsigned long s)
|
|
{
|
|
if (rcu_exp_gp_seq_done(rsp, s)) {
|
|
trace_rcu_exp_grace_period(rsp->name, s, TPS("done"));
|
|
/* Ensure test happens before caller kfree(). */
|
|
smp_mb__before_atomic(); /* ^^^ */
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* Funnel-lock acquisition for expedited grace periods. Returns true
|
|
* if some other task completed an expedited grace period that this task
|
|
* can piggy-back on, and with no mutex held. Otherwise, returns false
|
|
* with the mutex held, indicating that the caller must actually do the
|
|
* expedited grace period.
|
|
*/
|
|
static bool exp_funnel_lock(struct rcu_state *rsp, unsigned long s)
|
|
{
|
|
struct rcu_data *rdp = per_cpu_ptr(rsp->rda, raw_smp_processor_id());
|
|
struct rcu_node *rnp = rdp->mynode;
|
|
struct rcu_node *rnp_root = rcu_get_root(rsp);
|
|
|
|
/* Low-contention fastpath. */
|
|
if (ULONG_CMP_LT(READ_ONCE(rnp->exp_seq_rq), s) &&
|
|
(rnp == rnp_root ||
|
|
ULONG_CMP_LT(READ_ONCE(rnp_root->exp_seq_rq), s)) &&
|
|
mutex_trylock(&rsp->exp_mutex))
|
|
goto fastpath;
|
|
|
|
/*
|
|
* Each pass through the following loop works its way up
|
|
* the rcu_node tree, returning if others have done the work or
|
|
* otherwise falls through to acquire rsp->exp_mutex. The mapping
|
|
* from CPU to rcu_node structure can be inexact, as it is just
|
|
* promoting locality and is not strictly needed for correctness.
|
|
*/
|
|
for (; rnp != NULL; rnp = rnp->parent) {
|
|
if (sync_exp_work_done(rsp, s))
|
|
return true;
|
|
|
|
/* Work not done, either wait here or go up. */
|
|
spin_lock(&rnp->exp_lock);
|
|
if (ULONG_CMP_GE(rnp->exp_seq_rq, s)) {
|
|
|
|
/* Someone else doing GP, so wait for them. */
|
|
spin_unlock(&rnp->exp_lock);
|
|
trace_rcu_exp_funnel_lock(rsp->name, rnp->level,
|
|
rnp->grplo, rnp->grphi,
|
|
TPS("wait"));
|
|
wait_event(rnp->exp_wq[rcu_seq_ctr(s) & 0x3],
|
|
sync_exp_work_done(rsp, s));
|
|
return true;
|
|
}
|
|
rnp->exp_seq_rq = s; /* Followers can wait on us. */
|
|
spin_unlock(&rnp->exp_lock);
|
|
trace_rcu_exp_funnel_lock(rsp->name, rnp->level, rnp->grplo,
|
|
rnp->grphi, TPS("nxtlvl"));
|
|
}
|
|
mutex_lock(&rsp->exp_mutex);
|
|
fastpath:
|
|
if (sync_exp_work_done(rsp, s)) {
|
|
mutex_unlock(&rsp->exp_mutex);
|
|
return true;
|
|
}
|
|
rcu_exp_gp_seq_start(rsp);
|
|
trace_rcu_exp_grace_period(rsp->name, s, TPS("start"));
|
|
return false;
|
|
}
|
|
|
|
/* Invoked on each online non-idle CPU for expedited quiescent state. */
|
|
static void sync_sched_exp_handler(void *data)
|
|
{
|
|
struct rcu_data *rdp;
|
|
struct rcu_node *rnp;
|
|
struct rcu_state *rsp = data;
|
|
|
|
rdp = this_cpu_ptr(rsp->rda);
|
|
rnp = rdp->mynode;
|
|
if (!(READ_ONCE(rnp->expmask) & rdp->grpmask) ||
|
|
__this_cpu_read(rcu_sched_data.cpu_no_qs.b.exp))
|
|
return;
|
|
if (rcu_is_cpu_rrupt_from_idle()) {
|
|
rcu_report_exp_rdp(&rcu_sched_state,
|
|
this_cpu_ptr(&rcu_sched_data), true);
|
|
return;
|
|
}
|
|
__this_cpu_write(rcu_sched_data.cpu_no_qs.b.exp, true);
|
|
/* Store .exp before .rcu_urgent_qs. */
|
|
smp_store_release(this_cpu_ptr(&rcu_dynticks.rcu_urgent_qs), true);
|
|
resched_cpu(smp_processor_id());
|
|
}
|
|
|
|
/* Send IPI for expedited cleanup if needed at end of CPU-hotplug operation. */
|
|
static void sync_sched_exp_online_cleanup(int cpu)
|
|
{
|
|
struct rcu_data *rdp;
|
|
int ret;
|
|
struct rcu_node *rnp;
|
|
struct rcu_state *rsp = &rcu_sched_state;
|
|
|
|
rdp = per_cpu_ptr(rsp->rda, cpu);
|
|
rnp = rdp->mynode;
|
|
if (!(READ_ONCE(rnp->expmask) & rdp->grpmask))
|
|
return;
|
|
ret = smp_call_function_single(cpu, sync_sched_exp_handler, rsp, 0);
|
|
WARN_ON_ONCE(ret);
|
|
}
|
|
|
|
/*
|
|
* Select the CPUs within the specified rcu_node that the upcoming
|
|
* expedited grace period needs to wait for.
|
|
*/
|
|
static void sync_rcu_exp_select_node_cpus(struct work_struct *wp)
|
|
{
|
|
int cpu;
|
|
unsigned long flags;
|
|
smp_call_func_t func;
|
|
unsigned long mask_ofl_test;
|
|
unsigned long mask_ofl_ipi;
|
|
int ret;
|
|
struct rcu_exp_work *rewp =
|
|
container_of(wp, struct rcu_exp_work, rew_work);
|
|
struct rcu_node *rnp = container_of(rewp, struct rcu_node, rew);
|
|
struct rcu_state *rsp = rewp->rew_rsp;
|
|
|
|
func = rewp->rew_func;
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
|
|
/* Each pass checks a CPU for identity, offline, and idle. */
|
|
mask_ofl_test = 0;
|
|
for_each_leaf_node_cpu_mask(rnp, cpu, rnp->expmask) {
|
|
unsigned long mask = leaf_node_cpu_bit(rnp, cpu);
|
|
struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
|
|
struct rcu_dynticks *rdtp = per_cpu_ptr(&rcu_dynticks, cpu);
|
|
int snap;
|
|
|
|
if (raw_smp_processor_id() == cpu ||
|
|
!(rnp->qsmaskinitnext & mask)) {
|
|
mask_ofl_test |= mask;
|
|
} else {
|
|
snap = rcu_dynticks_snap(rdtp);
|
|
if (rcu_dynticks_in_eqs(snap))
|
|
mask_ofl_test |= mask;
|
|
else
|
|
rdp->exp_dynticks_snap = snap;
|
|
}
|
|
}
|
|
mask_ofl_ipi = rnp->expmask & ~mask_ofl_test;
|
|
|
|
/*
|
|
* Need to wait for any blocked tasks as well. Note that
|
|
* additional blocking tasks will also block the expedited GP
|
|
* until such time as the ->expmask bits are cleared.
|
|
*/
|
|
if (rcu_preempt_has_tasks(rnp))
|
|
rnp->exp_tasks = rnp->blkd_tasks.next;
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
|
|
/* IPI the remaining CPUs for expedited quiescent state. */
|
|
for_each_leaf_node_cpu_mask(rnp, cpu, rnp->expmask) {
|
|
unsigned long mask = leaf_node_cpu_bit(rnp, cpu);
|
|
struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
|
|
|
|
if (!(mask_ofl_ipi & mask))
|
|
continue;
|
|
retry_ipi:
|
|
if (rcu_dynticks_in_eqs_since(rdp->dynticks,
|
|
rdp->exp_dynticks_snap)) {
|
|
mask_ofl_test |= mask;
|
|
continue;
|
|
}
|
|
ret = smp_call_function_single(cpu, func, rsp, 0);
|
|
if (!ret) {
|
|
mask_ofl_ipi &= ~mask;
|
|
continue;
|
|
}
|
|
/* Failed, raced with CPU hotplug operation. */
|
|
raw_spin_lock_irqsave_rcu_node(rnp, flags);
|
|
if ((rnp->qsmaskinitnext & mask) &&
|
|
(rnp->expmask & mask)) {
|
|
/* Online, so delay for a bit and try again. */
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
trace_rcu_exp_grace_period(rsp->name, rcu_exp_gp_seq_endval(rsp), TPS("selectofl"));
|
|
schedule_timeout_uninterruptible(1);
|
|
goto retry_ipi;
|
|
}
|
|
/* CPU really is offline, so we can ignore it. */
|
|
if (!(rnp->expmask & mask))
|
|
mask_ofl_ipi &= ~mask;
|
|
raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
|
|
}
|
|
/* Report quiescent states for those that went offline. */
|
|
mask_ofl_test |= mask_ofl_ipi;
|
|
if (mask_ofl_test)
|
|
rcu_report_exp_cpu_mult(rsp, rnp, mask_ofl_test, false);
|
|
}
|
|
|
|
/*
|
|
* Select the nodes that the upcoming expedited grace period needs
|
|
* to wait for.
|
|
*/
|
|
static void sync_rcu_exp_select_cpus(struct rcu_state *rsp,
|
|
smp_call_func_t func)
|
|
{
|
|
int cpu;
|
|
struct rcu_node *rnp;
|
|
|
|
trace_rcu_exp_grace_period(rsp->name, rcu_exp_gp_seq_endval(rsp), TPS("reset"));
|
|
sync_exp_reset_tree(rsp);
|
|
trace_rcu_exp_grace_period(rsp->name, rcu_exp_gp_seq_endval(rsp), TPS("select"));
|
|
|
|
/* Schedule work for each leaf rcu_node structure. */
|
|
rcu_for_each_leaf_node(rsp, rnp) {
|
|
rnp->exp_need_flush = false;
|
|
if (!READ_ONCE(rnp->expmask))
|
|
continue; /* Avoid early boot non-existent wq. */
|
|
rnp->rew.rew_func = func;
|
|
rnp->rew.rew_rsp = rsp;
|
|
if (!READ_ONCE(rcu_par_gp_wq) ||
|
|
rcu_scheduler_active != RCU_SCHEDULER_RUNNING ||
|
|
rcu_is_last_leaf_node(rsp, rnp)) {
|
|
/* No workqueues yet or last leaf, do direct call. */
|
|
sync_rcu_exp_select_node_cpus(&rnp->rew.rew_work);
|
|
continue;
|
|
}
|
|
INIT_WORK(&rnp->rew.rew_work, sync_rcu_exp_select_node_cpus);
|
|
preempt_disable();
|
|
cpu = cpumask_next(rnp->grplo - 1, cpu_online_mask);
|
|
/* If all offline, queue the work on an unbound CPU. */
|
|
if (unlikely(cpu > rnp->grphi))
|
|
cpu = WORK_CPU_UNBOUND;
|
|
queue_work_on(cpu, rcu_par_gp_wq, &rnp->rew.rew_work);
|
|
preempt_enable();
|
|
rnp->exp_need_flush = true;
|
|
}
|
|
|
|
/* Wait for workqueue jobs (if any) to complete. */
|
|
rcu_for_each_leaf_node(rsp, rnp)
|
|
if (rnp->exp_need_flush)
|
|
flush_work(&rnp->rew.rew_work);
|
|
}
|
|
|
|
static void synchronize_sched_expedited_wait(struct rcu_state *rsp)
|
|
{
|
|
int cpu;
|
|
unsigned long jiffies_stall;
|
|
unsigned long jiffies_start;
|
|
unsigned long mask;
|
|
int ndetected;
|
|
struct rcu_node *rnp;
|
|
struct rcu_node *rnp_root = rcu_get_root(rsp);
|
|
int ret;
|
|
|
|
trace_rcu_exp_grace_period(rsp->name, rcu_exp_gp_seq_endval(rsp), TPS("startwait"));
|
|
jiffies_stall = rcu_jiffies_till_stall_check();
|
|
jiffies_start = jiffies;
|
|
|
|
for (;;) {
|
|
ret = swait_event_timeout_exclusive(
|
|
rsp->expedited_wq,
|
|
sync_rcu_preempt_exp_done_unlocked(rnp_root),
|
|
jiffies_stall);
|
|
if (ret > 0 || sync_rcu_preempt_exp_done_unlocked(rnp_root))
|
|
return;
|
|
WARN_ON(ret < 0); /* workqueues should not be signaled. */
|
|
if (rcu_cpu_stall_suppress)
|
|
continue;
|
|
panic_on_rcu_stall();
|
|
pr_err("INFO: %s detected expedited stalls on CPUs/tasks: {",
|
|
rsp->name);
|
|
ndetected = 0;
|
|
rcu_for_each_leaf_node(rsp, rnp) {
|
|
ndetected += rcu_print_task_exp_stall(rnp);
|
|
for_each_leaf_node_possible_cpu(rnp, cpu) {
|
|
struct rcu_data *rdp;
|
|
|
|
mask = leaf_node_cpu_bit(rnp, cpu);
|
|
if (!(rnp->expmask & mask))
|
|
continue;
|
|
ndetected++;
|
|
rdp = per_cpu_ptr(rsp->rda, cpu);
|
|
pr_cont(" %d-%c%c%c", cpu,
|
|
"O."[!!cpu_online(cpu)],
|
|
"o."[!!(rdp->grpmask & rnp->expmaskinit)],
|
|
"N."[!!(rdp->grpmask & rnp->expmaskinitnext)]);
|
|
}
|
|
}
|
|
pr_cont(" } %lu jiffies s: %lu root: %#lx/%c\n",
|
|
jiffies - jiffies_start, rsp->expedited_sequence,
|
|
rnp_root->expmask, ".T"[!!rnp_root->exp_tasks]);
|
|
if (ndetected) {
|
|
pr_err("blocking rcu_node structures:");
|
|
rcu_for_each_node_breadth_first(rsp, rnp) {
|
|
if (rnp == rnp_root)
|
|
continue; /* printed unconditionally */
|
|
if (sync_rcu_preempt_exp_done_unlocked(rnp))
|
|
continue;
|
|
pr_cont(" l=%u:%d-%d:%#lx/%c",
|
|
rnp->level, rnp->grplo, rnp->grphi,
|
|
rnp->expmask,
|
|
".T"[!!rnp->exp_tasks]);
|
|
}
|
|
pr_cont("\n");
|
|
}
|
|
rcu_for_each_leaf_node(rsp, rnp) {
|
|
for_each_leaf_node_possible_cpu(rnp, cpu) {
|
|
mask = leaf_node_cpu_bit(rnp, cpu);
|
|
if (!(rnp->expmask & mask))
|
|
continue;
|
|
preempt_disable(); // For smp_processor_id() in dump_cpu_task().
|
|
dump_cpu_task(cpu);
|
|
preempt_enable();
|
|
}
|
|
}
|
|
jiffies_stall = 3 * rcu_jiffies_till_stall_check() + 3;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Wait for the current expedited grace period to complete, and then
|
|
* wake up everyone who piggybacked on the just-completed expedited
|
|
* grace period. Also update all the ->exp_seq_rq counters as needed
|
|
* in order to avoid counter-wrap problems.
|
|
*/
|
|
static void rcu_exp_wait_wake(struct rcu_state *rsp, unsigned long s)
|
|
{
|
|
struct rcu_node *rnp;
|
|
|
|
synchronize_sched_expedited_wait(rsp);
|
|
|
|
/* Switch over to wakeup mode, allowing the next GP to proceed.
|
|
* End the previous grace period only after acquiring the mutex
|
|
* to ensure that only one GP runs concurrently with wakeups.
|
|
*/
|
|
mutex_lock(&rsp->exp_wake_mutex);
|
|
rcu_exp_gp_seq_end(rsp);
|
|
trace_rcu_exp_grace_period(rcu_state.name, s, TPS("end"));
|
|
|
|
rcu_for_each_node_breadth_first(rsp, rnp) {
|
|
if (ULONG_CMP_LT(READ_ONCE(rnp->exp_seq_rq), s)) {
|
|
spin_lock(&rnp->exp_lock);
|
|
/* Recheck, avoid hang in case someone just arrived. */
|
|
if (ULONG_CMP_LT(rnp->exp_seq_rq, s))
|
|
rnp->exp_seq_rq = s;
|
|
spin_unlock(&rnp->exp_lock);
|
|
}
|
|
smp_mb(); /* All above changes before wakeup. */
|
|
wake_up_all(&rnp->exp_wq[rcu_seq_ctr(s) & 0x3]);
|
|
}
|
|
trace_rcu_exp_grace_period(rsp->name, s, TPS("endwake"));
|
|
mutex_unlock(&rsp->exp_wake_mutex);
|
|
}
|
|
|
|
/*
|
|
* Common code to drive an expedited grace period forward, used by
|
|
* workqueues and mid-boot-time tasks.
|
|
*/
|
|
static void rcu_exp_sel_wait_wake(struct rcu_state *rsp,
|
|
smp_call_func_t func, unsigned long s)
|
|
{
|
|
/* Initialize the rcu_node tree in preparation for the wait. */
|
|
sync_rcu_exp_select_cpus(rsp, func);
|
|
|
|
/* Wait and clean up, including waking everyone. */
|
|
rcu_exp_wait_wake(rsp, s);
|
|
}
|
|
|
|
/*
|
|
* Work-queue handler to drive an expedited grace period forward.
|
|
*/
|
|
static void wait_rcu_exp_gp(struct work_struct *wp)
|
|
{
|
|
struct rcu_exp_work *rewp;
|
|
|
|
rewp = container_of(wp, struct rcu_exp_work, rew_work);
|
|
rcu_exp_sel_wait_wake(rewp->rew_rsp, rewp->rew_func, rewp->rew_s);
|
|
}
|
|
|
|
/*
|
|
* Given an rcu_state pointer and a smp_call_function() handler, kick
|
|
* off the specified flavor of expedited grace period.
|
|
*/
|
|
static void _synchronize_rcu_expedited(struct rcu_state *rsp,
|
|
smp_call_func_t func)
|
|
{
|
|
struct rcu_data *rdp;
|
|
struct rcu_exp_work rew;
|
|
struct rcu_node *rnp;
|
|
unsigned long s;
|
|
|
|
/* If expedited grace periods are prohibited, fall back to normal. */
|
|
if (rcu_gp_is_normal()) {
|
|
wait_rcu_gp(rsp->call);
|
|
return;
|
|
}
|
|
|
|
/* Take a snapshot of the sequence number. */
|
|
s = rcu_exp_gp_seq_snap(rsp);
|
|
if (exp_funnel_lock(rsp, s))
|
|
return; /* Someone else did our work for us. */
|
|
|
|
/* Ensure that load happens before action based on it. */
|
|
if (unlikely(rcu_scheduler_active == RCU_SCHEDULER_INIT)) {
|
|
/* Direct call during scheduler init and early_initcalls(). */
|
|
rcu_exp_sel_wait_wake(rsp, func, s);
|
|
} else {
|
|
/* Marshall arguments & schedule the expedited grace period. */
|
|
rew.rew_func = func;
|
|
rew.rew_rsp = rsp;
|
|
rew.rew_s = s;
|
|
INIT_WORK_ONSTACK(&rew.rew_work, wait_rcu_exp_gp);
|
|
queue_work(rcu_gp_wq, &rew.rew_work);
|
|
}
|
|
|
|
/* Wait for expedited grace period to complete. */
|
|
rdp = per_cpu_ptr(rsp->rda, raw_smp_processor_id());
|
|
rnp = rcu_get_root(rsp);
|
|
wait_event(rnp->exp_wq[rcu_seq_ctr(s) & 0x3],
|
|
sync_exp_work_done(rsp, s));
|
|
smp_mb(); /* Workqueue actions happen before return. */
|
|
|
|
/* Let the next expedited grace period start. */
|
|
mutex_unlock(&rsp->exp_mutex);
|
|
}
|
|
|
|
/**
|
|
* synchronize_sched_expedited - Brute-force RCU-sched grace period
|
|
*
|
|
* Wait for an RCU-sched grace period to elapse, but use a "big hammer"
|
|
* approach to force the grace period to end quickly. This consumes
|
|
* significant time on all CPUs and is unfriendly to real-time workloads,
|
|
* so is thus not recommended for any sort of common-case code. In fact,
|
|
* if you are using synchronize_sched_expedited() in a loop, please
|
|
* restructure your code to batch your updates, and then use a single
|
|
* synchronize_sched() instead.
|
|
*
|
|
* This implementation can be thought of as an application of sequence
|
|
* locking to expedited grace periods, but using the sequence counter to
|
|
* determine when someone else has already done the work instead of for
|
|
* retrying readers.
|
|
*/
|
|
void synchronize_sched_expedited(void)
|
|
{
|
|
struct rcu_state *rsp = &rcu_sched_state;
|
|
|
|
RCU_LOCKDEP_WARN(lock_is_held(&rcu_bh_lock_map) ||
|
|
lock_is_held(&rcu_lock_map) ||
|
|
lock_is_held(&rcu_sched_lock_map),
|
|
"Illegal synchronize_sched_expedited() in RCU read-side critical section");
|
|
|
|
/* If only one CPU, this is automatically a grace period. */
|
|
if (rcu_blocking_is_gp())
|
|
return;
|
|
|
|
_synchronize_rcu_expedited(rsp, sync_sched_exp_handler);
|
|
}
|
|
EXPORT_SYMBOL_GPL(synchronize_sched_expedited);
|
|
|
|
#ifdef CONFIG_PREEMPT_RCU
|
|
|
|
/*
|
|
* Remote handler for smp_call_function_single(). If there is an
|
|
* RCU read-side critical section in effect, request that the
|
|
* next rcu_read_unlock() record the quiescent state up the
|
|
* ->expmask fields in the rcu_node tree. Otherwise, immediately
|
|
* report the quiescent state.
|
|
*/
|
|
static void sync_rcu_exp_handler(void *info)
|
|
{
|
|
struct rcu_data *rdp;
|
|
struct rcu_state *rsp = info;
|
|
struct task_struct *t = current;
|
|
|
|
/*
|
|
* Within an RCU read-side critical section, request that the next
|
|
* rcu_read_unlock() report. Unless this RCU read-side critical
|
|
* section has already blocked, in which case it is already set
|
|
* up for the expedited grace period to wait on it.
|
|
*/
|
|
if (t->rcu_read_lock_nesting > 0 &&
|
|
!t->rcu_read_unlock_special.b.blocked) {
|
|
t->rcu_read_unlock_special.b.exp_need_qs = true;
|
|
return;
|
|
}
|
|
|
|
/*
|
|
* We are either exiting an RCU read-side critical section (negative
|
|
* values of t->rcu_read_lock_nesting) or are not in one at all
|
|
* (zero value of t->rcu_read_lock_nesting). Or we are in an RCU
|
|
* read-side critical section that blocked before this expedited
|
|
* grace period started. Either way, we can immediately report
|
|
* the quiescent state.
|
|
*/
|
|
rdp = this_cpu_ptr(rsp->rda);
|
|
rcu_report_exp_rdp(rsp, rdp, true);
|
|
}
|
|
|
|
/**
|
|
* synchronize_rcu_expedited - Brute-force RCU grace period
|
|
*
|
|
* Wait for an RCU-preempt grace period, but expedite it. The basic
|
|
* idea is to IPI all non-idle non-nohz online CPUs. The IPI handler
|
|
* checks whether the CPU is in an RCU-preempt critical section, and
|
|
* if so, it sets a flag that causes the outermost rcu_read_unlock()
|
|
* to report the quiescent state. On the other hand, if the CPU is
|
|
* not in an RCU read-side critical section, the IPI handler reports
|
|
* the quiescent state immediately.
|
|
*
|
|
* Although this is a greate improvement over previous expedited
|
|
* implementations, it is still unfriendly to real-time workloads, so is
|
|
* thus not recommended for any sort of common-case code. In fact, if
|
|
* you are using synchronize_rcu_expedited() in a loop, please restructure
|
|
* your code to batch your updates, and then Use a single synchronize_rcu()
|
|
* instead.
|
|
*/
|
|
void synchronize_rcu_expedited(void)
|
|
{
|
|
struct rcu_state *rsp = rcu_state_p;
|
|
|
|
RCU_LOCKDEP_WARN(lock_is_held(&rcu_bh_lock_map) ||
|
|
lock_is_held(&rcu_lock_map) ||
|
|
lock_is_held(&rcu_sched_lock_map),
|
|
"Illegal synchronize_rcu_expedited() in RCU read-side critical section");
|
|
|
|
if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE)
|
|
return;
|
|
_synchronize_rcu_expedited(rsp, sync_rcu_exp_handler);
|
|
}
|
|
EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
|
|
|
|
#else /* #ifdef CONFIG_PREEMPT_RCU */
|
|
|
|
/*
|
|
* Wait for an rcu-preempt grace period, but make it happen quickly.
|
|
* But because preemptible RCU does not exist, map to rcu-sched.
|
|
*/
|
|
void synchronize_rcu_expedited(void)
|
|
{
|
|
synchronize_sched_expedited();
|
|
}
|
|
EXPORT_SYMBOL_GPL(synchronize_rcu_expedited);
|
|
|
|
#endif /* #else #ifdef CONFIG_PREEMPT_RCU */
|