83fdf72a16
* remotes/origin/tmp-4716ccc : UPSTREAM: media: rc: Fix use-after-free bugs caused by ene_tx_irqsim() ANDROID: incremental fs: Evict inodes before freeing mount data UPSTREAM: ext4: fix kernel BUG in 'ext4_write_inline_data_end()' UPSTREAM: hid: bigben_probe(): validate report count UPSTREAM: HID: bigben: use spinlock to safely schedule workers BACKPORT: of: base: Skip CPU nodes with "fail"/"fail-..." status UPSTREAM: HID: bigben_worker() remove unneeded check on report_field UPSTREAM: HID: bigben: use spinlock to protect concurrent accesses UPSTREAM: hwrng: virtio - add an internal buffer UPSTREAM: ext4: fix another off-by-one fsmap error on 1k block filesystems UPSTREAM: ext4: refuse to create ea block when umounted UPSTREAM: ext4: optimize ea_inode block expansion UPSTREAM: ext4: allocate extended attribute value in vmalloc area BACKPORT: FROMGIT: cgroup: Use separate src/dst nodes when preloading css_sets for migration ANDROID: fs/f2fs: fixup __f2fs_cluster_blocks with F2FS_FS_COMPRESSION UPSTREAM: usb: gadget: f_fs: Ensure ep0req is dequeued before free_request UPSTREAM: KVM: VMX: Execute IBPB on emulated VM-exit when guest has IBRS Revert "iommu: Add gfp parameter to iommu_ops::map" Revert "iommu/amd: Pass gfp flags to iommu_map_page() in amd_iommu_map()" Revert "RDMA/usnic: use iommu_map_atomic() under spin_lock()" Linux 5.4.233 bpf: add missing header file include Revert "net/sched: taprio: make qdisc_leaf() see the per-netdev-queue pfifo child qdiscs" ext4: Fix function prototype mismatch for ext4_feat_ktype wifi: mwifiex: Add missing compatible string for SD8787 uaccess: Add speculation barrier to copy_from_user() mac80211: mesh: embedd mesh_paths and mpp_paths into ieee80211_if_mesh drm/i915/gvt: fix double free bug in split_2MB_gtt_entry alarmtimer: Prevent starvation by small intervals and SIG_IGN powerpc: dts: t208x: Disable 10G on MAC1 and MAC2 can: kvaser_usb: hydra: help gcc-13 to figure out cmd_len KVM: VMX: Execute IBPB on emulated VM-exit when guest has IBRS KVM: x86: Fail emulation during EMULTYPE_SKIP on any exception random: always mix cycle counter in add_latent_entropy() powerpc: dts: t208x: Mark MAC1 and MAC2 as 10G wifi: rtl8xxxu: gen2: Turn on the rate control drm/etnaviv: don't truncate physical page address drm: etnaviv: fix common struct sg_table related issues scatterlist: add generic wrappers for iterating over sgtable objects dma-mapping: add generic helpers for mapping sgtable objects Linux 5.4.232 iommu/amd: Pass gfp flags to iommu_map_page() in amd_iommu_map() net: sched: sch: Fix off by one in htb_activate_prios() ASoC: SOF: Intel: hda-dai: fix possible stream_tag leak nilfs2: fix underflow in second superblock position calculations kvm: initialize all of the kvm_debugregs structure before sending it to userspace i40e: Add checking for null for nlmsg_find_attr() ipv6: Fix tcp socket connection with DSCP. ipv6: Fix datagram socket connection with DSCP. ixgbe: add double of VLAN header when computing the max MTU net: mpls: fix stale pointer if allocation fails during device rename net: stmmac: Restrict warning on disabling DMA store and fwd mode bnxt_en: Fix mqprio and XDP ring checking logic net: stmmac: fix order of dwmac5 FlexPPS parametrization sequence net/usb: kalmia: Don't pass act_len in usb_bulk_msg error path dccp/tcp: Avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions. sctp: sctp_sock_filter(): avoid list_entry() on possibly empty list net: bgmac: fix BCM5358 support by setting correct flags i40e: add double of VLAN header when computing the max MTU ixgbe: allow to increase MTU to 3K with XDP enabled revert "squashfs: harden sanity check in squashfs_read_xattr_id_table" net: Fix unwanted sign extension in netdev_stats_to_stats64() Revert "mm: Always release pages to the buddy allocator in memblock_free_late()." hugetlb: check for undefined shift on 32 bit architectures sched/psi: Fix use-after-free in ep_remove_wait_queue() ALSA: hda/realtek - fixed wrong gpio assigned ALSA: hda/conexant: add a new hda codec SN6180 mmc: mmc_spi: fix error handling in mmc_spi_probe() mmc: sdio: fix possible resource leaks in some error paths ipv4: Fix incorrect route flushing when source address is deleted Revert "ipv4: Fix incorrect route flushing when source address is deleted" xfs: sync lazy sb accounting on quiesce of read-only mounts xfs: prevent UAF in xfs_log_item_in_current_chkpt xfs: fix the forward progress assertion in xfs_iwalk_run_callbacks xfs: ensure inobt record walks always make forward progress xfs: fix missing CoW blocks writeback conversion retry xfs: only relog deferred intent items if free space in the log gets low xfs: expose the log push threshold xfs: periodically relog deferred intent items xfs: change the order in which child and parent defer ops are finished xfs: fix an incore inode UAF in xfs_bui_recover xfs: clean up xfs_bui_item_recover iget/trans_alloc/ilock ordering xfs: clean up bmap intent item recovery checking xfs: xfs_defer_capture should absorb remaining transaction reservation xfs: xfs_defer_capture should absorb remaining block reservations xfs: proper replay of deferred ops queued during log recovery xfs: fix finobt btree block recovery ordering xfs: log new intent items created as part of finishing recovered intent items xfs: refactor xfs_defer_finish_noroll xfs: turn dfp_intent into a xfs_log_item xfs: merge the ->diff_items defer op into ->create_intent xfs: merge the ->log_item defer op into ->create_intent xfs: factor out a xfs_defer_create_intent helper xfs: remove the xfs_inode_log_item_t typedef xfs: remove the xfs_efd_log_item_t typedef xfs: remove the xfs_efi_log_item_t typedef netfilter: nft_tproxy: restrict to prerouting hook btrfs: free device in btrfs_close_devices for a single device filesystem aio: fix mremap after fork null-deref nvme-fc: fix a missing queue put in nvmet_fc_ls_create_association s390/decompressor: specify __decompress() buf len to avoid overflow net: sched: sch: Bounds check priority net: stmmac: do not stop RX_CLK in Rx LPI state for qcs404 SoC net/rose: Fix to not accept on connected socket tools/virtio: fix the vringh test for virtio ring changes ASoC: cs42l56: fix DT probe selftests/bpf: Verify copy_register_state() preserves parent/live fields migrate: hugetlb: check for hugetlb shared PMD in node migration bpf: Always return target ifindex in bpf_fib_lookup nvme-pci: Move enumeration by class to be last in the table arm64: dts: meson-axg: Make mmc host controller interrupts level-sensitive arm64: dts: meson-g12-common: Make mmc host controller interrupts level-sensitive arm64: dts: meson-gx: Make mmc host controller interrupts level-sensitive riscv: Fixup race condition on PG_dcache_clean in flush_icache_pte ceph: flush cap releases when the session is flushed usb: typec: altmodes/displayport: Fix probe pin assign check usb: core: add quirk for Alcor Link AK9563 smartcard reader net: USB: Fix wrong-direction WARNING in plusb.c pinctrl: intel: Restore the pins that used to be in Direct IRQ mode pinctrl: single: fix potential NULL dereference pinctrl: aspeed: Fix confusing types in return value ALSA: pci: lx6464es: fix a debug loop selftests: forwarding: lib: quote the sysctl values rds: rds_rm_zerocopy_callback() use list_first_entry() ice: Do not use WQ_MEM_RECLAIM flag for workqueue ionic: clean interrupt before enabling queue to avoid credit race net: phy: meson-gxl: use MMD access dummy stubs for GXL, internal PHY bonding: fix error checking in bond_debug_reregister() xfrm: fix bug with DSCP copy to v6 from v4 tunnel RDMA/usnic: use iommu_map_atomic() under spin_lock() iommu: Add gfp parameter to iommu_ops::map IB/IPoIB: Fix legacy IPoIB due to wrong number of queues IB/hfi1: Restore allocated resources on failed copyout can: j1939: do not wait 250 ms if the same addr was already claimed tracing: Fix poll() and select() do not work on per_cpu trace_pipe and trace_pipe_raw ALSA: emux: Avoid potential array out-of-bound in snd_emux_xg_control() btrfs: zlib: zero-initialize zlib workspace btrfs: limit device extents to the device size iio:adc:twl6030: Enable measurement of VAC wifi: brcmfmac: Check the count value of channel spec to prevent out-of-bounds reads f2fs: fix to do sanity check on i_extra_isize in is_alive() fbdev: smscufx: fix error handling code in ufx_usb_probe powerpc/imc-pmu: Revert nest_init_lock to being a mutex serial: 8250_dma: Fix DMA Rx rearm race serial: 8250_dma: Fix DMA Rx completion race xprtrdma: Fix regbuf data not freed in rpcrdma_req_create() mm: swap: properly update readahead statistics in unuse_pte_range() nvmem: core: fix cell removal on error Squashfs: fix handling and sanity checking of xattr_ids count mm/swapfile: add cond_resched() in get_swap_pages() fpga: stratix10-soc: Fix return value check in s10_ops_write_init() mm: hugetlb: proc: check for hugetlb shared PMD in /proc/PID/smaps riscv: disable generation of unwind tables parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case parisc: Fix return code of pdc_iodc_print() iio:adc:twl6030: Enable measurements of VUSB, VBAT and others iio: adc: berlin2-adc: Add missing of_node_put() in error path iio: hid: fix the retval in accel_3d_capture_sample efi: Accept version 2 of memory attributes table watchdog: diag288_wdt: fix __diag288() inline assembly watchdog: diag288_wdt: do not use stack buffers for hardware data fbcon: Check font dimension limits Input: i8042 - add Clevo PCX0DX to i8042 quirk table Input: i8042 - add TUXEDO devices to i8042 quirk tables Input: i8042 - merge quirk tables Input: i8042 - move __initconst to fix code styling warning vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF usb: gadget: f_fs: Fix unbalanced spinlock in __ffs_ep0_queue_wait usb: dwc3: qcom: enable vbus override when in OTG dr-mode usb: dwc3: dwc3-qcom: Fix typo in the dwc3 vbus override API iio: adc: stm32-dfsdm: fill module aliases net/x25: Fix to not accept on connected socket i2c: rk3x: fix a bunch of kernel-doc warnings scsi: iscsi_tcp: Fix UAF during login when accessing the shost ipaddress scsi: target: core: Fix warning on RT kernels efi: fix potential NULL deref in efi_mem_reserve_persistent net: openvswitch: fix flow memory leak in ovs_flow_cmd_new virtio-net: Keep stop() to follow mirror sequence of open() selftests: net: udpgso_bench_tx: Cater for pending datagrams zerocopy benchmarking selftests: net: udpgso_bench: Fix racing bug between the rx/tx programs selftests: net: udpgso_bench_rx/tx: Stop when wrong CLI args are provided selftests: net: udpgso_bench_rx: Fix 'used uninitialized' compiler warning ata: libata: Fix sata_down_spd_limit() when no link speed is reported can: j1939: fix errant WARN_ON_ONCE in j1939_session_deactivate net: phy: meson-gxl: Add generic dummy stubs for MMD register access squashfs: harden sanity check in squashfs_read_xattr_id_table netfilter: br_netfilter: disable sabotage_in hook after first suppression netrom: Fix use-after-free caused by accept on already connected socket fix "direction" argument of iov_iter_kvec() fix iov_iter_bvec() "direction" argument WRITE is "data source", not destination... scsi: Revert "scsi: core: map PQ=1, PDT=other values to SCSI_SCAN_TARGET_PRESENT" arm64: dts: imx8mm: Fix pad control for UART1_DTE_RX ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path() ASoC: Intel: bytcr_rt5651: Drop reference count of ACPI device after use bus: sunxi-rsb: Fix error handling in sunxi_rsb_init() firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region Linux 5.4.231 Revert "xprtrdma: Fix regbuf data not freed in rpcrdma_req_create()" usb: host: xhci-plat: add wakeup entry at sysfs Bluetooth: fix null ptr deref on hci_sync_conn_complete_evt ipv6: ensure sane device mtu in tunnels exit: Use READ_ONCE() for all oops/warn limit reads docs: Fix path paste-o for /sys/kernel/warn_count panic: Expose "warn_count" to sysfs panic: Introduce warn_limit panic: Consolidate open-coded panic_on_warn checks exit: Allow oops_limit to be disabled exit: Expose "oops_count" to sysfs exit: Put an upper limit on how often we can oops ia64: make IA64_MCA_RECOVERY bool instead of tristate csky: Fix function name in csky_alignment() and die() h8300: Fix build errors from do_exit() to make_task_dead() transition hexagon: Fix function name in die() objtool: Add a missing comma to avoid string concatenation exit: Add and use make_task_dead. mm: kasan: do not panic if both panic_on_warn and kasan_multishot set panic: unset panic_on_warn inside panic() sysctl: add a new register_sysctl_init() interface dmaengine: imx-sdma: Fix a possible memory leak in sdma_transfer_init blk-cgroup: fix missing pd_online_fn() while activating policy bpf: Skip task with pid=1 in send_signal_common() ARM: dts: imx: Fix pca9547 i2c-mux node name x86/asm: Fix an assembler warning with current binutils clk: Fix pointer casting to prevent oops in devm_clk_release() perf/x86/amd: fix potential integer overflow on shift of a int netfilter: conntrack: unify established states for SCTP paths x86/i8259: Mark legacy PIC interrupts with IRQ_LEVEL block: fix and cleanup bio_check_ro nfsd: Ensure knfsd shuts down when the "nfsd" pseudofs is unmounted Revert "Input: synaptics - switch touchpad on HP Laptop 15-da3001TU to RMI mode" net: mdio-mux-meson-g12a: force internal PHY off on mux switch net: xgene: Move shared header file into include/linux net/phy/mdio-i2c: Move header file to include/linux/mdio net/tg3: resolve deadlock in tg3_reset_task() during EEH thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type() net: ravb: Fix possible hang if RIS2_QFF1 happen sctp: fail if no bound addresses can be used for a given scope net/sched: sch_taprio: do not schedule in taprio_reset() netrom: Fix use-after-free of a listening socket. netfilter: conntrack: fix vtag checks for ABORT/SHUTDOWN_COMPLETE ipv4: prevent potential spectre v1 gadget in fib_metrics_match() ipv4: prevent potential spectre v1 gadget in ip_metrics_convert() netlink: annotate data races around sk_state netlink: annotate data races around dst_portid and dst_group netlink: annotate data races around nlk->portid netfilter: nft_set_rbtree: skip elements in transaction from garbage collection net: fix UaF in netns ops registration error path netlink: prevent potential spectre v1 gadgets EDAC/qcom: Do not pass llcc_driv_data as edac_device_ctl_info's pvt_info EDAC/device: Respect any driver-supplied workqueue polling value ARM: 9280/1: mm: fix warning on phys_addr_t to void pointer assignment thermal: intel: int340x: Protect trip temperature from concurrent updates KVM: x86/vmx: Do not skip segment attributes if unusable bit is set cifs: Fix oops due to uncleared server->smbd_conn in reconnect ftrace/scripts: Update the instructions for ftrace-bisect.sh trace_events_hist: add check for return value of 'create_hist_field' tracing: Make sure trace_printk() can output as soon as it can be used module: Don't wait for GOING modules scsi: hpsa: Fix allocation size for scsi_host_alloc() Bluetooth: hci_sync: cancel cmd_timer if hci_open failed Revert "Revert "xhci: Set HCD flag to defer primary roothub registration"" fs: reiserfs: remove useless new_opts in reiserfs_remount netfilter: conntrack: do not renew entry stuck in tcp SYN_SENT state Revert "selftests/bpf: check null propagation only neither reg is PTR_TO_BTF_ID" mmc: sdhci-esdhc-imx: correct the tuning start tap and step setting mmc: sdhci-esdhc-imx: disable the CMD CRC check for standard tuning mmc: sdhci-esdhc-imx: clear pending interrupt and halt cqhci lockref: stop doing cpu_relax in the cmpxchg loop platform/x86: asus-nb-wmi: Add alternate mapping for KEY_SCREENLOCK platform/x86: touchscreen_dmi: Add info for the CSL Panther Tab HD scsi: hisi_sas: Set a port invalid only if there are no devices attached when refreshing port id KVM: s390: interrupt: use READ_ONCE() before cmpxchg() spi: spidev: remove debug messages that access spidev->spi without locking ASoC: fsl-asoc-card: Fix naming of AC'97 CODEC widgets ASoC: fsl_ssi: Rename AC'97 streams to avoid collisions with AC'97 CODEC cpufreq: armada-37xx: stop using 0 as NULL pointer s390/debug: add _ASM_S390_ prefix to header guard drm: Add orientation quirk for Lenovo ideapad D330-10IGL ASoC: fsl_micfil: Correct the number of steps on SX controls cpufreq: Add Tegra234 to cpufreq-dt-platdev blocklist tcp: fix rate_app_limited to default to 1 net: dsa: microchip: ksz9477: port map correction in ALU table entry register driver core: Fix test_async_probe_init saves device in wrong array w1: fix WARNING after calling w1_process() w1: fix deadloop in __w1_remove_master_device() tcp: avoid the lookup process failing to get sk in ehash table dmaengine: xilinx_dma: call of_node_put() when breaking out of for_each_child_of_node() dmaengine: xilinx_dma: Fix devm_platform_ioremap_resource error handling dmaengine: xilinx_dma: use devm_platform_ioremap_resource() HID: betop: check shape of output reports net: macb: fix PTP TX timestamp failure due to packet padding dmaengine: Fix double increment of client_count in dma_chan_get() drm/panfrost: fix GENERIC_ATOMIC64 dependency net: mlx5: eliminate anonymous module_init & module_exit usb: gadget: f_fs: Ensure ep0req is dequeued before free_request usb: gadget: f_fs: Prevent race during ffs_ep0_queue_wait HID: revert CHERRY_MOUSE_000C quirk net: stmmac: fix invalid call to mdiobus_get_phy() HID: check empty report_list in bigben_probe() HID: check empty report_list in hid_validate_values() net: mdio: validate parameter addr in mdiobus_get_phy() net: usb: sr9700: Handle negative len l2tp: Don't sleep and disable BH under writer-side sk_callback_lock l2tp: Serialize access to sk_user_data with sk_callback_lock net: fix a concurrency bug in l2tp_tunnel_register() net/sched: sch_taprio: fix possible use-after-free wifi: rndis_wlan: Prevent buffer overflow in rndis_query_oid gpio: mxc: Always set GPIOs used as interrupt source to INPUT mode net: wan: Add checks for NULL for utdm in undo_uhdlc_init and unmap_si_regs net: nfc: Fix use-after-free in local_cleanup() phy: rockchip-inno-usb2: Fix missing clk_disable_unprepare() in rockchip_usb2phy_power_on() bpf: Fix pointer-leak due to insufficient speculative store bypass mitigation amd-xgbe: Delay AN timeout during KR training amd-xgbe: TX Flow Ctrl Registers are h/w ver dependent affs: initialize fsdata in affs_truncate() IB/hfi1: Fix expected receive setup error exit issues IB/hfi1: Reserve user expected TIDs IB/hfi1: Reject a zero-length user expected buffer RDMA/core: Fix ib block iterator counter overflow tomoyo: fix broken dependency on *.conf.default EDAC/highbank: Fix memory leak in highbank_mc_probe() HID: intel_ish-hid: Add check for ishtp_dma_tx_map ARM: imx: add missing of_node_put() ARM: imx35: Retrieve the IIM base address from devicetree ARM: imx31: Retrieve the IIM base address from devicetree ARM: imx27: Retrieve the SYSCTRL base address from devicetree ARM: dts: imx6qdl-gw560x: Remove incorrect 'uart-has-rtscts' memory: mvebu-devbus: Fix missing clk_disable_unprepare in mvebu_devbus_probe() memory: atmel-sdramc: Fix missing clk_disable_unprepare in atmel_ramc_probe() clk: Provide new devm_clk helpers for prepared and enabled clocks clk: generalize devm_clk_get() a bit Linux 5.4.230 mm/khugepaged: fix collapse_pte_mapped_thp() to allow anon_vma x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN drm/amd/display: Fix COLOR_SPACE_YCBCR2020_TYPE matrix drm/amd/display: Fix set scaling doesn's work drm/i915: re-disable RC6p on Sandy Bridge gsmi: fix null-deref in gsmi_get_variable serial: atmel: fix incorrect baudrate setup dmaengine: tegra210-adma: fix global intr clear serial: pch_uart: Pass correct sg to dma_unmap_sg() dt-bindings: phy: g12a-usb3-pcie-phy: fix compatible string documentation usb-storage: apply IGNORE_UAS only for HIKSEMI MD202 on RTL9210 usb: gadget: f_ncm: fix potential NULL ptr deref in ncm_bitrate() usb: gadget: g_webcam: Send color matching descriptor per frame usb: typec: altmodes/displayport: Fix pin assignment calculation usb: typec: altmodes/displayport: Add pin assignment helper usb: host: ehci-fsl: Fix module alias USB: serial: cp210x: add SCALANCE LPE-9000 device id USB: gadgetfs: Fix race between mounting and unmounting cifs: do not include page data when checking signature btrfs: fix race between quota rescan and disable leading to NULL pointer deref mmc: sunxi-mmc: Fix clock refcount imbalance during unbind comedi: adv_pci1760: Fix PWM instruction handling usb: core: hub: disable autosuspend for TI TUSB8041 misc: fastrpc: Fix use-after-free race condition for maps misc: fastrpc: Don't remove map on creater_process and device_release USB: misc: iowarrior: fix up header size for USB_DEVICE_ID_CODEMERCS_IOW100 USB: serial: option: add Quectel EM05CN modem USB: serial: option: add Quectel EM05CN (SG) modem USB: serial: option: add Quectel EC200U modem USB: serial: option: add Quectel EM05-G (RS) modem USB: serial: option: add Quectel EM05-G (CS) modem USB: serial: option: add Quectel EM05-G (GR) modem prlimit: do_prlimit needs to have a speculation check xhci: Detect lpm incapable xHC USB3 roothub ports from ACPI tables usb: acpi: add helper to check port lpm capability using acpi _DSM xhci: Add a flag to disable USB3 lpm on a xhci root port level. xhci: Add update_hub_device override for PCI xHCI hosts xhci: Fix null pointer dereference when host dies usb: xhci: Check endpoint is valid before dereferencing it xhci-pci: set the dma max_seg_size ALSA: hda/realtek - Turn on power early drm/i915/gt: Reset twice efi: fix userspace infinite retry read efivars after EFI runtime services page fault nilfs2: fix general protection fault in nilfs_btree_insert() Add exception protection processing for vd in axi_chan_handle_err function wifi: brcmfmac: fix regression for Broadcom PCIe wifi devices f2fs: let's avoid panic if extent_tree is not created RDMA/srp: Move large values to a new enum for gcc13 net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats selftests/bpf: check null propagation only neither reg is PTR_TO_BTF_ID pNFS/filelayout: Fix coalescing test for single DS Revert "net: add atomic_long_t to net_device_stats fields" Revert "PM/devfreq: governor: Add a private governor_data for governor" Linux 5.4.229 tipc: call tipc_lxc_xmit without holding node_read_lock ocfs2: fix freeing uninitialized resource on ocfs2_dlm_shutdown tipc: Add a missing case of TIPC_DIRECT_MSG type tty: serial: tegra: Handle RX transfer in PIO mode if DMA wasn't started tipc: fix use-after-free in tipc_disc_rcv() Revert "usb: ulpi: defer ulpi_register on ulpi_read_id timeout" mm: Always release pages to the buddy allocator in memblock_free_late(). efi: fix NULL-deref in init error path arm64: cmpxchg_double*: hazard against entire exchange variable arm64: atomics: remove LL/SC trampolines arm64: atomics: format whitespace consistently drm/virtio: Fix GEM handle creation UAF x86/resctrl: Fix task CLOSID/RMID update race x86/resctrl: Use task_curr() instead of task_struct->on_cpu to prevent unnecessary IPI iommu/mediatek-v1: Fix an error handling path in mtk_iommu_v1_probe() iommu/mediatek-v1: Add error handle for mtk_iommu_probe net/mlx5: Fix ptp max frequency adjustment range net/mlx5: Rename ptp clock info net/sched: act_mpls: Fix warning during failed attribute validation nfc: pn533: Wait for out_urb's completion in pn533_usb_send_frame() hvc/xen: lock console list traversal tipc: fix unexpected link reset due to discovery messages tipc: eliminate checking netns if node established tipc: improve throughput between nodes in netns regulator: da9211: Use irq handler when ready EDAC/device: Fix period calculation in edac_device_reset_delay_period() x86/boot: Avoid using Intel mnemonics in AT&T syntax asm powerpc/imc-pmu: Fix use of mutex in IRQs disabled section netfilter: ipset: Fix overflow before widen in the bitmap_ip_create() function. ext4: fix uninititialized value in 'ext4_evict_inode' ext4: fix use-after-free in ext4_orphan_cleanup ext4: lost matching-pair of trace in ext4_truncate ext4: fix bug_on in __es_tree_search caused by bad quota inode quota: Factor out setup of quota inode jbd2: use the correct print format usb: ulpi: defer ulpi_register on ulpi_read_id timeout wifi: wilc1000: sdio: fix module autoloading ipv6: raw: Deduct extension header length in rawv6_push_pending_frames ixgbe: fix pci device refcount leak platform/x86: sony-laptop: Don't turn off 0x153 keyboard backlight during probe drm/msm/adreno: Make adreno quirks not overwrite each other cifs: Fix uninitialized memory read for smb311 posix symlink create ALSA: hda/hdmi: Add a HP device 0x8715 to force connect list ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF net/ulp: prevent ULP without clone op from entering the LISTEN status s390/percpu: add READ_ONCE() to arch_this_cpu_to_op_simple() s390/kexec: fix ipl report address for kdump perf auxtrace: Fix address filter duplicate symbol selection docs: Fix the docs build with Sphinx 6.0 efi: tpm: Avoid READ_ONCE() for accessing the event log KVM: arm64: Fix S1PTW handling on RO memslots net: sched: disallow noqueue for qdisc classes driver core: Fix bus_type.match() error handling in __driver_attach() selftests: set the BUILD variable to absolute path selftests: Fix kselftest O=objdir build from cluttering top level objdir parisc: Align parisc MADV_XXX constants with all other architectures mbcache: Avoid nesting of cache->c_list_lock under bit locks hfs/hfsplus: avoid WARN_ON() for sanity check, use proper error handling hfs/hfsplus: use WARN_ON for sanity check ext4: don't allow journal inode to have encrypt flag riscv: uaccess: fix type of 0 variable on error in get_user() nfsd: fix handling of readdir in v4root vs. mount upcall timeout x86/bugs: Flush IBP in ib_prctl_set() ASoC: Intel: bytcr_rt5640: Add quirk for the Advantech MICA-071 tablet udf: Fix extension of the last extent in the file caif: fix memory leak in cfctrl_linkup_request() drm/i915: unpin on error in intel_vgpu_shadow_mm_pin() usb: rndis_host: Secure rndis_query check against int overflow drivers/net/bonding/bond_3ad: return when there's no aggregator perf tools: Fix resources leak in perf_data__open_dir() net: sched: cbq: dont intepret cls results when asked to drop net: sched: atm: dont intepret cls results when asked to drop RDMA/mlx5: Fix validation of max_rd_atomic caps for DC RDMA/uverbs: Silence shiftTooManyBitsSigned warning net: phy: xgmiitorgmii: Fix refcount leak in xgmiitorgmii_probe net: amd-xgbe: add missed tasklet_kill vhost: fix range used in translate_desc() nfc: Fix potential resource leaks qlcnic: prevent ->dcb use-after-free on qlcnic_dcb_enable() failure net: sched: fix memory leak in tcindex_set_parms net: hns3: add interrupts re-initialization while doing VF FLR nfsd: shut down the NFSv4 state objects before the filecache bpf: pull before calling skb_postpull_rcsum() SUNRPC: ensure the matching upcall is in-flight upon downcall ext4: fix deadlock due to mbcache entry corruption mbcache: automatically delete entries from cache on freeing ext4: fix race when reusing xattr blocks ext4: unindent codeblock in ext4_xattr_block_set() ext4: remove EA inode entry from mbcache on inode eviction mbcache: add functions to delete entry if unused mbcache: don't reclaim used entries ext4: use kmemdup() to replace kmalloc + memcpy fs: ext4: initialize fsdata in pagecache_write() ext4: use memcpy_to_page() in pagecache_write() mm/highmem: Lift memcpy_[to|from]_page to core ext4: correct inconsistent error msg in nojournal mode ext4: goto right label 'failed_mount3a' ravb: Fix "failed to switch device to config mode" message during unbind KVM: nVMX: Properly expose ENABLE_USR_WAIT_PAUSE control to L1 KVM: VMX: Fix the spelling of CPU_BASED_USE_TSC_OFFSETTING KVM: VMX: Rename NMI_PENDING to NMI_WINDOW KVM: VMX: Rename INTERRUPT_PENDING to INTERRUPT_WINDOW KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers KVM: x86: optimize more exit handlers in vmx.c perf probe: Fix to get the DW_AT_decl_file and DW_AT_call_file as unsinged data perf probe: Use dwarf_attr_integrate as generic DWARF attr accessor dm thin: resume even if in FAIL mode media: s5p-mfc: Fix in register read and write for H264 media: s5p-mfc: Clear workbit to handle error condition media: s5p-mfc: Fix to handle reference queue during finishing PM/devfreq: governor: Add a private governor_data for governor btrfs: replace strncpy() with strscpy() ext4: allocate extended attribute value in vmalloc area ext4: avoid unaccounted block allocation when expanding inode ext4: initialize quota before expanding inode in setproject ioctl ext4: fix inode leak in ext4_xattr_inode_create() on an error path ext4: avoid BUG_ON when creating xattrs ext4: fix error code return to user-space in ext4_get_branch() ext4: fix corruption when online resizing a 1K bigalloc fs ext4: fix delayed allocation bug in ext4_clu_mapped for bigalloc + inline ext4: init quota for 'old.inode' in 'ext4_rename' ext4: fix bug_on in __es_tree_search caused by bad boot loader inode ext4: fix reserved cluster accounting in __es_remove_extent() ext4: add helper to check quota inums ext4: add EXT4_IGET_BAD flag to prevent unexpected bad inode ext4: fix undefined behavior in bit shift for ext4_check_flag_values ext4: add inode table check in __ext4_get_inode_loc to aovid possible infinite loop drm/vmwgfx: Validate the box size for the snooped cursor drm/connector: send hotplug uevent on connector cleanup device_cgroup: Roll back to original exceptions after copy failure parisc: led: Fix potential null-ptr-deref in start_task() iommu/amd: Fix ivrs_acpihid cmdline parsing code crypto: n2 - add missing hash statesize PCI/sysfs: Fix double free in error path PCI: Fix pci_device_is_present() for VFs by checking PF ipmi: fix use after free in _ipmi_destroy_user() ima: Fix a potential NULL pointer access in ima_restore_measurement_list mtd: spi-nor: Check for zero erase size in spi_nor_find_best_erase_type() ipmi: fix long wait in unload when IPMI disconnect efi: Add iMac Pro 2017 to uefi skip cert quirk md/bitmap: Fix bitmap chunk size overflow issues cifs: fix missing display of three mount options cifs: fix confusing debug message media: dvb-core: Fix UAF due to refcount races at releasing media: dvb-core: Fix double free in dvb_register_device() ARM: 9256/1: NWFPE: avoid compiler-generated __aeabi_uldivmod tracing: Fix infinite loop in tracing_read_pipe on overflowed print_trace_line tracing/hist: Fix wrong return value in parse_action_params() x86/microcode/intel: Do not retry microcode reloading on the APs tracing/hist: Fix out-of-bound write on 'action_data.var_ref_idx' dm cache: set needs_check flag after aborting metadata dm cache: Fix UAF in destroy() dm clone: Fix UAF in clone_dtr() dm integrity: Fix UAF in dm_integrity_dtr() dm thin: Fix UAF in run_timer_softirq() dm thin: Use last transaction's pmd->root when commit failed dm thin: Fix ABBA deadlock between shrink_slab and dm_pool_abort_metadata dm cache: Fix ABBA deadlock between shrink_slab and dm_cache_metadata_abort binfmt: Fix error return code in load_elf_fdpic_binary() binfmt: Move install_exec_creds after setup_new_exec to match binfmt_elf cpufreq: Init completion before kobject_init_and_add() selftests: Use optional USERCFLAGS and USERLDFLAGS arm64: dts: qcom: sdm850-lenovo-yoga-c630: correct I2C12 pins drive strength ARM: ux500: do not directly dereference __iomem btrfs: fix resolving backrefs for inline extent followed by prealloc mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K ktest.pl minconfig: Unset configs instead of just removing them kest.pl: Fix grub2 menu handling for rebooting soc: qcom: Select REMAP_MMIO for LLCC driver media: stv0288: use explicitly signed char net/af_packet: make sure to pull mac header net/af_packet: add VLAN support for AF_PACKET SOCK_RAW GSO SUNRPC: Don't leak netobj memory when gss_read_proxy_verf() fails tpm: tpm_tis: Add the missed acpi_put_table() to fix memory leak tpm: tpm_crb: Add the missed acpi_put_table() to fix memory leak mmc: vub300: fix warning - do not call blocking ops when !TASK_RUNNING f2fs: should put a page when checking the summary info mm, compaction: fix fast_isolate_around() to stay within boundaries md: fix a crash in mempool_free pnode: terminate at peers of source ALSA: line6: fix stack overflow in line6_midi_transmit ALSA: line6: correct midi status byte when receiving data from podxt ovl: Use ovl mounter's fsuid and fsgid in ovl_link() hfsplus: fix bug causing custom uid and gid being unable to be assigned with mount HID: plantronics: Additional PIDs for double volume key presses quirk HID: multitouch: fix Asus ExpertBook P2 P2451FA trackpoint powerpc/rtas: avoid scheduling in rtas_os_term() powerpc/rtas: avoid device tree lookups in rtas_os_term() objtool: Fix SEGFAULT nvme: fix the NVME_CMD_EFFECTS_CSE_MASK definition nvme: resync include/linux/nvme.h with nvmecli ata: ahci: Fix PCS quirk application for suspend nvme-pci: fix doorbell buffer value endianness cifs: fix oops during encryption media: dvbdev: fix refcnt bug media: dvbdev: fix build warning due to comments gcov: add support for checksum field regulator: core: fix deadlock on regulator enable iio: adc128s052: add proper .data members in adc128_of_match table iio: adc: ad_sigma_delta: do not use internal iio_dev lock reiserfs: Add missing calls to reiserfs_security_free() HID: wacom: Ensure bootloader PID is usable in hidraw mode usb: dwc3: core: defer probe on ulpi_read_id timeout ALSA: hda/hdmi: Add HP Device 0x8711 to force connect list ALSA: hda/realtek: Add quirk for Lenovo TianYi510Pro-14IOB pstore: Make sure CONFIG_PSTORE_PMSG selects CONFIG_RT_MUTEXES pstore: Switch pmsg_lock to an rt_mutex to avoid priority inversion ASoC: rt5670: Remove unbalanced pm_runtime_put() ASoC: rockchip: spdif: Add missing clk_disable_unprepare() in rk_spdif_runtime_resume() ASoC: wm8994: Fix potential deadlock ASoC: rockchip: pdm: Add missing clk_disable_unprepare() in rockchip_pdm_runtime_resume() ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link() ASoC: mediatek: mt8173-rt5650-rt5514: fix refcount leak in mt8173_rt5650_rt5514_dev_probe() ASoC: Intel: Skylake: Fix driver hang during shutdown ALSA: hda: add snd_hdac_stop_streams() helper ALSA/ASoC: hda: move/rename snd_hdac_ext_stop_streams to hdac_stream.c orangefs: Fix kmemleak in orangefs_{kernel,client}_debug_init() orangefs: Fix kmemleak in orangefs_prepare_debugfs_help_string() drm/sti: Fix return type of sti_{dvo,hda,hdmi}_connector_mode_valid() drm/fsl-dcu: Fix return type of fsl_dcu_drm_connector_mode_valid() hugetlbfs: fix null-ptr-deref in hugetlbfs_parse_param() clk: st: Fix memory leak in st_of_quadfs_setup() media: si470x: Fix use-after-free in si470x_int_in_callback() mmc: f-sdh30: Add quirks for broken timeout clock capability regulator: core: fix use_count leakage when handling boot-on blk-mq: fix possible memleak when register 'hctx' failed media: dvb-usb: fix memory leak in dvb_usb_adapter_init() media: dvbdev: adopts refcnt to avoid UAF media: dvb-frontends: fix leak of memory fw bpf: Prevent decl_tag from being referenced in func_proto arg ppp: associate skb with a device at tx mrp: introduce active flags to prevent UAF when applicant uninit net: add atomic_long_t to net_device_stats fields md/raid1: stop mdx_raid1 thread when raid1 array run failed drivers/md/md-bitmap: check the return value of md_bitmap_get_counter() drm/sti: Use drm_mode_copy() drm/rockchip: Use drm_mode_copy() s390/lcs: Fix return type of lcs_start_xmit() s390/netiucv: Fix return type of netiucv_tx() s390/ctcm: Fix return type of ctc{mp,}m_tx() igb: Do not free q_vector unless new one was allocated wifi: brcmfmac: Fix potential shift-out-of-bounds in brcmf_fw_alloc_request() hamradio: baycom_epp: Fix return type of baycom_send_packet() net: ethernet: ti: Fix return type of netcp_ndo_start_xmit() bpf: make sure skb->len != 0 when redirecting to a tunneling device ipmi: fix memleak when unload ipmi driver ASoC: codecs: rt298: Add quirk for KBL-R RVP platform wifi: ar5523: Fix use-after-free on ar5523_cmd() timed out wifi: ath9k: verify the expected usb_endpoints are present brcmfmac: return error when getting invalid max_flowrings from dongle drm/etnaviv: add missing quirks for GC300 hfs: fix OOB Read in __hfs_brec_find acct: fix potential integer overflow in encode_comp_t() nilfs2: fix shift-out-of-bounds/overflow in nilfs_sb2_bad_offset() ACPICA: Fix error code path in acpi_ds_call_control_method() fs: jfs: fix shift-out-of-bounds in dbDiscardAG udf: Avoid double brelse() in udf_rename() fs: jfs: fix shift-out-of-bounds in dbAllocAG binfmt_misc: fix shift-out-of-bounds in check_special_flags rcu: Fix __this_cpu_read() lockdep warning in rcu_force_quiescent_state() net: stream: purge sk_error_queue in sk_stream_kill_queues() myri10ge: Fix an error handling path in myri10ge_probe() rxrpc: Fix missing unlock in rxrpc_do_sendmsg() net_sched: reject TCF_EM_SIMPLE case for complex ematch module mailbox: zynq-ipi: fix error handling while device_register() fails skbuff: Account for tail adjustment during pull operations openvswitch: Fix flow lookup to use unmasked key rtc: mxc_v2: Add missing clk_disable_unprepare() r6040: Fix kmemleak in probe and remove nfc: pn533: Clear nfc_target before being used mISDN: hfcmulti: don't call dev_kfree_skb/kfree_skb() under spin_lock_irqsave() mISDN: hfcpci: don't call dev_kfree_skb/kfree_skb() under spin_lock_irqsave() mISDN: hfcsusb: don't call dev_kfree_skb/kfree_skb() under spin_lock_irqsave() nfsd: under NFSv4.1, fix double svc_xprt_put on rpc_create failure NFSD: Add tracepoints to NFSD's duplicate reply cache nfsd: Define the file access mode enum for tracing rtc: pic32: Move devm_rtc_allocate_device earlier in pic32_rtc_probe() rtc: st-lpc: Add missing clk_disable_unprepare in st_rtc_probe() remoteproc: qcom_q6v5_pas: Fix missing of_node_put() in adsp_alloc_memory_region() remoteproc: sysmon: fix memory leak in qcom_add_sysmon_subdev() pwm: sifive: Call pwm_sifive_update_clock() while mutex is held selftests/powerpc: Fix resource leaks powerpc/hv-gpci: Fix hv_gpci event list powerpc/83xx/mpc832x_rdb: call platform_device_put() in error case in of_fsl_spi_probe() powerpc/perf: callchain validate kernel stack pointer bounds powerpc/xive: add missing iounmap() in error path in xive_spapr_populate_irq_data() cxl: Fix refcount leak in cxl_calc_capp_routing powerpc/52xx: Fix a resource leak in an error handling path macintosh/macio-adb: check the return value of ioremap() macintosh: fix possible memory leak in macio_add_one_device() iommu/fsl_pamu: Fix resource leak in fsl_pamu_probe() iommu/amd: Fix pci device refcount leak in ppr_notifier() rtc: pcf85063: Fix reading alarm rtc: snvs: Allow a time difference on clock register read include/uapi/linux/swab: Fix potentially missing __always_inline RDMA/siw: Fix pointer cast warning power: supply: fix null pointer dereferencing in power_supply_get_battery_info HSI: omap_ssi_core: Fix error handling in ssi_init() perf symbol: correction while adjusting symbol perf trace: Handle failure when trace point folder is missed perf trace: Use macro RAW_SYSCALL_ARGS_NUM to replace number perf trace: Add a strtoul() method to 'struct syscall_arg_fmt' perf trace: Allow associating scnprintf routines with well known arg names perf trace: Add the syscall_arg_fmt pointer to syscall_arg perf trace: Factor out the initialization of syscal_arg_fmt->scnprintf perf trace: Separate 'struct syscall_fmt' definition from syscall_fmts variable perf trace: Return error if a system call doesn't exist power: supply: fix residue sysfs file in error handle route of __power_supply_register() HSI: omap_ssi_core: fix possible memory leak in ssi_probe() HSI: omap_ssi_core: fix unbalanced pm_runtime_disable() fbdev: uvesafb: Fixes an error handling path in uvesafb_probe() fbdev: vermilion: decrease reference count in error path fbdev: via: Fix error in via_core_init() fbdev: pm2fb: fix missing pci_disable_device() fbdev: ssd1307fb: Drop optional dependency samples: vfio-mdev: Fix missing pci_disable_device() in mdpy_fb_probe() tracing/hist: Fix issue of losting command info in error_log usb: storage: Add check for kcalloc i2c: ismt: Fix an out-of-bounds bug in ismt_access() vme: Fix error not catched in fake_init() staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor() staging: rtl8192u: Fix use after free in ieee80211_rx() i2c: pxa-pci: fix missing pci_disable_device() on error in ce4100_i2c_probe chardev: fix error handling in cdev_device_add() mcb: mcb-parse: fix error handing in chameleon_parse_gdd() drivers: mcb: fix resource leak in mcb_probe() usb: gadget: f_hid: fix refcount leak on error path usb: gadget: f_hid: fix f_hidg lifetime vs cdev usb: gadget: f_hid: optional SETUP/SET_REPORT mode usb: roles: fix of node refcount leak in usb_role_switch_is_parent() counter: stm32-lptimer-cnt: fix the check on arr and cmp registers update cxl: fix possible null-ptr-deref in cxl_pci_init_afu|adapter() cxl: fix possible null-ptr-deref in cxl_guest_init_afu|adapter() misc: sgi-gru: fix use-after-free error in gru_set_context_option, gru_fault and gru_handle_user_call_os misc: tifm: fix possible memory leak in tifm_7xx1_switch_media() misc: ocxl: fix possible name leak in ocxl_file_register_afu() test_firmware: fix memory leak in test_firmware_init() serial: sunsab: Fix error handling in sunsab_init() serial: altera_uart: fix locking in polling mode tty: serial: altera_uart_{r,t}x_chars() need only uart_port tty: serial: clean up stop-tx part in altera_uart_tx_chars() serial: pch: Fix PCI device refcount leak in pch_request_dma() serial: pl011: Do not clear RX FIFO & RX interrupt in unthrottle. serial: amba-pl011: avoid SBSA UART accessing DMACR register usb: typec: tcpci: fix of node refcount leak in tcpci_register_port() usb: typec: Check for ops->exit instead of ops->enter in altmode_exit staging: vme_user: Fix possible UAF in tsi148_dma_list_add usb: fotg210-udc: Fix ages old endianness issues uio: uio_dmem_genirq: Fix deadlock between irq config and handling uio: uio_dmem_genirq: Fix missing unlock in irq configuration vfio: platform: Do not pass return buffer to ACPI _RST method class: fix possible memory leak in __class_register() serial: tegra: Read DMA status before terminating tty: serial: tegra: Activate RX DMA transfer by request drivers: dio: fix possible memory leak in dio_init() IB/IPoIB: Fix queue count inconsistency for PKEY child interfaces hwrng: geode - Fix PCI device refcount leak hwrng: amd - Fix PCI device refcount leak crypto: img-hash - Fix variable dereferenced before check 'hdev->req' orangefs: Fix sysfs not cleanup when dev init failed RDMA/hfi1: Fix error return code in parse_platform_config() crypto: omap-sham - Use pm_runtime_resume_and_get() in omap_sham_probe() f2fs: avoid victim selection from previous victim section RDMA/nldev: Add checks for nla_nest_start() in fill_stat_counter_qps() scsi: snic: Fix possible UAF in snic_tgt_create() scsi: fcoe: Fix transport not deattached when fcoe_if_init() fails scsi: ipr: Fix WARNING in ipr_init() scsi: fcoe: Fix possible name leak when device_register() fails scsi: hpsa: Fix possible memory leak in hpsa_add_sas_device() scsi: hpsa: Fix error handling in hpsa_add_sas_host() scsi: mpt3sas: Fix possible resource leaks in mpt3sas_transport_port_add() crypto: tcrypt - Fix multibuffer skcipher speed test mem leak scsi: hpsa: Fix possible memory leak in hpsa_init_one() RDMA/rxe: Fix NULL-ptr-deref in rxe_qp_do_cleanup() when socket create failed crypto: ccree - Make cc_debugfs_global_fini() available for module init function RDMA/hfi: Decrease PCI device reference count in error path PCI: Check for alloc failure in pci_request_irq() crypto: ccree - Remove debugfs when platform_driver_register failed crypto: ccree - swap SHA384 and SHA512 larval hashes at build time scsi: scsi_debug: Fix a warning in resp_write_scat() RDMA/siw: Set defined status for work completion with undefined status RDMA/nldev: Return "-EAGAIN" if the cm_id isn't from expected port RDMA/siw: Fix immediate work request flush to completion queue f2fs: fix normal discard process RDMA/core: Fix order of nldev_exit call apparmor: Use pointer to struct aa_label for lbs_cred apparmor: Fix abi check to include v8 abi apparmor: fix lockdep warning when removing a namespace apparmor: fix a memleak in multi_transaction_new() stmmac: fix potential division by 0 Bluetooth: RFCOMM: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_core: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_bcsp: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_h5: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_ll: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: hci_qca: don't call kfree_skb() under spin_lock_irqsave() Bluetooth: btusb: don't call kfree_skb() under spin_lock_irqsave() ntb_netdev: Use dev_kfree_skb_any() in interrupt context net: lan9303: Fix read error execution path can: tcan4x5x: Remove invalid write in clear_interrupts net: amd-xgbe: Check only the minimum speed for active/passive cables net: amd-xgbe: Fix logic around active and passive cables net: amd: lance: don't call dev_kfree_skb() under spin_lock_irqsave() hamradio: don't call dev_kfree_skb() under spin_lock_irqsave() net: ethernet: dnet: don't call dev_kfree_skb() under spin_lock_irqsave() net: emaclite: don't call dev_kfree_skb() under spin_lock_irqsave() net: apple: bmac: don't call dev_kfree_skb() under spin_lock_irqsave() net: apple: mace: don't call dev_kfree_skb() under spin_lock_irqsave() net/tunnel: wait until all sk_user_data reader finish before releasing the sock net: farsync: Fix kmemleak when rmmods farsync ethernet: s2io: don't call dev_kfree_skb() under spin_lock_irqsave() of: overlay: fix null pointer dereferencing in find_dup_cset_node_entry() and find_dup_cset_prop() drivers: net: qlcnic: Fix potential memory leak in qlcnic_sriov_init() net: stmmac: selftests: fix potential memleak in stmmac_test_arpoffload() net: defxx: Fix missing err handling in dfx_init() net: vmw_vsock: vmci: Check memcpy_from_msg() clk: socfpga: Fix memory leak in socfpga_gate_init() clk: socfpga: use clk_hw_register for a5/c5 clk: socfpga: clk-pll: Remove unused variable 'rc' blktrace: Fix output non-blktrace event when blk_classic option enabled wifi: brcmfmac: Fix error return code in brcmf_sdio_download_firmware() wifi: rtl8xxxu: Add __packed to struct rtl8723bu_c2h spi: spi-gpio: Don't set MOSI as an input if not 3WIRE mode clk: samsung: Fix memory leak in _samsung_clk_register_pll() media: coda: Add check for kmalloc media: coda: Add check for dcoda_iram_alloc media: c8sectpfe: Add of_node_put() when breaking out of loop mmc: mmci: fix return value check of mmc_add_host() mmc: wbsd: fix return value check of mmc_add_host() mmc: via-sdmmc: fix return value check of mmc_add_host() mmc: meson-gx: fix return value check of mmc_add_host() mmc: omap_hsmmc: fix return value check of mmc_add_host() mmc: atmel-mci: fix return value check of mmc_add_host() mmc: wmt-sdmmc: fix return value check of mmc_add_host() mmc: vub300: fix return value check of mmc_add_host() mmc: toshsd: fix return value check of mmc_add_host() mmc: rtsx_usb_sdmmc: fix return value check of mmc_add_host() mmc: pxamci: fix return value check of mmc_add_host() mmc: mxcmmc: fix return value check of mmc_add_host() mmc: moxart: fix return value check of mmc_add_host() mmc: alcor: fix return value check of mmc_add_host() NFSv4.x: Fail client initialisation if state manager thread can't run SUNRPC: Fix missing release socket in rpc_sockname() xprtrdma: Fix regbuf data not freed in rpcrdma_req_create() ALSA: mts64: fix possible null-ptr-defer in snd_mts64_interrupt media: saa7164: fix missing pci_disable_device() bpf, sockmap: fix race in sock_map_free() regulator: core: fix resource leak in regulator_register() configfs: fix possible memory leak in configfs_create_dir() hsr: Avoid double remove of a node. clk: qcom: clk-krait: fix wrong div2 functions regulator: core: fix module refcount leak in set_supply() wifi: cfg80211: Fix not unregister reg_pdev when load_builtin_regdb_keys() fails spi: spidev: mask SPI_CS_HIGH in SPI_IOC_RD_MODE bonding: uninitialized variable in bond_miimon_inspect() bpf, sockmap: Fix data loss caused by using apply_bytes on ingress redirect bpf, sockmap: Fix repeated calls to sock_put() when msg has more_data netfilter: conntrack: set icmpv6 redirects as RELATED ASoC: pcm512x: Fix PM disable depth imbalance in pcm512x_probe drm/amdgpu: Fix PCI device refcount leak in amdgpu_atrm_get_bios() drm/radeon: Fix PCI device refcount leak in radeon_atrm_get_bios() ASoC: mediatek: mt8173: Enable IRQ when pdata is ready wifi: iwlwifi: mvm: fix double free on tx path. ALSA: asihpi: fix missing pci_disable_device() NFSv4: Fix a deadlock between nfs4_open_recover_helper() and delegreturn NFSv4.2: Fix initialisation of struct nfs4_label NFSv4.2: Fix a memory stomp in decode_attr_security_label NFSv4.2: Clear FATTR4_WORD2_SECURITY_LABEL when done decoding ASoC: mediatek: mtk-btcvsd: Add checks for write and read of mtk_btcvsd_snd ASoC: dt-bindings: wcd9335: fix reset line polarity in example drm/tegra: Add missing clk_disable_unprepare() in tegra_dc_probe() media: s5p-mfc: Add variant data for MFC v7 hardware for Exynos 3250 SoC media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer() media: dvb-core: Fix ignored return value in dvb_register_frontend() pinctrl: pinconf-generic: add missing of_node_put() clk: imx: replace osc_hdmi with dummy clk: imx8mn: correct the usb1_ctrl parent to be usb_bus media: imon: fix a race condition in send_packet() mtd: maps: pxa2xx-flash: fix memory leak in probe bonding: fix link recovery in mode 2 when updelay is nonzero bonding: Rename slave_arr to usable_slaves bonding: Export skip slave logic to function clk: rockchip: Fix memory leak in rockchip_clk_register_pll() regulator: core: use kfree_const() to free space conditionally ALSA: seq: fix undefined behavior in bit shift for SNDRV_SEQ_FILTER_USE_EVENT ALSA: pcm: fix undefined behavior in bit shift for SNDRV_PCM_RATE_KNOT HID: hid-sensor-custom: set fixed size for custom attributes bpf: Move skb->len == 0 checks into __bpf_redirect media: videobuf-dma-contig: use dma_mmap_coherent media: platform: exynos4-is: Fix error handling in fimc_md_init() media: solo6x10: fix possible memory leak in solo_sysfs_init() Input: elants_i2c - properly handle the reset GPIO when power is off mtd: lpddr2_nvm: Fix possible null-ptr-deref wifi: ath10k: Fix return value in ath10k_pci_init() ima: Fix misuse of dereference of pointer in template_desc_init_fields() integrity: Fix memory leakage in keyring allocation error path amdgpu/pm: prevent array underflow in vega20_odn_edit_dpm_table() regulator: core: fix unbalanced of node refcount in regulator_dev_lookup() ASoC: pxa: fix null-pointer dereference in filter() drm/mediatek: Modify dpi power on/off sequence. drm/radeon: Add the missed acpi_put_table() to fix memory leak rxrpc: Fix ack.bufferSize to be 0 when generating an ack net, proc: Provide PROC_FS=n fallback for proc_create_net_single_write() media: camss: Clean up received buffers on failed start of streaming wifi: rsi: Fix handling of 802.3 EAPOL frames sent via control port mtd: Fix device name leak when register device failed in add_mtd_device() bpf: propagate precision in ALU/ALU64 operations media: vivid: fix compose size exceed boundary ima: Handle -ESTALE returned by ima_filter_rule_match() ima: Fix fall-through warnings for Clang ima: Rename internal filter rule functions drm/panel/panel-sitronix-st7701: Remove panel on DSI attach failure spi: Update reference to struct spi_controller clk: renesas: r9a06g032: Repair grave increment error can: kvaser_usb: Compare requested bittiming parameters with actual parameters in do_set_{,data}_bittiming can: kvaser_usb: Add struct kvaser_usb_busparams can: kvaser_usb_leaf: Fix bogus restart events can: kvaser_usb_leaf: Fix wrong CAN state after stopping can: kvaser_usb_leaf: Fix improved state not being reported can: kvaser_usb_leaf: Set Warning state even without bus errors can: kvaser_usb: kvaser_usb_leaf: Handle CMD_ERROR_EVENT can: kvaser_usb: kvaser_usb_leaf: Rename {leaf,usbcan}_cmd_error_event to {leaf,usbcan}_cmd_can_error_event can: kvaser_usb: kvaser_usb_leaf: Get capabilities from device can: kvaser_usb: do not increase tx statistics when sending error message frames media: i2c: ad5820: Fix error path pata_ipx4xx_cf: Fix unsigned comparison with less than zero wifi: rtl8xxxu: Fix reading the vendor of combo chips wifi: ath9k: hif_usb: Fix use-after-free in ath9k_hif_usb_reg_in_cb() wifi: ath9k: hif_usb: fix memory leak of urbs in ath9k_hif_usb_dealloc_tx_urbs() rapidio: devices: fix missing put_device in mport_cdev_open hfs: Fix OOB Write in hfs_asc2mac relay: fix type mismatch when allocating memory in relay_create_buf() eventfd: change int to __u64 in eventfd_signal() ifndef CONFIG_EVENTFD rapidio: fix possible UAF when kfifo_alloc() fails fs: sysv: Fix sysv_nblocks() returns wrong value MIPS: OCTEON: warn only once if deprecated link status is being used MIPS: BCM63xx: Add check for NULL for clk in clk_enable platform/x86: mxm-wmi: fix memleak in mxm_wmi_call_mx[ds|mx]() PM: runtime: Do not call __rpm_callback() from rpm_idle() PM: runtime: Improve path in rpm_idle() when no callback xen/privcmd: Fix a possible warning in privcmd_ioctl_mmap_resource() x86/xen: Fix memory leak in xen_init_lock_cpu() x86/xen: Fix memory leak in xen_smp_intr_init{_pv}() xen/events: only register debug interrupt for 2-level events uprobes/x86: Allow to probe a NOP instruction with 0x66 prefix ACPICA: Fix use-after-free in acpi_ut_copy_ipackage_to_ipackage() clocksource/drivers/sh_cmt: Make sure channel clock supply is enabled rapidio: rio: fix possible name leak in rio_register_mport() rapidio: fix possible name leaks when rio_add_device() fails ocfs2: fix memory leak in ocfs2_mount_volume() ocfs2: rewrite error handling of ocfs2_fill_super ocfs2: ocfs2_mount_volume does cleanup job before return error debugfs: fix error when writing negative value to atomic_t debugfs file docs: fault-injection: fix non-working usage of negative values lib/notifier-error-inject: fix error when writing -errno to debugfs file libfs: add DEFINE_SIMPLE_ATTRIBUTE_SIGNED for signed value cpufreq: amd_freq_sensitivity: Add missing pci_dev_put() genirq/irqdesc: Don't try to remove non-existing sysfs files nfsd: don't call nfsd_file_put from client states seqfile display EDAC/i10nm: fix refcount leak in pci_get_dev_wrapper() irqchip: gic-pm: Use pm_runtime_resume_and_get() in gic_probe() perf/x86/intel/uncore: Fix reference count leak in hswep_has_limit_sbox() PNP: fix name memory leak in pnp_alloc_dev() selftests/efivarfs: Add checking of the test return value MIPS: vpe-cmp: fix possible memory leak while module exiting MIPS: vpe-mt: fix possible memory leak while module exiting ocfs2: fix memory leak in ocfs2_stack_glue_init() lib/fonts: fix undefined behavior in bit shift for get_default_font proc: fixup uptime selftest timerqueue: Use rb_entry_safe() in timerqueue_getnext() perf: Fix possible memleak in pmu_dev_alloc() selftests/ftrace: event_triggers: wait longer for test_event_enable fs: don't audit the capability check in simple_xattr_list() PM: hibernate: Fix mistake in kerneldoc comment alpha: fix syscall entry in !AUDUT_SYSCALL case cpuidle: dt: Return the correct numbers of parsed idle states tpm/tpm_crb: Fix error message in __crb_relinquish_locality() pstore: Avoid kcore oops by vmap()ing with VM_IOREMAP ARM: mmp: fix timer_read delay pstore/ram: Fix error return code in ramoops_probe() arm64: dts: armada-3720-turris-mox: Add missing interrupt for RTC ARM: dts: turris-omnia: Add switch port 6 node ARM: dts: turris-omnia: Add ethernet aliases ARM: dts: armada-39x: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-38x: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-375: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-xp: Fix assigned-addresses for every PCIe Root Port ARM: dts: armada-370: Fix assigned-addresses for every PCIe Root Port ARM: dts: dove: Fix assigned-addresses for every PCIe Root Port arm64: dts: mediatek: mt6797: Fix 26M oscillator unit name arm64: dts: mt2712-evb: Fix usb vbus regulators unit names arm64: dts: mt2712-evb: Fix vproc fixed regulators unit names arm64: dts: mt2712e: Fix unit address for pinctrl node arm64: dts: mt2712e: Fix unit_address_vs_reg warning for oscillators perf/smmuv3: Fix hotplug callback leak in arm_smmu_pmu_init() perf: arm_dsu: Fix hotplug callback leak in dsu_pmu_init() soc: ti: smartreflex: Fix PM disable depth imbalance in omap_sr_probe soc: ti: knav_qmss_queue: Fix PM disable depth imbalance in knav_queue_probe soc: ti: knav_qmss_queue: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync arm: dts: spear600: Fix clcd interrupt drivers: soc: ti: knav_qmss_queue: Mark knav_acc_firmwares as static arm64: dts: qcom: sdm845-cheza: fix AP suspend pin bias ARM: dts: qcom: apq8064: fix coresight compatible usb: musb: remove extra check in musb_gadget_vbus_draw net: loopback: use NET_NAME_PREDICTABLE for name_assign_type Bluetooth: L2CAP: Fix u8 overflow HID: uclogic: Add HID_QUIRK_HIDINPUT_FORCE quirk HID: ite: Enable QUIRK_TOUCHPAD_ON_OFF_REPORT on Acer Aspire Switch V 10 HID: ite: Enable QUIRK_TOUCHPAD_ON_OFF_REPORT on Acer Aspire Switch 10E HID: ite: Add support for Acer S1002 keyboard-dock xen-netback: move removal of "hotplug-status" to the right place igb: Initialize mailbox message for VF reset USB: serial: f81534: fix division by zero on line-speed change USB: serial: f81232: fix division by zero on line-speed change USB: serial: cp210x: add Kamstrup RF sniffer PIDs USB: serial: option: add Quectel EM05-G modem usb: gadget: uvc: Prevent buffer overflow in setup handler udf: Fix extending file within last block udf: Do not bother looking for prealloc extents if i_lenExtents matches i_size udf: Fix preallocation discarding at indirect extent boundary udf: Discard preallocation before extending file with a hole tracing/ring-buffer: Only do full wait when cpu != RING_BUFFER_ALL_CPUS ANDROID: Add more hvc devices for virtio-console. Revert "can: af_can: fix NULL pointer dereference in can_rcv_filter" ANDROID: Revert "tracing/ring-buffer: Have polling block on watermark" Linux 5.4.228 ASoC: ops: Correct bounds check for second channel on SX controls can: mcba_usb: Fix termination command argument can: sja1000: fix size of OCR_MODE_MASK define pinctrl: meditatek: Startup with the IRQs disabled ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx() nfp: fix use-after-free in area_cache_get() block: unhash blkdev part inode when the part is deleted mm/hugetlb: fix races when looking up a CONT-PTE/PMD size hugetlb page x86/smpboot: Move rcu_cpu_starting() earlier net: bpf: Allow TC programs to call BPF_FUNC_skb_change_head Linux 5.4.227 can: esd_usb: Allow REC and TEC to return to zero net: mvneta: Fix an out of bounds check ipv6: avoid use-after-free in ip6_fragment() net: plip: don't call kfree_skb/dev_kfree_skb() under spin_lock_irq() xen/netback: fix build warning ethernet: aeroflex: fix potential skb leak in greth_init_rings() ipv4: Fix incorrect route flushing when table ID 0 is used ipv4: Fix incorrect route flushing when source address is deleted tipc: Fix potential OOB in tipc_link_proto_rcv() net: hisilicon: Fix potential use-after-free in hix5hd2_rx() net: hisilicon: Fix potential use-after-free in hisi_femac_rx() net: thunderx: Fix missing destroy_workqueue of nicvf_rx_mode_wq net: stmmac: fix "snps,axi-config" node property parsing nvme initialize core quirks before calling nvme_init_subsystem NFC: nci: Bounds check struct nfc_target arrays i40e: Disallow ip4 and ip6 l4_4_bytes i40e: Fix for VF MAC address 0 i40e: Fix not setting default xps_cpus after reset net: mvneta: Prevent out of bounds read in mvneta_config_rss() xen-netfront: Fix NULL sring after live migration net: encx24j600: Fix invalid logic in reading of MISTAT register net: encx24j600: Add parentheses to fix precedence mac802154: fix missing INIT_LIST_HEAD in ieee802154_if_add() selftests: rtnetlink: correct xfrm policy rule in kci_test_ipsec_offload net: dsa: ksz: Check return value Bluetooth: Fix not cleanup led when bt_init fails Bluetooth: 6LoWPAN: add missing hci_dev_put() in get_l2cap_conn() af_unix: Get user_ns from in_skb in unix_diag_get_exact(). igb: Allocate MSI-X vector when testing e1000e: Fix TX dispatch condition gpio: amd8111: Fix PCI device reference count leak drm/bridge: ti-sn65dsi86: Fix output polarity setting bug ca8210: Fix crash by zero initializing data ieee802154: cc2520: Fix error return code in cc2520_hw_init() can: af_can: fix NULL pointer dereference in can_rcv_filter HID: core: fix shift-out-of-bounds in hid_report_raw_event HID: hid-lg4ff: Add check for empty lbuf HID: usbhid: Add ALWAYS_POLL quirk for some mice drm/shmem-helper: Remove errant put in error path KVM: s390: vsie: Fix the initialization of the epoch extension (epdx) field mm/gup: fix gup_pud_range() for dax memcg: fix possible use-after-free in memcg_write_event_control() media: v4l2-dv-timings.c: fix too strict blanking sanity checks Revert "net: dsa: b53: Fix valid setting for MDB entries" xen/netback: don't call kfree_skb() with interrupts disabled xen/netback: do some code cleanup xen/netback: Ensure protocol headers don't fall in the non-linear area mm/khugepaged: invoke MMU notifiers in shmem/file collapse paths mm/khugepaged: fix GUP-fast interaction by sending IPI mm/khugepaged: take the right locks for page table retraction net: usb: qmi_wwan: add u-blox 0x1342 composition 9p/xen: check logical size for buffer size fbcon: Use kzalloc() in fbcon_prepare_logo() regulator: twl6030: fix get status of twl6032 regulators ASoC: soc-pcm: Add NULL check in BE reparenting btrfs: send: avoid unaligned encoded writes when attempting to clone range ALSA: seq: Fix function prototype mismatch in snd_seq_expand_var_event regulator: slg51000: Wait after asserting CS pin 9p/fd: Use P9_HDRSZ for header size ARM: dts: rockchip: disable arm_global_timer on rk3066 and rk3188 ARM: 9266/1: mm: fix no-MMU ZERO_PAGE() implementation ARM: 9251/1: perf: Fix stacktraces for tracepoint events in THUMB2 kernels ARM: dts: rockchip: rk3188: fix lcdc1-rgb24 node name ARM: dts: rockchip: fix ir-receiver node names arm: dts: rockchip: fix node name for hym8563 rtc arm64: dts: rockchip: keep I2S1 disabled for GPIO function on ROCK Pi 4 series Change-Id: I6a643eaa2ee55257328d881f5b860200719e981e Signed-off-by: kamasali Satyanarayan <quic_kamasali@quicinc.com>
2739 lines
75 KiB
C
2739 lines
75 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* linux/mm/compaction.c
|
|
*
|
|
* Memory compaction for the reduction of external fragmentation. Note that
|
|
* this heavily depends upon page migration to do all the real heavy
|
|
* lifting
|
|
*
|
|
* Copyright IBM Corp. 2007-2010 Mel Gorman <mel@csn.ul.ie>
|
|
*/
|
|
#include <linux/cpu.h>
|
|
#include <linux/swap.h>
|
|
#include <linux/migrate.h>
|
|
#include <linux/compaction.h>
|
|
#include <linux/mm_inline.h>
|
|
#include <linux/sched/signal.h>
|
|
#include <linux/backing-dev.h>
|
|
#include <linux/sysctl.h>
|
|
#include <linux/sysfs.h>
|
|
#include <linux/page-isolation.h>
|
|
#include <linux/kasan.h>
|
|
#include <linux/kthread.h>
|
|
#include <linux/freezer.h>
|
|
#include <linux/page_owner.h>
|
|
#include <linux/psi.h>
|
|
#include "internal.h"
|
|
|
|
#ifdef CONFIG_COMPACTION
|
|
static inline void count_compact_event(enum vm_event_item item)
|
|
{
|
|
count_vm_event(item);
|
|
}
|
|
|
|
static inline void count_compact_events(enum vm_event_item item, long delta)
|
|
{
|
|
count_vm_events(item, delta);
|
|
}
|
|
#else
|
|
#define count_compact_event(item) do { } while (0)
|
|
#define count_compact_events(item, delta) do { } while (0)
|
|
#endif
|
|
|
|
#if defined CONFIG_COMPACTION || defined CONFIG_CMA
|
|
|
|
#define CREATE_TRACE_POINTS
|
|
#include <trace/events/compaction.h>
|
|
|
|
#define block_start_pfn(pfn, order) round_down(pfn, 1UL << (order))
|
|
#define block_end_pfn(pfn, order) ALIGN((pfn) + 1, 1UL << (order))
|
|
#define pageblock_start_pfn(pfn) block_start_pfn(pfn, pageblock_order)
|
|
#define pageblock_end_pfn(pfn) block_end_pfn(pfn, pageblock_order)
|
|
|
|
unsigned long release_freepages(struct list_head *freelist)
|
|
{
|
|
struct page *page, *next;
|
|
unsigned long high_pfn = 0;
|
|
|
|
list_for_each_entry_safe(page, next, freelist, lru) {
|
|
unsigned long pfn = page_to_pfn(page);
|
|
list_del(&page->lru);
|
|
__free_page(page);
|
|
if (pfn > high_pfn)
|
|
high_pfn = pfn;
|
|
}
|
|
|
|
return high_pfn;
|
|
}
|
|
|
|
void split_map_pages(struct list_head *list)
|
|
{
|
|
unsigned int i, order, nr_pages;
|
|
struct page *page, *next;
|
|
LIST_HEAD(tmp_list);
|
|
|
|
list_for_each_entry_safe(page, next, list, lru) {
|
|
list_del(&page->lru);
|
|
|
|
order = page_private(page);
|
|
nr_pages = 1 << order;
|
|
|
|
post_alloc_hook(page, order, __GFP_MOVABLE);
|
|
if (order)
|
|
split_page(page, order);
|
|
|
|
for (i = 0; i < nr_pages; i++) {
|
|
list_add(&page->lru, &tmp_list);
|
|
page++;
|
|
}
|
|
}
|
|
|
|
list_splice(&tmp_list, list);
|
|
}
|
|
|
|
#ifdef CONFIG_COMPACTION
|
|
|
|
int PageMovable(struct page *page)
|
|
{
|
|
struct address_space *mapping;
|
|
|
|
VM_BUG_ON_PAGE(!PageLocked(page), page);
|
|
if (!__PageMovable(page))
|
|
return 0;
|
|
|
|
mapping = page_mapping(page);
|
|
if (mapping && mapping->a_ops && mapping->a_ops->isolate_page)
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(PageMovable);
|
|
|
|
void __SetPageMovable(struct page *page, struct address_space *mapping)
|
|
{
|
|
VM_BUG_ON_PAGE(!PageLocked(page), page);
|
|
VM_BUG_ON_PAGE((unsigned long)mapping & PAGE_MAPPING_MOVABLE, page);
|
|
page->mapping = (void *)((unsigned long)mapping | PAGE_MAPPING_MOVABLE);
|
|
}
|
|
EXPORT_SYMBOL(__SetPageMovable);
|
|
|
|
void __ClearPageMovable(struct page *page)
|
|
{
|
|
VM_BUG_ON_PAGE(!PageLocked(page), page);
|
|
VM_BUG_ON_PAGE(!PageMovable(page), page);
|
|
/*
|
|
* Clear registered address_space val with keeping PAGE_MAPPING_MOVABLE
|
|
* flag so that VM can catch up released page by driver after isolation.
|
|
* With it, VM migration doesn't try to put it back.
|
|
*/
|
|
page->mapping = (void *)((unsigned long)page->mapping &
|
|
PAGE_MAPPING_MOVABLE);
|
|
}
|
|
EXPORT_SYMBOL(__ClearPageMovable);
|
|
|
|
/* Do not skip compaction more than 64 times */
|
|
#define COMPACT_MAX_DEFER_SHIFT 6
|
|
|
|
/*
|
|
* Compaction is deferred when compaction fails to result in a page
|
|
* allocation success. 1 << compact_defer_limit compactions are skipped up
|
|
* to a limit of 1 << COMPACT_MAX_DEFER_SHIFT
|
|
*/
|
|
void defer_compaction(struct zone *zone, int order)
|
|
{
|
|
zone->compact_considered = 0;
|
|
zone->compact_defer_shift++;
|
|
|
|
if (order < zone->compact_order_failed)
|
|
zone->compact_order_failed = order;
|
|
|
|
if (zone->compact_defer_shift > COMPACT_MAX_DEFER_SHIFT)
|
|
zone->compact_defer_shift = COMPACT_MAX_DEFER_SHIFT;
|
|
|
|
trace_mm_compaction_defer_compaction(zone, order);
|
|
}
|
|
|
|
/* Returns true if compaction should be skipped this time */
|
|
bool compaction_deferred(struct zone *zone, int order)
|
|
{
|
|
unsigned long defer_limit = 1UL << zone->compact_defer_shift;
|
|
|
|
if (order < zone->compact_order_failed)
|
|
return false;
|
|
|
|
/* Avoid possible overflow */
|
|
if (++zone->compact_considered > defer_limit)
|
|
zone->compact_considered = defer_limit;
|
|
|
|
if (zone->compact_considered >= defer_limit)
|
|
return false;
|
|
|
|
trace_mm_compaction_deferred(zone, order);
|
|
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* Update defer tracking counters after successful compaction of given order,
|
|
* which means an allocation either succeeded (alloc_success == true) or is
|
|
* expected to succeed.
|
|
*/
|
|
void compaction_defer_reset(struct zone *zone, int order,
|
|
bool alloc_success)
|
|
{
|
|
if (alloc_success) {
|
|
zone->compact_considered = 0;
|
|
zone->compact_defer_shift = 0;
|
|
}
|
|
if (order >= zone->compact_order_failed)
|
|
zone->compact_order_failed = order + 1;
|
|
|
|
trace_mm_compaction_defer_reset(zone, order);
|
|
}
|
|
|
|
/* Returns true if restarting compaction after many failures */
|
|
bool compaction_restarting(struct zone *zone, int order)
|
|
{
|
|
if (order < zone->compact_order_failed)
|
|
return false;
|
|
|
|
return zone->compact_defer_shift == COMPACT_MAX_DEFER_SHIFT &&
|
|
zone->compact_considered >= 1UL << zone->compact_defer_shift;
|
|
}
|
|
|
|
/* Returns true if the pageblock should be scanned for pages to isolate. */
|
|
static inline bool isolation_suitable(struct compact_control *cc,
|
|
struct page *page)
|
|
{
|
|
if (cc->ignore_skip_hint)
|
|
return true;
|
|
|
|
return !get_pageblock_skip(page);
|
|
}
|
|
|
|
static void reset_cached_positions(struct zone *zone)
|
|
{
|
|
zone->compact_cached_migrate_pfn[0] = zone->zone_start_pfn;
|
|
zone->compact_cached_migrate_pfn[1] = zone->zone_start_pfn;
|
|
zone->compact_cached_free_pfn =
|
|
pageblock_start_pfn(zone_end_pfn(zone) - 1);
|
|
}
|
|
|
|
/*
|
|
* Compound pages of >= pageblock_order should consistenly be skipped until
|
|
* released. It is always pointless to compact pages of such order (if they are
|
|
* migratable), and the pageblocks they occupy cannot contain any free pages.
|
|
*/
|
|
static bool pageblock_skip_persistent(struct page *page)
|
|
{
|
|
if (!PageCompound(page))
|
|
return false;
|
|
|
|
page = compound_head(page);
|
|
|
|
if (compound_order(page) >= pageblock_order)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
static bool
|
|
__reset_isolation_pfn(struct zone *zone, unsigned long pfn, bool check_source,
|
|
bool check_target)
|
|
{
|
|
struct page *page = pfn_to_online_page(pfn);
|
|
struct page *block_page;
|
|
struct page *end_page;
|
|
unsigned long block_pfn;
|
|
|
|
if (!page)
|
|
return false;
|
|
if (zone != page_zone(page))
|
|
return false;
|
|
if (pageblock_skip_persistent(page))
|
|
return false;
|
|
|
|
/*
|
|
* If skip is already cleared do no further checking once the
|
|
* restart points have been set.
|
|
*/
|
|
if (check_source && check_target && !get_pageblock_skip(page))
|
|
return true;
|
|
|
|
/*
|
|
* If clearing skip for the target scanner, do not select a
|
|
* non-movable pageblock as the starting point.
|
|
*/
|
|
if (!check_source && check_target &&
|
|
get_pageblock_migratetype(page) != MIGRATE_MOVABLE)
|
|
return false;
|
|
|
|
/* Ensure the start of the pageblock or zone is online and valid */
|
|
block_pfn = pageblock_start_pfn(pfn);
|
|
block_pfn = max(block_pfn, zone->zone_start_pfn);
|
|
block_page = pfn_to_online_page(block_pfn);
|
|
if (block_page) {
|
|
page = block_page;
|
|
pfn = block_pfn;
|
|
}
|
|
|
|
/* Ensure the end of the pageblock or zone is online and valid */
|
|
block_pfn = pageblock_end_pfn(pfn) - 1;
|
|
block_pfn = min(block_pfn, zone_end_pfn(zone) - 1);
|
|
end_page = pfn_to_online_page(block_pfn);
|
|
if (!end_page)
|
|
return false;
|
|
|
|
/*
|
|
* Only clear the hint if a sample indicates there is either a
|
|
* free page or an LRU page in the block. One or other condition
|
|
* is necessary for the block to be a migration source/target.
|
|
*/
|
|
do {
|
|
if (pfn_valid_within(pfn)) {
|
|
if (check_source && PageLRU(page)) {
|
|
clear_pageblock_skip(page);
|
|
return true;
|
|
}
|
|
|
|
if (check_target && PageBuddy(page)) {
|
|
clear_pageblock_skip(page);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
page += (1 << PAGE_ALLOC_COSTLY_ORDER);
|
|
pfn += (1 << PAGE_ALLOC_COSTLY_ORDER);
|
|
} while (page <= end_page);
|
|
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* This function is called to clear all cached information on pageblocks that
|
|
* should be skipped for page isolation when the migrate and free page scanner
|
|
* meet.
|
|
*/
|
|
static void __reset_isolation_suitable(struct zone *zone)
|
|
{
|
|
unsigned long migrate_pfn = zone->zone_start_pfn;
|
|
unsigned long free_pfn = zone_end_pfn(zone) - 1;
|
|
unsigned long reset_migrate = free_pfn;
|
|
unsigned long reset_free = migrate_pfn;
|
|
bool source_set = false;
|
|
bool free_set = false;
|
|
|
|
if (!zone->compact_blockskip_flush)
|
|
return;
|
|
|
|
zone->compact_blockskip_flush = false;
|
|
|
|
/*
|
|
* Walk the zone and update pageblock skip information. Source looks
|
|
* for PageLRU while target looks for PageBuddy. When the scanner
|
|
* is found, both PageBuddy and PageLRU are checked as the pageblock
|
|
* is suitable as both source and target.
|
|
*/
|
|
for (; migrate_pfn < free_pfn; migrate_pfn += pageblock_nr_pages,
|
|
free_pfn -= pageblock_nr_pages) {
|
|
cond_resched();
|
|
|
|
/* Update the migrate PFN */
|
|
if (__reset_isolation_pfn(zone, migrate_pfn, true, source_set) &&
|
|
migrate_pfn < reset_migrate) {
|
|
source_set = true;
|
|
reset_migrate = migrate_pfn;
|
|
zone->compact_init_migrate_pfn = reset_migrate;
|
|
zone->compact_cached_migrate_pfn[0] = reset_migrate;
|
|
zone->compact_cached_migrate_pfn[1] = reset_migrate;
|
|
}
|
|
|
|
/* Update the free PFN */
|
|
if (__reset_isolation_pfn(zone, free_pfn, free_set, true) &&
|
|
free_pfn > reset_free) {
|
|
free_set = true;
|
|
reset_free = free_pfn;
|
|
zone->compact_init_free_pfn = reset_free;
|
|
zone->compact_cached_free_pfn = reset_free;
|
|
}
|
|
}
|
|
|
|
/* Leave no distance if no suitable block was reset */
|
|
if (reset_migrate >= reset_free) {
|
|
zone->compact_cached_migrate_pfn[0] = migrate_pfn;
|
|
zone->compact_cached_migrate_pfn[1] = migrate_pfn;
|
|
zone->compact_cached_free_pfn = free_pfn;
|
|
}
|
|
}
|
|
|
|
void reset_isolation_suitable(pg_data_t *pgdat)
|
|
{
|
|
int zoneid;
|
|
|
|
for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
|
|
struct zone *zone = &pgdat->node_zones[zoneid];
|
|
if (!populated_zone(zone))
|
|
continue;
|
|
|
|
/* Only flush if a full compaction finished recently */
|
|
if (zone->compact_blockskip_flush)
|
|
__reset_isolation_suitable(zone);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Sets the pageblock skip bit if it was clear. Note that this is a hint as
|
|
* locks are not required for read/writers. Returns true if it was already set.
|
|
*/
|
|
static bool test_and_set_skip(struct compact_control *cc, struct page *page,
|
|
unsigned long pfn)
|
|
{
|
|
bool skip;
|
|
|
|
/* Do no update if skip hint is being ignored */
|
|
if (cc->ignore_skip_hint)
|
|
return false;
|
|
|
|
if (!IS_ALIGNED(pfn, pageblock_nr_pages))
|
|
return false;
|
|
|
|
skip = get_pageblock_skip(page);
|
|
if (!skip && !cc->no_set_skip_hint)
|
|
set_pageblock_skip(page);
|
|
|
|
return skip;
|
|
}
|
|
|
|
static void update_cached_migrate(struct compact_control *cc, unsigned long pfn)
|
|
{
|
|
struct zone *zone = cc->zone;
|
|
|
|
pfn = pageblock_end_pfn(pfn);
|
|
|
|
/* Set for isolation rather than compaction */
|
|
if (cc->no_set_skip_hint)
|
|
return;
|
|
|
|
if (pfn > zone->compact_cached_migrate_pfn[0])
|
|
zone->compact_cached_migrate_pfn[0] = pfn;
|
|
if (cc->mode != MIGRATE_ASYNC &&
|
|
pfn > zone->compact_cached_migrate_pfn[1])
|
|
zone->compact_cached_migrate_pfn[1] = pfn;
|
|
}
|
|
|
|
/*
|
|
* If no pages were isolated then mark this pageblock to be skipped in the
|
|
* future. The information is later cleared by __reset_isolation_suitable().
|
|
*/
|
|
static void update_pageblock_skip(struct compact_control *cc,
|
|
struct page *page, unsigned long pfn)
|
|
{
|
|
struct zone *zone = cc->zone;
|
|
|
|
if (cc->no_set_skip_hint)
|
|
return;
|
|
|
|
if (!page)
|
|
return;
|
|
|
|
set_pageblock_skip(page);
|
|
|
|
/* Update where async and sync compaction should restart */
|
|
if (pfn < zone->compact_cached_free_pfn)
|
|
zone->compact_cached_free_pfn = pfn;
|
|
}
|
|
#else
|
|
static inline bool isolation_suitable(struct compact_control *cc,
|
|
struct page *page)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static inline bool pageblock_skip_persistent(struct page *page)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline void update_pageblock_skip(struct compact_control *cc,
|
|
struct page *page, unsigned long pfn)
|
|
{
|
|
}
|
|
|
|
static void update_cached_migrate(struct compact_control *cc, unsigned long pfn)
|
|
{
|
|
}
|
|
|
|
static bool test_and_set_skip(struct compact_control *cc, struct page *page,
|
|
unsigned long pfn)
|
|
{
|
|
return false;
|
|
}
|
|
#endif /* CONFIG_COMPACTION */
|
|
|
|
/*
|
|
* Compaction requires the taking of some coarse locks that are potentially
|
|
* very heavily contended. For async compaction, trylock and record if the
|
|
* lock is contended. The lock will still be acquired but compaction will
|
|
* abort when the current block is finished regardless of success rate.
|
|
* Sync compaction acquires the lock.
|
|
*
|
|
* Always returns true which makes it easier to track lock state in callers.
|
|
*/
|
|
static bool compact_lock_irqsave(spinlock_t *lock, unsigned long *flags,
|
|
struct compact_control *cc)
|
|
{
|
|
/* Track if the lock is contended in async mode */
|
|
if (cc->mode == MIGRATE_ASYNC && !cc->contended) {
|
|
if (spin_trylock_irqsave(lock, *flags))
|
|
return true;
|
|
|
|
cc->contended = true;
|
|
}
|
|
|
|
spin_lock_irqsave(lock, *flags);
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* Compaction requires the taking of some coarse locks that are potentially
|
|
* very heavily contended. The lock should be periodically unlocked to avoid
|
|
* having disabled IRQs for a long time, even when there is nobody waiting on
|
|
* the lock. It might also be that allowing the IRQs will result in
|
|
* need_resched() becoming true. If scheduling is needed, async compaction
|
|
* aborts. Sync compaction schedules.
|
|
* Either compaction type will also abort if a fatal signal is pending.
|
|
* In either case if the lock was locked, it is dropped and not regained.
|
|
*
|
|
* Returns true if compaction should abort due to fatal signal pending, or
|
|
* async compaction due to need_resched()
|
|
* Returns false when compaction can continue (sync compaction might have
|
|
* scheduled)
|
|
*/
|
|
static bool compact_unlock_should_abort(spinlock_t *lock,
|
|
unsigned long flags, bool *locked, struct compact_control *cc)
|
|
{
|
|
if (*locked) {
|
|
spin_unlock_irqrestore(lock, flags);
|
|
*locked = false;
|
|
}
|
|
|
|
if (fatal_signal_pending(current)) {
|
|
cc->contended = true;
|
|
return true;
|
|
}
|
|
|
|
cond_resched();
|
|
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* Isolate free pages onto a private freelist. If @strict is true, will abort
|
|
* returning 0 on any invalid PFNs or non-free pages inside of the pageblock
|
|
* (even though it may still end up isolating some pages).
|
|
*/
|
|
static unsigned long isolate_freepages_block(struct compact_control *cc,
|
|
unsigned long *start_pfn,
|
|
unsigned long end_pfn,
|
|
struct list_head *freelist,
|
|
unsigned int stride,
|
|
bool strict)
|
|
{
|
|
int nr_scanned = 0, total_isolated = 0;
|
|
struct page *cursor;
|
|
unsigned long flags = 0;
|
|
bool locked = false;
|
|
unsigned long blockpfn = *start_pfn;
|
|
unsigned int order;
|
|
|
|
/* Strict mode is for isolation, speed is secondary */
|
|
if (strict)
|
|
stride = 1;
|
|
|
|
cursor = pfn_to_page(blockpfn);
|
|
|
|
/* Isolate free pages. */
|
|
for (; blockpfn < end_pfn; blockpfn += stride, cursor += stride) {
|
|
int isolated;
|
|
struct page *page = cursor;
|
|
|
|
/*
|
|
* Periodically drop the lock (if held) regardless of its
|
|
* contention, to give chance to IRQs. Abort if fatal signal
|
|
* pending or async compaction detects need_resched()
|
|
*/
|
|
if (!(blockpfn % SWAP_CLUSTER_MAX)
|
|
&& compact_unlock_should_abort(&cc->zone->lock, flags,
|
|
&locked, cc))
|
|
break;
|
|
|
|
nr_scanned++;
|
|
if (!pfn_valid_within(blockpfn))
|
|
goto isolate_fail;
|
|
|
|
/*
|
|
* For compound pages such as THP and hugetlbfs, we can save
|
|
* potentially a lot of iterations if we skip them at once.
|
|
* The check is racy, but we can consider only valid values
|
|
* and the only danger is skipping too much.
|
|
*/
|
|
if (PageCompound(page)) {
|
|
const unsigned int order = compound_order(page);
|
|
|
|
if (likely(order < MAX_ORDER)) {
|
|
blockpfn += (1UL << order) - 1;
|
|
cursor += (1UL << order) - 1;
|
|
}
|
|
goto isolate_fail;
|
|
}
|
|
|
|
if (!PageBuddy(page))
|
|
goto isolate_fail;
|
|
|
|
/*
|
|
* If we already hold the lock, we can skip some rechecking.
|
|
* Note that if we hold the lock now, checked_pageblock was
|
|
* already set in some previous iteration (or strict is true),
|
|
* so it is correct to skip the suitable migration target
|
|
* recheck as well.
|
|
*/
|
|
if (!locked) {
|
|
locked = compact_lock_irqsave(&cc->zone->lock,
|
|
&flags, cc);
|
|
|
|
/* Recheck this is a buddy page under lock */
|
|
if (!PageBuddy(page))
|
|
goto isolate_fail;
|
|
}
|
|
|
|
/* Found a free page, will break it into order-0 pages */
|
|
order = page_order(page);
|
|
isolated = __isolate_free_page(page, order);
|
|
if (!isolated)
|
|
break;
|
|
set_page_private(page, order);
|
|
|
|
total_isolated += isolated;
|
|
cc->nr_freepages += isolated;
|
|
list_add_tail(&page->lru, freelist);
|
|
|
|
if (!strict && cc->nr_migratepages <= cc->nr_freepages) {
|
|
blockpfn += isolated;
|
|
break;
|
|
}
|
|
/* Advance to the end of split page */
|
|
blockpfn += isolated - 1;
|
|
cursor += isolated - 1;
|
|
continue;
|
|
|
|
isolate_fail:
|
|
if (strict)
|
|
break;
|
|
else
|
|
continue;
|
|
|
|
}
|
|
|
|
if (locked)
|
|
spin_unlock_irqrestore(&cc->zone->lock, flags);
|
|
|
|
/*
|
|
* There is a tiny chance that we have read bogus compound_order(),
|
|
* so be careful to not go outside of the pageblock.
|
|
*/
|
|
if (unlikely(blockpfn > end_pfn))
|
|
blockpfn = end_pfn;
|
|
|
|
trace_mm_compaction_isolate_freepages(*start_pfn, blockpfn,
|
|
nr_scanned, total_isolated);
|
|
|
|
/* Record how far we have got within the block */
|
|
*start_pfn = blockpfn;
|
|
|
|
/*
|
|
* If strict isolation is requested by CMA then check that all the
|
|
* pages requested were isolated. If there were any failures, 0 is
|
|
* returned and CMA will fail.
|
|
*/
|
|
if (strict && blockpfn < end_pfn)
|
|
total_isolated = 0;
|
|
|
|
cc->total_free_scanned += nr_scanned;
|
|
if (total_isolated)
|
|
count_compact_events(COMPACTISOLATED, total_isolated);
|
|
return total_isolated;
|
|
}
|
|
|
|
/**
|
|
* isolate_freepages_range() - isolate free pages.
|
|
* @cc: Compaction control structure.
|
|
* @start_pfn: The first PFN to start isolating.
|
|
* @end_pfn: The one-past-last PFN.
|
|
*
|
|
* Non-free pages, invalid PFNs, or zone boundaries within the
|
|
* [start_pfn, end_pfn) range are considered errors, cause function to
|
|
* undo its actions and return zero.
|
|
*
|
|
* Otherwise, function returns one-past-the-last PFN of isolated page
|
|
* (which may be greater then end_pfn if end fell in a middle of
|
|
* a free page).
|
|
*/
|
|
unsigned long
|
|
isolate_freepages_range(struct compact_control *cc,
|
|
unsigned long start_pfn, unsigned long end_pfn)
|
|
{
|
|
unsigned long isolated, pfn, block_start_pfn, block_end_pfn;
|
|
LIST_HEAD(freelist);
|
|
|
|
pfn = start_pfn;
|
|
block_start_pfn = pageblock_start_pfn(pfn);
|
|
if (block_start_pfn < cc->zone->zone_start_pfn)
|
|
block_start_pfn = cc->zone->zone_start_pfn;
|
|
block_end_pfn = pageblock_end_pfn(pfn);
|
|
|
|
for (; pfn < end_pfn; pfn += isolated,
|
|
block_start_pfn = block_end_pfn,
|
|
block_end_pfn += pageblock_nr_pages) {
|
|
/* Protect pfn from changing by isolate_freepages_block */
|
|
unsigned long isolate_start_pfn = pfn;
|
|
|
|
block_end_pfn = min(block_end_pfn, end_pfn);
|
|
|
|
/*
|
|
* pfn could pass the block_end_pfn if isolated freepage
|
|
* is more than pageblock order. In this case, we adjust
|
|
* scanning range to right one.
|
|
*/
|
|
if (pfn >= block_end_pfn) {
|
|
block_start_pfn = pageblock_start_pfn(pfn);
|
|
block_end_pfn = pageblock_end_pfn(pfn);
|
|
block_end_pfn = min(block_end_pfn, end_pfn);
|
|
}
|
|
|
|
if (!pageblock_pfn_to_page(block_start_pfn,
|
|
block_end_pfn, cc->zone))
|
|
break;
|
|
|
|
isolated = isolate_freepages_block(cc, &isolate_start_pfn,
|
|
block_end_pfn, &freelist, 0, true);
|
|
|
|
/*
|
|
* In strict mode, isolate_freepages_block() returns 0 if
|
|
* there are any holes in the block (ie. invalid PFNs or
|
|
* non-free pages).
|
|
*/
|
|
if (!isolated)
|
|
break;
|
|
|
|
/*
|
|
* If we managed to isolate pages, it is always (1 << n) *
|
|
* pageblock_nr_pages for some non-negative n. (Max order
|
|
* page may span two pageblocks).
|
|
*/
|
|
}
|
|
|
|
/* __isolate_free_page() does not map the pages */
|
|
split_map_pages(&freelist);
|
|
|
|
if (pfn < end_pfn) {
|
|
/* Loop terminated early, cleanup. */
|
|
release_freepages(&freelist);
|
|
return 0;
|
|
}
|
|
|
|
/* We don't use freelists for anything. */
|
|
return pfn;
|
|
}
|
|
|
|
/* Similar to reclaim, but different enough that they don't share logic */
|
|
static bool too_many_isolated(pg_data_t *pgdat)
|
|
{
|
|
unsigned long active, inactive, isolated;
|
|
|
|
inactive = node_page_state(pgdat, NR_INACTIVE_FILE) +
|
|
node_page_state(pgdat, NR_INACTIVE_ANON);
|
|
active = node_page_state(pgdat, NR_ACTIVE_FILE) +
|
|
node_page_state(pgdat, NR_ACTIVE_ANON);
|
|
isolated = node_page_state(pgdat, NR_ISOLATED_FILE) +
|
|
node_page_state(pgdat, NR_ISOLATED_ANON);
|
|
|
|
return isolated > (inactive + active) / 2;
|
|
}
|
|
|
|
/**
|
|
* isolate_migratepages_block() - isolate all migrate-able pages within
|
|
* a single pageblock
|
|
* @cc: Compaction control structure.
|
|
* @low_pfn: The first PFN to isolate
|
|
* @end_pfn: The one-past-the-last PFN to isolate, within same pageblock
|
|
* @isolate_mode: Isolation mode to be used.
|
|
*
|
|
* Isolate all pages that can be migrated from the range specified by
|
|
* [low_pfn, end_pfn). The range is expected to be within same pageblock.
|
|
* Returns zero if there is a fatal signal pending, otherwise PFN of the
|
|
* first page that was not scanned (which may be both less, equal to or more
|
|
* than end_pfn).
|
|
*
|
|
* The pages are isolated on cc->migratepages list (not required to be empty),
|
|
* and cc->nr_migratepages is updated accordingly. The cc->migrate_pfn field
|
|
* is neither read nor updated.
|
|
*/
|
|
static unsigned long
|
|
isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
|
|
unsigned long end_pfn, isolate_mode_t isolate_mode)
|
|
{
|
|
pg_data_t *pgdat = cc->zone->zone_pgdat;
|
|
unsigned long nr_scanned = 0, nr_isolated = 0;
|
|
struct lruvec *lruvec;
|
|
unsigned long flags = 0;
|
|
bool locked = false;
|
|
struct page *page = NULL, *valid_page = NULL;
|
|
unsigned long start_pfn = low_pfn;
|
|
bool skip_on_failure = false;
|
|
unsigned long next_skip_pfn = 0;
|
|
bool skip_updated = false;
|
|
|
|
/*
|
|
* Ensure that there are not too many pages isolated from the LRU
|
|
* list by either parallel reclaimers or compaction. If there are,
|
|
* delay for some time until fewer pages are isolated
|
|
*/
|
|
while (unlikely(too_many_isolated(pgdat))) {
|
|
/* async migration should just abort */
|
|
if (cc->mode == MIGRATE_ASYNC)
|
|
return 0;
|
|
|
|
congestion_wait(BLK_RW_ASYNC, HZ/10);
|
|
|
|
if (fatal_signal_pending(current))
|
|
return 0;
|
|
}
|
|
|
|
cond_resched();
|
|
|
|
if (cc->direct_compaction && (cc->mode == MIGRATE_ASYNC)) {
|
|
skip_on_failure = true;
|
|
next_skip_pfn = block_end_pfn(low_pfn, cc->order);
|
|
}
|
|
|
|
/* Time to isolate some pages for migration */
|
|
for (; low_pfn < end_pfn; low_pfn++) {
|
|
|
|
if (skip_on_failure && low_pfn >= next_skip_pfn) {
|
|
/*
|
|
* We have isolated all migration candidates in the
|
|
* previous order-aligned block, and did not skip it due
|
|
* to failure. We should migrate the pages now and
|
|
* hopefully succeed compaction.
|
|
*/
|
|
if (nr_isolated)
|
|
break;
|
|
|
|
/*
|
|
* We failed to isolate in the previous order-aligned
|
|
* block. Set the new boundary to the end of the
|
|
* current block. Note we can't simply increase
|
|
* next_skip_pfn by 1 << order, as low_pfn might have
|
|
* been incremented by a higher number due to skipping
|
|
* a compound or a high-order buddy page in the
|
|
* previous loop iteration.
|
|
*/
|
|
next_skip_pfn = block_end_pfn(low_pfn, cc->order);
|
|
}
|
|
|
|
/*
|
|
* Periodically drop the lock (if held) regardless of its
|
|
* contention, to give chance to IRQs. Abort completely if
|
|
* a fatal signal is pending.
|
|
*/
|
|
if (!(low_pfn % SWAP_CLUSTER_MAX)
|
|
&& compact_unlock_should_abort(&pgdat->lru_lock,
|
|
flags, &locked, cc)) {
|
|
low_pfn = 0;
|
|
goto fatal_pending;
|
|
}
|
|
|
|
if (!pfn_valid_within(low_pfn))
|
|
goto isolate_fail;
|
|
nr_scanned++;
|
|
|
|
page = pfn_to_page(low_pfn);
|
|
|
|
/*
|
|
* Check if the pageblock has already been marked skipped.
|
|
* Only the aligned PFN is checked as the caller isolates
|
|
* COMPACT_CLUSTER_MAX at a time so the second call must
|
|
* not falsely conclude that the block should be skipped.
|
|
*/
|
|
if (!valid_page && IS_ALIGNED(low_pfn, pageblock_nr_pages)) {
|
|
if (!cc->ignore_skip_hint && get_pageblock_skip(page)) {
|
|
low_pfn = end_pfn;
|
|
goto isolate_abort;
|
|
}
|
|
valid_page = page;
|
|
}
|
|
|
|
/*
|
|
* Skip if free. We read page order here without zone lock
|
|
* which is generally unsafe, but the race window is small and
|
|
* the worst thing that can happen is that we skip some
|
|
* potential isolation targets.
|
|
*/
|
|
if (PageBuddy(page)) {
|
|
unsigned long freepage_order = page_order_unsafe(page);
|
|
|
|
/*
|
|
* Without lock, we cannot be sure that what we got is
|
|
* a valid page order. Consider only values in the
|
|
* valid order range to prevent low_pfn overflow.
|
|
*/
|
|
if (freepage_order > 0 && freepage_order < MAX_ORDER)
|
|
low_pfn += (1UL << freepage_order) - 1;
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Regardless of being on LRU, compound pages such as THP and
|
|
* hugetlbfs are not to be compacted. We can potentially save
|
|
* a lot of iterations if we skip them at once. The check is
|
|
* racy, but we can consider only valid values and the only
|
|
* danger is skipping too much.
|
|
*/
|
|
if (PageCompound(page)) {
|
|
const unsigned int order = compound_order(page);
|
|
|
|
if (likely(order < MAX_ORDER))
|
|
low_pfn += (1UL << order) - 1;
|
|
goto isolate_fail;
|
|
}
|
|
|
|
/*
|
|
* Check may be lockless but that's ok as we recheck later.
|
|
* It's possible to migrate LRU and non-lru movable pages.
|
|
* Skip any other type of page
|
|
*/
|
|
if (!PageLRU(page)) {
|
|
/*
|
|
* __PageMovable can return false positive so we need
|
|
* to verify it under page_lock.
|
|
*/
|
|
if (unlikely(__PageMovable(page)) &&
|
|
!PageIsolated(page)) {
|
|
if (locked) {
|
|
spin_unlock_irqrestore(&pgdat->lru_lock,
|
|
flags);
|
|
locked = false;
|
|
}
|
|
|
|
if (!isolate_movable_page(page, isolate_mode))
|
|
goto isolate_success;
|
|
}
|
|
|
|
goto isolate_fail;
|
|
}
|
|
|
|
/*
|
|
* Migration will fail if an anonymous page is pinned in memory,
|
|
* so avoid taking lru_lock and isolating it unnecessarily in an
|
|
* admittedly racy check.
|
|
*/
|
|
if (!page_mapping(page) &&
|
|
page_count(page) > page_mapcount(page))
|
|
goto isolate_fail;
|
|
|
|
/*
|
|
* Only allow to migrate anonymous pages in GFP_NOFS context
|
|
* because those do not depend on fs locks.
|
|
*/
|
|
if (!(cc->gfp_mask & __GFP_FS) && page_mapping(page))
|
|
goto isolate_fail;
|
|
|
|
/* If we already hold the lock, we can skip some rechecking */
|
|
if (!locked) {
|
|
locked = compact_lock_irqsave(&pgdat->lru_lock,
|
|
&flags, cc);
|
|
|
|
/* Try get exclusive access under lock */
|
|
if (!skip_updated) {
|
|
skip_updated = true;
|
|
if (test_and_set_skip(cc, page, low_pfn))
|
|
goto isolate_abort;
|
|
}
|
|
|
|
/* Recheck PageLRU and PageCompound under lock */
|
|
if (!PageLRU(page))
|
|
goto isolate_fail;
|
|
|
|
/*
|
|
* Page become compound since the non-locked check,
|
|
* and it's on LRU. It can only be a THP so the order
|
|
* is safe to read and it's 0 for tail pages.
|
|
*/
|
|
if (unlikely(PageCompound(page))) {
|
|
low_pfn += compound_nr(page) - 1;
|
|
goto isolate_fail;
|
|
}
|
|
}
|
|
|
|
lruvec = mem_cgroup_page_lruvec(page, pgdat);
|
|
|
|
/* Try isolate the page */
|
|
if (__isolate_lru_page(page, isolate_mode) != 0)
|
|
goto isolate_fail;
|
|
|
|
VM_BUG_ON_PAGE(PageCompound(page), page);
|
|
|
|
/* Successfully isolated */
|
|
del_page_from_lru_list(page, lruvec, page_lru(page));
|
|
inc_node_page_state(page,
|
|
NR_ISOLATED_ANON + page_is_file_cache(page));
|
|
|
|
isolate_success:
|
|
list_add(&page->lru, &cc->migratepages);
|
|
cc->nr_migratepages++;
|
|
nr_isolated++;
|
|
|
|
/*
|
|
* Avoid isolating too much unless this block is being
|
|
* rescanned (e.g. dirty/writeback pages, parallel allocation)
|
|
* or a lock is contended. For contention, isolate quickly to
|
|
* potentially remove one source of contention.
|
|
*/
|
|
if (cc->nr_migratepages == COMPACT_CLUSTER_MAX &&
|
|
!cc->rescan && !cc->contended) {
|
|
++low_pfn;
|
|
break;
|
|
}
|
|
|
|
continue;
|
|
isolate_fail:
|
|
if (!skip_on_failure)
|
|
continue;
|
|
|
|
/*
|
|
* We have isolated some pages, but then failed. Release them
|
|
* instead of migrating, as we cannot form the cc->order buddy
|
|
* page anyway.
|
|
*/
|
|
if (nr_isolated) {
|
|
if (locked) {
|
|
spin_unlock_irqrestore(&pgdat->lru_lock, flags);
|
|
locked = false;
|
|
}
|
|
putback_movable_pages(&cc->migratepages);
|
|
cc->nr_migratepages = 0;
|
|
nr_isolated = 0;
|
|
}
|
|
|
|
if (low_pfn < next_skip_pfn) {
|
|
low_pfn = next_skip_pfn - 1;
|
|
/*
|
|
* The check near the loop beginning would have updated
|
|
* next_skip_pfn too, but this is a bit simpler.
|
|
*/
|
|
next_skip_pfn += 1UL << cc->order;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* The PageBuddy() check could have potentially brought us outside
|
|
* the range to be scanned.
|
|
*/
|
|
if (unlikely(low_pfn > end_pfn))
|
|
low_pfn = end_pfn;
|
|
|
|
isolate_abort:
|
|
if (locked)
|
|
spin_unlock_irqrestore(&pgdat->lru_lock, flags);
|
|
|
|
/*
|
|
* Updated the cached scanner pfn once the pageblock has been scanned
|
|
* Pages will either be migrated in which case there is no point
|
|
* scanning in the near future or migration failed in which case the
|
|
* failure reason may persist. The block is marked for skipping if
|
|
* there were no pages isolated in the block or if the block is
|
|
* rescanned twice in a row.
|
|
*/
|
|
if (low_pfn == end_pfn && (!nr_isolated || cc->rescan)) {
|
|
if (valid_page && !skip_updated)
|
|
set_pageblock_skip(valid_page);
|
|
update_cached_migrate(cc, low_pfn);
|
|
}
|
|
|
|
trace_mm_compaction_isolate_migratepages(start_pfn, low_pfn,
|
|
nr_scanned, nr_isolated);
|
|
|
|
fatal_pending:
|
|
cc->total_migrate_scanned += nr_scanned;
|
|
if (nr_isolated)
|
|
count_compact_events(COMPACTISOLATED, nr_isolated);
|
|
|
|
return low_pfn;
|
|
}
|
|
|
|
/**
|
|
* isolate_migratepages_range() - isolate migrate-able pages in a PFN range
|
|
* @cc: Compaction control structure.
|
|
* @start_pfn: The first PFN to start isolating.
|
|
* @end_pfn: The one-past-last PFN.
|
|
*
|
|
* Returns zero if isolation fails fatally due to e.g. pending signal.
|
|
* Otherwise, function returns one-past-the-last PFN of isolated page
|
|
* (which may be greater than end_pfn if end fell in a middle of a THP page).
|
|
*/
|
|
unsigned long
|
|
isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn,
|
|
unsigned long end_pfn)
|
|
{
|
|
unsigned long pfn, block_start_pfn, block_end_pfn;
|
|
|
|
/* Scan block by block. First and last block may be incomplete */
|
|
pfn = start_pfn;
|
|
block_start_pfn = pageblock_start_pfn(pfn);
|
|
if (block_start_pfn < cc->zone->zone_start_pfn)
|
|
block_start_pfn = cc->zone->zone_start_pfn;
|
|
block_end_pfn = pageblock_end_pfn(pfn);
|
|
|
|
for (; pfn < end_pfn; pfn = block_end_pfn,
|
|
block_start_pfn = block_end_pfn,
|
|
block_end_pfn += pageblock_nr_pages) {
|
|
|
|
block_end_pfn = min(block_end_pfn, end_pfn);
|
|
|
|
if (!pageblock_pfn_to_page(block_start_pfn,
|
|
block_end_pfn, cc->zone))
|
|
continue;
|
|
|
|
pfn = isolate_migratepages_block(cc, pfn, block_end_pfn,
|
|
ISOLATE_UNEVICTABLE);
|
|
|
|
if (!pfn)
|
|
break;
|
|
|
|
if (cc->nr_migratepages == COMPACT_CLUSTER_MAX)
|
|
break;
|
|
}
|
|
|
|
return pfn;
|
|
}
|
|
|
|
#endif /* CONFIG_COMPACTION || CONFIG_CMA */
|
|
#ifdef CONFIG_COMPACTION
|
|
|
|
static bool suitable_migration_source(struct compact_control *cc,
|
|
struct page *page)
|
|
{
|
|
int block_mt;
|
|
|
|
if (pageblock_skip_persistent(page))
|
|
return false;
|
|
|
|
if ((cc->mode != MIGRATE_ASYNC) || !cc->direct_compaction)
|
|
return true;
|
|
|
|
block_mt = get_pageblock_migratetype(page);
|
|
|
|
if (cc->migratetype == MIGRATE_MOVABLE)
|
|
return is_migrate_movable(block_mt);
|
|
else
|
|
return block_mt == cc->migratetype;
|
|
}
|
|
|
|
/* Returns true if the page is within a block suitable for migration to */
|
|
static bool suitable_migration_target(struct compact_control *cc,
|
|
struct page *page)
|
|
{
|
|
/* If the page is a large free page, then disallow migration */
|
|
if (PageBuddy(page)) {
|
|
/*
|
|
* We are checking page_order without zone->lock taken. But
|
|
* the only small danger is that we skip a potentially suitable
|
|
* pageblock, so it's not worth to check order for valid range.
|
|
*/
|
|
if (page_order_unsafe(page) >= pageblock_order)
|
|
return false;
|
|
}
|
|
|
|
if (cc->ignore_block_suitable)
|
|
return true;
|
|
|
|
/* If the block is MIGRATE_MOVABLE or MIGRATE_CMA, allow migration */
|
|
if (is_migrate_movable(get_pageblock_migratetype(page)))
|
|
return true;
|
|
|
|
/* Otherwise skip the block */
|
|
return false;
|
|
}
|
|
|
|
static inline unsigned int
|
|
freelist_scan_limit(struct compact_control *cc)
|
|
{
|
|
unsigned short shift = BITS_PER_LONG - 1;
|
|
|
|
return (COMPACT_CLUSTER_MAX >> min(shift, cc->fast_search_fail)) + 1;
|
|
}
|
|
|
|
/*
|
|
* Test whether the free scanner has reached the same or lower pageblock than
|
|
* the migration scanner, and compaction should thus terminate.
|
|
*/
|
|
static inline bool compact_scanners_met(struct compact_control *cc)
|
|
{
|
|
return (cc->free_pfn >> pageblock_order)
|
|
<= (cc->migrate_pfn >> pageblock_order);
|
|
}
|
|
|
|
/*
|
|
* Used when scanning for a suitable migration target which scans freelists
|
|
* in reverse. Reorders the list such as the unscanned pages are scanned
|
|
* first on the next iteration of the free scanner
|
|
*/
|
|
static void
|
|
move_freelist_head(struct list_head *freelist, struct page *freepage)
|
|
{
|
|
LIST_HEAD(sublist);
|
|
|
|
if (!list_is_last(freelist, &freepage->lru)) {
|
|
list_cut_before(&sublist, freelist, &freepage->lru);
|
|
if (!list_empty(&sublist))
|
|
list_splice_tail(&sublist, freelist);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Similar to move_freelist_head except used by the migration scanner
|
|
* when scanning forward. It's possible for these list operations to
|
|
* move against each other if they search the free list exactly in
|
|
* lockstep.
|
|
*/
|
|
static void
|
|
move_freelist_tail(struct list_head *freelist, struct page *freepage)
|
|
{
|
|
LIST_HEAD(sublist);
|
|
|
|
if (!list_is_first(freelist, &freepage->lru)) {
|
|
list_cut_position(&sublist, freelist, &freepage->lru);
|
|
if (!list_empty(&sublist))
|
|
list_splice_tail(&sublist, freelist);
|
|
}
|
|
}
|
|
|
|
static void
|
|
fast_isolate_around(struct compact_control *cc, unsigned long pfn)
|
|
{
|
|
unsigned long start_pfn, end_pfn;
|
|
struct page *page = pfn_to_page(pfn);
|
|
|
|
/* Do not search around if there are enough pages already */
|
|
if (cc->nr_freepages >= cc->nr_migratepages)
|
|
return;
|
|
|
|
/* Minimise scanning during async compaction */
|
|
if (cc->direct_compaction && cc->mode == MIGRATE_ASYNC)
|
|
return;
|
|
|
|
/* Pageblock boundaries */
|
|
start_pfn = pageblock_start_pfn(pfn);
|
|
end_pfn = min(pageblock_end_pfn(pfn), zone_end_pfn(cc->zone)) - 1;
|
|
|
|
isolate_freepages_block(cc, &start_pfn, end_pfn, &cc->freepages, 1, false);
|
|
|
|
/* Skip this pageblock in the future as it's full or nearly full */
|
|
if (cc->nr_freepages < cc->nr_migratepages)
|
|
set_pageblock_skip(page);
|
|
|
|
return;
|
|
}
|
|
|
|
/* Search orders in round-robin fashion */
|
|
static int next_search_order(struct compact_control *cc, int order)
|
|
{
|
|
order--;
|
|
if (order < 0)
|
|
order = cc->order - 1;
|
|
|
|
/* Search wrapped around? */
|
|
if (order == cc->search_order) {
|
|
cc->search_order--;
|
|
if (cc->search_order < 0)
|
|
cc->search_order = cc->order - 1;
|
|
return -1;
|
|
}
|
|
|
|
return order;
|
|
}
|
|
|
|
static unsigned long
|
|
fast_isolate_freepages(struct compact_control *cc)
|
|
{
|
|
unsigned int limit = min(1U, freelist_scan_limit(cc) >> 1);
|
|
unsigned int nr_scanned = 0;
|
|
unsigned long low_pfn, min_pfn, highest = 0;
|
|
unsigned long nr_isolated = 0;
|
|
unsigned long distance;
|
|
struct page *page = NULL;
|
|
bool scan_start = false;
|
|
int order;
|
|
|
|
/* Full compaction passes in a negative order */
|
|
if (cc->order <= 0)
|
|
return cc->free_pfn;
|
|
|
|
/*
|
|
* If starting the scan, use a deeper search and use the highest
|
|
* PFN found if a suitable one is not found.
|
|
*/
|
|
if (cc->free_pfn >= cc->zone->compact_init_free_pfn) {
|
|
limit = pageblock_nr_pages >> 1;
|
|
scan_start = true;
|
|
}
|
|
|
|
/*
|
|
* Preferred point is in the top quarter of the scan space but take
|
|
* a pfn from the top half if the search is problematic.
|
|
*/
|
|
distance = (cc->free_pfn - cc->migrate_pfn);
|
|
low_pfn = pageblock_start_pfn(cc->free_pfn - (distance >> 2));
|
|
min_pfn = pageblock_start_pfn(cc->free_pfn - (distance >> 1));
|
|
|
|
if (WARN_ON_ONCE(min_pfn > low_pfn))
|
|
low_pfn = min_pfn;
|
|
|
|
/*
|
|
* Search starts from the last successful isolation order or the next
|
|
* order to search after a previous failure
|
|
*/
|
|
cc->search_order = min_t(unsigned int, cc->order - 1, cc->search_order);
|
|
|
|
for (order = cc->search_order;
|
|
!page && order >= 0;
|
|
order = next_search_order(cc, order)) {
|
|
struct free_area *area = &cc->zone->free_area[order];
|
|
struct list_head *freelist;
|
|
struct page *freepage;
|
|
unsigned long flags;
|
|
unsigned int order_scanned = 0;
|
|
unsigned long high_pfn = 0;
|
|
|
|
if (!area->nr_free)
|
|
continue;
|
|
|
|
spin_lock_irqsave(&cc->zone->lock, flags);
|
|
freelist = &area->free_list[MIGRATE_MOVABLE];
|
|
list_for_each_entry_reverse(freepage, freelist, lru) {
|
|
unsigned long pfn;
|
|
|
|
order_scanned++;
|
|
nr_scanned++;
|
|
pfn = page_to_pfn(freepage);
|
|
|
|
if (pfn >= highest)
|
|
highest = pageblock_start_pfn(pfn);
|
|
|
|
if (pfn >= low_pfn) {
|
|
cc->fast_search_fail = 0;
|
|
cc->search_order = order;
|
|
page = freepage;
|
|
break;
|
|
}
|
|
|
|
if (pfn >= min_pfn && pfn > high_pfn) {
|
|
high_pfn = pfn;
|
|
|
|
/* Shorten the scan if a candidate is found */
|
|
limit >>= 1;
|
|
}
|
|
|
|
if (order_scanned >= limit)
|
|
break;
|
|
}
|
|
|
|
/* Use a minimum pfn if a preferred one was not found */
|
|
if (!page && high_pfn) {
|
|
page = pfn_to_page(high_pfn);
|
|
|
|
/* Update freepage for the list reorder below */
|
|
freepage = page;
|
|
}
|
|
|
|
/* Reorder to so a future search skips recent pages */
|
|
move_freelist_head(freelist, freepage);
|
|
|
|
/* Isolate the page if available */
|
|
if (page) {
|
|
if (__isolate_free_page(page, order)) {
|
|
set_page_private(page, order);
|
|
nr_isolated = 1 << order;
|
|
cc->nr_freepages += nr_isolated;
|
|
list_add_tail(&page->lru, &cc->freepages);
|
|
count_compact_events(COMPACTISOLATED, nr_isolated);
|
|
} else {
|
|
/* If isolation fails, abort the search */
|
|
order = cc->search_order + 1;
|
|
page = NULL;
|
|
}
|
|
}
|
|
|
|
spin_unlock_irqrestore(&cc->zone->lock, flags);
|
|
|
|
/*
|
|
* Smaller scan on next order so the total scan ig related
|
|
* to freelist_scan_limit.
|
|
*/
|
|
if (order_scanned >= limit)
|
|
limit = min(1U, limit >> 1);
|
|
}
|
|
|
|
if (!page) {
|
|
cc->fast_search_fail++;
|
|
if (scan_start) {
|
|
/*
|
|
* Use the highest PFN found above min. If one was
|
|
* not found, be pessemistic for direct compaction
|
|
* and use the min mark.
|
|
*/
|
|
if (highest) {
|
|
page = pfn_to_page(highest);
|
|
cc->free_pfn = highest;
|
|
} else {
|
|
if (cc->direct_compaction && pfn_valid(min_pfn)) {
|
|
page = pfn_to_page(min_pfn);
|
|
cc->free_pfn = min_pfn;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (highest && highest >= cc->zone->compact_cached_free_pfn) {
|
|
highest -= pageblock_nr_pages;
|
|
cc->zone->compact_cached_free_pfn = highest;
|
|
}
|
|
|
|
cc->total_free_scanned += nr_scanned;
|
|
if (!page)
|
|
return cc->free_pfn;
|
|
|
|
low_pfn = page_to_pfn(page);
|
|
fast_isolate_around(cc, low_pfn);
|
|
return low_pfn;
|
|
}
|
|
|
|
/*
|
|
* Based on information in the current compact_control, find blocks
|
|
* suitable for isolating free pages from and then isolate them.
|
|
*/
|
|
static void isolate_freepages(struct compact_control *cc)
|
|
{
|
|
struct zone *zone = cc->zone;
|
|
struct page *page;
|
|
unsigned long block_start_pfn; /* start of current pageblock */
|
|
unsigned long isolate_start_pfn; /* exact pfn we start at */
|
|
unsigned long block_end_pfn; /* end of current pageblock */
|
|
unsigned long low_pfn; /* lowest pfn scanner is able to scan */
|
|
struct list_head *freelist = &cc->freepages;
|
|
unsigned int stride;
|
|
|
|
/* Try a small search of the free lists for a candidate */
|
|
isolate_start_pfn = fast_isolate_freepages(cc);
|
|
if (cc->nr_freepages)
|
|
goto splitmap;
|
|
|
|
/*
|
|
* Initialise the free scanner. The starting point is where we last
|
|
* successfully isolated from, zone-cached value, or the end of the
|
|
* zone when isolating for the first time. For looping we also need
|
|
* this pfn aligned down to the pageblock boundary, because we do
|
|
* block_start_pfn -= pageblock_nr_pages in the for loop.
|
|
* For ending point, take care when isolating in last pageblock of a
|
|
* a zone which ends in the middle of a pageblock.
|
|
* The low boundary is the end of the pageblock the migration scanner
|
|
* is using.
|
|
*/
|
|
isolate_start_pfn = cc->free_pfn;
|
|
block_start_pfn = pageblock_start_pfn(isolate_start_pfn);
|
|
block_end_pfn = min(block_start_pfn + pageblock_nr_pages,
|
|
zone_end_pfn(zone));
|
|
low_pfn = pageblock_end_pfn(cc->migrate_pfn);
|
|
stride = cc->mode == MIGRATE_ASYNC ? COMPACT_CLUSTER_MAX : 1;
|
|
|
|
/*
|
|
* Isolate free pages until enough are available to migrate the
|
|
* pages on cc->migratepages. We stop searching if the migrate
|
|
* and free page scanners meet or enough free pages are isolated.
|
|
*/
|
|
for (; block_start_pfn >= low_pfn;
|
|
block_end_pfn = block_start_pfn,
|
|
block_start_pfn -= pageblock_nr_pages,
|
|
isolate_start_pfn = block_start_pfn) {
|
|
unsigned long nr_isolated;
|
|
|
|
/*
|
|
* This can iterate a massively long zone without finding any
|
|
* suitable migration targets, so periodically check resched.
|
|
*/
|
|
if (!(block_start_pfn % (SWAP_CLUSTER_MAX * pageblock_nr_pages)))
|
|
cond_resched();
|
|
|
|
page = pageblock_pfn_to_page(block_start_pfn, block_end_pfn,
|
|
zone);
|
|
if (!page)
|
|
continue;
|
|
|
|
/* Check the block is suitable for migration */
|
|
if (!suitable_migration_target(cc, page))
|
|
continue;
|
|
|
|
/* If isolation recently failed, do not retry */
|
|
if (!isolation_suitable(cc, page))
|
|
continue;
|
|
|
|
/* Found a block suitable for isolating free pages from. */
|
|
nr_isolated = isolate_freepages_block(cc, &isolate_start_pfn,
|
|
block_end_pfn, freelist, stride, false);
|
|
|
|
/* Update the skip hint if the full pageblock was scanned */
|
|
if (isolate_start_pfn == block_end_pfn)
|
|
update_pageblock_skip(cc, page, block_start_pfn);
|
|
|
|
/* Are enough freepages isolated? */
|
|
if (cc->nr_freepages >= cc->nr_migratepages) {
|
|
if (isolate_start_pfn >= block_end_pfn) {
|
|
/*
|
|
* Restart at previous pageblock if more
|
|
* freepages can be isolated next time.
|
|
*/
|
|
isolate_start_pfn =
|
|
block_start_pfn - pageblock_nr_pages;
|
|
}
|
|
break;
|
|
} else if (isolate_start_pfn < block_end_pfn) {
|
|
/*
|
|
* If isolation failed early, do not continue
|
|
* needlessly.
|
|
*/
|
|
break;
|
|
}
|
|
|
|
/* Adjust stride depending on isolation */
|
|
if (nr_isolated) {
|
|
stride = 1;
|
|
continue;
|
|
}
|
|
stride = min_t(unsigned int, COMPACT_CLUSTER_MAX, stride << 1);
|
|
}
|
|
|
|
/*
|
|
* Record where the free scanner will restart next time. Either we
|
|
* broke from the loop and set isolate_start_pfn based on the last
|
|
* call to isolate_freepages_block(), or we met the migration scanner
|
|
* and the loop terminated due to isolate_start_pfn < low_pfn
|
|
*/
|
|
cc->free_pfn = isolate_start_pfn;
|
|
|
|
splitmap:
|
|
/* __isolate_free_page() does not map the pages */
|
|
split_map_pages(freelist);
|
|
}
|
|
|
|
/*
|
|
* This is a migrate-callback that "allocates" freepages by taking pages
|
|
* from the isolated freelists in the block we are migrating to.
|
|
*/
|
|
static struct page *compaction_alloc(struct page *migratepage,
|
|
unsigned long data)
|
|
{
|
|
struct compact_control *cc = (struct compact_control *)data;
|
|
struct page *freepage;
|
|
|
|
if (list_empty(&cc->freepages)) {
|
|
isolate_freepages(cc);
|
|
|
|
if (list_empty(&cc->freepages))
|
|
return NULL;
|
|
}
|
|
|
|
freepage = list_entry(cc->freepages.next, struct page, lru);
|
|
list_del(&freepage->lru);
|
|
cc->nr_freepages--;
|
|
|
|
return freepage;
|
|
}
|
|
|
|
/*
|
|
* This is a migrate-callback that "frees" freepages back to the isolated
|
|
* freelist. All pages on the freelist are from the same zone, so there is no
|
|
* special handling needed for NUMA.
|
|
*/
|
|
static void compaction_free(struct page *page, unsigned long data)
|
|
{
|
|
struct compact_control *cc = (struct compact_control *)data;
|
|
|
|
list_add(&page->lru, &cc->freepages);
|
|
cc->nr_freepages++;
|
|
}
|
|
|
|
/* possible outcome of isolate_migratepages */
|
|
typedef enum {
|
|
ISOLATE_ABORT, /* Abort compaction now */
|
|
ISOLATE_NONE, /* No pages isolated, continue scanning */
|
|
ISOLATE_SUCCESS, /* Pages isolated, migrate */
|
|
} isolate_migrate_t;
|
|
|
|
/*
|
|
* Allow userspace to control policy on scanning the unevictable LRU for
|
|
* compactable pages.
|
|
*/
|
|
int sysctl_compact_unevictable_allowed __read_mostly = 1;
|
|
|
|
static inline void
|
|
update_fast_start_pfn(struct compact_control *cc, unsigned long pfn)
|
|
{
|
|
if (cc->fast_start_pfn == ULONG_MAX)
|
|
return;
|
|
|
|
if (!cc->fast_start_pfn)
|
|
cc->fast_start_pfn = pfn;
|
|
|
|
cc->fast_start_pfn = min(cc->fast_start_pfn, pfn);
|
|
}
|
|
|
|
static inline unsigned long
|
|
reinit_migrate_pfn(struct compact_control *cc)
|
|
{
|
|
if (!cc->fast_start_pfn || cc->fast_start_pfn == ULONG_MAX)
|
|
return cc->migrate_pfn;
|
|
|
|
cc->migrate_pfn = cc->fast_start_pfn;
|
|
cc->fast_start_pfn = ULONG_MAX;
|
|
|
|
return cc->migrate_pfn;
|
|
}
|
|
|
|
/*
|
|
* Briefly search the free lists for a migration source that already has
|
|
* some free pages to reduce the number of pages that need migration
|
|
* before a pageblock is free.
|
|
*/
|
|
static unsigned long fast_find_migrateblock(struct compact_control *cc)
|
|
{
|
|
unsigned int limit = freelist_scan_limit(cc);
|
|
unsigned int nr_scanned = 0;
|
|
unsigned long distance;
|
|
unsigned long pfn = cc->migrate_pfn;
|
|
unsigned long high_pfn;
|
|
int order;
|
|
bool found_block = false;
|
|
|
|
/* Skip hints are relied on to avoid repeats on the fast search */
|
|
if (cc->ignore_skip_hint)
|
|
return pfn;
|
|
|
|
/*
|
|
* If the migrate_pfn is not at the start of a zone or the start
|
|
* of a pageblock then assume this is a continuation of a previous
|
|
* scan restarted due to COMPACT_CLUSTER_MAX.
|
|
*/
|
|
if (pfn != cc->zone->zone_start_pfn && pfn != pageblock_start_pfn(pfn))
|
|
return pfn;
|
|
|
|
/*
|
|
* For smaller orders, just linearly scan as the number of pages
|
|
* to migrate should be relatively small and does not necessarily
|
|
* justify freeing up a large block for a small allocation.
|
|
*/
|
|
if (cc->order <= PAGE_ALLOC_COSTLY_ORDER)
|
|
return pfn;
|
|
|
|
/*
|
|
* Only allow kcompactd and direct requests for movable pages to
|
|
* quickly clear out a MOVABLE pageblock for allocation. This
|
|
* reduces the risk that a large movable pageblock is freed for
|
|
* an unmovable/reclaimable small allocation.
|
|
*/
|
|
if (cc->direct_compaction && cc->migratetype != MIGRATE_MOVABLE)
|
|
return pfn;
|
|
|
|
/*
|
|
* When starting the migration scanner, pick any pageblock within the
|
|
* first half of the search space. Otherwise try and pick a pageblock
|
|
* within the first eighth to reduce the chances that a migration
|
|
* target later becomes a source.
|
|
*/
|
|
distance = (cc->free_pfn - cc->migrate_pfn) >> 1;
|
|
if (cc->migrate_pfn != cc->zone->zone_start_pfn)
|
|
distance >>= 2;
|
|
high_pfn = pageblock_start_pfn(cc->migrate_pfn + distance);
|
|
|
|
for (order = cc->order - 1;
|
|
order >= PAGE_ALLOC_COSTLY_ORDER && !found_block && nr_scanned < limit;
|
|
order--) {
|
|
struct free_area *area = &cc->zone->free_area[order];
|
|
struct list_head *freelist;
|
|
unsigned long flags;
|
|
struct page *freepage;
|
|
|
|
if (!area->nr_free)
|
|
continue;
|
|
|
|
spin_lock_irqsave(&cc->zone->lock, flags);
|
|
freelist = &area->free_list[MIGRATE_MOVABLE];
|
|
list_for_each_entry(freepage, freelist, lru) {
|
|
unsigned long free_pfn;
|
|
|
|
if (nr_scanned++ >= limit) {
|
|
move_freelist_tail(freelist, freepage);
|
|
break;
|
|
}
|
|
|
|
free_pfn = page_to_pfn(freepage);
|
|
if (free_pfn < high_pfn) {
|
|
/*
|
|
* Avoid if skipped recently. Ideally it would
|
|
* move to the tail but even safe iteration of
|
|
* the list assumes an entry is deleted, not
|
|
* reordered.
|
|
*/
|
|
if (get_pageblock_skip(freepage))
|
|
continue;
|
|
|
|
/* Reorder to so a future search skips recent pages */
|
|
move_freelist_tail(freelist, freepage);
|
|
|
|
update_fast_start_pfn(cc, free_pfn);
|
|
pfn = pageblock_start_pfn(free_pfn);
|
|
if (pfn < cc->zone->zone_start_pfn)
|
|
pfn = cc->zone->zone_start_pfn;
|
|
cc->fast_search_fail = 0;
|
|
found_block = true;
|
|
set_pageblock_skip(freepage);
|
|
break;
|
|
}
|
|
}
|
|
spin_unlock_irqrestore(&cc->zone->lock, flags);
|
|
}
|
|
|
|
cc->total_migrate_scanned += nr_scanned;
|
|
|
|
/*
|
|
* If fast scanning failed then use a cached entry for a page block
|
|
* that had free pages as the basis for starting a linear scan.
|
|
*/
|
|
if (!found_block) {
|
|
cc->fast_search_fail++;
|
|
pfn = reinit_migrate_pfn(cc);
|
|
}
|
|
return pfn;
|
|
}
|
|
|
|
/*
|
|
* Isolate all pages that can be migrated from the first suitable block,
|
|
* starting at the block pointed to by the migrate scanner pfn within
|
|
* compact_control.
|
|
*/
|
|
static isolate_migrate_t isolate_migratepages(struct compact_control *cc)
|
|
{
|
|
unsigned long block_start_pfn;
|
|
unsigned long block_end_pfn;
|
|
unsigned long low_pfn;
|
|
struct page *page;
|
|
const isolate_mode_t isolate_mode =
|
|
(sysctl_compact_unevictable_allowed ? ISOLATE_UNEVICTABLE : 0) |
|
|
(cc->mode != MIGRATE_SYNC ? ISOLATE_ASYNC_MIGRATE : 0);
|
|
bool fast_find_block;
|
|
|
|
/*
|
|
* Start at where we last stopped, or beginning of the zone as
|
|
* initialized by compact_zone(). The first failure will use
|
|
* the lowest PFN as the starting point for linear scanning.
|
|
*/
|
|
low_pfn = fast_find_migrateblock(cc);
|
|
block_start_pfn = pageblock_start_pfn(low_pfn);
|
|
if (block_start_pfn < cc->zone->zone_start_pfn)
|
|
block_start_pfn = cc->zone->zone_start_pfn;
|
|
|
|
/*
|
|
* fast_find_migrateblock marks a pageblock skipped so to avoid
|
|
* the isolation_suitable check below, check whether the fast
|
|
* search was successful.
|
|
*/
|
|
fast_find_block = low_pfn != cc->migrate_pfn && !cc->fast_search_fail;
|
|
|
|
/* Only scan within a pageblock boundary */
|
|
block_end_pfn = pageblock_end_pfn(low_pfn);
|
|
|
|
/*
|
|
* Iterate over whole pageblocks until we find the first suitable.
|
|
* Do not cross the free scanner.
|
|
*/
|
|
for (; block_end_pfn <= cc->free_pfn;
|
|
fast_find_block = false,
|
|
low_pfn = block_end_pfn,
|
|
block_start_pfn = block_end_pfn,
|
|
block_end_pfn += pageblock_nr_pages) {
|
|
|
|
/*
|
|
* This can potentially iterate a massively long zone with
|
|
* many pageblocks unsuitable, so periodically check if we
|
|
* need to schedule.
|
|
*/
|
|
if (!(low_pfn % (SWAP_CLUSTER_MAX * pageblock_nr_pages)))
|
|
cond_resched();
|
|
|
|
page = pageblock_pfn_to_page(block_start_pfn,
|
|
block_end_pfn, cc->zone);
|
|
if (!page)
|
|
continue;
|
|
|
|
/*
|
|
* If isolation recently failed, do not retry. Only check the
|
|
* pageblock once. COMPACT_CLUSTER_MAX causes a pageblock
|
|
* to be visited multiple times. Assume skip was checked
|
|
* before making it "skip" so other compaction instances do
|
|
* not scan the same block.
|
|
*/
|
|
if (IS_ALIGNED(low_pfn, pageblock_nr_pages) &&
|
|
!fast_find_block && !isolation_suitable(cc, page))
|
|
continue;
|
|
|
|
/*
|
|
* For async compaction, also only scan in MOVABLE blocks
|
|
* without huge pages. Async compaction is optimistic to see
|
|
* if the minimum amount of work satisfies the allocation.
|
|
* The cached PFN is updated as it's possible that all
|
|
* remaining blocks between source and target are unsuitable
|
|
* and the compaction scanners fail to meet.
|
|
*/
|
|
if (!suitable_migration_source(cc, page)) {
|
|
update_cached_migrate(cc, block_end_pfn);
|
|
continue;
|
|
}
|
|
|
|
/* Perform the isolation */
|
|
low_pfn = isolate_migratepages_block(cc, low_pfn,
|
|
block_end_pfn, isolate_mode);
|
|
|
|
if (!low_pfn)
|
|
return ISOLATE_ABORT;
|
|
|
|
/*
|
|
* Either we isolated something and proceed with migration. Or
|
|
* we failed and compact_zone should decide if we should
|
|
* continue or not.
|
|
*/
|
|
break;
|
|
}
|
|
|
|
/* Record where migration scanner will be restarted. */
|
|
cc->migrate_pfn = low_pfn;
|
|
|
|
return cc->nr_migratepages ? ISOLATE_SUCCESS : ISOLATE_NONE;
|
|
}
|
|
|
|
/*
|
|
* order == -1 is expected when compacting via
|
|
* /proc/sys/vm/compact_memory
|
|
*/
|
|
static inline bool is_via_compact_memory(int order)
|
|
{
|
|
return order == -1;
|
|
}
|
|
|
|
static enum compact_result __compact_finished(struct compact_control *cc)
|
|
{
|
|
unsigned int order;
|
|
const int migratetype = cc->migratetype;
|
|
int ret;
|
|
|
|
/* Compaction run completes if the migrate and free scanner meet */
|
|
if (compact_scanners_met(cc)) {
|
|
/* Let the next compaction start anew. */
|
|
reset_cached_positions(cc->zone);
|
|
|
|
/*
|
|
* Mark that the PG_migrate_skip information should be cleared
|
|
* by kswapd when it goes to sleep. kcompactd does not set the
|
|
* flag itself as the decision to be clear should be directly
|
|
* based on an allocation request.
|
|
*/
|
|
if (cc->direct_compaction)
|
|
cc->zone->compact_blockskip_flush = true;
|
|
|
|
if (cc->whole_zone)
|
|
return COMPACT_COMPLETE;
|
|
else
|
|
return COMPACT_PARTIAL_SKIPPED;
|
|
}
|
|
|
|
if (is_via_compact_memory(cc->order))
|
|
return COMPACT_CONTINUE;
|
|
|
|
/*
|
|
* Always finish scanning a pageblock to reduce the possibility of
|
|
* fallbacks in the future. This is particularly important when
|
|
* migration source is unmovable/reclaimable but it's not worth
|
|
* special casing.
|
|
*/
|
|
if (!IS_ALIGNED(cc->migrate_pfn, pageblock_nr_pages))
|
|
return COMPACT_CONTINUE;
|
|
|
|
/* Direct compactor: Is a suitable page free? */
|
|
ret = COMPACT_NO_SUITABLE_PAGE;
|
|
for (order = cc->order; order < MAX_ORDER; order++) {
|
|
struct free_area *area = &cc->zone->free_area[order];
|
|
bool can_steal;
|
|
|
|
/* Job done if page is free of the right migratetype */
|
|
if (!free_area_empty(area, migratetype))
|
|
return COMPACT_SUCCESS;
|
|
|
|
#ifdef CONFIG_CMA
|
|
/* MIGRATE_MOVABLE can fallback on MIGRATE_CMA */
|
|
if (migratetype == MIGRATE_MOVABLE &&
|
|
!free_area_empty(area, MIGRATE_CMA))
|
|
return COMPACT_SUCCESS;
|
|
#endif
|
|
/*
|
|
* Job done if allocation would steal freepages from
|
|
* other migratetype buddy lists.
|
|
*/
|
|
if (find_suitable_fallback(area, order, migratetype,
|
|
true, &can_steal) != -1) {
|
|
|
|
/* movable pages are OK in any pageblock */
|
|
if (migratetype == MIGRATE_MOVABLE)
|
|
return COMPACT_SUCCESS;
|
|
|
|
/*
|
|
* We are stealing for a non-movable allocation. Make
|
|
* sure we finish compacting the current pageblock
|
|
* first so it is as free as possible and we won't
|
|
* have to steal another one soon. This only applies
|
|
* to sync compaction, as async compaction operates
|
|
* on pageblocks of the same migratetype.
|
|
*/
|
|
if (cc->mode == MIGRATE_ASYNC ||
|
|
IS_ALIGNED(cc->migrate_pfn,
|
|
pageblock_nr_pages)) {
|
|
return COMPACT_SUCCESS;
|
|
}
|
|
|
|
ret = COMPACT_CONTINUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (cc->contended || fatal_signal_pending(current))
|
|
ret = COMPACT_CONTENDED;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static enum compact_result compact_finished(struct compact_control *cc)
|
|
{
|
|
int ret;
|
|
|
|
ret = __compact_finished(cc);
|
|
trace_mm_compaction_finished(cc->zone, cc->order, ret);
|
|
if (ret == COMPACT_NO_SUITABLE_PAGE)
|
|
ret = COMPACT_CONTINUE;
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* compaction_suitable: Is this suitable to run compaction on this zone now?
|
|
* Returns
|
|
* COMPACT_SKIPPED - If there are too few free pages for compaction
|
|
* COMPACT_SUCCESS - If the allocation would succeed without compaction
|
|
* COMPACT_CONTINUE - If compaction should run now
|
|
*/
|
|
static enum compact_result __compaction_suitable(struct zone *zone, int order,
|
|
unsigned int alloc_flags,
|
|
int classzone_idx,
|
|
unsigned long wmark_target)
|
|
{
|
|
unsigned long watermark;
|
|
|
|
if (is_via_compact_memory(order))
|
|
return COMPACT_CONTINUE;
|
|
|
|
watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
|
|
/*
|
|
* If watermarks for high-order allocation are already met, there
|
|
* should be no need for compaction at all.
|
|
*/
|
|
if (zone_watermark_ok(zone, order, watermark, classzone_idx,
|
|
alloc_flags))
|
|
return COMPACT_SUCCESS;
|
|
|
|
/*
|
|
* Watermarks for order-0 must be met for compaction to be able to
|
|
* isolate free pages for migration targets. This means that the
|
|
* watermark and alloc_flags have to match, or be more pessimistic than
|
|
* the check in __isolate_free_page(). We don't use the direct
|
|
* compactor's alloc_flags, as they are not relevant for freepage
|
|
* isolation. We however do use the direct compactor's classzone_idx to
|
|
* skip over zones where lowmem reserves would prevent allocation even
|
|
* if compaction succeeds.
|
|
* For costly orders, we require low watermark instead of min for
|
|
* compaction to proceed to increase its chances.
|
|
* ALLOC_CMA is used, as pages in CMA pageblocks are considered
|
|
* suitable migration targets
|
|
*/
|
|
watermark = (order > PAGE_ALLOC_COSTLY_ORDER) ?
|
|
low_wmark_pages(zone) : min_wmark_pages(zone);
|
|
watermark += compact_gap(order);
|
|
if (!__zone_watermark_ok(zone, 0, watermark, classzone_idx,
|
|
ALLOC_CMA, wmark_target))
|
|
return COMPACT_SKIPPED;
|
|
|
|
return COMPACT_CONTINUE;
|
|
}
|
|
|
|
enum compact_result compaction_suitable(struct zone *zone, int order,
|
|
unsigned int alloc_flags,
|
|
int classzone_idx)
|
|
{
|
|
enum compact_result ret;
|
|
int fragindex;
|
|
|
|
ret = __compaction_suitable(zone, order, alloc_flags, classzone_idx,
|
|
zone_page_state(zone, NR_FREE_PAGES));
|
|
/*
|
|
* fragmentation index determines if allocation failures are due to
|
|
* low memory or external fragmentation
|
|
*
|
|
* index of -1000 would imply allocations might succeed depending on
|
|
* watermarks, but we already failed the high-order watermark check
|
|
* index towards 0 implies failure is due to lack of memory
|
|
* index towards 1000 implies failure is due to fragmentation
|
|
*
|
|
* Only compact if a failure would be due to fragmentation. Also
|
|
* ignore fragindex for non-costly orders where the alternative to
|
|
* a successful reclaim/compaction is OOM. Fragindex and the
|
|
* vm.extfrag_threshold sysctl is meant as a heuristic to prevent
|
|
* excessive compaction for costly orders, but it should not be at the
|
|
* expense of system stability.
|
|
*/
|
|
if (ret == COMPACT_CONTINUE && (order > PAGE_ALLOC_COSTLY_ORDER)) {
|
|
fragindex = fragmentation_index(zone, order);
|
|
if (fragindex >= 0 && fragindex <= sysctl_extfrag_threshold)
|
|
ret = COMPACT_NOT_SUITABLE_ZONE;
|
|
}
|
|
|
|
trace_mm_compaction_suitable(zone, order, ret);
|
|
if (ret == COMPACT_NOT_SUITABLE_ZONE)
|
|
ret = COMPACT_SKIPPED;
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
|
|
int alloc_flags)
|
|
{
|
|
struct zone *zone;
|
|
struct zoneref *z;
|
|
|
|
/*
|
|
* Make sure at least one zone would pass __compaction_suitable if we continue
|
|
* retrying the reclaim.
|
|
*/
|
|
for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->high_zoneidx,
|
|
ac->nodemask) {
|
|
unsigned long available;
|
|
enum compact_result compact_result;
|
|
|
|
/*
|
|
* Do not consider all the reclaimable memory because we do not
|
|
* want to trash just for a single high order allocation which
|
|
* is even not guaranteed to appear even if __compaction_suitable
|
|
* is happy about the watermark check.
|
|
*/
|
|
available = zone_reclaimable_pages(zone) / order;
|
|
available += zone_page_state_snapshot(zone, NR_FREE_PAGES);
|
|
compact_result = __compaction_suitable(zone, order, alloc_flags,
|
|
ac_classzone_idx(ac), available);
|
|
if (compact_result != COMPACT_SKIPPED)
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static enum compact_result
|
|
compact_zone(struct compact_control *cc, struct capture_control *capc)
|
|
{
|
|
enum compact_result ret;
|
|
unsigned long start_pfn = cc->zone->zone_start_pfn;
|
|
unsigned long end_pfn = zone_end_pfn(cc->zone);
|
|
unsigned long last_migrated_pfn;
|
|
const bool sync = cc->mode != MIGRATE_ASYNC;
|
|
bool update_cached;
|
|
|
|
/*
|
|
* These counters track activities during zone compaction. Initialize
|
|
* them before compacting a new zone.
|
|
*/
|
|
cc->total_migrate_scanned = 0;
|
|
cc->total_free_scanned = 0;
|
|
cc->nr_migratepages = 0;
|
|
cc->nr_freepages = 0;
|
|
INIT_LIST_HEAD(&cc->freepages);
|
|
INIT_LIST_HEAD(&cc->migratepages);
|
|
|
|
cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask);
|
|
ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags,
|
|
cc->classzone_idx);
|
|
/* Compaction is likely to fail */
|
|
if (ret == COMPACT_SUCCESS || ret == COMPACT_SKIPPED)
|
|
return ret;
|
|
|
|
/* huh, compaction_suitable is returning something unexpected */
|
|
VM_BUG_ON(ret != COMPACT_CONTINUE);
|
|
|
|
/*
|
|
* Clear pageblock skip if there were failures recently and compaction
|
|
* is about to be retried after being deferred.
|
|
*/
|
|
if (compaction_restarting(cc->zone, cc->order))
|
|
__reset_isolation_suitable(cc->zone);
|
|
|
|
/*
|
|
* Setup to move all movable pages to the end of the zone. Used cached
|
|
* information on where the scanners should start (unless we explicitly
|
|
* want to compact the whole zone), but check that it is initialised
|
|
* by ensuring the values are within zone boundaries.
|
|
*/
|
|
cc->fast_start_pfn = 0;
|
|
if (cc->whole_zone) {
|
|
cc->migrate_pfn = start_pfn;
|
|
cc->free_pfn = pageblock_start_pfn(end_pfn - 1);
|
|
} else {
|
|
cc->migrate_pfn = cc->zone->compact_cached_migrate_pfn[sync];
|
|
cc->free_pfn = cc->zone->compact_cached_free_pfn;
|
|
if (cc->free_pfn < start_pfn || cc->free_pfn >= end_pfn) {
|
|
cc->free_pfn = pageblock_start_pfn(end_pfn - 1);
|
|
cc->zone->compact_cached_free_pfn = cc->free_pfn;
|
|
}
|
|
if (cc->migrate_pfn < start_pfn || cc->migrate_pfn >= end_pfn) {
|
|
cc->migrate_pfn = start_pfn;
|
|
cc->zone->compact_cached_migrate_pfn[0] = cc->migrate_pfn;
|
|
cc->zone->compact_cached_migrate_pfn[1] = cc->migrate_pfn;
|
|
}
|
|
|
|
if (cc->migrate_pfn <= cc->zone->compact_init_migrate_pfn)
|
|
cc->whole_zone = true;
|
|
}
|
|
|
|
last_migrated_pfn = 0;
|
|
|
|
/*
|
|
* Migrate has separate cached PFNs for ASYNC and SYNC* migration on
|
|
* the basis that some migrations will fail in ASYNC mode. However,
|
|
* if the cached PFNs match and pageblocks are skipped due to having
|
|
* no isolation candidates, then the sync state does not matter.
|
|
* Until a pageblock with isolation candidates is found, keep the
|
|
* cached PFNs in sync to avoid revisiting the same blocks.
|
|
*/
|
|
update_cached = !sync &&
|
|
cc->zone->compact_cached_migrate_pfn[0] == cc->zone->compact_cached_migrate_pfn[1];
|
|
|
|
trace_mm_compaction_begin(start_pfn, cc->migrate_pfn,
|
|
cc->free_pfn, end_pfn, sync);
|
|
|
|
migrate_prep_local();
|
|
|
|
while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) {
|
|
int err;
|
|
unsigned long start_pfn = cc->migrate_pfn;
|
|
|
|
/*
|
|
* Avoid multiple rescans which can happen if a page cannot be
|
|
* isolated (dirty/writeback in async mode) or if the migrated
|
|
* pages are being allocated before the pageblock is cleared.
|
|
* The first rescan will capture the entire pageblock for
|
|
* migration. If it fails, it'll be marked skip and scanning
|
|
* will proceed as normal.
|
|
*/
|
|
cc->rescan = false;
|
|
if (pageblock_start_pfn(last_migrated_pfn) ==
|
|
pageblock_start_pfn(start_pfn)) {
|
|
cc->rescan = true;
|
|
}
|
|
|
|
switch (isolate_migratepages(cc)) {
|
|
case ISOLATE_ABORT:
|
|
ret = COMPACT_CONTENDED;
|
|
putback_movable_pages(&cc->migratepages);
|
|
cc->nr_migratepages = 0;
|
|
last_migrated_pfn = 0;
|
|
goto out;
|
|
case ISOLATE_NONE:
|
|
if (update_cached) {
|
|
cc->zone->compact_cached_migrate_pfn[1] =
|
|
cc->zone->compact_cached_migrate_pfn[0];
|
|
}
|
|
|
|
/*
|
|
* We haven't isolated and migrated anything, but
|
|
* there might still be unflushed migrations from
|
|
* previous cc->order aligned block.
|
|
*/
|
|
goto check_drain;
|
|
case ISOLATE_SUCCESS:
|
|
update_cached = false;
|
|
last_migrated_pfn = start_pfn;
|
|
;
|
|
}
|
|
|
|
err = migrate_pages(&cc->migratepages, compaction_alloc,
|
|
compaction_free, (unsigned long)cc, cc->mode,
|
|
MR_COMPACTION);
|
|
|
|
trace_mm_compaction_migratepages(cc->nr_migratepages, err,
|
|
&cc->migratepages);
|
|
|
|
/* All pages were either migrated or will be released */
|
|
cc->nr_migratepages = 0;
|
|
if (err) {
|
|
putback_movable_pages(&cc->migratepages);
|
|
/*
|
|
* migrate_pages() may return -ENOMEM when scanners meet
|
|
* and we want compact_finished() to detect it
|
|
*/
|
|
if (err == -ENOMEM && !compact_scanners_met(cc)) {
|
|
ret = COMPACT_CONTENDED;
|
|
goto out;
|
|
}
|
|
/*
|
|
* We failed to migrate at least one page in the current
|
|
* order-aligned block, so skip the rest of it.
|
|
*/
|
|
if (cc->direct_compaction &&
|
|
(cc->mode == MIGRATE_ASYNC)) {
|
|
cc->migrate_pfn = block_end_pfn(
|
|
cc->migrate_pfn - 1, cc->order);
|
|
/* Draining pcplists is useless in this case */
|
|
last_migrated_pfn = 0;
|
|
}
|
|
}
|
|
|
|
check_drain:
|
|
/*
|
|
* Has the migration scanner moved away from the previous
|
|
* cc->order aligned block where we migrated from? If yes,
|
|
* flush the pages that were freed, so that they can merge and
|
|
* compact_finished() can detect immediately if allocation
|
|
* would succeed.
|
|
*/
|
|
if (cc->order > 0 && last_migrated_pfn) {
|
|
int cpu;
|
|
unsigned long current_block_start =
|
|
block_start_pfn(cc->migrate_pfn, cc->order);
|
|
|
|
if (last_migrated_pfn < current_block_start) {
|
|
cpu = get_cpu();
|
|
lru_add_drain_cpu(cpu);
|
|
drain_local_pages(cc->zone);
|
|
put_cpu();
|
|
/* No more flushing until we migrate again */
|
|
last_migrated_pfn = 0;
|
|
}
|
|
}
|
|
|
|
/* Stop if a page has been captured */
|
|
if (capc && capc->page) {
|
|
ret = COMPACT_SUCCESS;
|
|
break;
|
|
}
|
|
}
|
|
|
|
out:
|
|
/*
|
|
* Release free pages and update where the free scanner should restart,
|
|
* so we don't leave any returned pages behind in the next attempt.
|
|
*/
|
|
if (cc->nr_freepages > 0) {
|
|
unsigned long free_pfn = release_freepages(&cc->freepages);
|
|
|
|
cc->nr_freepages = 0;
|
|
VM_BUG_ON(free_pfn == 0);
|
|
/* The cached pfn is always the first in a pageblock */
|
|
free_pfn = pageblock_start_pfn(free_pfn);
|
|
/*
|
|
* Only go back, not forward. The cached pfn might have been
|
|
* already reset to zone end in compact_finished()
|
|
*/
|
|
if (free_pfn > cc->zone->compact_cached_free_pfn)
|
|
cc->zone->compact_cached_free_pfn = free_pfn;
|
|
}
|
|
|
|
count_compact_events(COMPACTMIGRATE_SCANNED, cc->total_migrate_scanned);
|
|
count_compact_events(COMPACTFREE_SCANNED, cc->total_free_scanned);
|
|
|
|
trace_mm_compaction_end(start_pfn, cc->migrate_pfn,
|
|
cc->free_pfn, end_pfn, sync, ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static enum compact_result compact_zone_order(struct zone *zone, int order,
|
|
gfp_t gfp_mask, enum compact_priority prio,
|
|
unsigned int alloc_flags, int classzone_idx,
|
|
struct page **capture)
|
|
{
|
|
enum compact_result ret;
|
|
struct compact_control cc = {
|
|
.order = order,
|
|
.search_order = order,
|
|
.gfp_mask = gfp_mask,
|
|
.zone = zone,
|
|
.mode = (prio == COMPACT_PRIO_ASYNC) ?
|
|
MIGRATE_ASYNC : MIGRATE_SYNC_LIGHT,
|
|
.alloc_flags = alloc_flags,
|
|
.classzone_idx = classzone_idx,
|
|
.direct_compaction = true,
|
|
.whole_zone = (prio == MIN_COMPACT_PRIORITY),
|
|
.ignore_skip_hint = (prio == MIN_COMPACT_PRIORITY),
|
|
.ignore_block_suitable = (prio == MIN_COMPACT_PRIORITY)
|
|
};
|
|
struct capture_control capc = {
|
|
.cc = &cc,
|
|
.page = NULL,
|
|
};
|
|
|
|
/*
|
|
* Make sure the structs are really initialized before we expose the
|
|
* capture control, in case we are interrupted and the interrupt handler
|
|
* frees a page.
|
|
*/
|
|
barrier();
|
|
WRITE_ONCE(current->capture_control, &capc);
|
|
|
|
ret = compact_zone(&cc, &capc);
|
|
|
|
VM_BUG_ON(!list_empty(&cc.freepages));
|
|
VM_BUG_ON(!list_empty(&cc.migratepages));
|
|
|
|
/*
|
|
* Make sure we hide capture control first before we read the captured
|
|
* page pointer, otherwise an interrupt could free and capture a page
|
|
* and we would leak it.
|
|
*/
|
|
WRITE_ONCE(current->capture_control, NULL);
|
|
*capture = READ_ONCE(capc.page);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int sysctl_extfrag_threshold = 500;
|
|
|
|
/**
|
|
* try_to_compact_pages - Direct compact to satisfy a high-order allocation
|
|
* @gfp_mask: The GFP mask of the current allocation
|
|
* @order: The order of the current allocation
|
|
* @alloc_flags: The allocation flags of the current allocation
|
|
* @ac: The context of current allocation
|
|
* @prio: Determines how hard direct compaction should try to succeed
|
|
* @capture: Pointer to free page created by compaction will be stored here
|
|
*
|
|
* This is the main entry point for direct page compaction.
|
|
*/
|
|
enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
|
|
unsigned int alloc_flags, const struct alloc_context *ac,
|
|
enum compact_priority prio, struct page **capture)
|
|
{
|
|
int may_perform_io = gfp_mask & __GFP_IO;
|
|
struct zoneref *z;
|
|
struct zone *zone;
|
|
enum compact_result rc = COMPACT_SKIPPED;
|
|
|
|
/*
|
|
* Check if the GFP flags allow compaction - GFP_NOIO is really
|
|
* tricky context because the migration might require IO
|
|
*/
|
|
if (!may_perform_io)
|
|
return COMPACT_SKIPPED;
|
|
|
|
trace_mm_compaction_try_to_compact_pages(order, gfp_mask, prio);
|
|
|
|
/* Compact each zone in the list */
|
|
for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->high_zoneidx,
|
|
ac->nodemask) {
|
|
enum compact_result status;
|
|
|
|
if (prio > MIN_COMPACT_PRIORITY
|
|
&& compaction_deferred(zone, order)) {
|
|
rc = max_t(enum compact_result, COMPACT_DEFERRED, rc);
|
|
continue;
|
|
}
|
|
|
|
status = compact_zone_order(zone, order, gfp_mask, prio,
|
|
alloc_flags, ac_classzone_idx(ac), capture);
|
|
rc = max(status, rc);
|
|
|
|
/* The allocation should succeed, stop compacting */
|
|
if (status == COMPACT_SUCCESS) {
|
|
/*
|
|
* We think the allocation will succeed in this zone,
|
|
* but it is not certain, hence the false. The caller
|
|
* will repeat this with true if allocation indeed
|
|
* succeeds in this zone.
|
|
*/
|
|
compaction_defer_reset(zone, order, false);
|
|
|
|
break;
|
|
}
|
|
|
|
if (prio != COMPACT_PRIO_ASYNC && (status == COMPACT_COMPLETE ||
|
|
status == COMPACT_PARTIAL_SKIPPED))
|
|
/*
|
|
* We think that allocation won't succeed in this zone
|
|
* so we defer compaction there. If it ends up
|
|
* succeeding after all, it will be reset.
|
|
*/
|
|
defer_compaction(zone, order);
|
|
|
|
/*
|
|
* We might have stopped compacting due to need_resched() in
|
|
* async compaction, or due to a fatal signal detected. In that
|
|
* case do not try further zones
|
|
*/
|
|
if ((prio == COMPACT_PRIO_ASYNC && need_resched())
|
|
|| fatal_signal_pending(current))
|
|
break;
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|
|
|
|
/* Compact all zones within a node */
|
|
static void compact_node(int nid)
|
|
{
|
|
pg_data_t *pgdat = NODE_DATA(nid);
|
|
int zoneid;
|
|
struct zone *zone;
|
|
struct compact_control cc = {
|
|
.order = -1,
|
|
.mode = MIGRATE_SYNC,
|
|
.ignore_skip_hint = true,
|
|
.whole_zone = true,
|
|
.gfp_mask = GFP_KERNEL,
|
|
};
|
|
|
|
|
|
for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
|
|
|
|
zone = &pgdat->node_zones[zoneid];
|
|
if (!populated_zone(zone))
|
|
continue;
|
|
|
|
cc.zone = zone;
|
|
|
|
compact_zone(&cc, NULL);
|
|
|
|
VM_BUG_ON(!list_empty(&cc.freepages));
|
|
VM_BUG_ON(!list_empty(&cc.migratepages));
|
|
}
|
|
}
|
|
|
|
/* Compact all nodes in the system */
|
|
static void compact_nodes(void)
|
|
{
|
|
int nid;
|
|
|
|
/* Flush pending updates to the LRU lists */
|
|
lru_add_drain_all();
|
|
|
|
for_each_online_node(nid)
|
|
compact_node(nid);
|
|
}
|
|
|
|
/* The written value is actually unused, all memory is compacted */
|
|
int sysctl_compact_memory;
|
|
|
|
/*
|
|
* This is the entry point for compacting all nodes via
|
|
* /proc/sys/vm/compact_memory
|
|
*/
|
|
int sysctl_compaction_handler(struct ctl_table *table, int write,
|
|
void __user *buffer, size_t *length, loff_t *ppos)
|
|
{
|
|
if (write)
|
|
compact_nodes();
|
|
|
|
return 0;
|
|
}
|
|
|
|
#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
|
|
static ssize_t sysfs_compact_node(struct device *dev,
|
|
struct device_attribute *attr,
|
|
const char *buf, size_t count)
|
|
{
|
|
int nid = dev->id;
|
|
|
|
if (nid >= 0 && nid < nr_node_ids && node_online(nid)) {
|
|
/* Flush pending updates to the LRU lists */
|
|
lru_add_drain_all();
|
|
|
|
compact_node(nid);
|
|
}
|
|
|
|
return count;
|
|
}
|
|
static DEVICE_ATTR(compact, 0200, NULL, sysfs_compact_node);
|
|
|
|
int compaction_register_node(struct node *node)
|
|
{
|
|
return device_create_file(&node->dev, &dev_attr_compact);
|
|
}
|
|
|
|
void compaction_unregister_node(struct node *node)
|
|
{
|
|
return device_remove_file(&node->dev, &dev_attr_compact);
|
|
}
|
|
#endif /* CONFIG_SYSFS && CONFIG_NUMA */
|
|
|
|
static inline bool kcompactd_work_requested(pg_data_t *pgdat)
|
|
{
|
|
return pgdat->kcompactd_max_order > 0 || kthread_should_stop();
|
|
}
|
|
|
|
static bool kcompactd_node_suitable(pg_data_t *pgdat)
|
|
{
|
|
int zoneid;
|
|
struct zone *zone;
|
|
enum zone_type classzone_idx = pgdat->kcompactd_classzone_idx;
|
|
|
|
for (zoneid = 0; zoneid <= classzone_idx; zoneid++) {
|
|
zone = &pgdat->node_zones[zoneid];
|
|
|
|
if (!populated_zone(zone))
|
|
continue;
|
|
|
|
if (compaction_suitable(zone, pgdat->kcompactd_max_order, 0,
|
|
classzone_idx) == COMPACT_CONTINUE)
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static void kcompactd_do_work(pg_data_t *pgdat)
|
|
{
|
|
/*
|
|
* With no special task, compact all zones so that a page of requested
|
|
* order is allocatable.
|
|
*/
|
|
int zoneid;
|
|
struct zone *zone;
|
|
struct compact_control cc = {
|
|
.order = pgdat->kcompactd_max_order,
|
|
.search_order = pgdat->kcompactd_max_order,
|
|
.classzone_idx = pgdat->kcompactd_classzone_idx,
|
|
.mode = MIGRATE_SYNC_LIGHT,
|
|
.ignore_skip_hint = false,
|
|
.gfp_mask = GFP_KERNEL,
|
|
};
|
|
trace_mm_compaction_kcompactd_wake(pgdat->node_id, cc.order,
|
|
cc.classzone_idx);
|
|
count_compact_event(KCOMPACTD_WAKE);
|
|
|
|
for (zoneid = 0; zoneid <= cc.classzone_idx; zoneid++) {
|
|
int status;
|
|
|
|
zone = &pgdat->node_zones[zoneid];
|
|
if (!populated_zone(zone))
|
|
continue;
|
|
|
|
if (compaction_deferred(zone, cc.order))
|
|
continue;
|
|
|
|
if (compaction_suitable(zone, cc.order, 0, zoneid) !=
|
|
COMPACT_CONTINUE)
|
|
continue;
|
|
|
|
if (kthread_should_stop())
|
|
return;
|
|
|
|
cc.zone = zone;
|
|
status = compact_zone(&cc, NULL);
|
|
|
|
if (status == COMPACT_SUCCESS) {
|
|
compaction_defer_reset(zone, cc.order, false);
|
|
} else if (status == COMPACT_PARTIAL_SKIPPED || status == COMPACT_COMPLETE) {
|
|
/*
|
|
* Buddy pages may become stranded on pcps that could
|
|
* otherwise coalesce on the zone's free area for
|
|
* order >= cc.order. This is ratelimited by the
|
|
* upcoming deferral.
|
|
*/
|
|
drain_all_pages(zone);
|
|
|
|
/*
|
|
* We use sync migration mode here, so we defer like
|
|
* sync direct compaction does.
|
|
*/
|
|
defer_compaction(zone, cc.order);
|
|
}
|
|
|
|
count_compact_events(KCOMPACTD_MIGRATE_SCANNED,
|
|
cc.total_migrate_scanned);
|
|
count_compact_events(KCOMPACTD_FREE_SCANNED,
|
|
cc.total_free_scanned);
|
|
|
|
VM_BUG_ON(!list_empty(&cc.freepages));
|
|
VM_BUG_ON(!list_empty(&cc.migratepages));
|
|
}
|
|
|
|
/*
|
|
* Regardless of success, we are done until woken up next. But remember
|
|
* the requested order/classzone_idx in case it was higher/tighter than
|
|
* our current ones
|
|
*/
|
|
if (pgdat->kcompactd_max_order <= cc.order)
|
|
pgdat->kcompactd_max_order = 0;
|
|
if (pgdat->kcompactd_classzone_idx >= cc.classzone_idx)
|
|
pgdat->kcompactd_classzone_idx = pgdat->nr_zones - 1;
|
|
}
|
|
|
|
void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
|
|
{
|
|
if (!order)
|
|
return;
|
|
|
|
if (pgdat->kcompactd_max_order < order)
|
|
pgdat->kcompactd_max_order = order;
|
|
|
|
if (pgdat->kcompactd_classzone_idx > classzone_idx)
|
|
pgdat->kcompactd_classzone_idx = classzone_idx;
|
|
|
|
/*
|
|
* Pairs with implicit barrier in wait_event_freezable()
|
|
* such that wakeups are not missed.
|
|
*/
|
|
if (!wq_has_sleeper(&pgdat->kcompactd_wait))
|
|
return;
|
|
|
|
if (!kcompactd_node_suitable(pgdat))
|
|
return;
|
|
|
|
trace_mm_compaction_wakeup_kcompactd(pgdat->node_id, order,
|
|
classzone_idx);
|
|
wake_up_interruptible(&pgdat->kcompactd_wait);
|
|
}
|
|
|
|
/*
|
|
* The background compaction daemon, started as a kernel thread
|
|
* from the init process.
|
|
*/
|
|
static int kcompactd(void *p)
|
|
{
|
|
pg_data_t *pgdat = (pg_data_t*)p;
|
|
struct task_struct *tsk = current;
|
|
|
|
const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id);
|
|
|
|
if (!cpumask_empty(cpumask))
|
|
set_cpus_allowed_ptr(tsk, cpumask);
|
|
|
|
set_freezable();
|
|
|
|
pgdat->kcompactd_max_order = 0;
|
|
pgdat->kcompactd_classzone_idx = pgdat->nr_zones - 1;
|
|
|
|
while (!kthread_should_stop()) {
|
|
unsigned long pflags;
|
|
|
|
trace_mm_compaction_kcompactd_sleep(pgdat->node_id);
|
|
wait_event_freezable(pgdat->kcompactd_wait,
|
|
kcompactd_work_requested(pgdat));
|
|
|
|
psi_memstall_enter(&pflags);
|
|
kcompactd_do_work(pgdat);
|
|
psi_memstall_leave(&pflags);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* This kcompactd start function will be called by init and node-hot-add.
|
|
* On node-hot-add, kcompactd will moved to proper cpus if cpus are hot-added.
|
|
*/
|
|
int kcompactd_run(int nid)
|
|
{
|
|
pg_data_t *pgdat = NODE_DATA(nid);
|
|
int ret = 0;
|
|
|
|
if (pgdat->kcompactd)
|
|
return 0;
|
|
|
|
pgdat->kcompactd = kthread_run(kcompactd, pgdat, "kcompactd%d", nid);
|
|
if (IS_ERR(pgdat->kcompactd)) {
|
|
pr_err("Failed to start kcompactd on node %d\n", nid);
|
|
ret = PTR_ERR(pgdat->kcompactd);
|
|
pgdat->kcompactd = NULL;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Called by memory hotplug when all memory in a node is offlined. Caller must
|
|
* hold mem_hotplug_begin/end().
|
|
*/
|
|
void kcompactd_stop(int nid)
|
|
{
|
|
struct task_struct *kcompactd = NODE_DATA(nid)->kcompactd;
|
|
|
|
if (kcompactd) {
|
|
kthread_stop(kcompactd);
|
|
NODE_DATA(nid)->kcompactd = NULL;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* It's optimal to keep kcompactd on the same CPUs as their memory, but
|
|
* not required for correctness. So if the last cpu in a node goes
|
|
* away, we get changed to run anywhere: as the first one comes back,
|
|
* restore their cpu bindings.
|
|
*/
|
|
static int kcompactd_cpu_online(unsigned int cpu)
|
|
{
|
|
int nid;
|
|
|
|
for_each_node_state(nid, N_MEMORY) {
|
|
pg_data_t *pgdat = NODE_DATA(nid);
|
|
const struct cpumask *mask;
|
|
|
|
mask = cpumask_of_node(pgdat->node_id);
|
|
|
|
if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids)
|
|
/* One of our CPUs online: restore mask */
|
|
set_cpus_allowed_ptr(pgdat->kcompactd, mask);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int __init kcompactd_init(void)
|
|
{
|
|
int nid;
|
|
int ret;
|
|
|
|
ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
|
|
"mm/compaction:online",
|
|
kcompactd_cpu_online, NULL);
|
|
if (ret < 0) {
|
|
pr_err("kcompactd: failed to register hotplug callbacks.\n");
|
|
return ret;
|
|
}
|
|
|
|
for_each_node_state(nid, N_MEMORY)
|
|
kcompactd_run(nid);
|
|
return 0;
|
|
}
|
|
subsys_initcall(kcompactd_init)
|
|
|
|
#endif /* CONFIG_COMPACTION */
|