
This is the merge of the upstream LTS release of 5.10.101 into the android12-5.10 branch. This merge contains the following new commits:c194212a03
Merge 5.10.101 into android12-5.10-lts3969aba589
Linux 5.10.101cb86e511e7
iommu: Fix potential use-after-free during probef6b5d51976
perf: Fix list corruption in perf_cgroup_switch()ce3ca12c63
arm64: dts: imx8mq: fix lcdif port node759aeacdfe
scsi: lpfc: Reduce log messages seen after firmware download57c5d7d420
scsi: lpfc: Remove NVMe support if kernel has NVME_FC disabled199dab00f0
can: isotp: fix error path in isotp_sendmsg() to unlock wait queue3b10ebeb95
Makefile.extrawarn: Move -Wunaligned-access to W=1ad53060bdf
hwmon: (dell-smm) Speed up setting of fan speed3c75d1017c
phy: ti: Fix missing sentinel for clk_div_table6eabe53492
speakup-dectlk: Restore pitch setting3836a5ff4b
USB: serial: cp210x: add CPI Bulk Coin Recycler id51b03a9bcd
USB: serial: cp210x: add NCR Retail IO box ida21e6b2e08
USB: serial: ch341: add support for GW Instek USB2.0-Serial devices7113440a36
USB: serial: option: add ZTE MF286D modemb7ed2f9619
USB: serial: ftdi_sio: add support for Brainboxes US-159/235/320e07dde31ac
usb: raw-gadget: fix handling of dual-direction-capable endpointse9f9b877eb
usb: gadget: f_uac2: Define specific wTerminalTypefb4ff0f96d
usb: gadget: rndis: check size of RNDIS_MSG_SET command22ec100472
USB: gadget: validate interface OS descriptor requests351159167c
usb: gadget: udc: renesas_usb3: Fix host to USB_ROLE_NONE transition3bfca38914
usb: dwc3: gadget: Prevent core from processing stale TRBs2a17bd9f52
usb: ulpi: Call of_node_put correctly8b89a69166
usb: ulpi: Move of_node_put to ulpi_dev_release758290defe
net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixupa66a2b17b8
Revert "usb: dwc2: drd: fix soft connect when gadget is unconfigured"73961057e9
usb: dwc2: drd: fix soft connect when gadget is unconfigureda37960df7e
eeprom: ee1004: limit i2c reads to I2C_SMBUS_BLOCK_MAX1b99fe34e2
n_tty: wake up poll(POLLRDNORM) on receiving dataf1b2573715
vt_ioctl: add array_index_nospec to VT_ACTIVATE778302ca09
vt_ioctl: fix array_index_nospec in vt_setactivate22249886dc
net: dsa: mv88e6xxx: fix use-after-free in mv88e6xxx_mdios_unregister3a3c65c487
net: mscc: ocelot: fix mutex lock error during ethtool stats read809f030745
ice: fix IPIP and SIT TSO offloadcf11949b91
ice: fix an error code in ice_cfg_phy_fec()f8edc6feab
dpaa2-eth: unregister the netdev before disconnecting from the PHYff6c9e0fce
net: amd-xgbe: disable interrupts during pci removal657aea7828
tipc: rate limit warning for received illegal binding updateef5cdae8bc
net: mdio: aspeed: Add missing MODULE_DEVICE_TABLEbf99c14436
veth: fix races around rq->rx_notify_masked00e6d6c3bc
net: fix a memleak when uncloning an skb dst and its metadata2e9fd2d0f6
net: do not keep the dst cache when uncloning an skb dst and its metadata0bae953d7a
nfp: flower: fix ida_idx not being released09ac0fcb0a
ipmr,ip6mr: acquire RTNL before calling ip[6]mr_free_table() on failure pathe177d2e85e
net: dsa: lantiq_gswip: don't use devres for mdiobus95e5402f94
net: dsa: felix: don't use devres for mdiobus2770b79529
net: dsa: bcm_sf2: don't use devres for mdiobus475ce5dcf2
net: dsa: ar9331: register the mdiobus under devres8ccebe77df
net: dsa: mv88e6xxx: don't use devres for mdiobus4a384c1e40
bonding: pair enable_port with slave_arr_updates1ba45dd326
gpio: sifive: use the correct register to read output values48e413087d
ACPI: PM: s2idle: Cancel wakeup before dispatching EC GPE3b72d3f020
drm/panel: simple: Assign data from panel_dpi_probe() correctlybf35639192
ixgbevf: Require large buffers for build_skb on 82599VFe5a64f548a
arm64: dts: meson-g12b-odroid-n2: fix typo 'dio2133'04fe6569a7
netfilter: ctnetlink: disable helper autoassigna5ce7ee5fc
misc: fastrpc: avoid double fput() on failed usercopy21c890ca8e
drm/vc4: hdmi: Allow DBLCLK modes even if horz timing is odd.70ea005626
gpio: aggregator: Fix calling into sleeping GPIO controllers0042178a69
usb: f_fs: Fix use-after-free for epfile5a37fd9fdc
ARM: dts: imx7ulp: Fix 'assigned-clocks-parents' typo39bf132a6e
phy: xilinx: zynqmp: Fix bus width setting for SGMII108868dae2
ARM: dts: imx6qdl-udoo: Properly describe the SD card detect0a7b5e8d8c
staging: fbtft: Fix error path in fbtft_driver_module_init()74cd5cb219
ARM: dts: meson8b: Fix the UART device-tree schema validation566b558e94
ARM: dts: meson8: Fix the UART device-tree schema validation210d70f081
ARM: dts: meson: Fix the UART compatible strings88f0e61354
ARM: dts: Fix timer regression for beagleboard revision cc943a297ec
drm/rockchip: vop: Correct RK3399 VOP register fieldsa941384fba
PM: s2idle: ACPI: Fix wakeup interrupts handlingfcbac51a64
ACPI/IORT: Check node revision for PMCG resources57ede0ce65
nvme-tcp: fix bogus request completion when failing to send AER3a669d77e5
ARM: socfpga: fix missing RESET_CONTROLLER435e62d566
ARM: dts: Fix boot regression on Skomerb217b89e60
ARM: dts: imx23-evk: Remove MX23_PAD_SSP1_DETECT from hog group3f9843f2f6
riscv: fix build with binutils 2.383aa5c86572
KVM: VMX: Set vmcs.PENDING_DBG.BS on #DB in STI/MOVSS blocking shadowbd39fe29bb
KVM: SVM: Don't kill SEV guest if SMAP erratum triggers in usermode9efad4cb03
KVM: nVMX: Also filter MSR_IA32_VMX_TRUE_PINBASED_CTLS when eVMCSdb58a3d978
KVM: nVMX: eVMCS: Filter out VM_EXIT_SAVE_VMX_PREEMPTION_TIMERdc129275a7
KVM: eventfd: Fix false positive RCU usage warning87bbd78a2c
net: stmmac: dwmac-sun8i: use return val of readl_poll_timeout()c9b8cc1046
nvme-pci: add the IGNORE_DEV_SUBNQN quirk for Intel P4500/P4600 SSDsd0774cf730
perf: Always wake the parent eventa117e986e9
usb: dwc2: gadget: don't try to disable ep0 in dwc2_hsotg_suspend4607218fde
PM: hibernate: Remove register_nosave_region_late()0e42c4a3d7
scsi: myrs: Fix crash in error case3bc5b128b9
scsi: ufs: Treat link loss as fatal error12cf120803
scsi: pm8001: Fix bogus FW crash for maxcpus=187f187e526
scsi: qedf: Fix refcount issue when LOGO is received during TMFaa7352aa15
scsi: qedf: Add stag_work to all the vports150d448c66
scsi: ufs: ufshcd-pltfrm: Check the return value of devm_kstrdup()7dbda616fc
scsi: target: iscsi: Make sure the np under each tpg is unique67baac10dd
powerpc/fixmap: Fix VM debug warning on unmap3d0eafd459
net: sched: Clarify error message when qdisc kind is unknown9b569faabd
drm: panel-orientation-quirks: Add quirk for the 1Netbook OneXPlayer0d6b9d15ec
x86/perf: Avoid warning for Arch LBR without XSAVEb37dd03f2f
NFSv4 handle port presence in fs_location server string6f2974b52b
NFSv4 expose nfs_parse_server_name function5a9c613a29
NFSv4 remove zero number of fs_locations entries error check1c79aad118
NFSv4.1: Fix uninitialised variable in devicenotifyc5619c510f
nfs: nfs4clinet: check the return value of kstrdup()db053bdece
NFSv4 only print the label when its queriede2b4435fd3
NFS: change nfs_access_get_cached to only report the maskb4e0c9bcf1
tracing: Propagate is_signed to expression5234de6c79
drm/amdgpu: Set a suitable dev_info.gart_page_size6215fb4558
NFSD: Fix offset type in I/O trace points3a6a2d43e3
NFSD: Clamp WRITE offsetsc72f7c2ec3
NFS: Fix initialisation of nfs_client cl_flags fieldf47ee3a35f
net: phy: marvell: Fix MDI-x polarity setting in 88e1118-compatible PHYs6a33aa7113
net: phy: marvell: Fix RGMII Tx/Rx delays setting in 88e1121-compatible PHYs7b53d2204c
can: isotp: fix potential CAN frame reception race in isotp_rcv()c9cc027c55
mmc: sdhci-of-esdhc: Check for error num after setting mask8027ba480c
ima: Do not print policy rule with inactive LSM labels8171c8a99f
ima: Allow template selection with ima_template[_fmt]= after ima_hash=0795b7100d
ima: Remove ima_policy file before directory7fea2e5200
integrity: check the return value of audit_log_start()86e6176a42
Merge 5.10.100 into android12-5.10-ltsd4f7d322a4
Linux 5.10.1003c7e594355
tipc: improve size validations for received domain records2951d21689
crypto: api - Move cryptomgr soft dependency into algapib62267b8b0
KVM: s390: Return error on SIDA memop on normal guestbe93028d30
moxart: fix potential use-after-free on remove pathca562bf79c
Merge branch 'android12-5.10' into `android12-5.10-lts`c3b53fcd90
Merge 5.10.99 into android12-5.10-ltsfb063a6465
Linux 5.10.994889d6ee9e
selftests: nft_concat_range: add test for reload with no element add/del5577273135
cgroup/cpuset: Fix "suspicious RCU usage" lockdep warningf1f7d1a22f
net: dsa: mt7530: make NET_DSA_MT7530 select MEDIATEK_GE_PHY84b76a509c
ext4: fix incorrect type issue during replay_del_range62e46e0ffc
ext4: fix error handling in ext4_fc_record_modified_inode()764793b4a5
ext4: fix error handling in ext4_restore_inline_data()6c5bd55e36
ext4: modify the logic of ext4_mb_new_blocks_simple8d71fc23fc
ext4: prevent used blocks from being allocated during fast commit replayef2053afd7
EDAC/xgene: Fix deferred probing2a12faf55b
EDAC/altera: Fix deferred probingdd274cf852
x86/perf: Default set FREEZE_ON_SMI for all456f041e03
perf/x86/intel/pt: Fix crash with stop filters in single-range mode8c0e6a8a63
perf stat: Fix display of grouped aliased events57e8859acc
fbcon: Add option to enable legacy hardware acceleration460f6b1a23
Revert "fbcon: Disable accelerated scrolling"460aa9d873
rtc: cmos: Evaluate century appropriate2324f5fcdf
tools/resolve_btfids: Do not print any commands when building silently1536fafa23
selftests: futex: Use variable MAKE instead of make8f0fff8b59
selftests/exec: Remove pipe from TEST_GEN_FILES6304a613a9
bpf: Use VM_MAP instead of VM_ALLOC for ringbuff744a06404
gve: fix the wrong AdminQ buffer queue index check51e88e8922
nfsd: nfsd4_setclientid_confirm mistakenly expires confirmed client.ec4334152d
scsi: bnx2fc: Make bnx2fc_recv_frame() mp safefd482f2d63
pinctrl: bcm2835: Fix a few error paths752d9eafc6
pinctrl: intel: fix unexpected interrupt14bc9978b4
pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line5a45448ac9
ASoC: max9759: fix underflow in speaker_gain_control_put()02f4597198
ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_namecb5f1fbd1f
ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes56e0747d59
ASoC: fsl: Add missing error handling in pcm030_fabric_probe3e69837551
drm/i915/overlay: Prevent divide by zero bugs in scaling9ea0185361
net: stmmac: ensure PTP time register reads are consistent41df2da2c1
net: stmmac: dump gmac4 DMA registers correctly114bf93504
net: macsec: Verify that send_sci is on when setting Tx sci explicitly2e7f5b6ee1
net: macsec: Fix offload support for NETDEV_UNREGISTER event87b1c9fab6
net: ieee802154: Return meaningful error codes from the netlink helpers78b3f20c17
net: ieee802154: ca8210: Stop leaking skb's0bfe50dc5d
net: ieee802154: mcr20a: Fix lifs/sifs periods75bbda3189
net: ieee802154: hwsim: Ensure proper channel selection at probe timee895e067d7
spi: uniphier: fix reference count leak in uniphier_spi_probe()ec942d08e0
spi: meson-spicc: add IRQ check in meson_spicc_probec2cf65e100
spi: mediatek: Avoid NULL pointer crash in interrupt30e05c98b9
spi: bcm-qspi: check for valid cs before applying chip select6d226e8afe
iommu/amd: Fix loop timeout issue in iommu_ga_log_enable()9d9995b037
iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping()b3958d3151
RDMA/mlx4: Don't continue event handler after memory allocation failured3f8b927df
RDMA/siw: Fix broken RDMA Read Fence/Resume logic.c7db20f5be
IB/rdmavt: Validate remote_addr during loopback atomic tests75c610212b
RDMA/ucma: Protect mc during concurrent multicast leaves371979069a
RDMA/cma: Use correct address when leaving multicast groupaa4ecd995f
memcg: charge fs_context and legacy_fs_context080f371d98
Revert "ASoC: mediatek: Check for error clk pointer"4a9bd1e678
IB/hfi1: Fix AIP early init panic5d40f1bdad
dma-buf: heaps: Fix potential spectre v1 gadget30de3bc099
block: bio-integrity: Advance seed correctly for larger interval sizes352715593e
mm/kmemleak: avoid scanning potential huge holes7053188ddb
mm/pgtable: define pte_index so that preprocessor could recognize itbce7f5d74d
mm/debug_vm_pgtable: remove pte entry from the page table2d83a7463d
nvme-fabrics: fix state check in nvmf_ctlr_matches_baseopts()a0c73dbdd1
drm/amd/display: Force link_rate as LINK_RATE_RBR2 for 2018 15" Apple Retina panelsf071d9fa85
drm/nouveau: fix off by one in BIOS boundary checking32747e0143
btrfs: fix deadlock between quota disable and qgroup rescan workeraa5d406153
ALSA: hda/realtek: Fix silent output on Gigabyte X570 Aorus Xtreme after reboot from Windowsd4aa3a9859
ALSA: hda/realtek: Fix silent output on Gigabyte X570S Aorus Master (newer chipset)3a8a8072e3
ALSA: hda/realtek: Add missing fixup-model entry for Gigabyte X570 ALC1220 quirks532cde962f
ALSA: hda/realtek: Add quirk for ASUS GU603410f231fd7
ALSA: hda: realtek: Fix race at concurrent COEF updatesa7de100213
ALSA: hda: Fix UAF of leds class devs at unbinding470bbb9cbd
ALSA: usb-audio: Correct quirk for VF07706877f87579
ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx()038f8b7caa
ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()a9394f21fb
ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()0ff6b80506
audit: improve audit queue handling when "audit=1" on cmdlinef446089a26
selinux: fix double free of cond_list on error paths08942dae64
Merge 5.10.98 into android-5.1026d02dc8ef
Merge 5.10.97 into android12-5.10-ltse33a5b611c
Revert "perf: Fix perf_event_read_local() time"0b4470b56e
Merge 5.10.96 into android12-5.10-lts12a0a56cba
Linux 5.10.9897a47e2555
Revert "drm/vc4: hdmi: Make sure the device is powered with CEC" againe27042060f
Revert "drm/vc4: hdmi: Make sure the device is powered with CEC"c8ed22bd97
Linux 5.10.97176356550c
tcp: add missing tcp_skb_can_collapse() test in tcp_shift_skb_data()32e1799710
af_packet: fix data-race in packet_setsockopt / packet_setsockoptaa9e96db31
cpuset: Fix the bug that subpart_cpus updated wrongly in update_cpumask()3bbe2019dd
rtnetlink: make sure to refresh master_dev/m_ops in __rtnl_newlink()e7be569263
net: sched: fix use-after-free in tc_new_tfilter()7b4741644c
fanotify: Fix stale file descriptor in copy_event_to_user()4d3fcfe846
net: amd-xgbe: Fix skb data length underflowcadfa7dce5
net: amd-xgbe: ensure to reset the tx_timer_active flag77534b114f
ipheth: fix EOVERFLOW in ipheth_rcvbulk_callbackb4ced7a46d
net/mlx5: E-Switch, Fix uninitialized variable modact502c37b033
net/mlx5: Use del_timer_sync in fw reset flow of halting polla01ee1b816
net/mlx5e: Fix handling of wrong devices during bond netevent1fc3444cda
cgroup-v1: Require capabilities to set release_agentac4ba79bb0
drm/vc4: hdmi: Make sure the device is powered with CEC46f919c6bd
x86/cpu: Add Xeon Icelake-D to list of CPUs that support PPINfbdbf6743f
x86/mce: Add Xeon Sapphire Rapids to list of CPUs that support PPINd4e4e61d4a
psi: Fix uaf issue when psi trigger is destroyed while being polled080dbe7e9b
KVM: x86: Forcibly leave nested virt when SMM state is toggled063029a882
Revert "drivers: bus: simple-pm-bus: Add support for probing simple bus only devices"42fdbf8b7d
net: ipa: prevent concurrent replenishad81380d3a
net: ipa: use a bitmap for endpoint replenish_enabled2ed912e3e0
net: ipa: fix atomic update in ipa_endpoint_replenish()3b4c966fb1
PCI: pciehp: Fix infinite loop in IRQ handler upon power faulta9839858b5
Merge 5.10.95 into android12-5.10-ltsf255ac9e87
Linux 5.10.96b43e9d2f6f
mtd: rawnand: mpc5121: Remove unused variable in ads5121_select_chip()b63e120189
block: Fix wrong offset in bio_truncate()0b4e82403c
fsnotify: invalidate dcache before IN_DELETE event8bae6db29c
usr/include/Makefile: add linux/nfc.h to the compile-test coveragef36554de78
dt-bindings: can: tcan4x5x: fix mram-cfg RX FIFO config446ff1fc37
net: bridge: vlan: fix memory leak in __allowed_ingressbc58a5bb9e
ipv4: remove sparse error in ip_neigh_gw4()ebc5b8e471
ipv4: tcp: send zero IPID in SYNACK messages58f72918f9
ipv4: raw: lock the socket in raw_bind()9ffc94a81b
net: bridge: vlan: fix single net device option dumping869f1704f1
Revert "ipv6: Honor all IPv6 PIO Valid Lifetime values"699eef4ed9
net: hns3: handle empty unknown interrupt for VFc9c81b393c
net: cpsw: Properly initialise struct page_pool_params729e54636b
yam: fix a memory leak in yam_siocdevprivate()93a6e920d8
drm/msm/dpu: invalid parameter check in dpu_setup_dspp_pcc0b7d8db87d
drm/msm/hdmi: Fix missing put_device() call in msm_hdmi_get_phyd1d4616d3e
video: hyperv_fb: Fix validation of screen resolution0a60d04abc
ibmvnic: don't spin in tasklet55258b5059
ibmvnic: init ->running_cap_crqs earlyb469cf91fb
ipv4: fix ip option filtering for locally generated fragments9b44441972
net: ipv4: Fix the warning for dereference2f56c4845d
net: ipv4: Move ip_options_fragment() out of loop55402a4618
powerpc/perf: Fix power_pmu_disable to call clear_pmi_irq_pending only if PMI is pending0bdbf93ee2
hwmon: (lm90) Mark alert as broken for MAX6654c534287a57
efi/libstub: arm64: Fix image check alignment at entry3572205b19
rxrpc: Adjust retransmission backoff5067f5699d
octeontx2-pf: Forward error codes to VFbd024e36f6
phylib: fix potential use-after-freea839a79f4d
net: phy: broadcom: hook up soft_reset for BCM54616S57b2f3632b
sched/pelt: Relax the sync of util_sum with util_avg91b04e83c7
perf: Fix perf_event_read_local() timecffed7e631
kernel: delete repeated words in comments1af995c98b
netfilter: conntrack: don't increment invalid counter on NF_REPEAT129c71829d
powerpc64/bpf: Limit 'ldbrx' to processors compliant with ISA v2.067a32824f7a
NFS: Ensure the server has an up to date ctime before renaming666f6ab882
NFS: Ensure the server has an up to date ctime before hardlinking4cd0ef6215
ipv6: annotate accesses to fn->fn_sernum79c0b5287d
drm/msm/dsi: invalid parameter check in msm_dsi_phy_enable3ab44a408b
drm/msm/dsi: Fix missing put_device() call in dsi_get_phy82c310d04b
drm/msm: Fix wrong size calculationf57a99c9a5
net-procfs: show net devices bound packet types87880e3803
NFSv4: nfs_atomic_open() can race when looking up a non-regular filece8c552b88
NFSv4: Handle case where the lookup of a directory failsb48a05cee2
hwmon: (lm90) Reduce maximum conversion rate for G781b26fed25e6
ipv4: avoid using shared IP generator for connected sockets283aa5a5af
ping: fix the sk_bound_dev_if match in ping_lookup7bcb0c19ab
hwmon: (lm90) Mark alert as broken for MAX6680925cbd596a
hwmon: (lm90) Mark alert as broken for MAX6646/6647/6649db044d9746
net: fix information leakage in /proc/net/ptypefeb770cc00
ipv6_tunnel: Rate limit warning messages00849de10f
scsi: bnx2fc: Flush destroy_work queue before calling bnx2fc_interface_put()fcaf94c49a
rpmsg: char: Fix race between the release of rpmsg_eptdev and cdev1dbb206730
rpmsg: char: Fix race between the release of rpmsg_ctrldev and cdev20f6675821
usb: roles: fix include/linux/usb/role.h compile issue6aeff8a7c7
i40e: fix unsigned stat widthsd2ed5997a9
i40e: Fix for failed to init adminq while VF reset768eb705e6
i40e: Fix queues reservation for XDP39896710f7
i40e: Fix issue when maximum queues is exceeded9068bcb219
i40e: Increase delay to 1 s after global EMP resetb4c9b6afa3
powerpc/32: Fix boot failure with GCC latent entropy plugin50f5d0a8bd
powerpc/32s: Fix kasan_init_region() for KASAN5d3af1dfdf
powerpc/32s: Allocate one 256k IBAT instead of two consecutives 128k IBATs08f090bb9b
x86/MCE/AMD: Allow thresholding interface updates after init791e5d5daa
sched/membarrier: Fix membarrier-rseq fence command missing from query bitmaskafbde455eb
ocfs2: fix a deadlock when commit trans97f75e7d4c
jbd2: export jbd2_journal_[grab|put]_journal_head3921d081c9
ucsi_ccg: Check DEV_INT bit only when starting CCG4598a884c77
usb: typec: tcpm: Do not disconnect while receiving VBUS offe3b131e30e
USB: core: Fix hang in usb_kill_urb by adding memory barriers3ca928c824
usb: gadget: f_sourcesink: Fix isoc transfer for USB_SPEED_SUPER_PLUS053274bc6b
usb: common: ulpi: Fix crash in ulpi_match()20c51a4c52
usb: xhci-plat: fix crash when suspend if remote wake enable38d1bf67a3
usb-storage: Add unusual-devs entry for VL817 USB-SATA bridgee0fcae7bd7
tty: Add support for Brainboxes UC cards.7079283d32
tty: n_gsm: fix SW flow control encoding/handling2683b0d5d7
serial: stm32: fix software flow control transfer4628b26df5
serial: 8250: of: Fix mapped region size when using reg-offset property94b23988c3
netfilter: nft_payload: do not update layer 4 checksum when mangling fragmentsbf0d4ae5c6
arm64: errata: Fix exec handling in erratum1418040
workarounde92cac1dd8
KVM: x86: Update vCPU's runtime CPUID on write to MSR_IA32_XSS6b55af102b
drm/etnaviv: relax submit size limits7a32d17fb7
perf/x86/intel/uncore: Fix CAS_COUNT_WRITE issue for ICXa2c8e1d9e4
Revert "KVM: SVM: avoid infinite loop on NPF from bad address"abae88fb37
fsnotify: fix fsnotify hooks in pseudo filesystems6ceac38e9b
ceph: set pool_ns in new inode layout for async createse7be12ca7d
ceph: properly put ceph_string reference after async create attempt39986696fe
tracing: Don't inc err_log entry count if entry allocation failsd71b06aa99
tracing/histogram: Fix a potential memory leak for kstrdup()561a22d44a
PM: wakeup: simplify the output logic of pm_show_wakelocks()b0f1cc093b
efi: runtime: avoid EFIv2 runtime services on Apple x86 machinesde7cc8bcca
udf: Fix NULL ptr deref when converting from inline format0a3cfd2589
udf: Restore i_lenAlloc when inode expansion failsf08801252d
scsi: zfcp: Fix failed recovery on gone remote port with non-NPIV FCP devicesff6bdc205f
bpf: Guard against accessing NULL pt_regs in bpf_get_task_stack()6520fedfce
s390/hypfs: include z/VM guests with access control group setc10e0627c7
s390/module: fix loading modules with a lot of relocationsba7c71a777
net: stmmac: skip only stmmac_ptp_register when resume from suspend11191406f2
net: sfp: ignore disabled SFP nodee651772adc
media: venus: core: Drop second v4l2 device unregister83d5196b65
Bluetooth: refactor malicious adv data check34fd8cb7e7
ANDROID: Fix CRC issue up with xfrm headers in 5.10.94a50b069165
Revert "xfrm: rate limit SA mapping change message to user space"67ea95e0e8
Revert "clocksource: Reduce clocksource-skew threshold"fae0741a78
Revert "clocksource: Avoid accidental unstable marking of clocksources"77656fde3c
Linux 5.10.95ae2b20f277
drm/vmwgfx: Fix stale file descriptors on failed usercopy11ba2c6dfb
select: Fix indefinitely sleeping task in poll_schedule_timeout()a447d7f786
KVM: x86/mmu: Fix write-protection of PTs mapped by the TDP MMU12d3389b7a
rcu: Tighten rcu_advance_cbs_nowake() checks4d63363c88
bnx2x: Invalidate fastpath HSI version for VFsfdcfabd095
bnx2x: Utilize firmware 7.13.21.06a6acf9278
drm/i915: Flush TLBs before releasing backing store4ec3c2eea5
Merge 5.10.94 into android12-5.10-ltsc525532e4f
Linux 5.10.94c76c132444
scripts: sphinx-pre-install: Fix ctex support on Debian133cef0b61
scripts: sphinx-pre-install: add required ctex dependency15ce9329a5
ath10k: Fix the MTU size on QCA9377 SDIO25b1a6d330
mtd: nand: bbt: Fix corner case in bad block table handling8104e589fa
lib/test_meminit: destroy cache in kmem_cache_alloc_bulk() test6292503700
mm/hmm.c: allow VM_MIXEDMAP to work with hmm_range_fault33bb7f027b
lib82596: Fix IRQ check in sni_82596_probe078b5a4498
scripts/dtc: dtx_diff: remove broken example from help text21513c4615
dt-bindings: watchdog: Require samsung,syscon-phandle for Exynos723bcf3615b
dt-bindings: display: meson-vpu: Add missing amlogic,canvas property66467cc87a
dt-bindings: display: meson-dw-hdmi: add missing sound-name-prefix property4496e4a427
net: mscc: ocelot: fix using match before it is setee64479c9c
net: sfp: fix high power modules without diagnostic monitoring819e76bc57
net: ethernet: mtk_eth_soc: fix error checking in mtk_mac_config()4691c9f047
bcmgenet: add WOL IRQ check6973b38b9d
net_sched: restore "mpu xxx" handling20949c3816
net: bonding: fix bond_xmit_broadcast return value error bug799730d182
arm64: dts: qcom: msm8996: drop not documented adreno propertiesf6d4c0e017
devlink: Remove misleading internal_flags from health reporter dump2e51a761b7
perf probe: Fix ppc64 'perf probe add events failed' case59b44f7760
dmaengine: at_xdmac: Fix at_xdmac_lld struct definition0078f05371
dmaengine: at_xdmac: Fix lld view setting7ab120636d
dmaengine: at_xdmac: Fix concurrency over xfers_listb5b27c5e33
dmaengine: at_xdmac: Print debug message after realeasing the lockc536b351a7
dmaengine: at_xdmac: Start transfer for cyclic channels in issue_pendingcd22e22e8e
dmaengine: at_xdmac: Don't start transactions at tx_submit level68a83051c8
perf script: Fix hex dump character output7b9d40e9f6
libcxgb: Don't accidentally set RTO_ONLINK in cxgb_find_route()cd5c24d223
gre: Don't accidentally set RTO_ONLINK in gre_fill_metadata_dst()7f2ca96bd2
xfrm: Don't accidentally set RTO_ONLINK in decode_session4()2b1415c60b
netns: add schedule point in ops_exit_list()edc09548ff
inet: frags: annotate races around fqdir->dead and fqdir->high_thresh69e7e979ed
taskstats: Cleanup the use of task->exit_code56daa21414
virtio_ring: mark ring unused on error0c4ebcb00d
vdpa/mlx5: Fix wrong configuration of virtio_version_1_0c736ec01a2
rtc: pxa: fix null pointer dereference8b8ff4c793
HID: vivaldi: fix handling devices not using numbered reportsd7544cf693
net: axienet: increase default TX ring size to 128557829d42d
net: axienet: fix for TX busy handling41831d4967
net: axienet: fix number of TX ring slots for available check6301f3566a
net: axienet: Fix TX ring slot available check7a3d3d7f6d
net: axienet: limit minimum TX ring size2f548489d6
net: axienet: add missing memory barriersbcc5d57e60
net: axienet: reset core on initialization prior to MDIO access46c0ccaff2
net: axienet: Wait for PhyRstCmplt after core reset34942a228a
net: axienet: increase reset timeouta66b9bccf7
net/smc: Fix hung_task when removing SMC-R devices51b52cf354
clk: si5341: Fix clock HW provider cleanupfe40f7aef3
clk: Emit a stern warning with writable debugfs enabled38221afa03
af_unix: annote lockless accesses to unix_tot_inflight & gc_in_progressa49e402f23
f2fs: fix to reserve space for IO align feature39ad058117
f2fs: compress: fix potential deadlock of compress filee1840365ed
parisc: pdc_stable: Fix memory leak in pdcs_register_pathentriesd806eb5f4e
net/fsl: xgmac_mdio: Fix incorrect iounmap when removing module38c798384b
net/fsl: xgmac_mdio: Add workaround for erratum A-009885734f4b0f83
ipv4: avoid quadratic behavior in netns dismantle86f0587f74
ipv4: update fib_info_cnt under spinlock protection10e99ae9b5
perf evsel: Override attr->sample_period for non-libpfm4 events58fa3e9002
xdp: check prog type before updating BPF link38ee417f59
bpftool: Remove inclusion of utilities.mak from Makefiles2bcab471a2
block: Fix fsync always failed if once failed5e59f88535
powerpc/fsl/dts: Enable WA for erratum A-009885 on fman3l MDIO buses19aaef6519
powerpc/cell: Fix clang -Wimplicit-fallthrough warning4cb7aba1e0
Revert "net/mlx5: Add retry mechanism to the command entry index allocation"78cf5f63a3
dmaengine: stm32-mdma: fix STM32_MDMA_CTBR_TSEL_MASK16ad0aa917
RDMA/rxe: Fix a typo in opcode name885860717c
RDMA/hns: Modify the mapping attribute of doorbell to device57cd8597c3
dmaengine: uniphier-xdmac: Fix type of address variables4fe77b7cd2
scsi: core: Show SCMD_LAST in text formb30240911d
Bluetooth: hci_sync: Fix not setting adv set duration55698d11c8
Documentation: fix firewire.rst ABI file path error5d38cbf66d
Documentation: refer to config RANDOMIZE_BASE for kernel address-space randomizationabecf9d748
Documentation: ACPI: Fix data node reference documentationd1e85fcd73
Documentation: dmaengine: Correctly describe dmatest with channel unsetf6736bd81d
media: correct MEDIA_TEST_SUPPORT help text55b10b88ac
drm/vc4: hdmi: Make sure the device is powered with CEC81ac08a800
media: rcar-csi2: Optimize the selection PHTW register0baa3729d2
can: mcp251xfd: mcp251xfd_tef_obj_read(): fix typo in error messagef62bf6ee4f
firmware: Update Kconfig help text for Google firmware12224c0d19
of: base: Improve argument length mismatch error7bb99c7e13
drm/radeon: fix error handling in radeon_driver_open_kms0ca7ec6db2
ext4: don't use the orphan list when migrating an inode679fb06532
ext4: fix null-ptr-deref in '__ext4_journal_ensure_credits'd60e9daba2
ext4: destroy ext4_fc_dentry_cachep kmemcache on module removalf26b24b4c1
ext4: fast commit may miss tracking unwritten range during ftruncate04b5627306
ext4: use ext4_ext_remove_space() for fast commit replay delete range53998b3f6d
ext4: Fix BUG_ON in ext4_bread when write quota datada364ab358
ext4: set csum seed in tmp inode while migrating to extentse4221629d5
ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE720508dd11
ext4: initialize err_blk before calling __ext4_get_inode_locf9ed0ea0a9
ext4: fix a possible ABBA deadlock due to busy PA115b762b48
ext4: make sure quota gets properly shutdown on error762e4c33e9
ext4: make sure to reset inode lockdep class when quota enabling failsf8c3ec2e21
btrfs: respect the max size in the header when activating swap filee7764bccae
btrfs: check the root node for uptodate before returning it09e0ef287e
btrfs: fix deadlock between quota enable and other quota operations56f974d583
xfrm: fix policy lookup for ipv6 gre packets84166c1177
PCI: pci-bridge-emul: Set PCI_STATUS_CAP_LIST for PCIe device7aeeb9fe9c
PCI: pci-bridge-emul: Correctly set PCIe capabilitiesaf1d0acdac
PCI: pci-bridge-emul: Fix definitions of reserved bits0f2ae6691e
PCI: pci-bridge-emul: Properly mark reserved PCIe bits in PCI config space2a0d437d8a
PCI: pci-bridge-emul: Make expansion ROM Base Address register read-onlydef2825b09
PCI: pciehp: Use down_read/write_nested(reset_lock) to fix lockdep errors6cbe8f8deb
PCI: xgene: Fix IB window setupe09f47e77b
powerpc/64s/radix: Fix huge vmap false positiveeb44b1386a
parisc: Fix lpa and lpa_user defines9b78ee2341
drm/bridge: analogix_dp: Make PSR-exit block less8cbbf4a6f1
drm/nouveau/kms/nv04: use vzalloc for nv04_display605583fccc
drm/etnaviv: limit submit sizes6c1e3d8b1b
device property: Fix fwnode_graph_devcon_match() fwnode leakecb71f7bd5
s390/mm: fix 2KB pgtable release race798754ba48
iwlwifi: mvm: Increase the scan timeout guard to 30 secondsc524f4cfb3
tracing/kprobes: 'nmissed' not showed correctly for kretprobeb72075e395
cputime, cpuacct: Include guest time in user time in cpuacct.stat13518f058f
serial: Fix incorrect rs485 polarity on uart open9668cf9e4a
fuse: Pass correct lend value to filemap_write_and_wait_range()9fbaddd783
xen/gntdev: fix unmap notification order67b078d996
spi: uniphier: Fix a bug that doesn't point to private data correctly05026c4e94
tpm: fix NPE on probe for missing device76006d33f1
ubifs: Error path in ubifs_remount_rw() seems to wrongly free write buffers4f0762ac32
crypto: caam - replace this_cpu_ptr with raw_cpu_ptr9e6ff2d572
crypto: stm32/crc32 - Fix kernel BUG triggered in probe()2031e0246e
crypto: omap-aes - Fix broken pm_runtime_and_get() usage43e94431c3
rpmsg: core: Clean up resources on announce_create failure.082ff9e12b
phy: mediatek: Fix missing check in mtk_mipi_tx_probeff08cf1e34
ASoC: mediatek: mt8183: fix device_node leakf28672eef4
ASoC: mediatek: mt8173: fix device_node leak0df5104008
scsi: sr: Don't use GFP_DMAde9a936b04
MIPS: Octeon: Fix build errors using clangda7df943e2
i2c: designware-pci: Fix to change data types of hcnt and lcnt parametersf09f7ccb28
irqchip/gic-v4: Disable redistributors' view of the VPE table at boot timebc2d961d82
MIPS: OCTEON: add put_device() after of_find_device_by_node()ce34b03a71
udf: Fix error handling in udf_new_inode()15be042e7f
powerpc/fadump: Fix inaccurate CPU state info in vmcore generated with panicf2e658d9bd
powerpc: handle kdump appropriately with crash_kexec_post_notifiers option044164b419
selftests/powerpc/spectre_v2: Return skip code when miss_percent is high21125e0116
powerpc/40x: Map 32Mbytes of memory at startupc330442f46
MIPS: Loongson64: Use three arguments for sltiaf8d077350
ALSA: seq: Set upper limit of processed events297210783a
scsi: lpfc: Trigger SLI4 firmware dump before doing driver cleanupdfde7afed7
dm: fix alloc_dax error handling in alloc_dev2e2086f49e
nvmem: core: set size for sysfs bin file4a273a94bd
w1: Misuse of get_user()/put_user() reported by sparse87e91d6c6a
KVM: PPC: Book3S: Suppress failed alloc warning in H_COPY_TOFROM_GUEST23bb3f01ce
KVM: PPC: Book3S: Suppress warnings when allocating too big memory slots03c1595a18
powerpc/powermac: Add missing lockdep_register_key()df29c01b9f
clk: meson: gxbb: Fix the SDM_EN bit for MPLL0 on GXBB30d35a1abd
i2c: mpc: Correct I2C reset procedure4b25aad655
powerpc/smp: Move setup_profiling_timer() under CONFIG_PROFILING25714ad6bf
i2c: i801: Don't silently correct invalid transfer size75e2cfa5fa
powerpc/watchdog: Fix missed watchdog reset due to memory ordering racea83639521a
powerpc/btext: add missing of_node_putfc10d8f00a
powerpc/cell: add missing of_node_put297ff7d5f1
powerpc/powernv: add missing of_node_putc83ba875d7
powerpc/6xx: add missing of_node_putd240b08d8a
x86/kbuild: Enable CONFIG_KALLSYMS_ALL=y in the defconfigs3681e9f3f0
parisc: Avoid calling faulthandler_disabled() twicef2a27dd7a2
random: do not throw away excess input to crng_fast_loadf8fdebfb4b
serial: core: Keep mctrl register state and cached copy in synca03fd1b198
serial: pl010: Drop CR register reset on set_termios40ac338926
regulator: qcom_smd: Align probe function with rpmh-regulator3dc751213f
net: gemini: allow any RGMII interface mode1063de8975
net: phy: marvell: configure RGMII delays for 88E111800580670b9
mlxsw: pci: Avoid flow control for EMAD packetseaf8cffcf5
dm space map common: add bounds check to sm_ll_lookup_bitmap()5850bef8e9
dm btree: add a defensive bounds check to insert_at()754b663ea9
mac80211: allow non-standard VHT MCS-10/11e8da60b3a6
net: mdio: Demote probed message to debug print6b22c9824d
btrfs: remove BUG_ON(!eie) in find_parent_nodes623c65bc73
btrfs: remove BUG_ON() in find_parent_nodes()44cbd2a16a
ACPI: battery: Add the ThinkPad "Not Charging" quirk7b6dc07c6e
amdgpu/pm: Make sysfs pm attributes as read-only for VFs516e332d6f
drm/amdgpu: fixup bad vram size on gmc v8ee88ff140d
ACPICA: Hardware: Do not flush CPU cache when entering S4 and S58544074762
ACPICA: Fix wrong interpretation of PCC addresse70be17696
ACPICA: Executer: Fix the REFCLASS_REFOF case in acpi_ex_opcode_1A_0T_1R()8ea9216d20
ACPICA: Utilities: Avoid deleting the same object twice in a rowfcfd8282c5
ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitionse3a51d6c90
jffs2: GC deadlock reading a page that is used in jffs2_write_begin()e35cb5b122
drm/etnaviv: consider completed fence seqno in hang checka0b13335a3
xfrm: rate limit SA mapping change message to user space0b7beb2fea
Bluetooth: vhci: Set HCI_QUIRK_VALID_LE_STATES6ac117edac
ath11k: Fix napi related hang756a7188b2
um: registers: Rename function names to avoid conflicts and build problemsd817d10f7a
iwlwifi: pcie: make sure prph_info is set when treating wakeup IRQf266e1c5bf
iwlwifi: mvm: Fix calculation of frame length6e44b60054
iwlwifi: remove module loading failure messagefebab6b60d
iwlwifi: fix leaks/bad data after failed firmware load81d2e96aba
PM: AVS: qcom-cpr: Use div64_ul instead of do_divc0a1d844e3
rtw88: 8822c: update rx settings to prevent potential hw deadlock3ef25f3122
ath9k: Fix out-of-bound memcpy in ath9k_hif_usb_rx_streame10de31055
usb: hub: Add delay for SuperSpeed hub resume to let links transit to U0282286c632
cpufreq: Fix initialization of min and max frequency QoS requests37b25de3af
PM: runtime: Add safety net to supplier device release5dfc6fa0b8
arm64: tegra: Adjust length of CCPLEX cluster MMIO regionb68c56a149
arm64: dts: ls1028a-qds: move rtc node to the correct i2c busb6f7f0ad5a
audit: ensure userspace is penalized the same as the kernel when under pressure5d54ed1550
mmc: core: Fixup storing of OCR for MMC_QUIRK_NONSTD_SDIO51a5156bb7
media: saa7146: hexium_gemini: Fix a NULL pointer dereference in hexium_attach()f6bc6b178c
media: igorplugusb: receiver overflow should be reportedd698e024be
HID: quirks: Allow inverting the absolute X/Y values59f0363346
bpf: Do not WARN in bpf_warn_invalid_xdp_action()0e8805f73b
net: bonding: debug: avoid printing debug logs when bond is not notifying peers8c72de32ff
x86/mce: Mark mce_read_aux() noinstr1ad3e60f1f
x86/mce: Mark mce_end() noinstrf21ca973b4
x86/mce: Mark mce_panic() noinstrde360d9443
x86/mce: Allow instrumentation during task work queueingaf371e0abb
ath11k: Avoid false DEADLOCK warning reported by lockdepaec69e2f33
selftests/ftrace: make kprobe profile testcase description unique07ecabf15a
gpio: aspeed: Convert aspeed_gpio.lock to raw_spinlock7e09f9d15e
net: phy: prefer 1000baseT over 1000baseKX443133330a
net-sysfs: update the queue counts in the unregistration path58b4c1ce83
ath10k: Fix tx hangingfcba0bce33
ath11k: avoid deadlock by change ieee80211_queue_work for regd_update_work93a108d466
iwlwifi: mvm: avoid clearing a just saved session protection idec01e0fe21
iwlwifi: mvm: synchronize with FW after multicast commandsc1976a4248
thunderbolt: Runtime PM activate both ends of the device link830e5d1b43
media: m920x: don't use stack on USB readsc33f0f22bf
media: saa7146: hexium_orion: Fix a NULL pointer dereference in hexium_attach()526b6c9b45
media: rcar-vin: Update format alignment constraints74e60c1dce
media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds.d0e3ab637d
drm: rcar-du: Fix CRTC timings when CMM is usede61aa46d0f
x86/mm: Flush global TLB when switching to trampoline page-table0946fdd929
floppy: Add max size check for user space request409d45bcd3
usb: uhci: add aspeed ast2600 uhci supportd0aec428c0
arm64: dts: ti: j7200-main: Fix 'dtbs_check' serdes_ln_ctrl nodefcb45ac39f
ACPI / x86: Add not-present quirk for the PCI0.SDHB.BRC1 device on the GPD winb8b2e74a87
ACPI / x86: Allow specifying acpi_device_override_status() quirks by pathcda755506d
ACPI: Change acpi_device_always_present() into acpi_device_override_status()b029625063
ACPI / x86: Drop PWM2 device on Lenovo Yoga Book from always present tablecf3b1a160d
media: venus: avoid calling core_clk_setrate() concurrently during concurrent video sessionsadbe148672
ath11k: Avoid NULL ptr access during mgmt tx cleanupab523ea096
rsi: Fix out-of-bounds read in rsi_read_pkt()7525876750
rsi: Fix use-after-free in rsi_rx_done_handler()6036500fdf
mwifiex: Fix skb_over_panic in mwifiex_usb_recv()8a6371d84c
crypto: jitter - consider 32 LSB for APT240cf5d3cb
HSI: core: Fix return freed object in hsi_new_clientf4295b7dca
gpiolib: acpi: Do not set the IRQ type if the IRQ is already in usef0653cd4da
tty: serial: imx: disable UCR4_OREN in .stop_rx() instead of .shutdown()b8d10f601f
drm/bridge: megachips: Ensure both bridges are probed before registration43fc9e267e
mlxsw: pci: Add shutdown method in PCI driverb2e921fa92
soc: ti: pruss: fix referenced node in error message07fbbc4dc7
drm/amdgpu/display: set vblank_disable_immediate for DC019fe9723a
drm/amd/display: check top_pipe_to_program pointer3c3c0b6c4a
ARM: imx: rename DEBUG_IMX21_IMX27_UART to DEBUG_IMX27_UARTf54d8cd831
EDAC/synopsys: Use the quirk for version instead of ddr version0b85d73fdb
media: b2c2: Add missing check in flexcop_pci_isr:c978d39a8b
HID: apple: Do not reset quirks when the Fn key is not found2df002e327
drm: panel-orientation-quirks: Add quirk for the Lenovo Yoga Book X91F/L5aa57672c6
usb: gadget: f_fs: Use stream_open() for endpoint files129e8faaee
ath11k: Fix crash caused by uninitialized TX ringe8b271f2aa
media: atomisp: handle errors at sh_css_create_isp_params()ebe9c978d9
batman-adv: allow netlink usage in unprivileged containersff452db961
ARM: shmobile: rcar-gen2: Add missing of_node_put()ff2138d6c2
media: atomisp-ov2680: Fix ov2680_set_fmt() clobbering the exposure51ef6582a2
media: atomisp: set per-device's default modeac08140677
media: atomisp: fix try_fmt logic518e059789
drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACRe3ba02b043
drm/bridge: dw-hdmi: handle ELD when DRM_BRIDGE_ATTACH_NO_CONNECTOR2f13f10fdd
ar5523: Fix null-ptr-deref with unexpected WDCMSG_TARGET_START replya9d2ccfc7d
selftests/bpf: Fix bpf_object leak in skb_ctx selftestb207356933
drm/lima: fix warning when CONFIG_DEBUG_SG=y & CONFIG_DMA_API_DEBUG=ydb1e878373
fs: dlm: filter user dlm messages for kernel locksf9c9a46efd
Bluetooth: Fix debugfs entry leak in hci_register_dev()852d7d436f
ARM: dts: omap3-n900: Fix lp5523 for multi colorb5793aff11
of: base: Fix phandle argument length mismatch error messagee16e836d51
clk: bm1880: remove kfrees on static allocations36d46e21c9
ASoC: fsl_asrc: refine the check of available clock divider5a6864e2e6
RDMA/cxgb4: Set queue pair state when being queried80524c8cdf
ASoC: fsl_mqs: fix MODULE_ALIAS74988d017d
powerpc/xive: Add missing null check after calling kmalloc588e0b81ce
mips: bcm63xx: add support for clk_set_parent()e3de89d010
mips: lantiq: add support for clk_set_parent()8f8468a089
arm64: tegra: Remove non existent Tegra194 reset702902fc7f
arm64: tegra: Fix Tegra194 HDA {clock,reset}-names ordering24b047d72c
counter: stm32-lptimer-cnt: remove iio counter abia394606104
misc: lattice-ecp3-config: Fix task hung when firmware load failed696a50abbc
ASoC: samsung: idma: Check of ioremap return valued491a2c2cf
ASoC: mediatek: Check for error clk pointerc73ccdd62d
phy: uniphier-usb3ss: fix unintended writing zeros to PHY registerd781f4cd8c
scsi: block: pm: Always set request queue runtime active in blk_post_runtime_resume()6e2a169544
iommu/iova: Fix race between FQ timeout and teardown57bc898575
ASoC: Intel: catpt: Test dmaengine_submit() result before moving on676049a3d2
iommu/amd: Restore GA log/tail pointer on host resumec2bd7c31de
iommu/amd: Remove iommu_init_ga()62ea255f2b
dmaengine: pxa/mmp: stop referencing config->slave_id0be9ae1e53
mips: fix Kconfig reference to PHYS_ADDR_T_64BIT88d78b25db
mips: add SYS_HAS_CPU_MIPS64_R5 config for MIPS Release 5 support51b8e814bc
clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after system enter shelldff359e042
of: unittest: 64 bit dma address test requires arch support918105df78
of: unittest: fix warning on PowerPC frame size warning0e04518b1d
ASoC: rt5663: Handle device_property_read_u32_array error codes7c0d9c815c
RDMA/cma: Let cma_resolve_ib_dev() continue search even after empty entry2432d325f9
RDMA/core: Let ib_find_gid() continue search even after empty entryd77916df16
powerpc/powermac: Add additional missing lockdep_register_key()8b3783e517
PCI/MSI: Fix pci_irq_vector()/pci_irq_get_affinity()7be2a0bcaf
RDMA/qedr: Fix reporting max_{send/recv}_wr attrse19469468b
scsi: ufs: Fix race conditions related to driver dataed43b2e048
iommu/io-pgtable-arm: Fix table descriptor paddr formattinge9e4d1fb45
openrisc: Add clone3 ABI wrapper551a785c26
binder: fix handling of error during copy88ddf033a5
char/mwave: Adjust io port register size8937aee4c0
ALSA: usb-audio: Drop superfluous '0' in Presonus Studio 1810c's IDbcd533417f
ALSA: oss: fix compile error when OSS_DEBUG is enabledfd99aeb978
clocksource: Avoid accidental unstable marking of clocksourcescacc6c30e3
clocksource: Reduce clocksource-skew threshold86ad478c99
powerpc/32s: Fix shift-out-of-bounds in KASAN initef798cd035
powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC58014442a9
powerpc/irq: Add helper to set regs->softec9ffa84a3b
powerpc/perf: move perf irq/nmi handling details into traps.ca0758b3be4
powerpc/perf: MMCR0 control for PMU registers under PMCC=00f4df6db5b0
powerpc/64s: Convert some cpu_setup() and cpu_restore() functions to Ca9c9d2ff64
dt-bindings: thermal: Fix definition of cooling-maps contribution property2bd8d93795
ASoC: uniphier: drop selecting non-existing SND_SOC_UNIPHIER_AIO_DMA5a821af769
powerpc/prom_init: Fix improper check of prom_getprop()9ca761ef94
clk: imx8mn: Fix imx8mn_clko1_sels999528d8a7
scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd()c5f414d69a
RDMA/hns: Validate the pkey index04a032ea24
RDMA/bnxt_re: Scan the whole bitmap when checking if "disabling RCFW with pending cmd-bit"84cd5c029d
ALSA: hda: Add missing rwsem around snd_ctl_remove() calls180e9d7384
ALSA: PCM: Add missing rwsem around snd_ctl_remove() calls49d76154ba
ALSA: jack: Add missing rwsem around snd_ctl_remove() callsf871cd8ee0
ext4: avoid trim error on fs with small groups99590e820f
net: mcs7830: handle usb read errors properly2b948524ae
iwlwifi: mvm: Use div_s64 instead of do_div in iwl_mvm_ftm_rtt_smoothing()04ce9e2aed
pcmcia: fix setting of kthread task states5064bfe046
can: xilinx_can: xcan_probe(): check for error irqb6dd1577bc
can: softing: softing_startstop(): fix set but not used variable warningb9ac866c23
tpm_tis: Fix an error handling path in 'tpm_tis_core_init()'fb46223c9f
tpm: add request_locality before write TPM_INT_ENABLE20edf903a3
can: mcp251xfd: add missing newline to printed stringsd71fca5d01
regmap: Call regmap_debugfs_exit() prior to _init()838acddcdf
netrom: fix api breakage in nr_setsockopt()0d04479857
ax25: uninitialized variable in ax25_setsockopt()27e9910c45
spi: spi-meson-spifc: Add missing pm_runtime_disable() in meson_spifc_probe9d6350cf8e
Bluetooth: L2CAP: uninitialized variables in l2cap_sock_setsockopt()9defd7d4c0
lib/mpi: Add the return value check of kcalloc()e801f81cee
net/mlx5: Set command entry semaphore up once got index freed2b9ce705d
Revert "net/mlx5e: Block offload of outer header csum for UDP tunnels"67e1a449a1
net/mlx5e: Don't block routes with nexthop objects in SWcc40fa05c0
net/mlx5e: Fix page DMA map/unmap attributesb3dda01d1d
debugfs: lockdown: Allow reading debugfs files that are not world readableb9b5da3e18
HID: hid-uclogic-params: Invalid parameter check in uclogic_params_frame_init_v1_buttonpad541c3a044b
HID: hid-uclogic-params: Invalid parameter check in uclogic_params_huion_initc47f842e0c
HID: hid-uclogic-params: Invalid parameter check in uclogic_params_get_str_desccf5ad827ee
HID: hid-uclogic-params: Invalid parameter check in uclogic_params_init94177fcecc
usb: dwc3: qcom: Fix NULL vs IS_ERR checking in dwc3_qcom_probe4579954bf4
Bluetooth: hci_qca: Fix NULL vs IS_ERR_OR_NULL check in qca_serdev_probef6bf3d6639
Bluetooth: hci_bcm: Check for error irqf5e4f68d57
fsl/fman: Check for null pointer after calling devm_ioremap60aca6fdc1
staging: greybus: audio: Check null pointera1068bfee4
rocker: fix a sleeping in atomic bug2db344725e
ppp: ensure minimum packet size in ppp_write()45643b1b6c
netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone8772700a9f
bpf: Fix SO_RCVBUF/SO_SNDBUF handling in _bpf_setsockopt().342332fb0b
bpf: Don't promote bogus looking registers after null check.0036c78c49
netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check()2e718389b9
power: reset: mt6397: Check for null res pointer4210c35fe8
pcmcia: rsrc_nonstatic: Fix a NULL pointer dereference in nonstatic_find_mem_region()2dee347f35
pcmcia: rsrc_nonstatic: Fix a NULL pointer dereference in __nonstatic_find_io_region()0f03132191
ACPI: scan: Create platform device for BCM4752 and LNV4752 ACPI nodes595e1ec55b
x86/mce/inject: Avoid out-of-bounds write when setting flagsdf12681819
hwmon: (mr75203) fix wrong power-up delay valueaea5302d9d
x86/boot/compressed: Move CLANG_FLAGS to beginning of KBUILD_CFLAGS70eec71f32
Bluetooth: hci_qca: Stop IBS timer during BT OFF1d4e722b62
software node: fix wrong node passed to find nargs_propf8f3c1720d
backlight: qcom-wled: Respect enabled-strings in set_brightnessde79bcbfaf
backlight: qcom-wled: Use cpu_to_le16 macro to perform conversionc79f9b8d8e
backlight: qcom-wled: Override default length with qcom,enabled-stringsbf4daf6153
backlight: qcom-wled: Fix off-by-one maximum with default num_strings09aed85e8c
backlight: qcom-wled: Pass number of elements to read to read_u32_arrayf4ed4fc504
backlight: qcom-wled: Validate enabled string indices in DTe668ac6506
bpftool: Enable line buffering for stdout009bb7ee15
Bluetooth: L2CAP: Fix using wrong mode1a2241ad40
um: virtio_uml: Fix time-travel external time propagation8411722e56
um: fix ndelay/udelay definesb2b1b490bd
selinux: fix potential memleak in selinux_add_opt()3253cf0914
mmc: meson-mx-sdio: add IRQ checkdecb209954
mmc: meson-mx-sdhc: add IRQ checkbdc6c9fc5f
iwlwifi: mvm: test roc running status bits before removing the staa750fcd604
iwlwifi: mvm: fix 32-bit build in FTM86b0122d26
ARM: dts: armada-38x: Add generic compatible to UART nodes1f5428e438
arm64: dts: marvell: cn9130: enable CP0 GPIO controllers874b97e862
arm64: dts: marvell: cn9130: add GPIO and SPI aliases407ef1db40
usb: ftdi-elan: fix memory leak on device disconnect2a65da5a1e
ARM: 9159/1: decompressor: Avoid UNPREDICTABLE NOP encoding47dd693c94
xfrm: state and policy should fail if XFRMA_IF_ID 0db369047e3
xfrm: interface with if_id 0 should return error37441ddadc
media: hantro: Fix probe func error path3849ec830b
drm/tegra: vic: Fix DMA API misuseb230114bc5
drm/bridge: ti-sn65dsi86: Set max register for regmapdb97fc2c44
drm/msm/dpu: fix safe status debugfs file3580055d1f
arm64: dts: qcom: ipq6018: Fix gpio-ranges property6f20a5a98a
arm64: dts: qcom: c630: Fix soundcard setup394ee480aa
ath11k: Fix a NULL pointer dereference in ath11k_mac_op_hw_scan()f6e4a6cbdb
media: coda/imx-vdoa: Handle dma_set_coherent_mask error codes1a8869de32
media: msi001: fix possible null-ptr-deref in msi001_probe()a79327bb01
media: dw2102: Fix use after free958a8819d4
ARM: dts: gemini: NAS4220-B: fis-index-block with 128 KiB sectors3e51460638
ath11k: Fix deleting uninitialized kernel timer during fragment cache flushb35263f000
crypto: stm32 - Revert broken pm_runtime_resume_and_get changes1f5b81874f
crypto: stm32/cryp - fix bugs and crash in tests1f6151b077
crypto: stm32/cryp - fix lrw chaining mode2bd40e3a3a
crypto: stm32/cryp - fix double pm exit533af1621d
crypto: stm32/cryp - check early input data5deb24e503
crypto: stm32/cryp - fix xts and race condition in crypto_engine requestse9e0dd5da8
crypto: stm32/cryp - fix CTR counter carryc40b1bc851
crypto: stm32 - Fix last sparse warning in stm32_cryp_check_ctr_counter93033bbbdc
selftests: harness: avoid false negatives if test has no ASSERTsf568fd97d7
selftests: clone3: clone3: add case CLONE3_ARGS_NO_TESTd21b47c607
x86/uaccess: Move variable into switch case statement3e801ea43c
xfrm: fix a small bug in xfrm_sa_len()b87034d7a2
mwifiex: Fix possible ABBA deadlock0836f94040
rcu/exp: Mark current CPU as exp-QS in IPI loop second pass027165c491
drm/msm/dp: displayPort driver need algorithm rational268f352456
sched/rt: Try to restart rt period timer when rt runtime exceededbb0579ab50
wireless: iwlwifi: Fix a double free in iwl_txq_dyn_alloc_dmab4b911b164
media: si2157: Fix "warm" tuner state detection7009a5fbc5
media: saa7146: mxb: Fix a NULL pointer dereference in mxb_attach()df79d2bf95
media: dib8000: Fix a memleak in dib8000_init()f0cb43a2c6
arm64: clear_page() shouldn't use DC ZVA when DCZID_EL0.DZP == 188ed31aab4
arm64: lib: Annotate {clear, copy}_page() as position-independent69e402a985
bpf: Remove config check to enable bpf support for branch records924886fa22
bpf: Disallow BPF_LOG_KERNEL log level for bpf(BPF_BTF_LOAD)218d952160
bpf: Adjust BTF log size limit.b77ef5b4ea
sched/fair: Fix per-CPU kthread and wakee stacking for asym CPU capacityd7d5b3bc52
sched/fair: Fix detection of per-CPU kthreads waking a taskec121517ac
Bluetooth: btmtksdio: fix resume failure2a7edcb3ef
staging: rtl8192e: rtllib_module: fix error handle case in alloc_rtllib()49f5cd2b7c
staging: rtl8192e: return error code from rtllib_softmac_init()04fdd426ce
floppy: Fix hang in watchdog when disk is ejected45bbe00801
serial: amba-pl011: do not request memory region twice8409d2394c
tty: serial: uartlite: allow 64 bit addressa001a15ab3
arm64: dts: ti: k3-j7200: Correct the d-cache-sets info75919207c1
arm64: dts: ti: k3-j721e: Fix the L2 cache sets2dcfa3c765
arm64: dts: ti: k3-j7200: Fix the L2 cache setsf277978d6c
drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms()3ca1b3b82f
drm/amdgpu: Fix a NULL pointer dereference in amdgpu_connector_lcd_native_mode()96e05d2d93
thermal/drivers/imx8mm: Enable ADC when enabling monitoref72449e2d
ACPI: EC: Rework flushing of EC work while suspended to idlec0acd5a097
cgroup: Trace event cgroup id fields should be u64e7e178e264
arm64: dts: qcom: msm8916: fix MMC controller aliases894d91c633
netfilter: bridge: add support for pppoe filtering13f64bbe42
thermal/drivers/imx: Implement runtime PM supportc3a59f34e8
media: venus: core: Fix a resource leak in the error handling path of 'venus_probe()'50c4244906
media: venus: core: Fix a potential NULL pointer dereference in an error handling patheeefa2eae8
media: venus: core, venc, vdec: Fix probe dependency error53f65afc26
media: venus: pm_helpers: Control core power domain manually89f518b153
media: coda: fix CODA960 JPEG encoder buffer overflow1da628d351
media: mtk-vcodec: call v4l2_m2m_ctx_release first when file is released2028fb832d
media: si470x-i2c: fix possible memory leak in si470x_i2c_probe()e8d78f924f
media: imx-pxp: Initialize the spinlock prior to using it621e8ce75d
media: rcar-csi2: Correct the selection of hsfreqrangead52b9890b
mfd: atmel-flexcom: Use .resume_noirq46d6a23114
mfd: atmel-flexcom: Remove #ifdef CONFIG_PM_SLEEPf93c9aa1d3
tty: serial: atmel: Call dma_async_issue_pending()755a6c873b
tty: serial: atmel: Check return code of dmaengine_submit()bd85b2e77a
arm64: dts: ti: k3-j721e: correct cache-sets info32e9947e66
ath11k: Use host CE parameters for CE interrupts configuration6a49acfaca
crypto: qat - fix undetected PFVF timeout in ACK loop475ac5c565
crypto: qat - make pfvf send message direction agnosticee1c74c3c9
crypto: qat - remove unnecessary collision prevention step in PFVF472f768352
crypto: qat - fix spelling mistake: "messge" -> "message"ae766527e6
ARM: dts: stm32: fix dtbs_check warning on ili9341 dts binding on stm32f429 discoeab4204588
mtd: hyperbus: rpc-if: fix bug in rpcif_hb_remove867d4ace48
crypto: qce - fix uaf on qce_skcipher_register_onee19b3c1b57
crypto: qce - fix uaf on qce_ahash_register_one5de640f59f
media: dmxdev: fix UAF when dvb_register_device() fails1d64e2bd22
arm64: dts: renesas: cat875: Add rx/tx delaysa33eef23a6
drm/vboxvideo: fix a NULL vs IS_ERR() check43220a61e7
fs: dlm: fix build with CONFIG_IPV6 disabled0d7c5d10e7
tee: fix put order in teedev_close_context()097e601eb8
ath11k: reset RSN/WPA present state for open BSSfa51addd39
ath11k: clear the keys properly via DISABLE_KEYdf94b37e90
ath11k: Fix ETSI regd with weather radar overlapffc9019bd9
Bluetooth: stop proccessing malicious adv data3273541fed
memory: renesas-rpc-if: Return error in case devm_ioremap_resource() fails55917db359
fs: dlm: don't call kernel_getpeername() in error_report()98923ebb03
fs: dlm: use sk->sk_socket instead of con->sock6edd1bd8e3
arm64: dts: meson-gxbb-wetek: fix missing GPIO bindingeb1f75fa24
arm64: dts: meson-gxbb-wetek: fix HDMI in early boot6f012f2c44
arm64: dts: amlogic: Fix SPI NOR flash node name for ODROID N2/N2+96d710b1c6
arm64: dts: amlogic: meson-g12: Fix GPU operating point table node name0b57480ed5
media: aspeed: Update signal status immediately to ensure sane hw state0ff0ae69d2
media: em28xx: fix memory leak in em28xx_init_devb441d94287
media: aspeed: fix mode-detect always time out at 2nd run8d132d9dd8
media: atomisp: fix uninitialized bug in gmin_get_pmic_id_and_addr()fc2b95e7ae
media: atomisp: fix enum formats logic6e5353238c
media: atomisp: add NULL check for asd obtained from atomisp_video_pipe6cbabad304
media: staging: media: atomisp: pci: Balance braces around conditional statements in file atomisp_cmd.c22b0b68f7d
media: atomisp: fix ifdefs in sh_css.c0bf5e8af6e
media: atomisp: fix inverted error check for ia_css_mipi_is_source_port_valid()3cb3e66f58
media: atomisp: do not use err var when checking port validity for ISP240008e43223fb
media: atomisp: fix inverted logic in buffers_needed()fb370f6dc7
media: atomisp: fix punit_ddr_dvfs_enable() argument for mrfld_power up case1daacf9bb6
media: atomisp: add missing media_device_cleanup() in atomisp_unregister_entities()e1da9301cf
media: videobuf2: Fix the size printk format90807ab437
mtd: hyperbus: rpc-if: Check return value of rpcif_sw_init()9bfed11dcf
ath11k: Send PPDU_STATS_CFG with proper pdev mask to firmware2fe056d979
wcn36xx: fix RX BD rate mapping for 5GHz legacy rates22406ed4e3
wcn36xx: populate band before determining rate on RX92fea7bd5a
wcn36xx: Put DXE block into reset before freeing memory0d53c47f6a
wcn36xx: Release DMA channel descriptor allocations1850195a85
wcn36xx: Fix DMA channel enable/disable cycle38a7842889
wcn36xx: Indicate beacon not connection loss on MISSED_BEACON_INDfcb267bb95
wcn36xx: ensure pairing of init_scan/finish_scan and start_scan/end_scane53ff4dd70
drm/vc4: hdmi: Set a default HSM rateb9c2343373
clk: bcm-2835: Remove rounding up the dividers836dd37fe2
clk: bcm-2835: Pick the closest clock rate88f1b613c3
Bluetooth: cmtp: fix possible panic when cmtp_init_sockets() fails9ddfa1c191
drm/rockchip: dsi: Reconfigure hardware on resume()58904ed186
drm/rockchip: dsi: Disable PLL clock on bind error6215cde020
drm/rockchip: dsi: Hold pm-runtime across bind/unbind8ccaafa1ca
drm/rockchip: dsi: Fix unbalanced clock on probe error9bc19022aa
drm/panel: innolux-p079zca: Delete panel on attach() failureb01b7b8684
drm/panel: kingdisplay-kd097d04: Delete panel on attach() failure0499c863a8
drm: fix null-ptr-deref in drm_dev_init_release()7798757013
drm/bridge: display-connector: fix an uninitialized pointer in probe()cb5813b0e5
Bluetooth: L2CAP: Fix not initializing sk_peer_pided0b1fd3ec
drm/ttm: Put BO in its memory manager's lru list7b9fa915a5
shmem: fix a race between shmem_unused_huge_shrink and shmem_evict_inode6c6f86bb61
mm/page_alloc.c: do not warn allocation failure on zone DMA if no managed pagese04b1dfe15
dma/pool: create dma atomic pool only if dma zone has managed pagesd2e5724117
mm_zone: add function to check if managed dma zone exists2142a7e9bd
PCI: Add function 1 DMA alias quirk for Marvell 88SE9125 SATA controller45c74f4f54
dma_fence_array: Fix PENDING_ERROR leak in dma_fence_array_signaled()191a24ceae
gpu: host1x: Add back arm_iommu_detach_device()0680674536
iommu/io-pgtable-arm-v7s: Add error handle for page table allocation failure3dae11f8e3
lkdtm: Fix content of section containing lkdtm_rodata_do_nothing()e4a2c924a1
iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs256302cb2f
can: softing_cs: softingcs_probe(): fix memleak on registration failureaa57725e2d
media: cec-pin: fix interrupt en/disable handling2e566cacc3
media: stk1160: fix control-message timeouts1a0ca711df
media: pvrusb2: fix control-message timeouts2dbf430ead
media: redrat3: fix control-message timeouts6e9c120bf9
media: dib0700: fix undefined behavior in tuner shutdown5e98ac260d
media: s2255: fix control-message timeouts09b0b918a6
media: cpia2: fix control-message timeoutsd90833106c
media: em28xx: fix control-message timeouts2182575c83
media: mceusb: fix control-message timeouts460525acc9
media: flexcop-usb: fix control-message timeouts7cac8a5624
media: v4l2-ioctl.c: readbuffers depends on V4L2_CAP_READWRITE1da0b1cd42
rtc: cmos: take rtc_lock while reading from CMOS14f6cfe0d7
tools/nolibc: fix incorrect truncation of exit code5e258640ba
tools/nolibc: i386: fix initial stack alignment06f7528d64
tools/nolibc: x86-64: Fix startup code bug98259dd54e
x86/gpu: Reserve stolen memory for first integrated Intel GPUe2a17dcad5
mtd: rawnand: davinci: Rewrite function description8933138a66
mtd: rawnand: davinci: Avoid duplicated page read677764634b
mtd: rawnand: davinci: Don't calculate ECC when reading pagea8a607b004
mtd: Fixed breaking list in __mtd_del_partition.ff10cd7bb2
mtd: rawnand: gpmi: Remove explicit default gpmi clock setting for i.MX6538a5e208e
mtd: rawnand: gpmi: Add ERR007117 protection for nfc_apply_timings777a700ccf
nfc: llcp: fix NULL error pointer dereference on sendmsg() after failed bind()08283b076f
f2fs: fix to do sanity check in is_alive()57cfc965e3
HID: wacom: Avoid using stale array indicies to read contact count7fd22c99bb
HID: wacom: Ignore the confidence flag when a touch is removed9a4800e0f6
HID: wacom: Reset expected and received contact counts at the same timec2e39d5df0
HID: uhid: Fix worker destroying device without any protectionaa1346113c
KVM: VMX: switch blocked_vcpu_on_cpu_lock to raw spinlock0347b16583
Merge 5.10.93 into android12-5.10-ltsfd187a4925
Linux 5.10.93bed97c9036
mtd: fixup CFI on ixp4xxf50803b519
powerpc/pseries: Get entry and uaccess flush required bits from H_GET_CPU_CHARACTERISTICS68c1aa82be
ALSA: hda/realtek: Re-order quirk entries for Lenovo4d15a17d06
ALSA: hda/realtek: Add quirk for Legion Y9000X 2020d7b41464f1
ALSA: hda: ALC287: Add Lenovo IdeaPad Slim 9i 14ITL5 speaker quirk87246ae94b
ALSA: hda/realtek - Fix silent output on Gigabyte X570 Aorus Master after reboot from Windows9c27e513fb
ALSA: hda/realtek: Add speaker fixup for some Yoga 15ITL5 devices4c7fb4d519
KVM: x86: remove PMU FIXED_CTR3 from msrs_to_save_all6b8c3a1853
firmware: qemu_fw_cfg: fix kobject leak in probe error path889c73305b
firmware: qemu_fw_cfg: fix NULL-pointer deref on duplicate entriesff9588cf15
firmware: qemu_fw_cfg: fix sysfs information leak358a4b054a
rtlwifi: rtl8192cu: Fix WARNING when calling local_irq_restore() with interrupts enabled93c4506f9f
media: uvcvideo: fix division by zero at stream start4c3f70be6f
video: vga16fb: Only probe for EGA and VGA 16 color graphic cards161e43ab8c
9p: only copy valid iattrs in 9P2000.L setattr implementation0e6c0f3f40
KVM: s390: Clarify SIGP orders versus STOP/RESTART413b427f5f
KVM: x86: Register Processor Trace interrupt hook iff PT enabled in guest723acd75a0
perf: Protect perf_guest_cbs with RCUeadde287a6
vfs: fs_context: fix up param length parsing in legacy_parse_paramc5f3827716
remoteproc: qcom: pil_info: Don't memcpy_toio more than is provided5d88e24b23
orangefs: Fix the size of a memory allocation in orangefs_bufmap_alloc()0084fefe29
devtmpfs regression fix: reconfigure on each mountee40594c95
kbuild: Add $(KBUILD_HOSTLDFLAGS) to 'has_libelf' testf45f895af5
Merge branch 'android12-5.10' into `android12-5.10-lts`7dd0d263fe
Merge 5.10.92 into android12-5.10-ltsc982c1a839
Linux 5.10.92c0091233f3
staging: greybus: fix stack size warning with UBSAN66d21c005d
drm/i915: Avoid bitwise vs logical OR warning in snb_wm_latency_quirk()2d4fda471d
staging: wlan-ng: Avoid bitwise vs logical OR warning in hfa384x_usb_throttlefn()3609fed7ac
media: Revert "media: uvcvideo: Set unique vdev name based in type"9b3c761e78
random: fix crash on multiple early calls to add_bootloader_randomness()61cca7d191
random: fix data race on crng init time3de9478230
random: fix data race on crng_node_pool43c494294f
can: gs_usb: gs_can_start_xmit(): zero-initialize hf->{flags,reserved}45221a57b6
can: isotp: convert struct tpcon::{idx,len} to unsigned intbd61ae808b
can: gs_usb: fix use of uninitialized variable, detach device on reception of invalid USB dataf68e600017
mfd: intel-lpss: Fix too early PM enablement in the ACPI ->probe()5f76445a31
veth: Do not record rx queue hint in veth_xmitddfa53825f
mmc: sdhci-pci: Add PCI ID for Intel ADL2e691f9894
ath11k: Fix buffer overflow when scanning with extraiea87cecf943
USB: Fix "slab-out-of-bounds Write" bug in usb_hcd_poll_rh_status15982330b6
USB: core: Fix bug in resuming hub's handling of wakeup requests413108ce3b
ARM: dts: exynos: Fix BCM4330 Bluetooth reset polarity in I9100b6dd070236
Bluetooth: bfusb: fix division by zero in send path869e1677a0
Bluetooth: btusb: Add support for Foxconn QCA 0xe0d0c20021ce94
Bluetooth: btusb: Add support for Foxconn MT7922A8349391838
Bluetooth: btusb: Add two more Bluetooth parts for WCN6855294c0dd80d
Bluetooth: btusb: fix memory leak in btusb_mtk_submit_wmt_recv_urb()35ab8c9085
bpf: Fix out of bounds access from invalid *_or_null type verificationc84fbba8a9
workqueue: Fix unbind_workers() VS wq_worker_running() racec39d68ab38
md: revert io stats accountingd605f2f30d
Merge 5.10.91 into android12-5.10-ltsdf395c763b
Linux 5.10.91674071c9eb
Input: zinitix - make sure the IRQ is allocated before it gets enabledef81f7d406
ARM: dts: gpio-ranges property is now requiredf63fa1a0d4
ipv6: raw: check passed optlen before readingcf07884e6b
drm/amd/display: Added power down for DCN1010b9ccd067
mISDN: change function names to avoid conflictsdd8a09cfbb
atlantic: Fix buff_ring OOB in aq_ring_rx_cleanc2f4bb251e
net: udp: fix alignment problem in udp4_seq_show()f82b48d1d8
ip6_vti: initialize __ip6_tnl_parm struct in vti6_siocdevprivate8c87a83ef8
scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown()b798b677f9
usb: mtu3: fix interval value for intr and isoc498d77fc5e
ipv6: Do cleanup if attribute validation fails in multipath route72b0d14a0a
ipv6: Continue processing multipath route even if gateway attribute is invalid5a7d650bb1
power: bq25890: Enable continuous conversion for ADC at charging4f260ea553
phonet: refcount leak in pep_sock_accep6195293460
rndis_host: support Hytera digital radios62cbde77d9
power: reset: ltc2952: Fix use of floating point literals998d157e3b
power: supply: core: Break capacity loop16d8568378
xfs: map unwritten blocks in XFS_IOC_{ALLOC,FREE}SP just like fallocateaa606b82cd
net: ena: Fix error handling when calculating max IO queues numbere7f5480978
net: ena: Fix undefined state when tx request id is out of bounds2de3d961f8
sch_qfq: prevent shift-out-of-bounds in qfq_init_qdisc4c34d5fd8c
batman-adv: mcast: don't send link-local multicast to mcast routersf403b5f96e
lwtunnel: Validate RTA_ENCAP_TYPE attribute length48d5adb08d
ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route173bfa2782
ipv6: Check attribute length for RTA_GATEWAY in multipath route914420a2a6
ipv4: Check attribute length for RTA_FLOW in multipath routea8fe915be6
ipv4: Check attribute length for RTA_GATEWAY in multipath route786a335fef
ftrace/samples: Add missing prototypes direct functionsc859c4de0b
i40e: Fix incorrect netdev's real number of RX/TX queuesd0ad64438f
i40e: Fix for displaying message regarding NVM version32845aa602
i40e: fix use-after-free in i40e_sync_filters_subtask()f7edb6b943
sfc: The RX page_ring is optional2b3f34da0d
mac80211: initialize variable have_higher_than_11mbit16e5cad6ec
RDMA/uverbs: Check for null return of kmalloc_arraya7c2cae997
netrom: fix copying in user data in nr_setsockoptbeeb0fdeda
RDMA/core: Don't infoleak GRH fields3ca132e6b0
iavf: Fix limit of total number of queues to active queues of VF396e301690
i40e: Fix to not show opcode msg on unsuccessful VF MAC change7f13d14e56
ieee802154: atusb: fix uninit value in atusb_set_extended_addr7db1e245cb
tracing: Tag trace_percpu_buffer as a percpu pointer760c6a6255
tracing: Fix check for trace_percpu_buffer validity in get_trace_buf()c1e2da4b3f
selftests: x86: fix [-Wstringop-overread] warn in test_process_vm_readv()384111e123
f2fs: quota: fix potential deadlocka1bb21475e
Merge 5.10.90 into android12-5.10-ltsd3e491a20d
Linux 5.10.908c15bfb36a
bpf: Add kconfig knob for disabling unpriv bpf by defaultd8a5b1377b
perf script: Fix CPU filtering of a script's switch events2386e81a1d
net: fix use-after-free in tw_timer_handler34087cf960
Input: spaceball - fix parsing of movement data packets9f329d0d6c
Input: appletouch - initialize work before device registration2a4f551dec
scsi: vmw_pvscsi: Set residual data length conditionally1cb8444f31
binder: fix async_free_space accounting for empty parcelsa6e26251dd
usb: mtu3: set interval of FS intr and isoc endpoint3b6efe0b7b
usb: mtu3: fix list_head check warningf10b01c48f
usb: mtu3: add memory barrier before set GPD's HWO1c4ace3e6b
usb: gadget: f_fs: Clear ffs_eventfd in ffs_data_clear.1933fe8ce7
xhci: Fresco FL1100 controller should not have BROKEN_MSI quirk set.b8553330a0
drm/amdgpu: add support for IP discovery gc_info table v228863ffe21
drm/amdgpu: When the VCN(1.0) block is suspended, powergating is explicitly enableda0f3ac399e
uapi: fix linux/nfc.h userspace compilation errors818c9e0a04
nfc: uapi: use kernel size_t to fix user-space builds8d31cbab4c
i2c: validate user data in compat ioctl51c94d8fbd
fsl/fman: Fix missing put_device() call in fman_port_probe920932b20e
net/ncsi: check for error return from call to nla_put_u32610af55f9f
selftests/net: udpgso_bench_tx: fix dst ip argument78503589b1
net/mlx5e: Fix wrong features assignment in case of error6114600808
ionic: Initialize the 'lif->dbid_inuse' bitmapb7c9a1427b
igc: Fix TX timestamp support for non-MSI-X platformse8a5988a85
net/smc: fix kernel panic caused by race of smc_sock97c87c1db9
net/smc: don't send CDC/LLC message if link not ready99f19566b1
net/smc: improved fix wait on already cleared linke553265ea5
NFC: st21nfca: Fix memory leak in device probe and remove8d70dc0eec
net: lantiq_xrx200: fix statistics of received bytes7ef89bd1e8
net: ag71xx: Fix a potential double free in error handling paths40d3618691
net: usb: pegasus: Do not drop long Ethernet framesa67becdaa8
net/smc: fix using of uninitialized completions769d14abd3
sctp: use call_rcu to free endpoint13c1bf43b6
selftests: Calculate udpgso segment count without header adjustmentabe74fb433
udp: using datalen to cap ipv6 udp max gso segments5e6ad649e9
net/mlx5e: Fix ICOSQ recovery flow for XSK73665165b6
net/mlx5e: Wrap the tx reporter dump callback to extract the sq4cd1da02f0
net/mlx5: DR, Fix NULL vs IS_ERR checking in dr_domain_init_resourcesfcb32eb3d0
scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()4833ad4908
selinux: initialize proto variable in selinux_ip_postroute_compat()ec941a2277
recordmcount.pl: fix typo in s390 mcount regexa0e82d5ef9
memblock: fix memblock_phys_alloc() section mismatch error7da855e939
platform/x86: apple-gmux: use resource_size() with resd01e9ce1af
parisc: Clear stale IIR value on instruction access rights trap0643d9175d
tomoyo: use hwight16() in tomoyo_domain_quota_is_ok()e2048a1f91
tomoyo: Check exceeded quota early in tomoyo_domain_quota_is_ok().210c7c6908
Input: i8042 - enable deferred probe quirk for ASUS UM325UAbb672eff74
Input: i8042 - add deferred probe support9b28b48fb3
Merge 5.10.89 into android12-5.10-ltseb967e323f
Linux 5.10.8952ad5da8e3
phonet/pep: refuse to enable an unbound pipe7dd52af1eb
hamradio: improve the incomplete fix to avoid NPD450121075a
hamradio: defer ax25 kfree after unregister_netdev8e34d07dd4
ax25: NPD bug when detaching AX25 device50f78486f9
hwmon: (lm90) Do not report 'busy' status bit as alarmec1d222d37
hwmom: (lm90) Fix citical alarm status for MAX6680/MAX6681441d387366
pinctrl: mediatek: fix global-out-of-bounds issue9c75a9657b
ASoC: rt5682: fix the wrong jack type detected94caab5af1
ASoC: tas2770: Fix setting of high sample ratesc7282790c7
Input: goodix - add id->model mapping for the "9111" model3bb3bf50d6
Input: elants_i2c - do not check Remark ID on eKTH3900/eKTH5312ee6f34215c
mm: mempolicy: fix THP allocations escaping mempolicy restrictions8008fc1d0b
KVM: VMX: Fix stale docs for kvm-intel.emulate_invalid_guest_stated91ed251fd
usb: gadget: u_ether: fix race in setting MAC address in setup phase6697f29bf5
ceph: fix up non-directory creation in SGID directoriesfffb6581a2
f2fs: fix to do sanity check on last xattr entry in __f2fs_setxattr()ad338d825e
tee: optee: Fix incorrect page free bug1f20707674
mm/hwpoison: clear MF_COUNT_INCREASED before retrying get_any_page()ac61b9c6c0
mac80211: fix locking in ieee80211_start_ap error path89876d1083
ARM: 9169/1: entry: fix Thumb2 bug in iWMMXt exception handlingc3253d3a38
mmc: mmci: stm32: clear DLYB_CR after sending tuning command0d66b39521
mmc: core: Disable card detect during shutdownc8e366a01c
mmc: meson-mx-sdhc: Set MANUAL_STOP for multi-block SDIO commands4af7915361
mmc: sdhci-tegra: Fix switch to HS400ES mode9a7ec79797
gpio: dln2: Fix interrupts when replugging the devicef5b02912e2
pinctrl: stm32: consider the GPIO offset to expose all the GPIO lines28626e76ba
KVM: VMX: Wake vCPU when delivering posted IRQ even if vCPU == this vCPU7a37f2e370
platform/x86: intel_pmc_core: fix memleak on registration failureb57afd1240
x86/pkey: Fix undefined behaviour with PKRU_WD_BITc05d8f66ec
tee: handle lookup of shm with reference count 00ffb9f83e4
parisc: Fix mask used to select futex spinlock5deeb9ad59
parisc: Correct completer in lws start8b745616ba
ipmi: fix initialization when workqueue allocation fails1f6ab84746
ipmi: ssif: initialize ssif_info->client earlya5192f3116
ipmi: bail out if init_srcu_struct failsbc674f1b21
Input: atmel_mxt_ts - fix double free in mxt_read_info_block30140e252f
ASoC: meson: aiu: Move AIU_I2S_MISC hold setting to aiu-fifo-i2s2b4c020b70
ALSA: hda/realtek: Fix quirk for Clevo NJ51CU7470780f3b
ALSA: hda/realtek: Add new alc285-hp-amp-init model4cb7dc2e30
ALSA: hda/realtek: Amp init fixup for HP ZBook 15 G669e492161c
ALSA: drivers: opl3: Fix incorrect use of vp->statea96c08e0b4
ALSA: jack: Check the return value of kstrdup()51c7b2a7b8
hwmon: (lm90) Drop critical attribute support for MAX66542464738d0e
hwmon: (lm90) Introduce flag indicating extended temperature support196df56c3d
hwmon: (lm90) Add basic support for TI TMP461fa2e149260
hwmon: (lm90) Fix usage of CONFIG2 register in detect functionba696b4708
pinctrl: bcm2835: Change init order for gpio hogs676c572439
Input: elantech - fix stack out of bound access in elantech_change_report_id()2792fde84c
sfc: falcon: Check null pointer of rx_queue->page_ringd70b4001ef
sfc: Check null pointer of rx_queue->page_ring75c962f02a
net: ks8851: Check for error irq9db0f8d395
drivers: net: smc911x: Check for error irqca2a15053b
fjes: Check for error irqc6d2754006
bonding: fix ad_actor_system option setting to default6809da5185
ipmi: Fix UAF when uninstall ipmi_si and ipmi_msghandler module61e6b82e7b
igb: fix deadlock caused by taking RTNL in RPM resume pathe00eace232
net: skip virtio_net_hdr_set_proto if protocol already seted05e4dcfb
net: accept UFOv6 packages in virtio_net_hdr_to_skb56b0bbba78
qlcnic: potential dereference null pointer of rx_queue->page_ring78e49d77e5
net: marvell: prestera: fix incorrect return of port_find861b4413e4
ARM: dts: imx6qdl-wandboard: Fix Ethernet supportd79f5e0d45
netfilter: fix regression in looped (broad|multi)cast's MAC handling579cefef7c
RDMA/hns: Replace kfree() with kvfree()7cf6466e00
IB/qib: Fix memory leak in qib_user_sdma_queue_pkts()cd9c90682b
ASoC: meson: aiu: fifo: Add missing dma_coerce_mask_and_coherent()580ecf86e7
spi: change clk_disable_unprepare to clk_unprepare93a957bbf4
arm64: dts: allwinner: orangepi-zero-plus: fix PHY modeef2dce4325
HID: potential dereference of null pointer3110bc5862
HID: holtek: fix mouse probing0875873b2a
ext4: check for inconsistent extents between index and leaf block76366c024f
ext4: check for out-of-order index extents in ext4_valid_extent_entries()1d4b1c4e8b
ext4: prevent partial update of the extent blocksf69a47fcbb
net: usb: lan78xx: add Allied Telesis AT29M2-AF8c0059a25c
arm64: vdso32: require CROSS_COMPILE_COMPAT for gcc+bfdb16b124a42
arm64: vdso32: drop -no-integrated-as flagba13eb1927
Merge 5.10.88 into android12-5.10-lts856f88f27b
Linux 5.10.8888f20cccbe
xen/netback: don't queue unlimited number of packages525875c410
xen/netback: fix rx queue stall detection8fa3a370cc
xen/console: harden hvc_xen against event channel stormsd31b337917
xen/netfront: harden netfront against event channel storms8ac3b6ee7c
xen/blkfront: harden blkfront against event channel storms76ec7fe2d8
Revert "xsk: Do not sleep in poll() when need_wakeup set"e24fc89830
bus: ti-sysc: Fix variable set but not used warning for reinit_modules70692b0620
rcu: Mark accesses to rcu_state.n_force_qsa9078e7914
scsi: scsi_debug: Sanity check block descriptor length in resp_mode_select()bdb854f134
scsi: scsi_debug: Fix type in min_t to avoid stack OOBaa1f912712
scsi: scsi_debug: Don't call kcalloc() if size arg is zero6859985a2f
ovl: fix warning in ovl_create_real()5fd7d62daa
fuse: annotate lock in fuse_reverse_inval_entry()b99bdf127a
media: mxl111sf: change mutex_init() location0413f7a1a5
xsk: Do not sleep in poll() when need_wakeup set6b8d8ecdd9
ARM: dts: imx6ull-pinfunc: Fix CSI_DATA07__ESAI_TX0 pad name8affa1b68d
Input: touchscreen - avoid bitwise vs logical OR warningaec5897b27
drm/amdgpu: correct register access for RLC_JUMP_TABLE_RESTOREc1d519263d
libata: if T_LENGTH is zero, dma direction should be DMA_NONEa9f2c6af5a
timekeeping: Really make sure wall_to_monotonic isn't positive6471ebcd6f
serial: 8250_fintek: Fix garbled text for consolea7c8067453
iocost: Fix divide-by-zero on donation from low hweight cgroupbcebb8eb19
zonefs: add MODULE_ALIAS_FS1c414ff63b
btrfs: fix double free of anon_dev after failure to create subvolume005d9292b5
btrfs: fix memory leak in __add_inode_ref()cd98cb5216
USB: serial: option: add Telit FN990 compositions5c93584d9a
USB: serial: cp210x: fix CP2105 GPIO registration8f207f1263
usb: xhci: Extend support for runtime power management for AMD's Yellow carp.e5949933f3
PCI/MSI: Mask MSI-X vectors only on successf8aa09186c
PCI/MSI: Clear PCI_MSIX_FLAGS_MASKALL on errord17c5a3897
usb: dwc2: fix STM ID/VBUS detection startup delay in dwc2_driver_probe2b2edc8fc5
USB: NO_LPM quirk Lenovo USB-C to Ethernet Adapher(RTL8153-04)fd623e16b2
tty: n_hdlc: make n_hdlc_tty_wakeup() asynchronous9439fabfc3
KVM: x86: Drop guest CPUID check for host initiated writes to MSR_IA32_PERF_CAPABILITIES5fe305c6d4
Revert "usb: early: convert to readl_poll_timeout_atomic()"2b54f485f2
USB: gadget: bRequestType is a bitfield, not a enum151ffac3ac
powerpc/85xx: Fix oops when CONFIG_FSL_PMC=nfcf9194d36
bpf, selftests: Fix racing issue in btf_skc_cls_ingress test6f46c59e60
sit: do not call ipip6_dev_free() from sit_init_net()6e1011cd18
net: systemport: Add global locking for descriptor lifecycled1765f984c
net/smc: Prevent smc_release() from long blocking337bb7bf7c
net: Fix double 0x prefix print in SKB dump734a3f3106
sfc_ef100: potential dereference of null pointer7da349f07e
net/packet: rx_owner_map depends on pg_vec1a34fb9e2b
netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_allocd3e1f54508
ixgbe: set X550 MDIO speed before talking to PHY48e01e3881
ixgbe: Document how to enable NBASE-T support776ed8b366
igc: Fix typo in i225 LTR functions74a16e062b
igbvf: fix double free in `igbvf_probe`ddac50d04f
igb: Fix removal of unicast MAC filters of VFs12c1938870
soc/tegra: fuse: Fix bitwise vs. logical OR warning451f1eded7
mptcp: clear 'kern' flag from fallback sockets222cebd995
drm/amd/pm: fix a potential gpu_metrics_table memory leak74dc97dfb2
rds: memory leak in __rds_conn_create()67f4362ae2
flow_offload: return EOPNOTSUPP for the unsupported mpls action type03fd6ca056
mac80211: fix lookup when adding AddBA extension elementbef59d6a83
mac80211: agg-tx: don't schedule_and_wake_txq() under sta->lock96bc86cac0
drm/ast: potential dereference of null pointercac0fd4b9b
selftest/net/forwarding: declare NETIFS p9 p1081fbdd4565
net/sched: sch_ets: don't remove idle classes from the round-robin listbe32c8a788
dmaengine: st_fdma: fix MODULE_ALIASdfff1d5e85
selftests: Fix IPv6 address bind tests08896ecfff
selftests: Fix raw socket bind tests with VRF5ba4dfb8b8
selftests: Add duplicate config only for MD5 VRF tests12512bc8f2
net: hns3: fix use-after-free bug in hclgevf_send_mbx_msg3a4f6dba1e
inet_diag: fix kernel-infoleak for UDP sockets20ad1ef02f
sch_cake: do not call cake_destroy() from cake_init()1208b445a4
s390/kexec_file: fix error handling when applying relocationsc058c544e7
selftests: net: Correct ping6 expected rc from 2 to 19983425c20
virtio/vsock: fix the transport to work with VMADDR_CID_ANY94a01e6fb2
soc: imx: Register SoC device only on i.MX boardscc426a91d3
clk: Don't parent clks until the parent is fully registered429bb01e4d
ARM: socfpga: dts: fix qspi node compatible7b4cc168d9
ceph: initialize pathlen variable in reconnect_caps_cbe0f06c32af
ceph: fix duplicate increment of opened_inodes metric640e28d618
tee: amdtee: fix an IS_ERR() vs NULL bugeed897a222
mac80211: track only QoS data frames for admission control24983f7508
arm64: dts: rockchip: fix audio-supply for Rock Pi 449bd597719
arm64: dts: rockchip: fix rk3399-leez-p710 vcc3v3-lan supply9fcdbbf396
arm64: dts: rockchip: fix rk3308-roc-cc vcc-sd supplyba866840b2
arm64: dts: rockchip: remove mmc-hs400-enhanced-strobe from rk3399-khadas-edge3516bc1492
arm64: dts: imx8mp-evk: Improve the Ethernet PHY description06294e7e34
arm64: dts: imx8m: correct assigned clocks for FEC4cc6badff9
audit: improve robustness of the audit queue handling0e21e6cd5e
dm btree remove: fix use after free in rebalance_children()f5187a9d52
recordmcount.pl: look for jgnop instruction as well as bcrl on s39051f6302f81
vdpa: check that offsets are within boundse3a1ab5aea
virtio_ring: Fix querying of maximum DMA mapping size for virtio device0612679e48
bpf, selftests: Add test case trying to taint map value pointer279e0bf80d
bpf: Make 32->64 bounds propagation slightly more robuste2aad0b5f2
bpf: Fix signed bounds propagation after mov32f0f484714f
firmware: arm_scpi: Fix string overflow in SCPI genpd driver7fd214fc7f
mac80211: validate extended element ID is present0bb50470f1
mac80211: send ADDBA requests using the tid/queue of the aggregation session29bb131dbb
mac80211: mark TX-during-stop for TX in in_reconfig15640e40e3
mac80211: fix regression in SSN handling of addba tx49b7e49692
KVM: downgrade two BUG_ONs to WARN_ON_ONCE8d0f56c2ed
KVM: selftests: Make sure kvm_create_max_vcpus test won't hit RLIMIT_NOFILEc4d08791d9
Merge 5.10.87 into android12-5.10-lts272aedd4a3
Linux 5.10.878dd559d53b
arm: ioremap: don't abuse pfn_valid() to check if pfn is in RAM65c578935b
arm: extend pfn_valid to take into account freed memory map alignment6e634c0e71
memblock: ensure there is no overflow in memblock_overlaps_region()74551f13c6
memblock: align freed memory map on pageblock boundaries with SPARSEMEMb4b54c7ba1
memblock: free_unused_memmap: use pageblock units instead of MAX_ORDERb6a1cbd187
perf intel-pt: Fix error timestamp setting on the decoder error path0612aa02c2
perf intel-pt: Fix missing 'instruction' events with 'q' option71c795028b
perf intel-pt: Fix next 'err' value, walking trace02681dd178
perf intel-pt: Fix state setting when receiving overflow (OVF) packetcbed09b44c
perf intel-pt: Fix intel_pt_fup_event() assumptions about setting state type3bb7fd4be8
perf intel-pt: Fix sync state when a PSB (synchronization) packet is found731ff78841
perf intel-pt: Fix some PGE (packet generation enable/control flow packets) usageb23f9252a4
perf inject: Fix itrace space allowed for new attributes7c26da3be1
ethtool: do not perform operations on net devices being unregistered6992d8c215
hwmon: (dell-smm) Fix warning on /proc/i8k creation errorc31470a30c
fuse: make sure reclaim doesn't write the inode613725436e
bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc9099f35126
staging: most: dim2: use device release methodac76adc87a
KVM: x86: Ignore sparse banks size for an "all CPUs", non-sparse IPI req6f0d9d3e74
tracing: Fix a kmemleak false positive in tracing_mapf35f7f04aa
drm/amd/display: add connector type check for CRC source setdd3cea3425
drm/amd/display: Fix for the no Audio bug with Tiled Displaysdadce61247
net: netlink: af_netlink: Prevent empty skb by adding a check on len.bca6af4325
i2c: rk3x: Handle a spurious start completion interrupt flagd6edec8a7b
parisc/agp: Annotate parisc agp init functions with __initcf520ccffd
ALSA: hda/hdmi: fix HDA codec entry table order for ADL-P701a07fd02
ALSA: hda: Add Intel DG2 PCI ID and HDMI codec vid6d22a96d12
net/mlx4_en: Update reported link modes for 1/10G999069d8b0
Revert "tty: serial: fsl_lpuart: drop earlycon entry for i.MX8QXP"27f4ce02b3
s390/test_unwind: use raw opcode instead of invalid instruction9eab949e2b
KVM: arm64: Save PSTATE early on exit990fd815ec
drm/msm/dsi: set default num_data_lanesc602863ad2
nfc: fix segfault in nfc_genl_dump_devices_done4f0b8b90b8
Merge 5.10.86 into android12-5.10-lts37050f17f2
Linux 5.10.863241449183
netfilter: selftest: conntrack_vrf.sh: fix file permissionafc997898e
Merge 5.10.85 into android12-5.10-ltse4f2aee661
Linux 5.10.8547301c06f6
Documentation/Kbuild: Remove references to gcc-plugin.shaf5ba49cf7
MAINTAINERS: adjust GCC PLUGINS after gcc-plugin.sh removalad13421fd2
doc: gcc-plugins: update gcc-plugins.rst9fc17c3af5
kbuild: simplify GCC_PLUGINS enablement in dummy-tools/gccd428e54774
bpf: Add selftests to cover packet access corner cases0ec0eda3f3
misc: fastrpc: fix improper packet size calculation261d45a4c2
irqchip: nvic: Fix offset for Interrupt Priority Offsetscd946f0ebe
irqchip/irq-gic-v3-its.c: Force synchronisation when issuing INVALLe1c6611f82
irqchip/armada-370-xp: Fix support for Multi-MSI interrupts8f3ed9deaa
irqchip/armada-370-xp: Fix return value of armada_370_xp_msi_alloc()d530e9943d
irqchip/aspeed-scu: Replace update_bits with write_bits.014c2fa5dc
csky: fix typo of fpu config macroee86d0bad8
iio: accel: kxcjk-1013: Fix possible memory leak in probe and removec10c53419d
iio: ad7768-1: Call iio_trigger_notify_done() on error0f86c9e818
iio: adc: axp20x_adc: fix charging current reporting on AXP22xaf7fbb8c0b
iio: adc: stm32: fix a current leak by resetting pcsel before disabling vddafff92f3712
iio: at91-sama5d2: Fix incorrect sign extensiona2545b147d
iio: dln2: Check return value of devm_iio_trigger_register()69ae78c1ab
iio: dln2-adc: Fix lockdep complaint416383999c
iio: itg3200: Call iio_trigger_notify_done() on errorbc4d8367ed
iio: kxsd9: Don't return error code in trigger handler28ea539a31
iio: ltr501: Don't return error code in trigger handlerdb12d95085
iio: mma8452: Fix trigger reference couting4e78529110
iio: stk3310: Don't return error code in interrupt handler5c4a0f307f
iio: trigger: stm32-timer: fix MODULE_ALIAS5de9c5b130
iio: trigger: Fix reference countingcbc04c0c9a
iio: gyro: adxrs290: fix data signednessfee8be5bde
xhci: avoid race between disable slot command and host runtime suspend1b43c9b65f
usb: core: config: using bit mask instead of individual bits74b6a6a239
xhci: Remove CONFIG_USB_DEFAULT_PERSIST to prevent xHCI from runtime suspendingef284f086d
usb: core: config: fix validation of wMaxPacketValue entriese4de8ca013
USB: gadget: zero allocate endpoint 0 buffers7193ad3e50
USB: gadget: detect too-big endpoint 0 requests63fc70bffa
selftests/fib_tests: Rework fib_rp_filter_test()126d1897cb
net/qla3xxx: fix an error code in ql_adapter_up()5e663bcd9a
net, neigh: clear whole pneigh_entry at alloc timeae67383208
net: fec: only clear interrupt of handling queue in fec_enet_rx_queue()83b16b9c44
net: altera: set a couple error code in probe()385ffd31eb
net: cdc_ncm: Allow for dwNtbOutMaxSize to be unset or zero47322fddb4
tools build: Remove needless libpython-version feature check that breaks test-all fast path42bea3a1b7
dt-bindings: net: Reintroduce PHY no lane swap binding3f57215f74
Documentation/locking/locktypes: Update migrate_disable() bits.77d255d28b
perf tools: Fix SMT detection fast read path391ca20ea1
Revert "PCI: aardvark: Fix support for PCI_ROM_ADDRESS1 on emulated bridge"e5b7fb2198
i40e: Fix NULL pointer dereference in i40e_dbg_dump_desc347cc9b4d9
mtd: rawnand: fsmc: Fix timing computation0b2e1fccdf
mtd: rawnand: fsmc: Take instruction delay into account57f290572f
i40e: Fix pre-set max number of queues for VFeb87117c27
i40e: Fix failed opcode appearing if handling messages from VF82ed3829c9
clk: imx: use module_platform_driver4d12546cf9
RDMA/hns: Do not destroy QP resources in the hw resetting phase33f320c35d
RDMA/hns: Do not halt commands during reset until later4458938b29
ASoC: codecs: wcd934x: return correct value from mixer put1089dac26c
ASoC: codecs: wcd934x: handle channel mappping list correctly83dae68fc0
ASoC: codecs: wsa881x: fix return values from kcontrol put62e4dc5e13
ASoC: qdsp6: q6routing: Fix return value from msm_routing_put_audio_mixer2f4764fe36
ASoC: rt5682: Fix crash due to out of scope stack varsbdd8129c66
PM: runtime: Fix pm_runtime_active() kerneldoc comment661c4412c5
qede: validate non LSO skb lengthc4d2d7c935
scsi: scsi_debug: Fix buffer size of REPORT ZONES command1e434d2687
scsi: pm80xx: Do not call scsi_remove_host() in pm8001_alloc()5dfe611474
block: fix ioprio_get(IOPRIO_WHO_PGRP) vs setuid(2)5f1f94c26b
tracefs: Set all files to the same group ownership as the mount option2ba0738f71
net: mvpp2: fix XDP rx queues registering47ffefd88a
aio: fix use-after-free due to missing POLLFREE handlinge4d19740bc
aio: keep poll requests on waitqueue until completedfc2f636ffc
signalfd: use wake_up_pollfree()9f3acee7ea
binder: use wake_up_pollfree()8e04c8397b
wait: add wake_up_pollfree()2f8eb4c4c8
libata: add horkage for ASMedia 1092f76580d82c
can: m_can: Disable and ignore ELO interrupt703dde1120
can: pch_can: pch_can_rx_normal: fix use after free2737d0bc21
drm/syncobj: Deal with signalled fences in drm_syncobj_find_fence.17edb38e76
clk: qcom: regmap-mux: fix parent clock lookup172a982244
mmc: renesas_sdhi: initialize variable properly when tuning33204825cc
tracefs: Have new files inherit the ownership of their parentc520943a00
nfsd: Fix nsfd startup race (again)eeb0711801
nfsd: fix use-after-free due to delegation race8b4264c27b
md: fix update super 1.0 on rdev size changecaf9b352dc
btrfs: replace the BUG_ON in btrfs_del_root_ref with proper error handling41b3cc57d6
btrfs: clear extent buffer uptodate when we fail to write it75490bcbd0
scsi: qla2xxx: Format log strings only if needed07977a3f3d
ALSA: pcm: oss: Handle missing errors in snd_pcm_oss_change_params*()ad45babf78
ALSA: pcm: oss: Limit the period size to 16MB02b2b691b7
ALSA: pcm: oss: Fix negative period/buffer sizes6760e6ddeb
ALSA: hda/realtek: Fix quirk for TongFang PHxTxX17fe903d354
ALSA: hda/realtek - Add headset Mic support for Lenovo ALC897 platform3063ee5164
ALSA: ctl: Fix copy of updated id with element read/writec581090228
mm: bdi: initialize bdi_min_ratio when bdi is unregistered06368922f3
KVM: x86: Wait for IPIs to be delivered when handling Hyper-V TLB flush hypercall2a51edaf5c
net/sched: fq_pie: prevent dismantle issue4b7e90672a
devlink: fix netns refcount leak in devlink_nl_cmd_reload()9d683d14f6
IB/hfi1: Correct guard on eager buffer deallocation2e2edebb5d
iavf: Fix reporting when setting descriptor countaada0b3f33
iavf: restore MSI state on reset32a329b731
netfilter: conntrack: annotate data-races around ct->timeout5e39de85b7
udp: using datalen to cap max gso segments666521b385
seg6: fix the iif in the IPv6 socket control block484069b5de
nfp: Fix memory leak in nfp_cpp_area_cache_add()b1830ede16
bonding: make tx_rebalance_counter an atomica59df4ea71
ice: ignore dropped packets during init349e83c0cf
bpf: Fix the off-by-two error in range markingsf26951db84
bpf, x86: Fix "no previous prototype" warning74685aaece
vrf: don't run conntrack on vrf with !dflt qdiscd5cf399a6d
selftests: netfilter: add a vrf+conntrack testcase83ea620a1b
nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_donef3d9114ac9
drm/amdkfd: fix boot failure when iommu is disabled in Picasso.7508a9aa65
drm/amdgpu: init iommu after amdkfd device initac9db04ee3
drm/amdgpu: move iommu_resume before ip init/resumefe9dca7dda
drm/amdgpu: add amdgpu_amdkfd_resume_iommu5d191b0976
drm/amdkfd: separate kfd_iommu_resume from kfd_resume46dcf66d6e
drm/amd/amdkfd: adjust dummy functions' placementdded8d76a7
x86/sme: Explicitly map new EFI memmap table as encrypted923f4dc5df
can: sja1000: fix use after free in ems_pcmcia_add_card()819251da71
can: kvaser_pciefd: kvaser_pciefd_rx_error_frame(): increase correct stats->{rx,tx}_errors counter854a2bede1
can: kvaser_usb: get CAN clock frequency from device2c08271f4e
IB/hfi1: Fix leak of rcvhdrtail_dummy_kvaddrd87c10607b
IB/hfi1: Fix early init panicd60dd3685d
IB/hfi1: Insure use of smp_processor_id() is preempt disabled05eb0e4a12
nft_set_pipapo: Fix bucket load in AVX2 lookup routine for six 8-bit groups89f3edc98f
HID: check for valid USB device for many HID drivers889c39113f
HID: wacom: fix problems when device is not a valid USB device6272b17001
HID: bigbenff: prevent null pointer dereferenced877651afd
HID: add USB_HID dependancy on some USB HID driversa7e9c5ddf5
HID: add USB_HID dependancy to hid-chicony28989ed4d7
HID: add USB_HID dependancy to hid-prodikeys6114432960
HID: add hid_is_usb() function to make it simpler for USB detection2298d5edd8
HID: google: add eel USB id12362cd3a4
HID: quirks: Add quirk for the Microsoft Surface 3 type-covercc97d73215
gcc-plugins: fix gcc 11 indigestion with plugins...1eee36a552
gcc-plugins: simplify GCC plugin-dev capability test518c3f98e5
usb: gadget: uvc: fix multiple opense2aed161fc
ANDROID: GKI: fix up abi breakage in fib_rules.h1b71a028a2
Merge 5.10.84 into android12-5.10-ltsa0582e24d3
Linux 5.10.84e6edaf2677
ipmi: msghandler: Make symbol 'remove_work_wq' statica8d18fb4d1
net/tls: Fix authentication failure in CCM modedbe73dace9
parisc: Mark cr16 CPU clocksource unstable on all SMP machines01300d2150
iwlwifi: mvm: retry init flow if faileda5d0a72b80
serial: 8250: Fix RTS modem control while in rs485 modef9802d7049
serial: 8250_pci: rewrite pericom_do_set_divisor()50b06889c8
serial: 8250_pci: Fix ACCES entries in pci_serial_quirks arraye1722acf4f
serial: core: fix transmit-buffer reset and memleakbda142bbeb
serial: tegra: Change lower tolerance baud rate limit for tegra20 and tegra30901f7e0aa4
serial: pl011: Add ACPI SBSA UART match id946ded2287
tty: serial: msm_serial: Deactivate RX DMA for polling support67d08450a0
x86/64/mm: Map all kernel memory into trampoline_pgdb3a519b5a5
x86/tsc: Disable clocksource watchdog for TSC on qualified platorms1ed4a8fd36
x86/tsc: Add a timer to make sure TSC_adjust is always checkeda92f044a9f
usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect6d8c191bf4
USB: NO_LPM quirk Lenovo Powered USB-C Travel Hub90c915051c
xhci: Fix commad ring abort, write all 64 bits to CRCR register.1235485c63
vgacon: Propagate console boot parameters before calling `vc_resize'92b9113c6d
parisc: Fix "make install" on newer debian releasesc27a548d3f
parisc: Fix KBUILD_IMAGE for self-extracting kernel92f309c838
x86/entry: Add a fence for kernel entry SWAPGS in paranoid_entry()4bbbc9c4f3
x86/pv: Switch SWAPGS to ALTERNATIVE4d42b7bcf0
sched/uclamp: Fix rq->uclamp_max not set on first enqueue2015ffa3a4
x86/xen: Add xenpv_restore_regs_and_return_to_usermode()8b9279cad2
x86/entry: Use the correct fence macro after swapgs in kernel CR3c8e3411918
x86/sev: Fix SEV-ES INS/OUTS instructions for word, dword, and qword64ca109bf8
KVM: VMX: Set failure code in prepare_vmcs02()60ce9a7540
KVM: x86/pmu: Fix reserved bits for AMD PerfEvtSeln registercfebd5a277
atlantic: Remove warn trace message.95f6fae9a0
atlantic: Fix statistics logic for production hardware695d9c6bc6
Remove Half duplex mode speed capabilities.0c67e7b98f
atlantic: Add missing DIDs and fix 115c.ca350298bc
atlantic: Fix to display FW bundle version instead of FW mac version.93a4f3f4fd
atlatnic: enable Nbase-t speeds with base-t44812111a3
atlantic: Increase delay for fw transactions13f290d5aa
drm/msm: Do hw_init() before capturing GPU stated646856a60
drm/msm/a6xx: Allocate enough space for GMU registersa792b3d564
net/smc: Keep smc_close_final rc during active closee226180acc
net/rds: correct socket tunable error in rds_tcp_tune()77731fede2
net/smc: fix wrong list_del in smc_lgr_cleanup_early9a40a1e0eb
ipv4: convert fib_num_tclassid_users to atomic_tfa973bf5fd
net: annotate data-races on txq->xmit_lock_ownere26dab79e1
dpaa2-eth: destroy workqueue at the end of remove functiondde240695d
net: marvell: mvpp2: Fix the computation of shared CPUs3260b8d120
net: usb: lan78xx: lan78xx_phy_init(): use PHY_POLL instead of "0" if no IRQ is availableacef1c2b15
ALSA: intel-dsp-config: add quirk for CML devices based on ES8336 codec60f0b9c42c
rxrpc: Fix rxrpc_local leak in rxrpc_lookup_peer()35b40f724c
rxrpc: Fix rxrpc_peer leak in rxrpc_look_up_bundle()4afb32090a
ASoC: tegra: Fix kcontrol put callback in AHUBfe4eb5297a
ASoC: tegra: Fix kcontrol put callback in DSPK256aa15aac
ASoC: tegra: Fix kcontrol put callback in DMIC1cf1f9a1f3
ASoC: tegra: Fix kcontrol put callback in I2S0ee53a1d88
ASoC: tegra: Fix kcontrol put callback in ADMAIFe6fb4c3fd3
ASoC: tegra: Fix wrong value type in DSPK0265ef0dff
ASoC: tegra: Fix wrong value type in DMICe66e75fb22
ASoC: tegra: Fix wrong value type in I2S6b54c0d845
ASoC: tegra: Fix wrong value type in ADMAIF932b338f4e
mt76: mt7915: fix NULL pointer dereference in mt7915_get_phy_modea0335cda6d
selftests: net: Correct case namef1d43efa59
net/mlx4_en: Fix an use-after-free bug in mlx4_en_try_alloc_resources()59d2dc7710
arm64: ftrace: add missing BTIsef55f0f8af
siphash: use _unaligned version by defaultfd52e1f8c0
net: mpls: Fix notifications when deleting a device15fa12c119
net: qlogic: qlcnic: Fix a NULL pointer dereference in qlcnic_83xx_add_rings()c6f340a331
tcp: fix page frag corruption on page faultaa6c393a3c
natsemi: xtensa: fix section mismatch warnings289ee320b5
i2c: cbus-gpio: set atomic transfer callback58d5c53f25
i2c: stm32f7: stop dma transfer in case of NACKc221244917
i2c: stm32f7: recover the bus on access timeout8de6ea757c
i2c: stm32f7: flush TX FIFO upon transfer errors1c75779dd9
wireguard: ratelimiter: use kvcalloc() instead of kvzalloc()cb2d7c1992
wireguard: receive: drop handshakes if queue lock is contended8a29a50dbd
wireguard: receive: use ring buffer for incoming handshakese3be118327
wireguard: device: reset peer src endpoint when netns exitsf7b6672fab
wireguard: selftests: rename DEBUG_PI_LIST to DEBUG_PLIST0584bf51c3
wireguard: selftests: actually test for routing loops3d1dc3c677
wireguard: allowedips: add missing __rcu annotation to satisfy sparse4caf965f6c
wireguard: selftests: increase default dmesg log size3d73021f8d
tracing/histograms: String compares should not care about signed valuesd4af6d9749
KVM: X86: Use vcpu->arch.walk_mmu for kvm_mmu_invlpg()c71b5f37b5
KVM: arm64: Avoid setting the upper 32 bits of TCR_EL2 and CPTR_EL2 to 15f33887a36
KVM: x86: Use a stable condition around all VT-d PI paths7722e88505
KVM: nVMX: Flush current VPID (L1 vs. L2) for KVM_REQ_TLB_FLUSH_GUEST6a44f200f1
KVM: Disallow user memslot with size that exceeds "unsigned long"775191dd4c
drm/amd/display: Allow DSC on supported MST branch devices209d35ee34
ipv6: fix memory leak in fib6_rule_suppress16c242b091
sata_fsl: fix warning in remove_proc_entry when rmmod sata_fsl4a46b2f5dc
sata_fsl: fix UAF in sata_fsl_port_stop when rmmod sata_fsl4baba6ba56
fget: check that the fd still exists after getting a ref to it80bfed369b
s390/pci: move pseudo-MMIO to prevent MIO overlap92283c2728
cpufreq: Fix get_cpu_device() failure in add_cpu_dev_symlink()f717f29e84
ipmi: Move remove_work to dedicated workqueuede4f5eb02c
rt2x00: do not mark device gone on EPROTO errors during startc200721f8e
kprobes: Limit max data_size of the kretprobe instances2a74c13dfe
vrf: Reset IPCB/IP6CB when processing outbound pkts in vrf dev xmit136cabf157
ACPI: Add stubs for wakeup handler functionscc443ac5bb
net/smc: Avoid warning of possible recursive lockingff061b5bda
perf report: Fix memory leaks around perf_tip()a4c17ebdd6
perf hist: Fix memory leak of a perf_hpp_fmtd9b72274f3
perf inject: Fix ARM SPE handling2c15d2a6ba
net: ethernet: dec: tulip: de4x5: fix possible array overflows in type3_infoblock()f059fa40f0
net: tulip: de4x5: fix the problem that the array 'lp->phy[8]' may be out of bound4d5968ea06
ipv6: check return value of ipv6_skip_exthdr22519eff7d
ethernet: hisilicon: hns: hns_dsaf_misc: fix a possible array overflow in hns_dsaf_ge_srst_by_port()9a32d3c08d
ata: ahci: Add Green Sardine vendor ID as board_ahci_mobilec746945fb6
drm/amd/amdgpu: fix potential memleak74aafe99ef
drm/amd/amdkfd: Fix kernel panic when reset failed and been triggered againf0c9f49b0c
scsi: iscsi: Unblock session then wake up error handlerbc8c423a28
thermal: core: Reset previous low and high trip during thermal zone init8e4d2ac434
btrfs: check-integrity: fix a warning on write caching disabled disk0395722905
s390/setup: avoid using memblock_enforce_memory_limitfd1e70ef65
platform/x86: thinkpad_acpi: Fix WWAN device disabled issue after S3 deep226b21ad01
platform/x86: thinkpad_acpi: Add support for dual fan control3fc88660ed
net: return correct error code2c514d2500
atlantic: Fix OOB read and write in hw_atl_utils_fw_rpc_waitff6eeb6278
net/smc: Transfer remaining wait queue entries during fallbacke1a165599a
mac80211: do not access the IV when it was strippedc386d7aa59
drm/sun4i: fix unmet dependency on RESET_CONTROLLER for PHY_SUN6I_MIPI_DPHY57e36973fa
powerpc/pseries/ddw: Revert "Extend upper limit for huge DMA window for persistent memory"7b2b7e03e8
gfs2: Fix length of holes reported at end-of-file664cceab6f
gfs2: release iopen glock early in evictbcce010f92
ovl: fix deadlock in splice writedca4f9a581
ovl: simplify file splice7774dd934a
can: j1939: j1939_tp_cmd_recv(): check the dst address of TP.CM_BAM60ae63ef19
NFSv42: Fix pagecache invalidation after COPY/CLONE6e6898e23c
ANDROID: GKI: update abi_gki_aarch64.xml due to bpf changes in 5.10.83cd1062d64e
Revert "net: ipv6: add fib6_nh_release_dsts stub"0bf59ac0b2
Revert "net: nexthop: release IPv6 per-cpu dsts when replacing a nexthop group"65836a68d9
Revert "mmc: sdhci: Fix ADMA for PAGE_SIZE >= 64KiB"249dae115a
Merge 5.10.83 into android-5.10bc8ae0e2af
Merge branch 'android12-5.10' into `android12-5.10-lts`a324ad7945
Linux 5.10.8345b42cd053
drm/amdgpu/gfx9: switch to golden tsc registers for renoir+98b02755d5
net: stmmac: platform: fix build warning when with !CONFIG_PM_SLEEPa15261d2a1
shm: extend forced shm destroy to support objects from several IPC nsesaa20e966d8
s390/mm: validate VMA in PGSTE manipulation functionsa94e4a7b77
tty: hvc: replace BUG_ON() with negative return value1c5f722a8f
xen/netfront: don't trust the backend response data blindly334b0f2787
xen/netfront: disentangle tx_skb_freeliste17ee047ee
xen/netfront: don't read data from request on the ring pagef5e4937098
xen/netfront: read response from backend only once1ffb20f052
xen/blkfront: don't trust the backend response data blindly8e147855fc
xen/blkfront: don't take local copy of a request from the ring page273f04d5d1
xen/blkfront: read response from backend only onceb98284aa3f
xen: sync include/xen/interface/io/ring.h with Xen's newest version406f2d5fe3
tracing: Check pid filtering when creating events4fd0ad08ee
vhost/vsock: fix incorrect used length reported to the guestfbc0514e1a
iommu/amd: Clarify AMD IOMMUv2 initialization messages5655b8bccb
smb3: do not error on fsync when readonlyc380062d08
ceph: properly handle statfs on multifs setups22423c966e
f2fs: set SBI_NEED_FSCK flag when inconsistent node block founde6ee7abd6b
sched/scs: Reset task stack state in bringup_cpu()71e38a0c7c
tcp: correctly handle increased zerocopy args struct size72f2117e45
net: mscc: ocelot: correctly report the timestamping RX filters in ethtool73115a2b38
net: mscc: ocelot: don't downgrade timestamping RX filters in SIOCSHWTSTAMP62343dadbb
net: hns3: fix VF RSS failed problem after PF enable multi-TCs215167df45
net/smc: Don't call clcsock shutdown twice when smc shutdown6e800ee432
net: vlan: fix underflow for the real_dev refcntae2659d2c6
net/sched: sch_ets: don't peek at classes beyond 'nbands'e3509feb46
tls: fix replacing proto_ops22156242b1
tls: splice_read: fix record type check3b6c71c097
MIPS: use 3-level pgtable for 64KB page size on MIPS_VA_BITS_48a6a5d853f1
MIPS: loongson64: fix FTLB configuration5e823dbee2
igb: fix netpoll exit with trafficf2a58ff3e3
nvmet: use IOCB_NOWAIT only if the filesystem supports it12ceb52f2c
net/smc: Fix loop in smc_listenc94cbd262b
net/smc: Fix NULL pointer dereferencing in smc_vlan_by_tcpsk()3d4937c6a3
net: phylink: Force retrigger in case of latched link-fail indicator50162ff3c8
net: phylink: Force link down and retrigger resolve on interface change95ba8f0d57
lan743x: fix deadlock in lan743x_phy_link_status_change()c5e4316d9c
tcp_cubic: fix spurious Hystart ACK train detections for not-cwnd-limited flows3187623096
drm/amd/display: Set plane update flags for all planes in resetf634c755a0
PM: hibernate: use correct mode for swsusp_close()440bd9faad
net/ncsi : Add payload to be 32-bit aligned to fix dropped packetsac88cb3c44
nvmet-tcp: fix incomplete data digest send8889ff80fd
net: marvell: mvpp2: increase MTU limit when XDP enabled90d0736876
mlxsw: spectrum: Protect driver from buggy firmware33d89128a9
mlxsw: Verify the accessed index doesn't exceed the array length29e1b57347
net/smc: Ensure the active closing peer first closes clcsock77d9c2efa8
erofs: fix deadlock when shrink erofs slab9f540c7ffb
scsi: scsi_debug: Zero clear zones at reset write pointer725ba12895
scsi: core: sysfs: Fix setting device state to SDEV_RUNNINGe65a8707b4
ice: avoid bpf_prog refcount underflow1eb5395add
ice: fix vsi->txq_map sizing26ed13d064
net: nexthop: release IPv6 per-cpu dsts when replacing a nexthop group3c40584595
net: ipv6: add fib6_nh_release_dsts stubdc2f7e9d8d
net: stmmac: retain PTP clock time during SIOCSHWTSTAMP ioctls79068e6b1c
net: stmmac: fix system hang caused by eee_ctrl_timer during suspend/resumecc301ad312
nfp: checking parameter process for rx-usecs/tx-usecs is invalid9b44cb67d3
ipv6: fix typos in __ip6_finish_output()6d9e8dabd4
firmware: smccc: Fix check for ARCH_SOC_ID not implementedbbd1683e79
mptcp: fix delack timer061542815a
ALSA: intel-dsp-config: add quirk for JSL devices based on ES8336 codecf5af2def7e
iavf: Prevent changing static ITR values if adaptive moderation is on5dca8eff46
net: marvell: prestera: fix double free issue on err pathb33c5c8281
drm/vc4: fix error code in vc4_create_object()2bf9c5a503
scsi: mpt3sas: Fix kernel panic during drive powercycle test29ecb4c0f0
drm/nouveau/acr: fix a couple NULL vs IS_ERR() checks0effb7f51b
ARM: socfpga: Fix crash with CONFIG_FORTIRY_SOURCE86c5adc780
NFSv42: Don't fail clone() unless the OP_CLONE operation failedc9ba7864d3
firmware: arm_scmi: pm: Propagate return value to caller8730a679c3
net: ieee802154: handle iftypes as u322925aadd1f
ASoC: codecs: wcd934x: return error code correctly from hw_params3a25def06d
ASoC: topology: Add missing rwsem around snd_ctl_remove() calls4a4f900e04
ASoC: qdsp6: q6asm: fix q6asm_dai_prepare error handling9196a68581
ASoC: qdsp6: q6routing: Conditionally reset FrontEnd Mixer2be17eca48
ARM: dts: bcm2711: Fix PCIe interrupts9db1d4a3c2
ARM: dts: BCM5301X: Add interrupt properties to GPIO nodeb2cd6fdcbe
ARM: dts: BCM5301X: Fix I2C controller interruptb7ef25e8c2
netfilter: flowtable: fix IPv6 tunnel addr matchd689176e0e
netfilter: ipvs: Fix reuse connection if RS weight is 0994065f6ef
netfilter: ctnetlink: do not erase error code with EINVALa3d829e5f3
netfilter: ctnetlink: fix filtering with CTA_TUPLE_REPLYa8a917058f
proc/vmcore: fix clearing user buffer by properly using clear_user()1f520a0d78
PCI: aardvark: Fix link trainingaec0751f61
PCI: aardvark: Simplify initialization of rootcap on virtual bridgedf57480988
PCI: aardvark: Implement re-issuing config requests on CRS responsee7f2e2c758
PCI: aardvark: Update comment about disabling link training2b7bc1c4b2
PCI: aardvark: Deduplicate code in advk_pcie_rd_conf()dfe906da9a
powerpc/32: Fix hardlockup on vmap stack overflowbf00edd9e6
mdio: aspeed: Fix "Link is Down" issue14c3ce30dd
mmc: sdhci: Fix ADMA for PAGE_SIZE >= 64KiB63195705b3
mmc: sdhci-esdhc-imx: disable CMDQ support092a58f0d9
tracing: Fix pid filtering when triggers are attached68fa6bf7f1
tracing/uprobe: Fix uprobe_perf_open probes iterationb777c866aa
KVM: PPC: Book3S HV: Prevent POWER7/8 TLB flush flushing SLBbfed9c2f2f
xen: detect uninitialized xenbus in xenbus_inite1d492c275
xen: don't continue xenstore initialization in case of errors8f4d0719f3
fuse: release pipe buf after last use8d0163cec7
staging: rtl8192e: Fix use after free in _rtl92e_pci_disconnect()0bfed81b2c
staging: greybus: Add missing rwsem around snd_ctl_remove() calls146283f16b
staging/fbtft: Fix backlight8fc5e3c7ca
HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts6ca32e2e77
Revert "parisc: Fix backtrace to always include init funtion names"3a4aeb37a7
media: cec: copy sequence field for the reply3798218a1a
ALSA: hda/realtek: Fix LED on HP ProBook 435 G760274e248e
ALSA: hda/realtek: Add quirk for ASRock NUC Box 1100172167bc8d
ALSA: ctxfi: Fix out-of-range access4402cf0402
binder: fix test regression due to sender_euid changeaea184ae64
usb: hub: Fix locking issues with address0_mutex5bf3a0c778
usb: hub: Fix usb enumeration issue due to address0 race00f1038c72
usb: typec: fusb302: Fix masking of comparator and bc_lvl interrupts56fbab4937
usb: chipidea: ci_hdrc_imx: fix potential error pointer dereference in probeb70ff391de
net: nexthop: fix null pointer dereference when IPv6 is not enabled0755f3f322
usb: dwc3: gadget: Fix null pointer exception140e2df472
usb: dwc3: gadget: Check for L1/L2/U3 for Start Transfer3abf746e80
usb: dwc3: gadget: Ignore NoStream after End Transfer2b7ab82f51
usb: dwc2: hcd_queue: Fix use of floating point literal4b18ccad96
usb: dwc2: gadget: Fix ISOC flow for elapsed frames16f1cac8f7
USB: serial: option: add Fibocom FM101-GL variantsff72128636
USB: serial: option: add Telit LE910S1 0x9200 composition854c14b2a1
ACPI: Get acpi_device's parent from the parent field33fe044f6a
bpf: Fix toctou on read-only map's constant scalar tracking8d21bcc704
Merge 5.10.82 into android12-5.10-ltsd5259a9ba6
Linux 5.10.82d35250ec5a
Revert "perf: Rework perf_event_exit_event()"6718f79c40
ALSA: hda: hdac_stream: fix potential locking issue in snd_hdac_stream_assign()f751fb54f2
ALSA: hda: hdac_ext_stream: fix potential locking issuesb3ef5051a7
x86/Kconfig: Fix an unused variable error in dell-smm-hwmon2ec78af152
btrfs: update device path inode time instead of bd_inode9febc9d8d2
fs: export an inode_update_time helpercade5d7a28
ice: Delete always true check of PF pointerfe65cecd27
usb: max-3421: Use driver data instead of maintaining a list of bound devices6186c7b9bd
ASoC: DAPM: Cover regression by kctl change notification fixb17dd53cac
selinux: fix NULL-pointer dereference when hashtab allocation fails1ae0d59c4f
RDMA/netlink: Add __maybe_unused to static inline in C file40bc831ab5
hugetlbfs: flush TLBs correctly after huge_pmd_unshare86ab0f8ff0
scsi: ufs: core: Fix task management completion timeout raceddd4e46cff
scsi: ufs: core: Fix task management completion04c586a601
drm/amdgpu: fix set scaling mode Full/Full aspect/Center not works on vga and dvi connectors47901b77bf
drm/i915/dp: Ensure sink rate values are always valid82de15ca6b
drm/nouveau: clean up all clients on device removalc81c90fbf5
drm/nouveau: use drm_dev_unplug() during device removal9221aff33e
drm/nouveau: Add a dedicated mutex for the clients list65517975cb
drm/udl: fix control-message timeout3d68d6ee83
drm/amd/display: Update swizzle mode enums7b97b5776d
cfg80211: call cfg80211_stop_ap when switch from P2P_GO type1ab297809d
parisc/sticon: fix reverse colors6adbc07ebc
btrfs: fix memory ordering between normal and ordered work functions6289b494b3
net: stmmac: socfpga: add runtime suspend/resume callback for stratix10 platform5875f87e2f
udf: Fix crash after seekdir6b43cf113a
KVM: nVMX: don't use vcpu->arch.efer when checking host state on nested state loadcc73242889
block: Check ADMIN before NICE for IOPRIO_CLASS_RT63e2f34abc
s390/kexec: fix memory leak of ipl report bufferb1cf0d2fc4
scsi: qla2xxx: Fix mailbox direction flags in qla2xxx_get_adapter_id()08fd6df8ea
powerpc/8xx: Fix pinned TLBs with CONFIG_STRICT_KERNEL_RWX9c177eee11
x86/hyperv: Fix NULL deref in set_hv_tscchange_cb() if Hyper-V setup failsb2e2fb6407
mm: kmemleak: slob: respect SLAB_NOLEAKTRACE flag99032adf7d
ipc: WARN if trying to remove ipc object which is absenta7d9162586
tipc: check for null after calling kmemdupf5995fcb75
hexagon: clean up timer-regs.h0854c9ff21
hexagon: export raw I/O routines for modules528971af64
tun: fix bonding active backup with arp monitoringaf1d3c437e
arm64: vdso32: suppress error message for 'make mrproper'97653ba562
net: stmmac: dwmac-rk: Fix ethernet on rk3399 based devices4cebe23c03
s390/kexec: fix return code handlingd4fb80ae98
perf/x86/intel/uncore: Fix IIO event constraints for Skylake Server175135a5ea
perf/x86/intel/uncore: Fix filter_tid mask for CHA events on Skylake Server84f64c7c52
pinctrl: qcom: sdm845: Enable dual edge errataa8230fb74b
KVM: PPC: Book3S HV: Use GLOBAL_TOC for kvmppc_h_set_dabr/xdabr()4e6cce20fb
e100: fix device suspend/resume34e54703fb
NFC: add NCI_UNREG flag to eliminate the raceb2a60b4a01
net: nfc: nci: Change the NCI close sequence73a0d12114
NFC: reorder the logic in nfc_{un,}register_devicecb14b196d9
NFC: reorganize the functions in nci_request41dc8dcb49
i40e: Fix display error code in dmesg028ea7b090
i40e: Fix creation of first queue by omitting it if is not power of two69868d7a88
i40e: Fix warning message and call stack during rmmod i40e driver20645482d1
i40e: Fix ping is lost after configuring ADq on VF6d64743045
i40e: Fix changing previously set num_queue_pairs for PFsf866513ead
i40e: Fix NULL ptr dereference on VSI filter sync0719488565
i40e: Fix correct max_pkt_size on VF RX queue8e6bae950d
net: virtio_net_hdr_to_skb: count transport header in UFO1c4099dc0d
net: dpaa2-eth: fix use-after-free in dpaa2_eth_remove381a30f7e3
net: sched: act_mirred: drop dst for the direction from egress to ingressa792e0128d
scsi: core: sysfs: Fix hang when device state is set via sysfs4b4302a02b
net/mlx5: E-Switch, return error if encap isn't supported68748ea4d1
net/mlx5: E-Switch, Change mode lock from mutex to rw semaphore6190e1a2d4
net/mlx5: Lag, update tracker when state change event received471c492890
net/mlx5e: nullify cq->dbg pointer in mlx5_debug_cq_remove()d1f8f1e04a
platform/x86: hp_accel: Fix an error handling path in 'lis3lv02d_probe()'da16f907cb
mips: lantiq: add support for clk_get_parent()17dfbe1b2f
mips: bcm63xx: add support for clk_get_parent()34284b3a2f
MIPS: generic/yamon-dt: fix uninitialized variable errora61f90b216
iavf: Fix for setting queues to 0a8a1e601c2
iavf: Fix for the false positive ASQ/ARQ errors while issuing VF reset77f5ae5441
iavf: validate pointersddcc185baa
iavf: prevent accidental free of filter structurea420b26128
iavf: Fix failure to exit out from last all-multicast mode78638b4713
iavf: free q_vectors before queues in iavf_disable_vf84a13bfe27
iavf: check for null in iavf_fix_features1555d83ddb
iavf: Fix return of set the new channel count09decd0a10
net/smc: Make sure the link_id is unique437e21e2c9
sock: fix /proc/net/sockstat underflow in sk_clone_lock()4da14ddad1
net: reduce indentation level in sk_clone_lock()9c3c2ef6ca
tipc: only accept encrypted MSG_CRYPTO msgs3d59416647
bnxt_en: reject indirect blk offload when hw-tc-offload is off4fc060abaa
net: bnx2x: fix variable dereferenced before check3ae75cc38a
net: ipa: disable HOLB drop when updating timer3984876f91
tracing: Add length protection to histogram string copies900ea2f628
tcp: Fix uninitialized access in skb frags array for Rx 0cp.d1a6150ca6
net-zerocopy: Refactor skb frag fast-forward op.5f7aadf03f
net-zerocopy: Copy straggler unaligned data for TCP Rx. zerocopy.8da80ec6d4
drm/nouveau: hdmigv100.c: fix corrupted HDMI Vendor InfoFrameaa31e3fda6
perf tests: Remove bash construct from record+zstd_comp_decomp.sh2ada5c0877
perf bench futex: Fix memory leak of perf_cpu_map__new()11589d3144
perf bpf: Avoid memory leak from perf_env__insert_btf()5b2f2cbbc9
tracing/histogram: Do not copy the fixed-size char array field over the field size1d61255327
blkcg: Remove extra blkcg_bio_issue_initdadcc935f4
perf/x86/vlbr: Add c->flags to vlbr event constraints68fcb52b61
sched/core: Mitigate race cpus_share_cache()/update_top_cache_domain()91191d47af
mips: BCM63XX: ensure that CPU_SUPPORTS_32BIT_KERNEL is setfbe27d0e1d
clk: qcom: gcc-msm8996: Drop (again) gcc_aggre1_pnoc_ahb_clk9b3d3b72be
clk/ast2600: Fix soc revision for AHB03bc8ea0ae
clk: ingenic: Fix bugs with divided dividers7a5439474e
f2fs: fix incorrect return value in f2fs_sanity_check_ckpt()0a17fff6f0
f2fs: compress: disallow disabling compress on non-empty compressed file4ce685cc9a
sh: define __BIG_ENDIAN for math-emu73383f670d
sh: math-emu: drop unused functionsf44defd569
sh: fix kconfig unmet dependency warning for FRAME_POINTER3d7c5d08a4
f2fs: fix to use WHINT_MODEe8bd5e3305
f2fs: fix up f2fs_lookup tracepoints5d5bf899e5
maple: fix wrong return value of maple_bus_init().8748f08a2f
sh: check return code of request_irq29b742690a
powerpc/8xx: Fix Oops with STRICT_KERNEL_RWX without DEBUG_RODATA_TESTbc4bc07fb4
powerpc/dcr: Use cmplwi instead of 3-argument cmpli1ac6cd87d8
ALSA: gus: fix null pointer dereference on pointer block850416bead
ARM: dts: qcom: fix memory and mdio nodes naming for RB30118c4d9764e7
powerpc/5200: dts: fix memory node unit name833ad27927
iio: imu: st_lsm6dsx: Avoid potential array overflow in st_lsm6dsx_set_odr()e0fef1c8cd
scsi: target: Fix alua_tg_pt_gps_count tracking8176441373
scsi: target: Fix ordered tag handling8440377e1a
scsi: scsi_debug: Fix out-of-bound read in resp_report_tgtpgs()3e20cb0726
scsi: scsi_debug: Fix out-of-bound read in resp_readcap16()9635581aa9
MIPS: sni: Fix the build77e9fed330
tty: tty_buffer: Fix the softlockup issue in flush_to_ldiscda82a207c4
ALSA: ISA: not for M68Kc788ac4750
ARM: dts: ls1021a-tsn: use generic "jedec,spi-nor" compatible for flashcbba09f869
ARM: dts: ls1021a: move thermal-zones node out of soc/2474eb7fc3
usb: host: ohci-tmio: check return value after calling platform_get_resource()02d9ebe0cc
ARM: dts: omap: fix gpmc,mux-add-data typec6c9bbe7fa
firmware_loader: fix pre-allocated buf built-in firmware use02a22911ed
ALSA: intel-dsp-config: add quirk for APL/GLK/TGL devices based on ES8336 codec055eced3ed
scsi: advansys: Fix kernel pointer leak97f3cbb57b
ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detectae2207a078
clk: imx: imx6ul: Move csi_sel mux to correct base register0c6daf4799
ASoC: SOF: Intel: hda-dai: fix potential locking issue19d193c576
arm64: dts: freescale: fix arm,sp805 compatible string36446a094a
arm64: dts: qcom: ipq6018: Fix qcom,controlled-remotely propertye52fecdd0c
arm64: dts: qcom: msm8998: Fix CPU/L2 idle state latency and residency568d94c5c9
ARM: BCM53016: Specify switch ports for Meraki MR323a53d9ad9b
staging: rtl8723bs: remove possible deadlock when disconnect (v2)3544c33879
ARM: dts: ux500: Skomer regulator fixeseff8b76284
usb: typec: tipd: Remove WARN_ON in tps6598x_block_read679eee466d
usb: musb: tusb6010: check return value after calling platform_get_resource()2492de6f5e
bus: ti-sysc: Use context lost quirk for otg5eca1c8412
bus: ti-sysc: Add quirk handling for reinit on context lostdcd6eefcee
RDMA/bnxt_re: Check if the vlan is valid before reporting4e5bc9fb23
arm64: dts: hisilicon: fix arm,sp805 compatible string109a63bb07
arm64: dts: rockchip: Disable CDN DP on Pinebook Proc097bd5a59
scsi: lpfc: Fix list_add() corruption in lpfc_drain_txq()db90c50783
ARM: dts: NSP: Fix mpcore, mmc node names5010df76ab
staging: wfx: ensure IRQ is ready before enabling it2651d06e46
arm64: dts: allwinner: a100: Fix thermal zone node namefa98ac472e
arm64: dts: allwinner: h5: Fix GPU thermal zone node nameaed195558f
ARM: dts: sunxi: Fix OPPs node namee2e1056312
arm64: zynqmp: Fix serial compatible string48f154e8b9
arm64: zynqmp: Do not duplicate flash partition label property Some minor ABI signatures have changed due to internal structures changing. All of these have been pre-approved already: Leaf changes summary: 3 artifacts changed Changed leaf types summary: 3 leaf types changed Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable 'struct bpf_map at bpf.h:146:1' changed: type size hasn't changed there are data member changes: type 'typedef u64' of 'bpf_map::writecnt' changed: typedef name changed from u64 to atomic64_t at types.h:175:1 underlying type 'typedef __u64' at int-ll64.h:31:1 changed: entity changed from 'typedef __u64' to 'struct {s64 counter;}' at types.h:173:1 type size hasn't changed 4790 impacted interfaces 'struct bpf_offloaded_map at bpf.h:229:1' changed (indirectly): type size hasn't changed there are data member changes: type 'struct bpf_map' of 'bpf_offloaded_map::map' changed, as reported earlier 4790 impacted interfaces 'struct fib_rules_ops at fib_rules.h:60:1' changed: type size hasn't changed there are data member changes: type 'typedef bool (fib_rule*, fib_lookup_arg*)*' of 'fib_rules_ops::suppress' changed: pointer type changed from: 'typedef bool (fib_rule*, fib_lookup_arg*)*' to: 'typedef bool (fib_rule*, int, fib_lookup_arg*)*' 4790 impacted interfaces Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: Id7f25c9e0edb30698178b138cc1b15a82ca5ef48
8917 lines
225 KiB
C
8917 lines
225 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* kernel/sched/core.c
|
|
*
|
|
* Core kernel scheduler code and related syscalls
|
|
*
|
|
* Copyright (C) 1991-2002 Linus Torvalds
|
|
*/
|
|
#define CREATE_TRACE_POINTS
|
|
#include <trace/events/sched.h>
|
|
#undef CREATE_TRACE_POINTS
|
|
|
|
#include "sched.h"
|
|
|
|
#include <linux/nospec.h>
|
|
|
|
#include <linux/kcov.h>
|
|
#include <linux/scs.h>
|
|
|
|
#include <asm/switch_to.h>
|
|
#include <asm/tlb.h>
|
|
|
|
#include "../workqueue_internal.h"
|
|
#include "../../fs/io-wq.h"
|
|
#include "../smpboot.h"
|
|
|
|
#include "pelt.h"
|
|
#include "smp.h"
|
|
|
|
#include <trace/hooks/sched.h>
|
|
#include <trace/hooks/dtask.h>
|
|
|
|
/*
|
|
* Export tracepoints that act as a bare tracehook (ie: have no trace event
|
|
* associated with them) to allow external modules to probe them.
|
|
*/
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_cfs_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_rt_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_dl_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_irq_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_se_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_cpu_capacity_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_overutilized_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_se_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_switch);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_waking);
|
|
#ifdef CONFIG_SCHEDSTATS
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_stat_sleep);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_stat_wait);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_stat_iowait);
|
|
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_stat_blocked);
|
|
#endif
|
|
|
|
DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
|
|
EXPORT_SYMBOL_GPL(runqueues);
|
|
|
|
#ifdef CONFIG_SCHED_DEBUG
|
|
/*
|
|
* Debugging: various feature bits
|
|
*
|
|
* If SCHED_DEBUG is disabled, each compilation unit has its own copy of
|
|
* sysctl_sched_features, defined in sched.h, to allow constants propagation
|
|
* at compile time and compiler optimization based on features default.
|
|
*/
|
|
#define SCHED_FEAT(name, enabled) \
|
|
(1UL << __SCHED_FEAT_##name) * enabled |
|
|
const_debug unsigned int sysctl_sched_features =
|
|
#include "features.h"
|
|
0;
|
|
EXPORT_SYMBOL_GPL(sysctl_sched_features);
|
|
#undef SCHED_FEAT
|
|
#endif
|
|
|
|
/*
|
|
* Number of tasks to iterate in a single balance run.
|
|
* Limited because this is done with IRQs disabled.
|
|
*/
|
|
const_debug unsigned int sysctl_sched_nr_migrate = 32;
|
|
|
|
/*
|
|
* period over which we measure -rt task CPU usage in us.
|
|
* default: 1s
|
|
*/
|
|
unsigned int sysctl_sched_rt_period = 1000000;
|
|
|
|
__read_mostly int scheduler_running;
|
|
|
|
/*
|
|
* part of the period that we allow rt tasks to run in us.
|
|
* default: 0.95s
|
|
*/
|
|
int sysctl_sched_rt_runtime = 950000;
|
|
|
|
|
|
/*
|
|
* Serialization rules:
|
|
*
|
|
* Lock order:
|
|
*
|
|
* p->pi_lock
|
|
* rq->lock
|
|
* hrtimer_cpu_base->lock (hrtimer_start() for bandwidth controls)
|
|
*
|
|
* rq1->lock
|
|
* rq2->lock where: rq1 < rq2
|
|
*
|
|
* Regular state:
|
|
*
|
|
* Normal scheduling state is serialized by rq->lock. __schedule() takes the
|
|
* local CPU's rq->lock, it optionally removes the task from the runqueue and
|
|
* always looks at the local rq data structures to find the most elegible task
|
|
* to run next.
|
|
*
|
|
* Task enqueue is also under rq->lock, possibly taken from another CPU.
|
|
* Wakeups from another LLC domain might use an IPI to transfer the enqueue to
|
|
* the local CPU to avoid bouncing the runqueue state around [ see
|
|
* ttwu_queue_wakelist() ]
|
|
*
|
|
* Task wakeup, specifically wakeups that involve migration, are horribly
|
|
* complicated to avoid having to take two rq->locks.
|
|
*
|
|
* Special state:
|
|
*
|
|
* System-calls and anything external will use task_rq_lock() which acquires
|
|
* both p->pi_lock and rq->lock. As a consequence the state they change is
|
|
* stable while holding either lock:
|
|
*
|
|
* - sched_setaffinity()/
|
|
* set_cpus_allowed_ptr(): p->cpus_ptr, p->nr_cpus_allowed
|
|
* - set_user_nice(): p->se.load, p->*prio
|
|
* - __sched_setscheduler(): p->sched_class, p->policy, p->*prio,
|
|
* p->se.load, p->rt_priority,
|
|
* p->dl.dl_{runtime, deadline, period, flags, bw, density}
|
|
* - sched_setnuma(): p->numa_preferred_nid
|
|
* - sched_move_task()/
|
|
* cpu_cgroup_fork(): p->sched_task_group
|
|
* - uclamp_update_active() p->uclamp*
|
|
*
|
|
* p->state <- TASK_*:
|
|
*
|
|
* is changed locklessly using set_current_state(), __set_current_state() or
|
|
* set_special_state(), see their respective comments, or by
|
|
* try_to_wake_up(). This latter uses p->pi_lock to serialize against
|
|
* concurrent self.
|
|
*
|
|
* p->on_rq <- { 0, 1 = TASK_ON_RQ_QUEUED, 2 = TASK_ON_RQ_MIGRATING }:
|
|
*
|
|
* is set by activate_task() and cleared by deactivate_task(), under
|
|
* rq->lock. Non-zero indicates the task is runnable, the special
|
|
* ON_RQ_MIGRATING state is used for migration without holding both
|
|
* rq->locks. It indicates task_cpu() is not stable, see task_rq_lock().
|
|
*
|
|
* p->on_cpu <- { 0, 1 }:
|
|
*
|
|
* is set by prepare_task() and cleared by finish_task() such that it will be
|
|
* set before p is scheduled-in and cleared after p is scheduled-out, both
|
|
* under rq->lock. Non-zero indicates the task is running on its CPU.
|
|
*
|
|
* [ The astute reader will observe that it is possible for two tasks on one
|
|
* CPU to have ->on_cpu = 1 at the same time. ]
|
|
*
|
|
* task_cpu(p): is changed by set_task_cpu(), the rules are:
|
|
*
|
|
* - Don't call set_task_cpu() on a blocked task:
|
|
*
|
|
* We don't care what CPU we're not running on, this simplifies hotplug,
|
|
* the CPU assignment of blocked tasks isn't required to be valid.
|
|
*
|
|
* - for try_to_wake_up(), called under p->pi_lock:
|
|
*
|
|
* This allows try_to_wake_up() to only take one rq->lock, see its comment.
|
|
*
|
|
* - for migration called under rq->lock:
|
|
* [ see task_on_rq_migrating() in task_rq_lock() ]
|
|
*
|
|
* o move_queued_task()
|
|
* o detach_task()
|
|
*
|
|
* - for migration called under double_rq_lock():
|
|
*
|
|
* o __migrate_swap_task()
|
|
* o push_rt_task() / pull_rt_task()
|
|
* o push_dl_task() / pull_dl_task()
|
|
* o dl_task_offline_migration()
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* __task_rq_lock - lock the rq @p resides on.
|
|
*/
|
|
struct rq *__task_rq_lock(struct task_struct *p, struct rq_flags *rf)
|
|
__acquires(rq->lock)
|
|
{
|
|
struct rq *rq;
|
|
|
|
lockdep_assert_held(&p->pi_lock);
|
|
|
|
for (;;) {
|
|
rq = task_rq(p);
|
|
raw_spin_lock(&rq->lock);
|
|
if (likely(rq == task_rq(p) && !task_on_rq_migrating(p))) {
|
|
rq_pin_lock(rq, rf);
|
|
return rq;
|
|
}
|
|
raw_spin_unlock(&rq->lock);
|
|
|
|
while (unlikely(task_on_rq_migrating(p)))
|
|
cpu_relax();
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(__task_rq_lock);
|
|
|
|
/*
|
|
* task_rq_lock - lock p->pi_lock and lock the rq @p resides on.
|
|
*/
|
|
struct rq *task_rq_lock(struct task_struct *p, struct rq_flags *rf)
|
|
__acquires(p->pi_lock)
|
|
__acquires(rq->lock)
|
|
{
|
|
struct rq *rq;
|
|
|
|
for (;;) {
|
|
raw_spin_lock_irqsave(&p->pi_lock, rf->flags);
|
|
rq = task_rq(p);
|
|
raw_spin_lock(&rq->lock);
|
|
/*
|
|
* move_queued_task() task_rq_lock()
|
|
*
|
|
* ACQUIRE (rq->lock)
|
|
* [S] ->on_rq = MIGRATING [L] rq = task_rq()
|
|
* WMB (__set_task_cpu()) ACQUIRE (rq->lock);
|
|
* [S] ->cpu = new_cpu [L] task_rq()
|
|
* [L] ->on_rq
|
|
* RELEASE (rq->lock)
|
|
*
|
|
* If we observe the old CPU in task_rq_lock(), the acquire of
|
|
* the old rq->lock will fully serialize against the stores.
|
|
*
|
|
* If we observe the new CPU in task_rq_lock(), the address
|
|
* dependency headed by '[L] rq = task_rq()' and the acquire
|
|
* will pair with the WMB to ensure we then also see migrating.
|
|
*/
|
|
if (likely(rq == task_rq(p) && !task_on_rq_migrating(p))) {
|
|
rq_pin_lock(rq, rf);
|
|
return rq;
|
|
}
|
|
raw_spin_unlock(&rq->lock);
|
|
raw_spin_unlock_irqrestore(&p->pi_lock, rf->flags);
|
|
|
|
while (unlikely(task_on_rq_migrating(p)))
|
|
cpu_relax();
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(task_rq_lock);
|
|
|
|
/*
|
|
* RQ-clock updating methods:
|
|
*/
|
|
|
|
static void update_rq_clock_task(struct rq *rq, s64 delta)
|
|
{
|
|
/*
|
|
* In theory, the compile should just see 0 here, and optimize out the call
|
|
* to sched_rt_avg_update. But I don't trust it...
|
|
*/
|
|
s64 __maybe_unused steal = 0, irq_delta = 0;
|
|
|
|
#ifdef CONFIG_IRQ_TIME_ACCOUNTING
|
|
irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;
|
|
|
|
/*
|
|
* Since irq_time is only updated on {soft,}irq_exit, we might run into
|
|
* this case when a previous update_rq_clock() happened inside a
|
|
* {soft,}irq region.
|
|
*
|
|
* When this happens, we stop ->clock_task and only update the
|
|
* prev_irq_time stamp to account for the part that fit, so that a next
|
|
* update will consume the rest. This ensures ->clock_task is
|
|
* monotonic.
|
|
*
|
|
* It does however cause some slight miss-attribution of {soft,}irq
|
|
* time, a more accurate solution would be to update the irq_time using
|
|
* the current rq->clock timestamp, except that would require using
|
|
* atomic ops.
|
|
*/
|
|
if (irq_delta > delta)
|
|
irq_delta = delta;
|
|
|
|
rq->prev_irq_time += irq_delta;
|
|
delta -= irq_delta;
|
|
#endif
|
|
#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
|
|
if (static_key_false((¶virt_steal_rq_enabled))) {
|
|
steal = paravirt_steal_clock(cpu_of(rq));
|
|
steal -= rq->prev_steal_time_rq;
|
|
|
|
if (unlikely(steal > delta))
|
|
steal = delta;
|
|
|
|
rq->prev_steal_time_rq += steal;
|
|
delta -= steal;
|
|
}
|
|
#endif
|
|
|
|
rq->clock_task += delta;
|
|
|
|
#ifdef CONFIG_HAVE_SCHED_AVG_IRQ
|
|
if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
|
|
update_irq_load_avg(rq, irq_delta + steal);
|
|
#endif
|
|
update_rq_clock_pelt(rq, delta);
|
|
}
|
|
|
|
void update_rq_clock(struct rq *rq)
|
|
{
|
|
s64 delta;
|
|
|
|
lockdep_assert_held(&rq->lock);
|
|
|
|
if (rq->clock_update_flags & RQCF_ACT_SKIP)
|
|
return;
|
|
|
|
#ifdef CONFIG_SCHED_DEBUG
|
|
if (sched_feat(WARN_DOUBLE_CLOCK))
|
|
SCHED_WARN_ON(rq->clock_update_flags & RQCF_UPDATED);
|
|
rq->clock_update_flags |= RQCF_UPDATED;
|
|
#endif
|
|
|
|
delta = sched_clock_cpu(cpu_of(rq)) - rq->clock;
|
|
if (delta < 0)
|
|
return;
|
|
rq->clock += delta;
|
|
update_rq_clock_task(rq, delta);
|
|
}
|
|
EXPORT_SYMBOL_GPL(update_rq_clock);
|
|
|
|
static inline void
|
|
rq_csd_init(struct rq *rq, struct __call_single_data *csd, smp_call_func_t func)
|
|
{
|
|
csd->flags = 0;
|
|
csd->func = func;
|
|
csd->info = rq;
|
|
}
|
|
|
|
#ifdef CONFIG_SCHED_HRTICK
|
|
/*
|
|
* Use HR-timers to deliver accurate preemption points.
|
|
*/
|
|
|
|
static void hrtick_clear(struct rq *rq)
|
|
{
|
|
if (hrtimer_active(&rq->hrtick_timer))
|
|
hrtimer_cancel(&rq->hrtick_timer);
|
|
}
|
|
|
|
/*
|
|
* High-resolution timer tick.
|
|
* Runs from hardirq context with interrupts disabled.
|
|
*/
|
|
static enum hrtimer_restart hrtick(struct hrtimer *timer)
|
|
{
|
|
struct rq *rq = container_of(timer, struct rq, hrtick_timer);
|
|
struct rq_flags rf;
|
|
|
|
WARN_ON_ONCE(cpu_of(rq) != smp_processor_id());
|
|
|
|
rq_lock(rq, &rf);
|
|
update_rq_clock(rq);
|
|
rq->curr->sched_class->task_tick(rq, rq->curr, 1);
|
|
rq_unlock(rq, &rf);
|
|
|
|
return HRTIMER_NORESTART;
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
static void __hrtick_restart(struct rq *rq)
|
|
{
|
|
struct hrtimer *timer = &rq->hrtick_timer;
|
|
ktime_t time = rq->hrtick_time;
|
|
|
|
hrtimer_start(timer, time, HRTIMER_MODE_ABS_PINNED_HARD);
|
|
}
|
|
|
|
/*
|
|
* called from hardirq (IPI) context
|
|
*/
|
|
static void __hrtick_start(void *arg)
|
|
{
|
|
struct rq *rq = arg;
|
|
struct rq_flags rf;
|
|
|
|
rq_lock(rq, &rf);
|
|
__hrtick_restart(rq);
|
|
rq_unlock(rq, &rf);
|
|
}
|
|
|
|
/*
|
|
* Called to set the hrtick timer state.
|
|
*
|
|
* called with rq->lock held and irqs disabled
|
|
*/
|
|
void hrtick_start(struct rq *rq, u64 delay)
|
|
{
|
|
struct hrtimer *timer = &rq->hrtick_timer;
|
|
s64 delta;
|
|
|
|
/*
|
|
* Don't schedule slices shorter than 10000ns, that just
|
|
* doesn't make sense and can cause timer DoS.
|
|
*/
|
|
delta = max_t(s64, delay, 10000LL);
|
|
rq->hrtick_time = ktime_add_ns(timer->base->get_time(), delta);
|
|
|
|
if (rq == this_rq())
|
|
__hrtick_restart(rq);
|
|
else
|
|
smp_call_function_single_async(cpu_of(rq), &rq->hrtick_csd);
|
|
}
|
|
|
|
#else
|
|
/*
|
|
* Called to set the hrtick timer state.
|
|
*
|
|
* called with rq->lock held and irqs disabled
|
|
*/
|
|
void hrtick_start(struct rq *rq, u64 delay)
|
|
{
|
|
/*
|
|
* Don't schedule slices shorter than 10000ns, that just
|
|
* doesn't make sense. Rely on vruntime for fairness.
|
|
*/
|
|
delay = max_t(u64, delay, 10000LL);
|
|
hrtimer_start(&rq->hrtick_timer, ns_to_ktime(delay),
|
|
HRTIMER_MODE_REL_PINNED_HARD);
|
|
}
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
static void hrtick_rq_init(struct rq *rq)
|
|
{
|
|
#ifdef CONFIG_SMP
|
|
rq_csd_init(rq, &rq->hrtick_csd, __hrtick_start);
|
|
#endif
|
|
hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
|
|
rq->hrtick_timer.function = hrtick;
|
|
}
|
|
#else /* CONFIG_SCHED_HRTICK */
|
|
static inline void hrtick_clear(struct rq *rq)
|
|
{
|
|
}
|
|
|
|
static inline void hrtick_rq_init(struct rq *rq)
|
|
{
|
|
}
|
|
#endif /* CONFIG_SCHED_HRTICK */
|
|
|
|
/*
|
|
* cmpxchg based fetch_or, macro so it works for different integer types
|
|
*/
|
|
#define fetch_or(ptr, mask) \
|
|
({ \
|
|
typeof(ptr) _ptr = (ptr); \
|
|
typeof(mask) _mask = (mask); \
|
|
typeof(*_ptr) _old, _val = *_ptr; \
|
|
\
|
|
for (;;) { \
|
|
_old = cmpxchg(_ptr, _val, _val | _mask); \
|
|
if (_old == _val) \
|
|
break; \
|
|
_val = _old; \
|
|
} \
|
|
_old; \
|
|
})
|
|
|
|
#if defined(CONFIG_SMP) && defined(TIF_POLLING_NRFLAG)
|
|
/*
|
|
* Atomically set TIF_NEED_RESCHED and test for TIF_POLLING_NRFLAG,
|
|
* this avoids any races wrt polling state changes and thereby avoids
|
|
* spurious IPIs.
|
|
*/
|
|
static bool set_nr_and_not_polling(struct task_struct *p)
|
|
{
|
|
struct thread_info *ti = task_thread_info(p);
|
|
return !(fetch_or(&ti->flags, _TIF_NEED_RESCHED) & _TIF_POLLING_NRFLAG);
|
|
}
|
|
|
|
/*
|
|
* Atomically set TIF_NEED_RESCHED if TIF_POLLING_NRFLAG is set.
|
|
*
|
|
* If this returns true, then the idle task promises to call
|
|
* sched_ttwu_pending() and reschedule soon.
|
|
*/
|
|
static bool set_nr_if_polling(struct task_struct *p)
|
|
{
|
|
struct thread_info *ti = task_thread_info(p);
|
|
typeof(ti->flags) old, val = READ_ONCE(ti->flags);
|
|
|
|
for (;;) {
|
|
if (!(val & _TIF_POLLING_NRFLAG))
|
|
return false;
|
|
if (val & _TIF_NEED_RESCHED)
|
|
return true;
|
|
old = cmpxchg(&ti->flags, val, val | _TIF_NEED_RESCHED);
|
|
if (old == val)
|
|
break;
|
|
val = old;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#else
|
|
static bool set_nr_and_not_polling(struct task_struct *p)
|
|
{
|
|
set_tsk_need_resched(p);
|
|
return true;
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
static bool set_nr_if_polling(struct task_struct *p)
|
|
{
|
|
return false;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
static bool __wake_q_add(struct wake_q_head *head, struct task_struct *task)
|
|
{
|
|
struct wake_q_node *node = &task->wake_q;
|
|
|
|
/*
|
|
* Atomically grab the task, if ->wake_q is !nil already it means
|
|
* its already queued (either by us or someone else) and will get the
|
|
* wakeup due to that.
|
|
*
|
|
* In order to ensure that a pending wakeup will observe our pending
|
|
* state, even in the failed case, an explicit smp_mb() must be used.
|
|
*/
|
|
smp_mb__before_atomic();
|
|
if (unlikely(cmpxchg_relaxed(&node->next, NULL, WAKE_Q_TAIL)))
|
|
return false;
|
|
|
|
/*
|
|
* The head is context local, there can be no concurrency.
|
|
*/
|
|
*head->lastp = node;
|
|
head->lastp = &node->next;
|
|
head->count++;
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* wake_q_add() - queue a wakeup for 'later' waking.
|
|
* @head: the wake_q_head to add @task to
|
|
* @task: the task to queue for 'later' wakeup
|
|
*
|
|
* Queue a task for later wakeup, most likely by the wake_up_q() call in the
|
|
* same context, _HOWEVER_ this is not guaranteed, the wakeup can come
|
|
* instantly.
|
|
*
|
|
* This function must be used as-if it were wake_up_process(); IOW the task
|
|
* must be ready to be woken at this location.
|
|
*/
|
|
void wake_q_add(struct wake_q_head *head, struct task_struct *task)
|
|
{
|
|
if (__wake_q_add(head, task))
|
|
get_task_struct(task);
|
|
}
|
|
|
|
/**
|
|
* wake_q_add_safe() - safely queue a wakeup for 'later' waking.
|
|
* @head: the wake_q_head to add @task to
|
|
* @task: the task to queue for 'later' wakeup
|
|
*
|
|
* Queue a task for later wakeup, most likely by the wake_up_q() call in the
|
|
* same context, _HOWEVER_ this is not guaranteed, the wakeup can come
|
|
* instantly.
|
|
*
|
|
* This function must be used as-if it were wake_up_process(); IOW the task
|
|
* must be ready to be woken at this location.
|
|
*
|
|
* This function is essentially a task-safe equivalent to wake_q_add(). Callers
|
|
* that already hold reference to @task can call the 'safe' version and trust
|
|
* wake_q to do the right thing depending whether or not the @task is already
|
|
* queued for wakeup.
|
|
*/
|
|
void wake_q_add_safe(struct wake_q_head *head, struct task_struct *task)
|
|
{
|
|
if (!__wake_q_add(head, task))
|
|
put_task_struct(task);
|
|
}
|
|
|
|
void wake_up_q(struct wake_q_head *head)
|
|
{
|
|
struct wake_q_node *node = head->first;
|
|
|
|
while (node != WAKE_Q_TAIL) {
|
|
struct task_struct *task;
|
|
|
|
task = container_of(node, struct task_struct, wake_q);
|
|
BUG_ON(!task);
|
|
/* Task can safely be re-inserted now: */
|
|
node = node->next;
|
|
task->wake_q.next = NULL;
|
|
task->wake_q_count = head->count;
|
|
|
|
/*
|
|
* wake_up_process() executes a full barrier, which pairs with
|
|
* the queueing in wake_q_add() so as not to miss wakeups.
|
|
*/
|
|
wake_up_process(task);
|
|
task->wake_q_count = 0;
|
|
put_task_struct(task);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* resched_curr - mark rq's current task 'to be rescheduled now'.
|
|
*
|
|
* On UP this means the setting of the need_resched flag, on SMP it
|
|
* might also involve a cross-CPU call to trigger the scheduler on
|
|
* the target CPU.
|
|
*/
|
|
void resched_curr(struct rq *rq)
|
|
{
|
|
struct task_struct *curr = rq->curr;
|
|
int cpu;
|
|
|
|
lockdep_assert_held(&rq->lock);
|
|
|
|
if (test_tsk_need_resched(curr))
|
|
return;
|
|
|
|
cpu = cpu_of(rq);
|
|
|
|
if (cpu == smp_processor_id()) {
|
|
set_tsk_need_resched(curr);
|
|
set_preempt_need_resched();
|
|
return;
|
|
}
|
|
|
|
if (set_nr_and_not_polling(curr))
|
|
smp_send_reschedule(cpu);
|
|
else
|
|
trace_sched_wake_idle_without_ipi(cpu);
|
|
}
|
|
EXPORT_SYMBOL_GPL(resched_curr);
|
|
|
|
void resched_cpu(int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
unsigned long flags;
|
|
|
|
raw_spin_lock_irqsave(&rq->lock, flags);
|
|
if (cpu_online(cpu) || cpu == smp_processor_id())
|
|
resched_curr(rq);
|
|
raw_spin_unlock_irqrestore(&rq->lock, flags);
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
#ifdef CONFIG_NO_HZ_COMMON
|
|
/*
|
|
* In the semi idle case, use the nearest busy CPU for migrating timers
|
|
* from an idle CPU. This is good for power-savings.
|
|
*
|
|
* We don't do similar optimization for completely idle system, as
|
|
* selecting an idle CPU will add more delays to the timers than intended
|
|
* (as that CPU's timer base may not be uptodate wrt jiffies etc).
|
|
*/
|
|
int get_nohz_timer_target(void)
|
|
{
|
|
int i, cpu = smp_processor_id(), default_cpu = -1;
|
|
struct sched_domain *sd;
|
|
|
|
if (housekeeping_cpu(cpu, HK_FLAG_TIMER) && cpu_active(cpu)) {
|
|
if (!idle_cpu(cpu))
|
|
return cpu;
|
|
default_cpu = cpu;
|
|
}
|
|
|
|
rcu_read_lock();
|
|
for_each_domain(cpu, sd) {
|
|
for_each_cpu_and(i, sched_domain_span(sd),
|
|
housekeeping_cpumask(HK_FLAG_TIMER)) {
|
|
if (cpu == i)
|
|
continue;
|
|
|
|
if (!idle_cpu(i)) {
|
|
cpu = i;
|
|
goto unlock;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (default_cpu == -1) {
|
|
for_each_cpu_and(i, cpu_active_mask,
|
|
housekeeping_cpumask(HK_FLAG_TIMER)) {
|
|
if (cpu == i)
|
|
continue;
|
|
|
|
if (!idle_cpu(i)) {
|
|
cpu = i;
|
|
goto unlock;
|
|
}
|
|
}
|
|
|
|
/* no active, not-idle, housekpeeing CPU found. */
|
|
default_cpu = cpumask_any(cpu_active_mask);
|
|
|
|
if (unlikely(default_cpu >= nr_cpu_ids))
|
|
goto unlock;
|
|
}
|
|
|
|
cpu = default_cpu;
|
|
unlock:
|
|
rcu_read_unlock();
|
|
return cpu;
|
|
}
|
|
|
|
/*
|
|
* When add_timer_on() enqueues a timer into the timer wheel of an
|
|
* idle CPU then this timer might expire before the next timer event
|
|
* which is scheduled to wake up that CPU. In case of a completely
|
|
* idle system the next event might even be infinite time into the
|
|
* future. wake_up_idle_cpu() ensures that the CPU is woken up and
|
|
* leaves the inner idle loop so the newly added timer is taken into
|
|
* account when the CPU goes back to idle and evaluates the timer
|
|
* wheel for the next timer event.
|
|
*/
|
|
static void wake_up_idle_cpu(int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
|
|
if (cpu == smp_processor_id())
|
|
return;
|
|
|
|
if (set_nr_and_not_polling(rq->idle))
|
|
smp_send_reschedule(cpu);
|
|
else
|
|
trace_sched_wake_idle_without_ipi(cpu);
|
|
}
|
|
|
|
static bool wake_up_full_nohz_cpu(int cpu)
|
|
{
|
|
/*
|
|
* We just need the target to call irq_exit() and re-evaluate
|
|
* the next tick. The nohz full kick at least implies that.
|
|
* If needed we can still optimize that later with an
|
|
* empty IRQ.
|
|
*/
|
|
if (cpu_is_offline(cpu))
|
|
return true; /* Don't try to wake offline CPUs. */
|
|
if (tick_nohz_full_cpu(cpu)) {
|
|
if (cpu != smp_processor_id() ||
|
|
tick_nohz_tick_stopped())
|
|
tick_nohz_full_kick_cpu(cpu);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* Wake up the specified CPU. If the CPU is going offline, it is the
|
|
* caller's responsibility to deal with the lost wakeup, for example,
|
|
* by hooking into the CPU_DEAD notifier like timers and hrtimers do.
|
|
*/
|
|
void wake_up_nohz_cpu(int cpu)
|
|
{
|
|
if (!wake_up_full_nohz_cpu(cpu))
|
|
wake_up_idle_cpu(cpu);
|
|
}
|
|
|
|
static void nohz_csd_func(void *info)
|
|
{
|
|
struct rq *rq = info;
|
|
int cpu = cpu_of(rq);
|
|
unsigned int flags;
|
|
|
|
/*
|
|
* Release the rq::nohz_csd.
|
|
*/
|
|
flags = atomic_fetch_andnot(NOHZ_KICK_MASK, nohz_flags(cpu));
|
|
WARN_ON(!(flags & NOHZ_KICK_MASK));
|
|
|
|
rq->idle_balance = idle_cpu(cpu);
|
|
if (rq->idle_balance && !need_resched()) {
|
|
rq->nohz_idle_balance = flags;
|
|
raise_softirq_irqoff(SCHED_SOFTIRQ);
|
|
}
|
|
}
|
|
|
|
#endif /* CONFIG_NO_HZ_COMMON */
|
|
|
|
#ifdef CONFIG_NO_HZ_FULL
|
|
bool sched_can_stop_tick(struct rq *rq)
|
|
{
|
|
int fifo_nr_running;
|
|
|
|
/* Deadline tasks, even if single, need the tick */
|
|
if (rq->dl.dl_nr_running)
|
|
return false;
|
|
|
|
/*
|
|
* If there are more than one RR tasks, we need the tick to effect the
|
|
* actual RR behaviour.
|
|
*/
|
|
if (rq->rt.rr_nr_running) {
|
|
if (rq->rt.rr_nr_running == 1)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* If there's no RR tasks, but FIFO tasks, we can skip the tick, no
|
|
* forced preemption between FIFO tasks.
|
|
*/
|
|
fifo_nr_running = rq->rt.rt_nr_running - rq->rt.rr_nr_running;
|
|
if (fifo_nr_running)
|
|
return true;
|
|
|
|
/*
|
|
* If there are no DL,RR/FIFO tasks, there must only be CFS tasks left;
|
|
* if there's more than one we need the tick for involuntary
|
|
* preemption.
|
|
*/
|
|
if (rq->nr_running > 1)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
#endif /* CONFIG_NO_HZ_FULL */
|
|
#endif /* CONFIG_SMP */
|
|
|
|
#if defined(CONFIG_RT_GROUP_SCHED) || (defined(CONFIG_FAIR_GROUP_SCHED) && \
|
|
(defined(CONFIG_SMP) || defined(CONFIG_CFS_BANDWIDTH)))
|
|
/*
|
|
* Iterate task_group tree rooted at *from, calling @down when first entering a
|
|
* node and @up when leaving it for the final time.
|
|
*
|
|
* Caller must hold rcu_lock or sufficient equivalent.
|
|
*/
|
|
int walk_tg_tree_from(struct task_group *from,
|
|
tg_visitor down, tg_visitor up, void *data)
|
|
{
|
|
struct task_group *parent, *child;
|
|
int ret;
|
|
|
|
parent = from;
|
|
|
|
down:
|
|
ret = (*down)(parent, data);
|
|
if (ret)
|
|
goto out;
|
|
list_for_each_entry_rcu(child, &parent->children, siblings) {
|
|
parent = child;
|
|
goto down;
|
|
|
|
up:
|
|
continue;
|
|
}
|
|
ret = (*up)(parent, data);
|
|
if (ret || parent == from)
|
|
goto out;
|
|
|
|
child = parent;
|
|
parent = parent->parent;
|
|
if (parent)
|
|
goto up;
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
int tg_nop(struct task_group *tg, void *data)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
static void set_load_weight(struct task_struct *p, bool update_load)
|
|
{
|
|
int prio = p->static_prio - MAX_RT_PRIO;
|
|
struct load_weight *load = &p->se.load;
|
|
|
|
/*
|
|
* SCHED_IDLE tasks get minimal weight:
|
|
*/
|
|
if (task_has_idle_policy(p)) {
|
|
load->weight = scale_load(WEIGHT_IDLEPRIO);
|
|
load->inv_weight = WMULT_IDLEPRIO;
|
|
return;
|
|
}
|
|
|
|
/*
|
|
* SCHED_OTHER tasks have to update their load when changing their
|
|
* weight
|
|
*/
|
|
if (update_load && p->sched_class == &fair_sched_class) {
|
|
reweight_task(p, prio);
|
|
} else {
|
|
load->weight = scale_load(sched_prio_to_weight[prio]);
|
|
load->inv_weight = sched_prio_to_wmult[prio];
|
|
}
|
|
}
|
|
|
|
#ifdef CONFIG_UCLAMP_TASK
|
|
/*
|
|
* Serializes updates of utilization clamp values
|
|
*
|
|
* The (slow-path) user-space triggers utilization clamp value updates which
|
|
* can require updates on (fast-path) scheduler's data structures used to
|
|
* support enqueue/dequeue operations.
|
|
* While the per-CPU rq lock protects fast-path update operations, user-space
|
|
* requests are serialized using a mutex to reduce the risk of conflicting
|
|
* updates or API abuses.
|
|
*/
|
|
static DEFINE_MUTEX(uclamp_mutex);
|
|
|
|
/* Max allowed minimum utilization */
|
|
unsigned int sysctl_sched_uclamp_util_min = SCHED_CAPACITY_SCALE;
|
|
|
|
/* Max allowed maximum utilization */
|
|
unsigned int sysctl_sched_uclamp_util_max = SCHED_CAPACITY_SCALE;
|
|
|
|
/*
|
|
* By default RT tasks run at the maximum performance point/capacity of the
|
|
* system. Uclamp enforces this by always setting UCLAMP_MIN of RT tasks to
|
|
* SCHED_CAPACITY_SCALE.
|
|
*
|
|
* This knob allows admins to change the default behavior when uclamp is being
|
|
* used. In battery powered devices, particularly, running at the maximum
|
|
* capacity and frequency will increase energy consumption and shorten the
|
|
* battery life.
|
|
*
|
|
* This knob only affects RT tasks that their uclamp_se->user_defined == false.
|
|
*
|
|
* This knob will not override the system default sched_util_clamp_min defined
|
|
* above.
|
|
*/
|
|
unsigned int sysctl_sched_uclamp_util_min_rt_default = SCHED_CAPACITY_SCALE;
|
|
|
|
/* All clamps are required to be less or equal than these values */
|
|
static struct uclamp_se uclamp_default[UCLAMP_CNT];
|
|
|
|
/*
|
|
* This static key is used to reduce the uclamp overhead in the fast path. It
|
|
* primarily disables the call to uclamp_rq_{inc, dec}() in
|
|
* enqueue/dequeue_task().
|
|
*
|
|
* This allows users to continue to enable uclamp in their kernel config with
|
|
* minimum uclamp overhead in the fast path.
|
|
*
|
|
* As soon as userspace modifies any of the uclamp knobs, the static key is
|
|
* enabled, since we have an actual users that make use of uclamp
|
|
* functionality.
|
|
*
|
|
* The knobs that would enable this static key are:
|
|
*
|
|
* * A task modifying its uclamp value with sched_setattr().
|
|
* * An admin modifying the sysctl_sched_uclamp_{min, max} via procfs.
|
|
* * An admin modifying the cgroup cpu.uclamp.{min, max}
|
|
*/
|
|
DEFINE_STATIC_KEY_FALSE(sched_uclamp_used);
|
|
EXPORT_SYMBOL_GPL(sched_uclamp_used);
|
|
|
|
/* Integer rounded range for each bucket */
|
|
#define UCLAMP_BUCKET_DELTA DIV_ROUND_CLOSEST(SCHED_CAPACITY_SCALE, UCLAMP_BUCKETS)
|
|
|
|
#define for_each_clamp_id(clamp_id) \
|
|
for ((clamp_id) = 0; (clamp_id) < UCLAMP_CNT; (clamp_id)++)
|
|
|
|
static inline unsigned int uclamp_bucket_id(unsigned int clamp_value)
|
|
{
|
|
return min_t(unsigned int, clamp_value / UCLAMP_BUCKET_DELTA, UCLAMP_BUCKETS - 1);
|
|
}
|
|
|
|
static inline unsigned int uclamp_none(enum uclamp_id clamp_id)
|
|
{
|
|
if (clamp_id == UCLAMP_MIN)
|
|
return 0;
|
|
return SCHED_CAPACITY_SCALE;
|
|
}
|
|
|
|
static inline void uclamp_se_set(struct uclamp_se *uc_se,
|
|
unsigned int value, bool user_defined)
|
|
{
|
|
uc_se->value = value;
|
|
uc_se->bucket_id = uclamp_bucket_id(value);
|
|
uc_se->user_defined = user_defined;
|
|
}
|
|
|
|
static inline unsigned int
|
|
uclamp_idle_value(struct rq *rq, enum uclamp_id clamp_id,
|
|
unsigned int clamp_value)
|
|
{
|
|
/*
|
|
* Avoid blocked utilization pushing up the frequency when we go
|
|
* idle (which drops the max-clamp) by retaining the last known
|
|
* max-clamp.
|
|
*/
|
|
if (clamp_id == UCLAMP_MAX) {
|
|
rq->uclamp_flags |= UCLAMP_FLAG_IDLE;
|
|
return clamp_value;
|
|
}
|
|
|
|
return uclamp_none(UCLAMP_MIN);
|
|
}
|
|
|
|
static inline void uclamp_idle_reset(struct rq *rq, enum uclamp_id clamp_id,
|
|
unsigned int clamp_value)
|
|
{
|
|
/* Reset max-clamp retention only on idle exit */
|
|
if (!(rq->uclamp_flags & UCLAMP_FLAG_IDLE))
|
|
return;
|
|
|
|
WRITE_ONCE(rq->uclamp[clamp_id].value, clamp_value);
|
|
}
|
|
|
|
static inline
|
|
unsigned int uclamp_rq_max_value(struct rq *rq, enum uclamp_id clamp_id,
|
|
unsigned int clamp_value)
|
|
{
|
|
struct uclamp_bucket *bucket = rq->uclamp[clamp_id].bucket;
|
|
int bucket_id = UCLAMP_BUCKETS - 1;
|
|
|
|
/*
|
|
* Since both min and max clamps are max aggregated, find the
|
|
* top most bucket with tasks in.
|
|
*/
|
|
for ( ; bucket_id >= 0; bucket_id--) {
|
|
if (!bucket[bucket_id].tasks)
|
|
continue;
|
|
return bucket[bucket_id].value;
|
|
}
|
|
|
|
/* No tasks -- default clamp values */
|
|
return uclamp_idle_value(rq, clamp_id, clamp_value);
|
|
}
|
|
|
|
static void __uclamp_update_util_min_rt_default(struct task_struct *p)
|
|
{
|
|
unsigned int default_util_min;
|
|
struct uclamp_se *uc_se;
|
|
|
|
lockdep_assert_held(&p->pi_lock);
|
|
|
|
uc_se = &p->uclamp_req[UCLAMP_MIN];
|
|
|
|
/* Only sync if user didn't override the default */
|
|
if (uc_se->user_defined)
|
|
return;
|
|
|
|
default_util_min = sysctl_sched_uclamp_util_min_rt_default;
|
|
uclamp_se_set(uc_se, default_util_min, false);
|
|
}
|
|
|
|
static void uclamp_update_util_min_rt_default(struct task_struct *p)
|
|
{
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
if (!rt_task(p))
|
|
return;
|
|
|
|
/* Protect updates to p->uclamp_* */
|
|
rq = task_rq_lock(p, &rf);
|
|
__uclamp_update_util_min_rt_default(p);
|
|
task_rq_unlock(rq, p, &rf);
|
|
}
|
|
|
|
static void uclamp_sync_util_min_rt_default(void)
|
|
{
|
|
struct task_struct *g, *p;
|
|
|
|
/*
|
|
* copy_process() sysctl_uclamp
|
|
* uclamp_min_rt = X;
|
|
* write_lock(&tasklist_lock) read_lock(&tasklist_lock)
|
|
* // link thread smp_mb__after_spinlock()
|
|
* write_unlock(&tasklist_lock) read_unlock(&tasklist_lock);
|
|
* sched_post_fork() for_each_process_thread()
|
|
* __uclamp_sync_rt() __uclamp_sync_rt()
|
|
*
|
|
* Ensures that either sched_post_fork() will observe the new
|
|
* uclamp_min_rt or for_each_process_thread() will observe the new
|
|
* task.
|
|
*/
|
|
read_lock(&tasklist_lock);
|
|
smp_mb__after_spinlock();
|
|
read_unlock(&tasklist_lock);
|
|
|
|
rcu_read_lock();
|
|
for_each_process_thread(g, p)
|
|
uclamp_update_util_min_rt_default(p);
|
|
rcu_read_unlock();
|
|
}
|
|
|
|
static inline struct uclamp_se
|
|
uclamp_tg_restrict(struct task_struct *p, enum uclamp_id clamp_id)
|
|
{
|
|
/* Copy by value as we could modify it */
|
|
struct uclamp_se uc_req = p->uclamp_req[clamp_id];
|
|
#ifdef CONFIG_UCLAMP_TASK_GROUP
|
|
unsigned int tg_min, tg_max, value;
|
|
|
|
/*
|
|
* Tasks in autogroups or root task group will be
|
|
* restricted by system defaults.
|
|
*/
|
|
if (task_group_is_autogroup(task_group(p)))
|
|
return uc_req;
|
|
if (task_group(p) == &root_task_group)
|
|
return uc_req;
|
|
|
|
tg_min = task_group(p)->uclamp[UCLAMP_MIN].value;
|
|
tg_max = task_group(p)->uclamp[UCLAMP_MAX].value;
|
|
value = uc_req.value;
|
|
value = clamp(value, tg_min, tg_max);
|
|
uclamp_se_set(&uc_req, value, false);
|
|
#endif
|
|
|
|
return uc_req;
|
|
}
|
|
|
|
/*
|
|
* The effective clamp bucket index of a task depends on, by increasing
|
|
* priority:
|
|
* - the task specific clamp value, when explicitly requested from userspace
|
|
* - the task group effective clamp value, for tasks not either in the root
|
|
* group or in an autogroup
|
|
* - the system default clamp value, defined by the sysadmin
|
|
*/
|
|
static inline struct uclamp_se
|
|
uclamp_eff_get(struct task_struct *p, enum uclamp_id clamp_id)
|
|
{
|
|
struct uclamp_se uc_req = uclamp_tg_restrict(p, clamp_id);
|
|
struct uclamp_se uc_max = uclamp_default[clamp_id];
|
|
struct uclamp_se uc_eff;
|
|
int ret = 0;
|
|
|
|
trace_android_rvh_uclamp_eff_get(p, clamp_id, &uc_max, &uc_eff, &ret);
|
|
if (ret)
|
|
return uc_eff;
|
|
|
|
/* System default restrictions always apply */
|
|
if (unlikely(uc_req.value > uc_max.value))
|
|
return uc_max;
|
|
|
|
return uc_req;
|
|
}
|
|
|
|
unsigned long uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id)
|
|
{
|
|
struct uclamp_se uc_eff;
|
|
|
|
/* Task currently refcounted: use back-annotated (effective) value */
|
|
if (p->uclamp[clamp_id].active)
|
|
return (unsigned long)p->uclamp[clamp_id].value;
|
|
|
|
uc_eff = uclamp_eff_get(p, clamp_id);
|
|
|
|
return (unsigned long)uc_eff.value;
|
|
}
|
|
EXPORT_SYMBOL_GPL(uclamp_eff_value);
|
|
|
|
/*
|
|
* When a task is enqueued on a rq, the clamp bucket currently defined by the
|
|
* task's uclamp::bucket_id is refcounted on that rq. This also immediately
|
|
* updates the rq's clamp value if required.
|
|
*
|
|
* Tasks can have a task-specific value requested from user-space, track
|
|
* within each bucket the maximum value for tasks refcounted in it.
|
|
* This "local max aggregation" allows to track the exact "requested" value
|
|
* for each bucket when all its RUNNABLE tasks require the same clamp.
|
|
*/
|
|
static inline void uclamp_rq_inc_id(struct rq *rq, struct task_struct *p,
|
|
enum uclamp_id clamp_id)
|
|
{
|
|
struct uclamp_rq *uc_rq = &rq->uclamp[clamp_id];
|
|
struct uclamp_se *uc_se = &p->uclamp[clamp_id];
|
|
struct uclamp_bucket *bucket;
|
|
|
|
lockdep_assert_held(&rq->lock);
|
|
|
|
/* Update task effective clamp */
|
|
p->uclamp[clamp_id] = uclamp_eff_get(p, clamp_id);
|
|
|
|
bucket = &uc_rq->bucket[uc_se->bucket_id];
|
|
bucket->tasks++;
|
|
uc_se->active = true;
|
|
|
|
uclamp_idle_reset(rq, clamp_id, uc_se->value);
|
|
|
|
/*
|
|
* Local max aggregation: rq buckets always track the max
|
|
* "requested" clamp value of its RUNNABLE tasks.
|
|
*/
|
|
if (bucket->tasks == 1 || uc_se->value > bucket->value)
|
|
bucket->value = uc_se->value;
|
|
|
|
if (uc_se->value > READ_ONCE(uc_rq->value))
|
|
WRITE_ONCE(uc_rq->value, uc_se->value);
|
|
}
|
|
|
|
/*
|
|
* When a task is dequeued from a rq, the clamp bucket refcounted by the task
|
|
* is released. If this is the last task reference counting the rq's max
|
|
* active clamp value, then the rq's clamp value is updated.
|
|
*
|
|
* Both refcounted tasks and rq's cached clamp values are expected to be
|
|
* always valid. If it's detected they are not, as defensive programming,
|
|
* enforce the expected state and warn.
|
|
*/
|
|
static inline void uclamp_rq_dec_id(struct rq *rq, struct task_struct *p,
|
|
enum uclamp_id clamp_id)
|
|
{
|
|
struct uclamp_rq *uc_rq = &rq->uclamp[clamp_id];
|
|
struct uclamp_se *uc_se = &p->uclamp[clamp_id];
|
|
struct uclamp_bucket *bucket;
|
|
unsigned int bkt_clamp;
|
|
unsigned int rq_clamp;
|
|
|
|
lockdep_assert_held(&rq->lock);
|
|
|
|
/*
|
|
* If sched_uclamp_used was enabled after task @p was enqueued,
|
|
* we could end up with unbalanced call to uclamp_rq_dec_id().
|
|
*
|
|
* In this case the uc_se->active flag should be false since no uclamp
|
|
* accounting was performed at enqueue time and we can just return
|
|
* here.
|
|
*
|
|
* Need to be careful of the following enqeueue/dequeue ordering
|
|
* problem too
|
|
*
|
|
* enqueue(taskA)
|
|
* // sched_uclamp_used gets enabled
|
|
* enqueue(taskB)
|
|
* dequeue(taskA)
|
|
* // Must not decrement bukcet->tasks here
|
|
* dequeue(taskB)
|
|
*
|
|
* where we could end up with stale data in uc_se and
|
|
* bucket[uc_se->bucket_id].
|
|
*
|
|
* The following check here eliminates the possibility of such race.
|
|
*/
|
|
if (unlikely(!uc_se->active))
|
|
return;
|
|
|
|
bucket = &uc_rq->bucket[uc_se->bucket_id];
|
|
|
|
SCHED_WARN_ON(!bucket->tasks);
|
|
if (likely(bucket->tasks))
|
|
bucket->tasks--;
|
|
|
|
uc_se->active = false;
|
|
|
|
/*
|
|
* Keep "local max aggregation" simple and accept to (possibly)
|
|
* overboost some RUNNABLE tasks in the same bucket.
|
|
* The rq clamp bucket value is reset to its base value whenever
|
|
* there are no more RUNNABLE tasks refcounting it.
|
|
*/
|
|
if (likely(bucket->tasks))
|
|
return;
|
|
|
|
rq_clamp = READ_ONCE(uc_rq->value);
|
|
/*
|
|
* Defensive programming: this should never happen. If it happens,
|
|
* e.g. due to future modification, warn and fixup the expected value.
|
|
*/
|
|
SCHED_WARN_ON(bucket->value > rq_clamp);
|
|
if (bucket->value >= rq_clamp) {
|
|
bkt_clamp = uclamp_rq_max_value(rq, clamp_id, uc_se->value);
|
|
WRITE_ONCE(uc_rq->value, bkt_clamp);
|
|
}
|
|
}
|
|
|
|
static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p)
|
|
{
|
|
enum uclamp_id clamp_id;
|
|
|
|
/*
|
|
* Avoid any overhead until uclamp is actually used by the userspace.
|
|
*
|
|
* The condition is constructed such that a NOP is generated when
|
|
* sched_uclamp_used is disabled.
|
|
*/
|
|
if (!static_branch_unlikely(&sched_uclamp_used))
|
|
return;
|
|
|
|
if (unlikely(!p->sched_class->uclamp_enabled))
|
|
return;
|
|
|
|
for_each_clamp_id(clamp_id)
|
|
uclamp_rq_inc_id(rq, p, clamp_id);
|
|
|
|
/* Reset clamp idle holding when there is one RUNNABLE task */
|
|
if (rq->uclamp_flags & UCLAMP_FLAG_IDLE)
|
|
rq->uclamp_flags &= ~UCLAMP_FLAG_IDLE;
|
|
}
|
|
|
|
static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p)
|
|
{
|
|
enum uclamp_id clamp_id;
|
|
|
|
/*
|
|
* Avoid any overhead until uclamp is actually used by the userspace.
|
|
*
|
|
* The condition is constructed such that a NOP is generated when
|
|
* sched_uclamp_used is disabled.
|
|
*/
|
|
if (!static_branch_unlikely(&sched_uclamp_used))
|
|
return;
|
|
|
|
if (unlikely(!p->sched_class->uclamp_enabled))
|
|
return;
|
|
|
|
for_each_clamp_id(clamp_id)
|
|
uclamp_rq_dec_id(rq, p, clamp_id);
|
|
}
|
|
|
|
static inline void uclamp_rq_reinc_id(struct rq *rq, struct task_struct *p,
|
|
enum uclamp_id clamp_id)
|
|
{
|
|
if (!p->uclamp[clamp_id].active)
|
|
return;
|
|
|
|
uclamp_rq_dec_id(rq, p, clamp_id);
|
|
uclamp_rq_inc_id(rq, p, clamp_id);
|
|
|
|
/*
|
|
* Make sure to clear the idle flag if we've transiently reached 0
|
|
* active tasks on rq.
|
|
*/
|
|
if (clamp_id == UCLAMP_MAX && (rq->uclamp_flags & UCLAMP_FLAG_IDLE))
|
|
rq->uclamp_flags &= ~UCLAMP_FLAG_IDLE;
|
|
}
|
|
|
|
static inline void
|
|
uclamp_update_active(struct task_struct *p)
|
|
{
|
|
enum uclamp_id clamp_id;
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
/*
|
|
* Lock the task and the rq where the task is (or was) queued.
|
|
*
|
|
* We might lock the (previous) rq of a !RUNNABLE task, but that's the
|
|
* price to pay to safely serialize util_{min,max} updates with
|
|
* enqueues, dequeues and migration operations.
|
|
* This is the same locking schema used by __set_cpus_allowed_ptr().
|
|
*/
|
|
rq = task_rq_lock(p, &rf);
|
|
|
|
/*
|
|
* Setting the clamp bucket is serialized by task_rq_lock().
|
|
* If the task is not yet RUNNABLE and its task_struct is not
|
|
* affecting a valid clamp bucket, the next time it's enqueued,
|
|
* it will already see the updated clamp bucket value.
|
|
*/
|
|
for_each_clamp_id(clamp_id)
|
|
uclamp_rq_reinc_id(rq, p, clamp_id);
|
|
|
|
task_rq_unlock(rq, p, &rf);
|
|
}
|
|
|
|
#ifdef CONFIG_UCLAMP_TASK_GROUP
|
|
static inline void
|
|
uclamp_update_active_tasks(struct cgroup_subsys_state *css)
|
|
{
|
|
struct css_task_iter it;
|
|
struct task_struct *p;
|
|
|
|
css_task_iter_start(css, 0, &it);
|
|
while ((p = css_task_iter_next(&it)))
|
|
uclamp_update_active(p);
|
|
css_task_iter_end(&it);
|
|
}
|
|
|
|
static void cpu_util_update_eff(struct cgroup_subsys_state *css);
|
|
static void uclamp_update_root_tg(void)
|
|
{
|
|
struct task_group *tg = &root_task_group;
|
|
|
|
uclamp_se_set(&tg->uclamp_req[UCLAMP_MIN],
|
|
sysctl_sched_uclamp_util_min, false);
|
|
uclamp_se_set(&tg->uclamp_req[UCLAMP_MAX],
|
|
sysctl_sched_uclamp_util_max, false);
|
|
|
|
rcu_read_lock();
|
|
cpu_util_update_eff(&root_task_group.css);
|
|
rcu_read_unlock();
|
|
}
|
|
#else
|
|
static void uclamp_update_root_tg(void) { }
|
|
#endif
|
|
|
|
int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
|
|
void *buffer, size_t *lenp, loff_t *ppos)
|
|
{
|
|
bool update_root_tg = false;
|
|
int old_min, old_max, old_min_rt;
|
|
int result;
|
|
|
|
mutex_lock(&uclamp_mutex);
|
|
old_min = sysctl_sched_uclamp_util_min;
|
|
old_max = sysctl_sched_uclamp_util_max;
|
|
old_min_rt = sysctl_sched_uclamp_util_min_rt_default;
|
|
|
|
result = proc_dointvec(table, write, buffer, lenp, ppos);
|
|
if (result)
|
|
goto undo;
|
|
if (!write)
|
|
goto done;
|
|
|
|
if (sysctl_sched_uclamp_util_min > sysctl_sched_uclamp_util_max ||
|
|
sysctl_sched_uclamp_util_max > SCHED_CAPACITY_SCALE ||
|
|
sysctl_sched_uclamp_util_min_rt_default > SCHED_CAPACITY_SCALE) {
|
|
|
|
result = -EINVAL;
|
|
goto undo;
|
|
}
|
|
|
|
if (old_min != sysctl_sched_uclamp_util_min) {
|
|
uclamp_se_set(&uclamp_default[UCLAMP_MIN],
|
|
sysctl_sched_uclamp_util_min, false);
|
|
update_root_tg = true;
|
|
}
|
|
if (old_max != sysctl_sched_uclamp_util_max) {
|
|
uclamp_se_set(&uclamp_default[UCLAMP_MAX],
|
|
sysctl_sched_uclamp_util_max, false);
|
|
update_root_tg = true;
|
|
}
|
|
|
|
if (update_root_tg) {
|
|
static_branch_enable(&sched_uclamp_used);
|
|
uclamp_update_root_tg();
|
|
}
|
|
|
|
if (old_min_rt != sysctl_sched_uclamp_util_min_rt_default) {
|
|
static_branch_enable(&sched_uclamp_used);
|
|
uclamp_sync_util_min_rt_default();
|
|
}
|
|
|
|
/*
|
|
* We update all RUNNABLE tasks only when task groups are in use.
|
|
* Otherwise, keep it simple and do just a lazy update at each next
|
|
* task enqueue time.
|
|
*/
|
|
|
|
goto done;
|
|
|
|
undo:
|
|
sysctl_sched_uclamp_util_min = old_min;
|
|
sysctl_sched_uclamp_util_max = old_max;
|
|
sysctl_sched_uclamp_util_min_rt_default = old_min_rt;
|
|
done:
|
|
mutex_unlock(&uclamp_mutex);
|
|
|
|
return result;
|
|
}
|
|
|
|
static int uclamp_validate(struct task_struct *p,
|
|
const struct sched_attr *attr)
|
|
{
|
|
int util_min = p->uclamp_req[UCLAMP_MIN].value;
|
|
int util_max = p->uclamp_req[UCLAMP_MAX].value;
|
|
|
|
if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) {
|
|
util_min = attr->sched_util_min;
|
|
|
|
if (util_min + 1 > SCHED_CAPACITY_SCALE + 1)
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) {
|
|
util_max = attr->sched_util_max;
|
|
|
|
if (util_max + 1 > SCHED_CAPACITY_SCALE + 1)
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (util_min != -1 && util_max != -1 && util_min > util_max)
|
|
return -EINVAL;
|
|
|
|
/*
|
|
* We have valid uclamp attributes; make sure uclamp is enabled.
|
|
*
|
|
* We need to do that here, because enabling static branches is a
|
|
* blocking operation which obviously cannot be done while holding
|
|
* scheduler locks.
|
|
*/
|
|
static_branch_enable(&sched_uclamp_used);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static bool uclamp_reset(const struct sched_attr *attr,
|
|
enum uclamp_id clamp_id,
|
|
struct uclamp_se *uc_se)
|
|
{
|
|
/* Reset on sched class change for a non user-defined clamp value. */
|
|
if (likely(!(attr->sched_flags & SCHED_FLAG_UTIL_CLAMP)) &&
|
|
!uc_se->user_defined)
|
|
return true;
|
|
|
|
/* Reset on sched_util_{min,max} == -1. */
|
|
if (clamp_id == UCLAMP_MIN &&
|
|
attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN &&
|
|
attr->sched_util_min == -1) {
|
|
return true;
|
|
}
|
|
|
|
if (clamp_id == UCLAMP_MAX &&
|
|
attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX &&
|
|
attr->sched_util_max == -1) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static void __setscheduler_uclamp(struct task_struct *p,
|
|
const struct sched_attr *attr)
|
|
{
|
|
enum uclamp_id clamp_id;
|
|
|
|
for_each_clamp_id(clamp_id) {
|
|
struct uclamp_se *uc_se = &p->uclamp_req[clamp_id];
|
|
unsigned int value;
|
|
|
|
if (!uclamp_reset(attr, clamp_id, uc_se))
|
|
continue;
|
|
|
|
/*
|
|
* RT by default have a 100% boost value that could be modified
|
|
* at runtime.
|
|
*/
|
|
if (unlikely(rt_task(p) && clamp_id == UCLAMP_MIN))
|
|
value = sysctl_sched_uclamp_util_min_rt_default;
|
|
else
|
|
value = uclamp_none(clamp_id);
|
|
|
|
uclamp_se_set(uc_se, value, false);
|
|
|
|
}
|
|
|
|
if (likely(!(attr->sched_flags & SCHED_FLAG_UTIL_CLAMP)))
|
|
return;
|
|
|
|
if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN &&
|
|
attr->sched_util_min != -1) {
|
|
uclamp_se_set(&p->uclamp_req[UCLAMP_MIN],
|
|
attr->sched_util_min, true);
|
|
trace_android_vh_setscheduler_uclamp(p, UCLAMP_MIN, attr->sched_util_min);
|
|
}
|
|
|
|
if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX &&
|
|
attr->sched_util_max != -1) {
|
|
uclamp_se_set(&p->uclamp_req[UCLAMP_MAX],
|
|
attr->sched_util_max, true);
|
|
trace_android_vh_setscheduler_uclamp(p, UCLAMP_MAX, attr->sched_util_max);
|
|
}
|
|
}
|
|
|
|
static void uclamp_fork(struct task_struct *p)
|
|
{
|
|
enum uclamp_id clamp_id;
|
|
|
|
/*
|
|
* We don't need to hold task_rq_lock() when updating p->uclamp_* here
|
|
* as the task is still at its early fork stages.
|
|
*/
|
|
for_each_clamp_id(clamp_id)
|
|
p->uclamp[clamp_id].active = false;
|
|
|
|
if (likely(!p->sched_reset_on_fork))
|
|
return;
|
|
|
|
for_each_clamp_id(clamp_id) {
|
|
uclamp_se_set(&p->uclamp_req[clamp_id],
|
|
uclamp_none(clamp_id), false);
|
|
}
|
|
}
|
|
|
|
static void uclamp_post_fork(struct task_struct *p)
|
|
{
|
|
uclamp_update_util_min_rt_default(p);
|
|
}
|
|
|
|
static void __init init_uclamp_rq(struct rq *rq)
|
|
{
|
|
enum uclamp_id clamp_id;
|
|
struct uclamp_rq *uc_rq = rq->uclamp;
|
|
|
|
for_each_clamp_id(clamp_id) {
|
|
uc_rq[clamp_id] = (struct uclamp_rq) {
|
|
.value = uclamp_none(clamp_id)
|
|
};
|
|
}
|
|
|
|
rq->uclamp_flags = UCLAMP_FLAG_IDLE;
|
|
}
|
|
|
|
static void __init init_uclamp(void)
|
|
{
|
|
struct uclamp_se uc_max = {};
|
|
enum uclamp_id clamp_id;
|
|
int cpu;
|
|
|
|
for_each_possible_cpu(cpu)
|
|
init_uclamp_rq(cpu_rq(cpu));
|
|
|
|
for_each_clamp_id(clamp_id) {
|
|
uclamp_se_set(&init_task.uclamp_req[clamp_id],
|
|
uclamp_none(clamp_id), false);
|
|
}
|
|
|
|
/* System defaults allow max clamp values for both indexes */
|
|
uclamp_se_set(&uc_max, uclamp_none(UCLAMP_MAX), false);
|
|
for_each_clamp_id(clamp_id) {
|
|
uclamp_default[clamp_id] = uc_max;
|
|
#ifdef CONFIG_UCLAMP_TASK_GROUP
|
|
root_task_group.uclamp_req[clamp_id] = uc_max;
|
|
root_task_group.uclamp[clamp_id] = uc_max;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#else /* CONFIG_UCLAMP_TASK */
|
|
static inline void uclamp_rq_inc(struct rq *rq, struct task_struct *p) { }
|
|
static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p) { }
|
|
static inline int uclamp_validate(struct task_struct *p,
|
|
const struct sched_attr *attr)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
static void __setscheduler_uclamp(struct task_struct *p,
|
|
const struct sched_attr *attr) { }
|
|
static inline void uclamp_fork(struct task_struct *p) { }
|
|
static inline void uclamp_post_fork(struct task_struct *p) { }
|
|
static inline void init_uclamp(void) { }
|
|
#endif /* CONFIG_UCLAMP_TASK */
|
|
|
|
static inline void enqueue_task(struct rq *rq, struct task_struct *p, int flags)
|
|
{
|
|
if (!(flags & ENQUEUE_NOCLOCK))
|
|
update_rq_clock(rq);
|
|
|
|
if (!(flags & ENQUEUE_RESTORE)) {
|
|
sched_info_queued(rq, p);
|
|
psi_enqueue(p, flags & ENQUEUE_WAKEUP);
|
|
}
|
|
|
|
uclamp_rq_inc(rq, p);
|
|
trace_android_rvh_enqueue_task(rq, p, flags);
|
|
p->sched_class->enqueue_task(rq, p, flags);
|
|
trace_android_rvh_after_enqueue_task(rq, p);
|
|
}
|
|
|
|
static inline void dequeue_task(struct rq *rq, struct task_struct *p, int flags)
|
|
{
|
|
if (!(flags & DEQUEUE_NOCLOCK))
|
|
update_rq_clock(rq);
|
|
|
|
if (!(flags & DEQUEUE_SAVE)) {
|
|
sched_info_dequeued(rq, p);
|
|
psi_dequeue(p, flags & DEQUEUE_SLEEP);
|
|
}
|
|
|
|
uclamp_rq_dec(rq, p);
|
|
trace_android_rvh_dequeue_task(rq, p, flags);
|
|
p->sched_class->dequeue_task(rq, p, flags);
|
|
trace_android_rvh_after_dequeue_task(rq, p);
|
|
}
|
|
|
|
void activate_task(struct rq *rq, struct task_struct *p, int flags)
|
|
{
|
|
enqueue_task(rq, p, flags);
|
|
|
|
p->on_rq = TASK_ON_RQ_QUEUED;
|
|
}
|
|
EXPORT_SYMBOL_GPL(activate_task);
|
|
|
|
void deactivate_task(struct rq *rq, struct task_struct *p, int flags)
|
|
{
|
|
p->on_rq = (flags & DEQUEUE_SLEEP) ? 0 : TASK_ON_RQ_MIGRATING;
|
|
|
|
dequeue_task(rq, p, flags);
|
|
}
|
|
EXPORT_SYMBOL_GPL(deactivate_task);
|
|
|
|
static inline int __normal_prio(int policy, int rt_prio, int nice)
|
|
{
|
|
int prio;
|
|
|
|
if (dl_policy(policy))
|
|
prio = MAX_DL_PRIO - 1;
|
|
else if (rt_policy(policy))
|
|
prio = MAX_RT_PRIO - 1 - rt_prio;
|
|
else
|
|
prio = NICE_TO_PRIO(nice);
|
|
|
|
return prio;
|
|
}
|
|
|
|
/*
|
|
* Calculate the expected normal priority: i.e. priority
|
|
* without taking RT-inheritance into account. Might be
|
|
* boosted by interactivity modifiers. Changes upon fork,
|
|
* setprio syscalls, and whenever the interactivity
|
|
* estimator recalculates.
|
|
*/
|
|
static inline int normal_prio(struct task_struct *p)
|
|
{
|
|
return __normal_prio(p->policy, p->rt_priority, PRIO_TO_NICE(p->static_prio));
|
|
}
|
|
|
|
/*
|
|
* Calculate the current priority, i.e. the priority
|
|
* taken into account by the scheduler. This value might
|
|
* be boosted by RT tasks, or might be boosted by
|
|
* interactivity modifiers. Will be RT if the task got
|
|
* RT-boosted. If not then it returns p->normal_prio.
|
|
*/
|
|
static int effective_prio(struct task_struct *p)
|
|
{
|
|
p->normal_prio = normal_prio(p);
|
|
/*
|
|
* If we are RT tasks or we were boosted to RT priority,
|
|
* keep the priority unchanged. Otherwise, update priority
|
|
* to the normal priority:
|
|
*/
|
|
if (!rt_prio(p->prio))
|
|
return p->normal_prio;
|
|
return p->prio;
|
|
}
|
|
|
|
/**
|
|
* task_curr - is this task currently executing on a CPU?
|
|
* @p: the task in question.
|
|
*
|
|
* Return: 1 if the task is currently executing. 0 otherwise.
|
|
*/
|
|
inline int task_curr(const struct task_struct *p)
|
|
{
|
|
return cpu_curr(task_cpu(p)) == p;
|
|
}
|
|
|
|
/*
|
|
* switched_from, switched_to and prio_changed must _NOT_ drop rq->lock,
|
|
* use the balance_callback list if you want balancing.
|
|
*
|
|
* this means any call to check_class_changed() must be followed by a call to
|
|
* balance_callback().
|
|
*/
|
|
static inline void check_class_changed(struct rq *rq, struct task_struct *p,
|
|
const struct sched_class *prev_class,
|
|
int oldprio)
|
|
{
|
|
if (prev_class != p->sched_class) {
|
|
if (prev_class->switched_from)
|
|
prev_class->switched_from(rq, p);
|
|
|
|
p->sched_class->switched_to(rq, p);
|
|
} else if (oldprio != p->prio || dl_task(p))
|
|
p->sched_class->prio_changed(rq, p, oldprio);
|
|
}
|
|
|
|
void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags)
|
|
{
|
|
if (p->sched_class == rq->curr->sched_class)
|
|
rq->curr->sched_class->check_preempt_curr(rq, p, flags);
|
|
else if (p->sched_class > rq->curr->sched_class)
|
|
resched_curr(rq);
|
|
|
|
/*
|
|
* A queue event has occurred, and we're going to schedule. In
|
|
* this case, we can save a useless back to back clock update.
|
|
*/
|
|
if (task_on_rq_queued(rq->curr) && test_tsk_need_resched(rq->curr))
|
|
rq_clock_skip_update(rq);
|
|
}
|
|
EXPORT_SYMBOL_GPL(check_preempt_curr);
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/*
|
|
* Per-CPU kthreads are allowed to run on !active && online CPUs, see
|
|
* __set_cpus_allowed_ptr() and select_fallback_rq().
|
|
*/
|
|
static inline bool is_cpu_allowed(struct task_struct *p, int cpu)
|
|
{
|
|
if (!cpumask_test_cpu(cpu, p->cpus_ptr))
|
|
return false;
|
|
|
|
if (is_per_cpu_kthread(p))
|
|
return cpu_online(cpu);
|
|
|
|
if (!cpu_active(cpu))
|
|
return false;
|
|
|
|
return cpumask_test_cpu(cpu, task_cpu_possible_mask(p));
|
|
}
|
|
|
|
/*
|
|
* This is how migration works:
|
|
*
|
|
* 1) we invoke migration_cpu_stop() on the target CPU using
|
|
* stop_one_cpu().
|
|
* 2) stopper starts to run (implicitly forcing the migrated thread
|
|
* off the CPU)
|
|
* 3) it checks whether the migrated task is still in the wrong runqueue.
|
|
* 4) if it's in the wrong runqueue then the migration thread removes
|
|
* it and puts it into the right queue.
|
|
* 5) stopper completes and stop_one_cpu() returns and the migration
|
|
* is done.
|
|
*/
|
|
|
|
/*
|
|
* move_queued_task - move a queued task to new rq.
|
|
*
|
|
* Returns (locked) new rq. Old rq's lock is released.
|
|
*/
|
|
static struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf,
|
|
struct task_struct *p, int new_cpu)
|
|
{
|
|
int detached = 0;
|
|
|
|
lockdep_assert_held(&rq->lock);
|
|
|
|
/*
|
|
* The vendor hook may drop the lock temporarily, so
|
|
* pass the rq flags to unpin lock. We expect the
|
|
* rq lock to be held after return.
|
|
*/
|
|
trace_android_rvh_migrate_queued_task(rq, rf, p, new_cpu, &detached);
|
|
if (detached)
|
|
goto attach;
|
|
|
|
deactivate_task(rq, p, DEQUEUE_NOCLOCK);
|
|
set_task_cpu(p, new_cpu);
|
|
|
|
attach:
|
|
rq_unlock(rq, rf);
|
|
rq = cpu_rq(new_cpu);
|
|
|
|
rq_lock(rq, rf);
|
|
BUG_ON(task_cpu(p) != new_cpu);
|
|
activate_task(rq, p, 0);
|
|
check_preempt_curr(rq, p, 0);
|
|
|
|
return rq;
|
|
}
|
|
|
|
struct migration_arg {
|
|
struct task_struct *task;
|
|
int dest_cpu;
|
|
};
|
|
|
|
/*
|
|
* Move (not current) task off this CPU, onto the destination CPU. We're doing
|
|
* this because either it can't run here any more (set_cpus_allowed()
|
|
* away from this CPU, or CPU going down), or because we're
|
|
* attempting to rebalance this task on exec (sched_exec).
|
|
*
|
|
* So we race with normal scheduler movements, but that's OK, as long
|
|
* as the task is no longer on this CPU.
|
|
*/
|
|
static struct rq *__migrate_task(struct rq *rq, struct rq_flags *rf,
|
|
struct task_struct *p, int dest_cpu)
|
|
{
|
|
/* Affinity changed (again). */
|
|
if (!is_cpu_allowed(p, dest_cpu))
|
|
return rq;
|
|
|
|
update_rq_clock(rq);
|
|
rq = move_queued_task(rq, rf, p, dest_cpu);
|
|
|
|
return rq;
|
|
}
|
|
|
|
/*
|
|
* migration_cpu_stop - this will be executed by a highprio stopper thread
|
|
* and performs thread migration by bumping thread off CPU then
|
|
* 'pushing' onto another runqueue.
|
|
*/
|
|
static int migration_cpu_stop(void *data)
|
|
{
|
|
struct migration_arg *arg = data;
|
|
struct task_struct *p = arg->task;
|
|
struct rq *rq = this_rq();
|
|
struct rq_flags rf;
|
|
|
|
/*
|
|
* The original target CPU might have gone down and we might
|
|
* be on another CPU but it doesn't matter.
|
|
*/
|
|
local_irq_disable();
|
|
/*
|
|
* We need to explicitly wake pending tasks before running
|
|
* __migrate_task() such that we will not miss enforcing cpus_ptr
|
|
* during wakeups, see set_cpus_allowed_ptr()'s TASK_WAKING test.
|
|
*/
|
|
flush_smp_call_function_from_idle();
|
|
|
|
raw_spin_lock(&p->pi_lock);
|
|
rq_lock(rq, &rf);
|
|
/*
|
|
* If task_rq(p) != rq, it cannot be migrated here, because we're
|
|
* holding rq->lock, if p->on_rq == 0 it cannot get enqueued because
|
|
* we're holding p->pi_lock.
|
|
*/
|
|
if (task_rq(p) == rq) {
|
|
if (task_on_rq_queued(p))
|
|
rq = __migrate_task(rq, &rf, p, arg->dest_cpu);
|
|
else
|
|
p->wake_cpu = arg->dest_cpu;
|
|
}
|
|
rq_unlock(rq, &rf);
|
|
raw_spin_unlock(&p->pi_lock);
|
|
|
|
local_irq_enable();
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* sched_class::set_cpus_allowed must do the below, but is not required to
|
|
* actually call this function.
|
|
*/
|
|
void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask)
|
|
{
|
|
cpumask_copy(&p->cpus_mask, new_mask);
|
|
p->nr_cpus_allowed = cpumask_weight(new_mask);
|
|
trace_android_rvh_set_cpus_allowed_comm(p, new_mask);
|
|
}
|
|
|
|
void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
|
|
{
|
|
struct rq *rq = task_rq(p);
|
|
bool queued, running;
|
|
|
|
lockdep_assert_held(&p->pi_lock);
|
|
|
|
queued = task_on_rq_queued(p);
|
|
running = task_current(rq, p);
|
|
|
|
if (queued) {
|
|
/*
|
|
* Because __kthread_bind() calls this on blocked tasks without
|
|
* holding rq->lock.
|
|
*/
|
|
lockdep_assert_held(&rq->lock);
|
|
dequeue_task(rq, p, DEQUEUE_SAVE | DEQUEUE_NOCLOCK);
|
|
}
|
|
if (running)
|
|
put_prev_task(rq, p);
|
|
|
|
p->sched_class->set_cpus_allowed(p, new_mask);
|
|
|
|
if (queued)
|
|
enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK);
|
|
if (running)
|
|
set_next_task(rq, p);
|
|
}
|
|
|
|
/*
|
|
* Called with both p->pi_lock and rq->lock held; drops both before returning.
|
|
*/
|
|
static int __set_cpus_allowed_ptr_locked(struct task_struct *p,
|
|
const struct cpumask *new_mask,
|
|
bool check,
|
|
struct rq *rq,
|
|
struct rq_flags *rf)
|
|
{
|
|
const struct cpumask *cpu_valid_mask = cpu_active_mask;
|
|
const struct cpumask *cpu_allowed_mask = task_cpu_possible_mask(p);
|
|
unsigned int dest_cpu;
|
|
int ret = 0;
|
|
|
|
update_rq_clock(rq);
|
|
|
|
if (p->flags & PF_KTHREAD) {
|
|
/*
|
|
* Kernel threads are allowed on online && !active CPUs
|
|
*/
|
|
cpu_valid_mask = cpu_online_mask;
|
|
} else if (!cpumask_subset(new_mask, cpu_allowed_mask)) {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
/*
|
|
* Must re-check here, to close a race against __kthread_bind(),
|
|
* sched_setaffinity() is not guaranteed to observe the flag.
|
|
*/
|
|
if (check && (p->flags & PF_NO_SETAFFINITY)) {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
if (cpumask_equal(&p->cpus_mask, new_mask))
|
|
goto out;
|
|
|
|
/*
|
|
* Picking a ~random cpu helps in cases where we are changing affinity
|
|
* for groups of tasks (ie. cpuset), so that load balancing is not
|
|
* immediately required to distribute the tasks within their new mask.
|
|
*/
|
|
dest_cpu = cpumask_any_and_distribute(cpu_valid_mask, new_mask);
|
|
if (dest_cpu >= nr_cpu_ids) {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
do_set_cpus_allowed(p, new_mask);
|
|
|
|
if (p->flags & PF_KTHREAD) {
|
|
/*
|
|
* For kernel threads that do indeed end up on online &&
|
|
* !active we want to ensure they are strict per-CPU threads.
|
|
*/
|
|
WARN_ON(cpumask_intersects(new_mask, cpu_online_mask) &&
|
|
!cpumask_intersects(new_mask, cpu_active_mask) &&
|
|
p->nr_cpus_allowed != 1);
|
|
}
|
|
|
|
/* Can the task run on the task's current CPU? If so, we're done */
|
|
if (cpumask_test_cpu(task_cpu(p), new_mask))
|
|
goto out;
|
|
|
|
if (task_running(rq, p) || p->state == TASK_WAKING) {
|
|
struct migration_arg arg = { p, dest_cpu };
|
|
/* Need help from migration thread: drop lock and wait. */
|
|
task_rq_unlock(rq, p, rf);
|
|
stop_one_cpu(cpu_of(rq), migration_cpu_stop, &arg);
|
|
return 0;
|
|
} else if (task_on_rq_queued(p)) {
|
|
/*
|
|
* OK, since we're going to drop the lock immediately
|
|
* afterwards anyway.
|
|
*/
|
|
rq = move_queued_task(rq, rf, p, dest_cpu);
|
|
}
|
|
out:
|
|
task_rq_unlock(rq, p, rf);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Change a given task's CPU affinity. Migrate the thread to a
|
|
* proper CPU and schedule it away if the CPU it's executing on
|
|
* is removed from the allowed bitmask.
|
|
*
|
|
* NOTE: the caller must have a valid reference to the task, the
|
|
* task must not exit() & deallocate itself prematurely. The
|
|
* call is not atomic; no spinlocks may be held.
|
|
*/
|
|
static int __set_cpus_allowed_ptr(struct task_struct *p,
|
|
const struct cpumask *new_mask, bool check)
|
|
{
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
rq = task_rq_lock(p, &rf);
|
|
return __set_cpus_allowed_ptr_locked(p, new_mask, check, rq, &rf);
|
|
}
|
|
|
|
int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask)
|
|
{
|
|
return __set_cpus_allowed_ptr(p, new_mask, false);
|
|
}
|
|
EXPORT_SYMBOL_GPL(set_cpus_allowed_ptr);
|
|
|
|
/*
|
|
* Change a given task's CPU affinity to the intersection of its current
|
|
* affinity mask and @subset_mask, writing the resulting mask to @new_mask.
|
|
* If the resulting mask is empty, leave the affinity unchanged and return
|
|
* -EINVAL.
|
|
*/
|
|
static int restrict_cpus_allowed_ptr(struct task_struct *p,
|
|
struct cpumask *new_mask,
|
|
const struct cpumask *subset_mask)
|
|
{
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
rq = task_rq_lock(p, &rf);
|
|
if (!cpumask_and(new_mask, &p->cpus_mask, subset_mask)) {
|
|
task_rq_unlock(rq, p, &rf);
|
|
return -EINVAL;
|
|
}
|
|
|
|
return __set_cpus_allowed_ptr_locked(p, new_mask, false, rq, &rf);
|
|
}
|
|
|
|
/*
|
|
* Restrict a given task's CPU affinity so that it is a subset of
|
|
* task_cpu_possible_mask(). If the resulting mask is empty, we warn and
|
|
* walk up the cpuset hierarchy until we find a suitable mask.
|
|
*/
|
|
void force_compatible_cpus_allowed_ptr(struct task_struct *p)
|
|
{
|
|
cpumask_var_t new_mask;
|
|
const struct cpumask *override_mask = task_cpu_possible_mask(p);
|
|
|
|
alloc_cpumask_var(&new_mask, GFP_KERNEL);
|
|
|
|
/*
|
|
* __migrate_task() can fail silently in the face of concurrent
|
|
* offlining of the chosen destination CPU, so take the hotplug
|
|
* lock to ensure that the migration succeeds.
|
|
*/
|
|
trace_android_rvh_force_compatible_pre(NULL);
|
|
cpus_read_lock();
|
|
if (!cpumask_available(new_mask))
|
|
goto out_set_mask;
|
|
|
|
if (!restrict_cpus_allowed_ptr(p, new_mask, override_mask))
|
|
goto out_free_mask;
|
|
|
|
/*
|
|
* We failed to find a valid subset of the affinity mask for the
|
|
* task, so override it based on its cpuset hierarchy.
|
|
*/
|
|
cpuset_cpus_allowed(p, new_mask);
|
|
override_mask = new_mask;
|
|
|
|
out_set_mask:
|
|
if (printk_ratelimit()) {
|
|
printk_deferred("Overriding affinity for process %d (%s) to CPUs %*pbl\n",
|
|
task_pid_nr(p), p->comm,
|
|
cpumask_pr_args(override_mask));
|
|
}
|
|
|
|
WARN_ON(set_cpus_allowed_ptr(p, override_mask));
|
|
out_free_mask:
|
|
cpus_read_unlock();
|
|
trace_android_rvh_force_compatible_post(NULL);
|
|
free_cpumask_var(new_mask);
|
|
}
|
|
|
|
void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
|
|
{
|
|
#ifdef CONFIG_SCHED_DEBUG
|
|
/*
|
|
* We should never call set_task_cpu() on a blocked task,
|
|
* ttwu() will sort out the placement.
|
|
*/
|
|
WARN_ON_ONCE(p->state != TASK_RUNNING && p->state != TASK_WAKING &&
|
|
!p->on_rq);
|
|
|
|
/*
|
|
* Migrating fair class task must have p->on_rq = TASK_ON_RQ_MIGRATING,
|
|
* because schedstat_wait_{start,end} rebase migrating task's wait_start
|
|
* time relying on p->on_rq.
|
|
*/
|
|
WARN_ON_ONCE(p->state == TASK_RUNNING &&
|
|
p->sched_class == &fair_sched_class &&
|
|
(p->on_rq && !task_on_rq_migrating(p)));
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
/*
|
|
* The caller should hold either p->pi_lock or rq->lock, when changing
|
|
* a task's CPU. ->pi_lock for waking tasks, rq->lock for runnable tasks.
|
|
*
|
|
* sched_move_task() holds both and thus holding either pins the cgroup,
|
|
* see task_group().
|
|
*
|
|
* Furthermore, all task_rq users should acquire both locks, see
|
|
* task_rq_lock().
|
|
*/
|
|
WARN_ON_ONCE(debug_locks && !(lockdep_is_held(&p->pi_lock) ||
|
|
lockdep_is_held(&task_rq(p)->lock)));
|
|
#endif
|
|
/*
|
|
* Clearly, migrating tasks to offline CPUs is a fairly daft thing.
|
|
*/
|
|
WARN_ON_ONCE(!cpu_online(new_cpu));
|
|
#endif
|
|
|
|
trace_sched_migrate_task(p, new_cpu);
|
|
|
|
if (task_cpu(p) != new_cpu) {
|
|
if (p->sched_class->migrate_task_rq)
|
|
p->sched_class->migrate_task_rq(p, new_cpu);
|
|
p->se.nr_migrations++;
|
|
rseq_migrate(p);
|
|
perf_event_task_migrate(p);
|
|
trace_android_rvh_set_task_cpu(p, new_cpu);
|
|
}
|
|
|
|
__set_task_cpu(p, new_cpu);
|
|
}
|
|
EXPORT_SYMBOL_GPL(set_task_cpu);
|
|
|
|
static void __migrate_swap_task(struct task_struct *p, int cpu)
|
|
{
|
|
if (task_on_rq_queued(p)) {
|
|
struct rq *src_rq, *dst_rq;
|
|
struct rq_flags srf, drf;
|
|
|
|
src_rq = task_rq(p);
|
|
dst_rq = cpu_rq(cpu);
|
|
|
|
rq_pin_lock(src_rq, &srf);
|
|
rq_pin_lock(dst_rq, &drf);
|
|
|
|
deactivate_task(src_rq, p, 0);
|
|
set_task_cpu(p, cpu);
|
|
activate_task(dst_rq, p, 0);
|
|
check_preempt_curr(dst_rq, p, 0);
|
|
|
|
rq_unpin_lock(dst_rq, &drf);
|
|
rq_unpin_lock(src_rq, &srf);
|
|
|
|
} else {
|
|
/*
|
|
* Task isn't running anymore; make it appear like we migrated
|
|
* it before it went to sleep. This means on wakeup we make the
|
|
* previous CPU our target instead of where it really is.
|
|
*/
|
|
p->wake_cpu = cpu;
|
|
}
|
|
}
|
|
|
|
struct migration_swap_arg {
|
|
struct task_struct *src_task, *dst_task;
|
|
int src_cpu, dst_cpu;
|
|
};
|
|
|
|
static int migrate_swap_stop(void *data)
|
|
{
|
|
struct migration_swap_arg *arg = data;
|
|
struct rq *src_rq, *dst_rq;
|
|
int ret = -EAGAIN;
|
|
|
|
if (!cpu_active(arg->src_cpu) || !cpu_active(arg->dst_cpu))
|
|
return -EAGAIN;
|
|
|
|
src_rq = cpu_rq(arg->src_cpu);
|
|
dst_rq = cpu_rq(arg->dst_cpu);
|
|
|
|
double_raw_lock(&arg->src_task->pi_lock,
|
|
&arg->dst_task->pi_lock);
|
|
double_rq_lock(src_rq, dst_rq);
|
|
|
|
if (task_cpu(arg->dst_task) != arg->dst_cpu)
|
|
goto unlock;
|
|
|
|
if (task_cpu(arg->src_task) != arg->src_cpu)
|
|
goto unlock;
|
|
|
|
if (!cpumask_test_cpu(arg->dst_cpu, arg->src_task->cpus_ptr))
|
|
goto unlock;
|
|
|
|
if (!cpumask_test_cpu(arg->src_cpu, arg->dst_task->cpus_ptr))
|
|
goto unlock;
|
|
|
|
__migrate_swap_task(arg->src_task, arg->dst_cpu);
|
|
__migrate_swap_task(arg->dst_task, arg->src_cpu);
|
|
|
|
ret = 0;
|
|
|
|
unlock:
|
|
double_rq_unlock(src_rq, dst_rq);
|
|
raw_spin_unlock(&arg->dst_task->pi_lock);
|
|
raw_spin_unlock(&arg->src_task->pi_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Cross migrate two tasks
|
|
*/
|
|
int migrate_swap(struct task_struct *cur, struct task_struct *p,
|
|
int target_cpu, int curr_cpu)
|
|
{
|
|
struct migration_swap_arg arg;
|
|
int ret = -EINVAL;
|
|
|
|
arg = (struct migration_swap_arg){
|
|
.src_task = cur,
|
|
.src_cpu = curr_cpu,
|
|
.dst_task = p,
|
|
.dst_cpu = target_cpu,
|
|
};
|
|
|
|
if (arg.src_cpu == arg.dst_cpu)
|
|
goto out;
|
|
|
|
/*
|
|
* These three tests are all lockless; this is OK since all of them
|
|
* will be re-checked with proper locks held further down the line.
|
|
*/
|
|
if (!cpu_active(arg.src_cpu) || !cpu_active(arg.dst_cpu))
|
|
goto out;
|
|
|
|
if (!cpumask_test_cpu(arg.dst_cpu, arg.src_task->cpus_ptr))
|
|
goto out;
|
|
|
|
if (!cpumask_test_cpu(arg.src_cpu, arg.dst_task->cpus_ptr))
|
|
goto out;
|
|
|
|
trace_sched_swap_numa(cur, arg.src_cpu, p, arg.dst_cpu);
|
|
ret = stop_two_cpus(arg.dst_cpu, arg.src_cpu, migrate_swap_stop, &arg);
|
|
|
|
out:
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(migrate_swap);
|
|
|
|
/*
|
|
* wait_task_inactive - wait for a thread to unschedule.
|
|
*
|
|
* If @match_state is nonzero, it's the @p->state value just checked and
|
|
* not expected to change. If it changes, i.e. @p might have woken up,
|
|
* then return zero. When we succeed in waiting for @p to be off its CPU,
|
|
* we return a positive number (its total switch count). If a second call
|
|
* a short while later returns the same number, the caller can be sure that
|
|
* @p has remained unscheduled the whole time.
|
|
*
|
|
* The caller must ensure that the task *will* unschedule sometime soon,
|
|
* else this function might spin for a *long* time. This function can't
|
|
* be called with interrupts off, or it may introduce deadlock with
|
|
* smp_call_function() if an IPI is sent by the same process we are
|
|
* waiting to become inactive.
|
|
*/
|
|
unsigned long wait_task_inactive(struct task_struct *p, long match_state)
|
|
{
|
|
int running, queued;
|
|
struct rq_flags rf;
|
|
unsigned long ncsw;
|
|
struct rq *rq;
|
|
|
|
for (;;) {
|
|
/*
|
|
* We do the initial early heuristics without holding
|
|
* any task-queue locks at all. We'll only try to get
|
|
* the runqueue lock when things look like they will
|
|
* work out!
|
|
*/
|
|
rq = task_rq(p);
|
|
|
|
/*
|
|
* If the task is actively running on another CPU
|
|
* still, just relax and busy-wait without holding
|
|
* any locks.
|
|
*
|
|
* NOTE! Since we don't hold any locks, it's not
|
|
* even sure that "rq" stays as the right runqueue!
|
|
* But we don't care, since "task_running()" will
|
|
* return false if the runqueue has changed and p
|
|
* is actually now running somewhere else!
|
|
*/
|
|
while (task_running(rq, p)) {
|
|
if (match_state && unlikely(p->state != match_state))
|
|
return 0;
|
|
cpu_relax();
|
|
}
|
|
|
|
/*
|
|
* Ok, time to look more closely! We need the rq
|
|
* lock now, to be *sure*. If we're wrong, we'll
|
|
* just go back and repeat.
|
|
*/
|
|
rq = task_rq_lock(p, &rf);
|
|
trace_sched_wait_task(p);
|
|
running = task_running(rq, p);
|
|
queued = task_on_rq_queued(p);
|
|
ncsw = 0;
|
|
if (!match_state || p->state == match_state)
|
|
ncsw = p->nvcsw | LONG_MIN; /* sets MSB */
|
|
task_rq_unlock(rq, p, &rf);
|
|
|
|
/*
|
|
* If it changed from the expected state, bail out now.
|
|
*/
|
|
if (unlikely(!ncsw))
|
|
break;
|
|
|
|
/*
|
|
* Was it really running after all now that we
|
|
* checked with the proper locks actually held?
|
|
*
|
|
* Oops. Go back and try again..
|
|
*/
|
|
if (unlikely(running)) {
|
|
cpu_relax();
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* It's not enough that it's not actively running,
|
|
* it must be off the runqueue _entirely_, and not
|
|
* preempted!
|
|
*
|
|
* So if it was still runnable (but just not actively
|
|
* running right now), it's preempted, and we should
|
|
* yield - it could be a while.
|
|
*/
|
|
if (unlikely(queued)) {
|
|
ktime_t to = NSEC_PER_SEC / HZ;
|
|
|
|
set_current_state(TASK_UNINTERRUPTIBLE);
|
|
schedule_hrtimeout(&to, HRTIMER_MODE_REL);
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Ahh, all good. It wasn't running, and it wasn't
|
|
* runnable, which means that it will never become
|
|
* running in the future either. We're all done!
|
|
*/
|
|
break;
|
|
}
|
|
|
|
return ncsw;
|
|
}
|
|
|
|
/***
|
|
* kick_process - kick a running thread to enter/exit the kernel
|
|
* @p: the to-be-kicked thread
|
|
*
|
|
* Cause a process which is running on another CPU to enter
|
|
* kernel-mode, without any delay. (to get signals handled.)
|
|
*
|
|
* NOTE: this function doesn't have to take the runqueue lock,
|
|
* because all it wants to ensure is that the remote task enters
|
|
* the kernel. If the IPI races and the task has been migrated
|
|
* to another CPU then no harm is done and the purpose has been
|
|
* achieved as well.
|
|
*/
|
|
void kick_process(struct task_struct *p)
|
|
{
|
|
int cpu;
|
|
|
|
preempt_disable();
|
|
cpu = task_cpu(p);
|
|
if ((cpu != smp_processor_id()) && task_curr(p))
|
|
smp_send_reschedule(cpu);
|
|
preempt_enable();
|
|
}
|
|
EXPORT_SYMBOL_GPL(kick_process);
|
|
|
|
/*
|
|
* ->cpus_ptr is protected by both rq->lock and p->pi_lock
|
|
*
|
|
* A few notes on cpu_active vs cpu_online:
|
|
*
|
|
* - cpu_active must be a subset of cpu_online
|
|
*
|
|
* - on CPU-up we allow per-CPU kthreads on the online && !active CPU,
|
|
* see __set_cpus_allowed_ptr(). At this point the newly online
|
|
* CPU isn't yet part of the sched domains, and balancing will not
|
|
* see it.
|
|
*
|
|
* - on CPU-down we clear cpu_active() to mask the sched domains and
|
|
* avoid the load balancer to place new tasks on the to be removed
|
|
* CPU. Existing tasks will remain running there and will be taken
|
|
* off.
|
|
*
|
|
* This means that fallback selection must not select !active CPUs.
|
|
* And can assume that any active CPU must be online. Conversely
|
|
* select_task_rq() below may allow selection of !active CPUs in order
|
|
* to satisfy the above rules.
|
|
*/
|
|
static int select_fallback_rq(int cpu, struct task_struct *p)
|
|
{
|
|
int nid = cpu_to_node(cpu);
|
|
const struct cpumask *nodemask = NULL;
|
|
enum { cpuset, possible, fail } state = cpuset;
|
|
int dest_cpu = -1;
|
|
|
|
trace_android_rvh_select_fallback_rq(cpu, p, &dest_cpu);
|
|
if (dest_cpu >= 0)
|
|
return dest_cpu;
|
|
|
|
/*
|
|
* If the node that the CPU is on has been offlined, cpu_to_node()
|
|
* will return -1. There is no CPU on the node, and we should
|
|
* select the CPU on the other node.
|
|
*/
|
|
if (nid != -1) {
|
|
nodemask = cpumask_of_node(nid);
|
|
|
|
/* Look for allowed, online CPU in same node. */
|
|
for_each_cpu(dest_cpu, nodemask) {
|
|
if (is_cpu_allowed(p, dest_cpu))
|
|
return dest_cpu;
|
|
}
|
|
}
|
|
|
|
for (;;) {
|
|
/* Any allowed, online CPU? */
|
|
for_each_cpu(dest_cpu, p->cpus_ptr) {
|
|
if (!is_cpu_allowed(p, dest_cpu))
|
|
continue;
|
|
|
|
goto out;
|
|
}
|
|
|
|
/* No more Mr. Nice Guy. */
|
|
switch (state) {
|
|
case cpuset:
|
|
if (IS_ENABLED(CONFIG_CPUSETS)) {
|
|
cpuset_cpus_allowed_fallback(p);
|
|
state = possible;
|
|
break;
|
|
}
|
|
fallthrough;
|
|
case possible:
|
|
do_set_cpus_allowed(p, task_cpu_possible_mask(p));
|
|
state = fail;
|
|
break;
|
|
case fail:
|
|
BUG();
|
|
break;
|
|
}
|
|
}
|
|
|
|
out:
|
|
if (state != cpuset) {
|
|
/*
|
|
* Don't tell them about moving exiting tasks or
|
|
* kernel threads (both mm NULL), since they never
|
|
* leave kernel.
|
|
*/
|
|
if (p->mm && printk_ratelimit()) {
|
|
printk_deferred("process %d (%s) no longer affine to cpu%d\n",
|
|
task_pid_nr(p), p->comm, cpu);
|
|
}
|
|
}
|
|
|
|
return dest_cpu;
|
|
}
|
|
|
|
/*
|
|
* The caller (fork, wakeup) owns p->pi_lock, ->cpus_ptr is stable.
|
|
*/
|
|
static inline
|
|
int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
|
|
{
|
|
lockdep_assert_held(&p->pi_lock);
|
|
|
|
if (p->nr_cpus_allowed > 1)
|
|
cpu = p->sched_class->select_task_rq(p, cpu, sd_flags, wake_flags);
|
|
else
|
|
cpu = cpumask_any(p->cpus_ptr);
|
|
|
|
/*
|
|
* In order not to call set_task_cpu() on a blocking task we need
|
|
* to rely on ttwu() to place the task on a valid ->cpus_ptr
|
|
* CPU.
|
|
*
|
|
* Since this is common to all placement strategies, this lives here.
|
|
*
|
|
* [ this allows ->select_task() to simply return task_cpu(p) and
|
|
* not worry about this generic constraint ]
|
|
*/
|
|
if (unlikely(!is_cpu_allowed(p, cpu)))
|
|
cpu = select_fallback_rq(task_cpu(p), p);
|
|
|
|
return cpu;
|
|
}
|
|
|
|
void sched_set_stop_task(int cpu, struct task_struct *stop)
|
|
{
|
|
struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 };
|
|
struct task_struct *old_stop = cpu_rq(cpu)->stop;
|
|
|
|
if (stop) {
|
|
/*
|
|
* Make it appear like a SCHED_FIFO task, its something
|
|
* userspace knows about and won't get confused about.
|
|
*
|
|
* Also, it will make PI more or less work without too
|
|
* much confusion -- but then, stop work should not
|
|
* rely on PI working anyway.
|
|
*/
|
|
sched_setscheduler_nocheck(stop, SCHED_FIFO, ¶m);
|
|
|
|
stop->sched_class = &stop_sched_class;
|
|
}
|
|
|
|
cpu_rq(cpu)->stop = stop;
|
|
|
|
if (old_stop) {
|
|
/*
|
|
* Reset it back to a normal scheduling class so that
|
|
* it can die in pieces.
|
|
*/
|
|
old_stop->sched_class = &rt_sched_class;
|
|
}
|
|
}
|
|
|
|
#else
|
|
|
|
static inline int __set_cpus_allowed_ptr(struct task_struct *p,
|
|
const struct cpumask *new_mask, bool check)
|
|
{
|
|
return set_cpus_allowed_ptr(p, new_mask);
|
|
}
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
static void
|
|
ttwu_stat(struct task_struct *p, int cpu, int wake_flags)
|
|
{
|
|
struct rq *rq;
|
|
|
|
if (!schedstat_enabled())
|
|
return;
|
|
|
|
rq = this_rq();
|
|
|
|
#ifdef CONFIG_SMP
|
|
if (cpu == rq->cpu) {
|
|
__schedstat_inc(rq->ttwu_local);
|
|
__schedstat_inc(p->se.statistics.nr_wakeups_local);
|
|
} else {
|
|
struct sched_domain *sd;
|
|
|
|
__schedstat_inc(p->se.statistics.nr_wakeups_remote);
|
|
rcu_read_lock();
|
|
for_each_domain(rq->cpu, sd) {
|
|
if (cpumask_test_cpu(cpu, sched_domain_span(sd))) {
|
|
__schedstat_inc(sd->ttwu_wake_remote);
|
|
break;
|
|
}
|
|
}
|
|
rcu_read_unlock();
|
|
}
|
|
|
|
if (wake_flags & WF_MIGRATED)
|
|
__schedstat_inc(p->se.statistics.nr_wakeups_migrate);
|
|
#endif /* CONFIG_SMP */
|
|
|
|
__schedstat_inc(rq->ttwu_count);
|
|
__schedstat_inc(p->se.statistics.nr_wakeups);
|
|
|
|
if (wake_flags & WF_SYNC)
|
|
__schedstat_inc(p->se.statistics.nr_wakeups_sync);
|
|
}
|
|
|
|
/*
|
|
* Mark the task runnable and perform wakeup-preemption.
|
|
*/
|
|
static void ttwu_do_wakeup(struct rq *rq, struct task_struct *p, int wake_flags,
|
|
struct rq_flags *rf)
|
|
{
|
|
check_preempt_curr(rq, p, wake_flags);
|
|
p->state = TASK_RUNNING;
|
|
trace_sched_wakeup(p);
|
|
|
|
#ifdef CONFIG_SMP
|
|
if (p->sched_class->task_woken) {
|
|
/*
|
|
* Our task @p is fully woken up and running; so its safe to
|
|
* drop the rq->lock, hereafter rq is only used for statistics.
|
|
*/
|
|
rq_unpin_lock(rq, rf);
|
|
p->sched_class->task_woken(rq, p);
|
|
rq_repin_lock(rq, rf);
|
|
}
|
|
|
|
if (rq->idle_stamp) {
|
|
u64 delta = rq_clock(rq) - rq->idle_stamp;
|
|
u64 max = 2*rq->max_idle_balance_cost;
|
|
|
|
update_avg(&rq->avg_idle, delta);
|
|
|
|
if (rq->avg_idle > max)
|
|
rq->avg_idle = max;
|
|
|
|
rq->idle_stamp = 0;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
static void
|
|
ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags,
|
|
struct rq_flags *rf)
|
|
{
|
|
int en_flags = ENQUEUE_WAKEUP | ENQUEUE_NOCLOCK;
|
|
|
|
if (wake_flags & WF_SYNC)
|
|
en_flags |= ENQUEUE_WAKEUP_SYNC;
|
|
|
|
lockdep_assert_held(&rq->lock);
|
|
|
|
if (p->sched_contributes_to_load)
|
|
rq->nr_uninterruptible--;
|
|
|
|
#ifdef CONFIG_SMP
|
|
if (wake_flags & WF_MIGRATED)
|
|
en_flags |= ENQUEUE_MIGRATED;
|
|
else
|
|
#endif
|
|
if (p->in_iowait) {
|
|
delayacct_blkio_end(p);
|
|
atomic_dec(&task_rq(p)->nr_iowait);
|
|
}
|
|
|
|
activate_task(rq, p, en_flags);
|
|
ttwu_do_wakeup(rq, p, wake_flags, rf);
|
|
}
|
|
|
|
/*
|
|
* Consider @p being inside a wait loop:
|
|
*
|
|
* for (;;) {
|
|
* set_current_state(TASK_UNINTERRUPTIBLE);
|
|
*
|
|
* if (CONDITION)
|
|
* break;
|
|
*
|
|
* schedule();
|
|
* }
|
|
* __set_current_state(TASK_RUNNING);
|
|
*
|
|
* between set_current_state() and schedule(). In this case @p is still
|
|
* runnable, so all that needs doing is change p->state back to TASK_RUNNING in
|
|
* an atomic manner.
|
|
*
|
|
* By taking task_rq(p)->lock we serialize against schedule(), if @p->on_rq
|
|
* then schedule() must still happen and p->state can be changed to
|
|
* TASK_RUNNING. Otherwise we lost the race, schedule() has happened, and we
|
|
* need to do a full wakeup with enqueue.
|
|
*
|
|
* Returns: %true when the wakeup is done,
|
|
* %false otherwise.
|
|
*/
|
|
static int ttwu_runnable(struct task_struct *p, int wake_flags)
|
|
{
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
int ret = 0;
|
|
|
|
rq = __task_rq_lock(p, &rf);
|
|
if (task_on_rq_queued(p)) {
|
|
/* check_preempt_curr() may use rq clock */
|
|
update_rq_clock(rq);
|
|
ttwu_do_wakeup(rq, p, wake_flags, &rf);
|
|
ret = 1;
|
|
}
|
|
__task_rq_unlock(rq, &rf);
|
|
|
|
return ret;
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
void sched_ttwu_pending(void *arg)
|
|
{
|
|
struct llist_node *llist = arg;
|
|
struct rq *rq = this_rq();
|
|
struct task_struct *p, *t;
|
|
struct rq_flags rf;
|
|
|
|
if (!llist)
|
|
return;
|
|
|
|
/*
|
|
* rq::ttwu_pending racy indication of out-standing wakeups.
|
|
* Races such that false-negatives are possible, since they
|
|
* are shorter lived that false-positives would be.
|
|
*/
|
|
WRITE_ONCE(rq->ttwu_pending, 0);
|
|
|
|
rq_lock_irqsave(rq, &rf);
|
|
update_rq_clock(rq);
|
|
|
|
llist_for_each_entry_safe(p, t, llist, wake_entry.llist) {
|
|
if (WARN_ON_ONCE(p->on_cpu))
|
|
smp_cond_load_acquire(&p->on_cpu, !VAL);
|
|
|
|
if (WARN_ON_ONCE(task_cpu(p) != cpu_of(rq)))
|
|
set_task_cpu(p, cpu_of(rq));
|
|
|
|
ttwu_do_activate(rq, p, p->sched_remote_wakeup ? WF_MIGRATED : 0, &rf);
|
|
}
|
|
|
|
rq_unlock_irqrestore(rq, &rf);
|
|
}
|
|
|
|
void send_call_function_single_ipi(int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
|
|
if (!set_nr_if_polling(rq->idle))
|
|
arch_send_call_function_single_ipi(cpu);
|
|
else
|
|
trace_sched_wake_idle_without_ipi(cpu);
|
|
}
|
|
|
|
/*
|
|
* Queue a task on the target CPUs wake_list and wake the CPU via IPI if
|
|
* necessary. The wakee CPU on receipt of the IPI will queue the task
|
|
* via sched_ttwu_wakeup() for activation so the wakee incurs the cost
|
|
* of the wakeup instead of the waker.
|
|
*/
|
|
static void __ttwu_queue_wakelist(struct task_struct *p, int cpu, int wake_flags)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
|
|
p->sched_remote_wakeup = !!(wake_flags & WF_MIGRATED);
|
|
|
|
WRITE_ONCE(rq->ttwu_pending, 1);
|
|
__smp_call_single_queue(cpu, &p->wake_entry.llist);
|
|
}
|
|
|
|
void wake_up_if_idle(int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
struct rq_flags rf;
|
|
|
|
rcu_read_lock();
|
|
|
|
if (!is_idle_task(rcu_dereference(rq->curr)))
|
|
goto out;
|
|
|
|
if (set_nr_if_polling(rq->idle)) {
|
|
trace_sched_wake_idle_without_ipi(cpu);
|
|
} else {
|
|
rq_lock_irqsave(rq, &rf);
|
|
if (is_idle_task(rq->curr))
|
|
smp_send_reschedule(cpu);
|
|
/* Else CPU is not idle, do nothing here: */
|
|
rq_unlock_irqrestore(rq, &rf);
|
|
}
|
|
|
|
out:
|
|
rcu_read_unlock();
|
|
}
|
|
EXPORT_SYMBOL_GPL(wake_up_if_idle);
|
|
|
|
bool cpus_share_cache(int this_cpu, int that_cpu)
|
|
{
|
|
if (this_cpu == that_cpu)
|
|
return true;
|
|
|
|
return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
|
|
}
|
|
|
|
static inline bool ttwu_queue_cond(int cpu, int wake_flags)
|
|
{
|
|
/*
|
|
* If the CPU does not share cache, then queue the task on the
|
|
* remote rqs wakelist to avoid accessing remote data.
|
|
*/
|
|
if (!cpus_share_cache(smp_processor_id(), cpu))
|
|
return true;
|
|
|
|
/*
|
|
* If the task is descheduling and the only running task on the
|
|
* CPU then use the wakelist to offload the task activation to
|
|
* the soon-to-be-idle CPU as the current CPU is likely busy.
|
|
* nr_running is checked to avoid unnecessary task stacking.
|
|
*/
|
|
if ((wake_flags & WF_ON_CPU) && cpu_rq(cpu)->nr_running <= 1)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
static bool ttwu_queue_wakelist(struct task_struct *p, int cpu, int wake_flags)
|
|
{
|
|
bool cond = false;
|
|
|
|
trace_android_rvh_ttwu_cond(&cond);
|
|
|
|
if ((sched_feat(TTWU_QUEUE) && ttwu_queue_cond(cpu, wake_flags)) ||
|
|
cond) {
|
|
if (WARN_ON_ONCE(cpu == smp_processor_id()))
|
|
return false;
|
|
|
|
sched_clock_cpu(cpu); /* Sync clocks across CPUs */
|
|
__ttwu_queue_wakelist(p, cpu, wake_flags);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
#else /* !CONFIG_SMP */
|
|
|
|
static inline bool ttwu_queue_wakelist(struct task_struct *p, int cpu, int wake_flags)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
static void ttwu_queue(struct task_struct *p, int cpu, int wake_flags)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
struct rq_flags rf;
|
|
|
|
if (ttwu_queue_wakelist(p, cpu, wake_flags))
|
|
return;
|
|
|
|
rq_lock(rq, &rf);
|
|
update_rq_clock(rq);
|
|
ttwu_do_activate(rq, p, wake_flags, &rf);
|
|
rq_unlock(rq, &rf);
|
|
}
|
|
|
|
/*
|
|
* Notes on Program-Order guarantees on SMP systems.
|
|
*
|
|
* MIGRATION
|
|
*
|
|
* The basic program-order guarantee on SMP systems is that when a task [t]
|
|
* migrates, all its activity on its old CPU [c0] happens-before any subsequent
|
|
* execution on its new CPU [c1].
|
|
*
|
|
* For migration (of runnable tasks) this is provided by the following means:
|
|
*
|
|
* A) UNLOCK of the rq(c0)->lock scheduling out task t
|
|
* B) migration for t is required to synchronize *both* rq(c0)->lock and
|
|
* rq(c1)->lock (if not at the same time, then in that order).
|
|
* C) LOCK of the rq(c1)->lock scheduling in task
|
|
*
|
|
* Release/acquire chaining guarantees that B happens after A and C after B.
|
|
* Note: the CPU doing B need not be c0 or c1
|
|
*
|
|
* Example:
|
|
*
|
|
* CPU0 CPU1 CPU2
|
|
*
|
|
* LOCK rq(0)->lock
|
|
* sched-out X
|
|
* sched-in Y
|
|
* UNLOCK rq(0)->lock
|
|
*
|
|
* LOCK rq(0)->lock // orders against CPU0
|
|
* dequeue X
|
|
* UNLOCK rq(0)->lock
|
|
*
|
|
* LOCK rq(1)->lock
|
|
* enqueue X
|
|
* UNLOCK rq(1)->lock
|
|
*
|
|
* LOCK rq(1)->lock // orders against CPU2
|
|
* sched-out Z
|
|
* sched-in X
|
|
* UNLOCK rq(1)->lock
|
|
*
|
|
*
|
|
* BLOCKING -- aka. SLEEP + WAKEUP
|
|
*
|
|
* For blocking we (obviously) need to provide the same guarantee as for
|
|
* migration. However the means are completely different as there is no lock
|
|
* chain to provide order. Instead we do:
|
|
*
|
|
* 1) smp_store_release(X->on_cpu, 0) -- finish_task()
|
|
* 2) smp_cond_load_acquire(!X->on_cpu) -- try_to_wake_up()
|
|
*
|
|
* Example:
|
|
*
|
|
* CPU0 (schedule) CPU1 (try_to_wake_up) CPU2 (schedule)
|
|
*
|
|
* LOCK rq(0)->lock LOCK X->pi_lock
|
|
* dequeue X
|
|
* sched-out X
|
|
* smp_store_release(X->on_cpu, 0);
|
|
*
|
|
* smp_cond_load_acquire(&X->on_cpu, !VAL);
|
|
* X->state = WAKING
|
|
* set_task_cpu(X,2)
|
|
*
|
|
* LOCK rq(2)->lock
|
|
* enqueue X
|
|
* X->state = RUNNING
|
|
* UNLOCK rq(2)->lock
|
|
*
|
|
* LOCK rq(2)->lock // orders against CPU1
|
|
* sched-out Z
|
|
* sched-in X
|
|
* UNLOCK rq(2)->lock
|
|
*
|
|
* UNLOCK X->pi_lock
|
|
* UNLOCK rq(0)->lock
|
|
*
|
|
*
|
|
* However, for wakeups there is a second guarantee we must provide, namely we
|
|
* must ensure that CONDITION=1 done by the caller can not be reordered with
|
|
* accesses to the task state; see try_to_wake_up() and set_current_state().
|
|
*/
|
|
|
|
/**
|
|
* try_to_wake_up - wake up a thread
|
|
* @p: the thread to be awakened
|
|
* @state: the mask of task states that can be woken
|
|
* @wake_flags: wake modifier flags (WF_*)
|
|
*
|
|
* Conceptually does:
|
|
*
|
|
* If (@state & @p->state) @p->state = TASK_RUNNING.
|
|
*
|
|
* If the task was not queued/runnable, also place it back on a runqueue.
|
|
*
|
|
* This function is atomic against schedule() which would dequeue the task.
|
|
*
|
|
* It issues a full memory barrier before accessing @p->state, see the comment
|
|
* with set_current_state().
|
|
*
|
|
* Uses p->pi_lock to serialize against concurrent wake-ups.
|
|
*
|
|
* Relies on p->pi_lock stabilizing:
|
|
* - p->sched_class
|
|
* - p->cpus_ptr
|
|
* - p->sched_task_group
|
|
* in order to do migration, see its use of select_task_rq()/set_task_cpu().
|
|
*
|
|
* Tries really hard to only take one task_rq(p)->lock for performance.
|
|
* Takes rq->lock in:
|
|
* - ttwu_runnable() -- old rq, unavoidable, see comment there;
|
|
* - ttwu_queue() -- new rq, for enqueue of the task;
|
|
* - psi_ttwu_dequeue() -- much sadness :-( accounting will kill us.
|
|
*
|
|
* As a consequence we race really badly with just about everything. See the
|
|
* many memory barriers and their comments for details.
|
|
*
|
|
* Return: %true if @p->state changes (an actual wakeup was done),
|
|
* %false otherwise.
|
|
*/
|
|
static int
|
|
try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
|
|
{
|
|
unsigned long flags;
|
|
int cpu, success = 0;
|
|
|
|
preempt_disable();
|
|
if (p == current) {
|
|
/*
|
|
* We're waking current, this means 'p->on_rq' and 'task_cpu(p)
|
|
* == smp_processor_id()'. Together this means we can special
|
|
* case the whole 'p->on_rq && ttwu_runnable()' case below
|
|
* without taking any locks.
|
|
*
|
|
* In particular:
|
|
* - we rely on Program-Order guarantees for all the ordering,
|
|
* - we're serialized against set_special_state() by virtue of
|
|
* it disabling IRQs (this allows not taking ->pi_lock).
|
|
*/
|
|
if (!(p->state & state))
|
|
goto out;
|
|
|
|
success = 1;
|
|
trace_sched_waking(p);
|
|
p->state = TASK_RUNNING;
|
|
trace_sched_wakeup(p);
|
|
goto out;
|
|
}
|
|
|
|
/*
|
|
* If we are going to wake up a thread waiting for CONDITION we
|
|
* need to ensure that CONDITION=1 done by the caller can not be
|
|
* reordered with p->state check below. This pairs with smp_store_mb()
|
|
* in set_current_state() that the waiting thread does.
|
|
*/
|
|
raw_spin_lock_irqsave(&p->pi_lock, flags);
|
|
smp_mb__after_spinlock();
|
|
if (!(p->state & state))
|
|
goto unlock;
|
|
|
|
#ifdef CONFIG_FREEZER
|
|
/*
|
|
* If we're going to wake up a thread which may be frozen, then
|
|
* we can only do so if we have an active CPU which is capable of
|
|
* running it. This may not be the case when resuming from suspend,
|
|
* as the secondary CPUs may not yet be back online. See __thaw_task()
|
|
* for the actual wakeup.
|
|
*/
|
|
if (unlikely(frozen_or_skipped(p)) &&
|
|
!cpumask_intersects(cpu_active_mask, task_cpu_possible_mask(p)))
|
|
goto unlock;
|
|
#endif
|
|
|
|
trace_sched_waking(p);
|
|
|
|
/* We're going to change ->state: */
|
|
success = 1;
|
|
|
|
/*
|
|
* Ensure we load p->on_rq _after_ p->state, otherwise it would
|
|
* be possible to, falsely, observe p->on_rq == 0 and get stuck
|
|
* in smp_cond_load_acquire() below.
|
|
*
|
|
* sched_ttwu_pending() try_to_wake_up()
|
|
* STORE p->on_rq = 1 LOAD p->state
|
|
* UNLOCK rq->lock
|
|
*
|
|
* __schedule() (switch to task 'p')
|
|
* LOCK rq->lock smp_rmb();
|
|
* smp_mb__after_spinlock();
|
|
* UNLOCK rq->lock
|
|
*
|
|
* [task p]
|
|
* STORE p->state = UNINTERRUPTIBLE LOAD p->on_rq
|
|
*
|
|
* Pairs with the LOCK+smp_mb__after_spinlock() on rq->lock in
|
|
* __schedule(). See the comment for smp_mb__after_spinlock().
|
|
*
|
|
* A similar smb_rmb() lives in try_invoke_on_locked_down_task().
|
|
*/
|
|
smp_rmb();
|
|
if (READ_ONCE(p->on_rq) && ttwu_runnable(p, wake_flags))
|
|
goto unlock;
|
|
|
|
if (p->state & TASK_UNINTERRUPTIBLE)
|
|
trace_sched_blocked_reason(p);
|
|
|
|
#ifdef CONFIG_SMP
|
|
/*
|
|
* Ensure we load p->on_cpu _after_ p->on_rq, otherwise it would be
|
|
* possible to, falsely, observe p->on_cpu == 0.
|
|
*
|
|
* One must be running (->on_cpu == 1) in order to remove oneself
|
|
* from the runqueue.
|
|
*
|
|
* __schedule() (switch to task 'p') try_to_wake_up()
|
|
* STORE p->on_cpu = 1 LOAD p->on_rq
|
|
* UNLOCK rq->lock
|
|
*
|
|
* __schedule() (put 'p' to sleep)
|
|
* LOCK rq->lock smp_rmb();
|
|
* smp_mb__after_spinlock();
|
|
* STORE p->on_rq = 0 LOAD p->on_cpu
|
|
*
|
|
* Pairs with the LOCK+smp_mb__after_spinlock() on rq->lock in
|
|
* __schedule(). See the comment for smp_mb__after_spinlock().
|
|
*
|
|
* Form a control-dep-acquire with p->on_rq == 0 above, to ensure
|
|
* schedule()'s deactivate_task() has 'happened' and p will no longer
|
|
* care about it's own p->state. See the comment in __schedule().
|
|
*/
|
|
smp_acquire__after_ctrl_dep();
|
|
|
|
/*
|
|
* We're doing the wakeup (@success == 1), they did a dequeue (p->on_rq
|
|
* == 0), which means we need to do an enqueue, change p->state to
|
|
* TASK_WAKING such that we can unlock p->pi_lock before doing the
|
|
* enqueue, such as ttwu_queue_wakelist().
|
|
*/
|
|
p->state = TASK_WAKING;
|
|
|
|
/*
|
|
* If the owning (remote) CPU is still in the middle of schedule() with
|
|
* this task as prev, considering queueing p on the remote CPUs wake_list
|
|
* which potentially sends an IPI instead of spinning on p->on_cpu to
|
|
* let the waker make forward progress. This is safe because IRQs are
|
|
* disabled and the IPI will deliver after on_cpu is cleared.
|
|
*
|
|
* Ensure we load task_cpu(p) after p->on_cpu:
|
|
*
|
|
* set_task_cpu(p, cpu);
|
|
* STORE p->cpu = @cpu
|
|
* __schedule() (switch to task 'p')
|
|
* LOCK rq->lock
|
|
* smp_mb__after_spin_lock() smp_cond_load_acquire(&p->on_cpu)
|
|
* STORE p->on_cpu = 1 LOAD p->cpu
|
|
*
|
|
* to ensure we observe the correct CPU on which the task is currently
|
|
* scheduling.
|
|
*/
|
|
if (smp_load_acquire(&p->on_cpu) &&
|
|
ttwu_queue_wakelist(p, task_cpu(p), wake_flags | WF_ON_CPU))
|
|
goto unlock;
|
|
|
|
/*
|
|
* If the owning (remote) CPU is still in the middle of schedule() with
|
|
* this task as prev, wait until its done referencing the task.
|
|
*
|
|
* Pairs with the smp_store_release() in finish_task().
|
|
*
|
|
* This ensures that tasks getting woken will be fully ordered against
|
|
* their previous state and preserve Program Order.
|
|
*/
|
|
smp_cond_load_acquire(&p->on_cpu, !VAL);
|
|
|
|
trace_android_rvh_try_to_wake_up(p);
|
|
|
|
cpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags);
|
|
if (task_cpu(p) != cpu) {
|
|
if (p->in_iowait) {
|
|
delayacct_blkio_end(p);
|
|
atomic_dec(&task_rq(p)->nr_iowait);
|
|
}
|
|
|
|
wake_flags |= WF_MIGRATED;
|
|
psi_ttwu_dequeue(p);
|
|
set_task_cpu(p, cpu);
|
|
}
|
|
#else
|
|
cpu = task_cpu(p);
|
|
#endif /* CONFIG_SMP */
|
|
|
|
ttwu_queue(p, cpu, wake_flags);
|
|
unlock:
|
|
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
|
|
out:
|
|
if (success) {
|
|
trace_android_rvh_try_to_wake_up_success(p);
|
|
ttwu_stat(p, task_cpu(p), wake_flags);
|
|
}
|
|
preempt_enable();
|
|
|
|
return success;
|
|
}
|
|
|
|
/**
|
|
* try_invoke_on_locked_down_task - Invoke a function on task in fixed state
|
|
* @p: Process for which the function is to be invoked, can be @current.
|
|
* @func: Function to invoke.
|
|
* @arg: Argument to function.
|
|
*
|
|
* If the specified task can be quickly locked into a definite state
|
|
* (either sleeping or on a given runqueue), arrange to keep it in that
|
|
* state while invoking @func(@arg). This function can use ->on_rq and
|
|
* task_curr() to work out what the state is, if required. Given that
|
|
* @func can be invoked with a runqueue lock held, it had better be quite
|
|
* lightweight.
|
|
*
|
|
* Returns:
|
|
* @false if the task slipped out from under the locks.
|
|
* @true if the task was locked onto a runqueue or is sleeping.
|
|
* However, @func can override this by returning @false.
|
|
*/
|
|
bool try_invoke_on_locked_down_task(struct task_struct *p, bool (*func)(struct task_struct *t, void *arg), void *arg)
|
|
{
|
|
struct rq_flags rf;
|
|
bool ret = false;
|
|
struct rq *rq;
|
|
|
|
raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
|
|
if (p->on_rq) {
|
|
rq = __task_rq_lock(p, &rf);
|
|
if (task_rq(p) == rq)
|
|
ret = func(p, arg);
|
|
rq_unlock(rq, &rf);
|
|
} else {
|
|
switch (p->state) {
|
|
case TASK_RUNNING:
|
|
case TASK_WAKING:
|
|
break;
|
|
default:
|
|
smp_rmb(); // See smp_rmb() comment in try_to_wake_up().
|
|
if (!p->on_rq)
|
|
ret = func(p, arg);
|
|
}
|
|
}
|
|
raw_spin_unlock_irqrestore(&p->pi_lock, rf.flags);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* wake_up_process - Wake up a specific process
|
|
* @p: The process to be woken up.
|
|
*
|
|
* Attempt to wake up the nominated process and move it to the set of runnable
|
|
* processes.
|
|
*
|
|
* Return: 1 if the process was woken up, 0 if it was already running.
|
|
*
|
|
* This function executes a full memory barrier before accessing the task state.
|
|
*/
|
|
int wake_up_process(struct task_struct *p)
|
|
{
|
|
return try_to_wake_up(p, TASK_NORMAL, 0);
|
|
}
|
|
EXPORT_SYMBOL(wake_up_process);
|
|
|
|
int wake_up_state(struct task_struct *p, unsigned int state)
|
|
{
|
|
return try_to_wake_up(p, state, 0);
|
|
}
|
|
|
|
/*
|
|
* Perform scheduler related setup for a newly forked process p.
|
|
* p is forked by current.
|
|
*
|
|
* __sched_fork() is basic setup used by init_idle() too:
|
|
*/
|
|
static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
|
|
{
|
|
p->on_rq = 0;
|
|
|
|
p->se.on_rq = 0;
|
|
p->se.exec_start = 0;
|
|
p->se.sum_exec_runtime = 0;
|
|
p->se.prev_sum_exec_runtime = 0;
|
|
p->se.nr_migrations = 0;
|
|
p->se.vruntime = 0;
|
|
INIT_LIST_HEAD(&p->se.group_node);
|
|
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
p->se.cfs_rq = NULL;
|
|
#endif
|
|
|
|
trace_android_rvh_sched_fork_init(p);
|
|
|
|
#ifdef CONFIG_SCHEDSTATS
|
|
/* Even if schedstat is disabled, there should not be garbage */
|
|
memset(&p->se.statistics, 0, sizeof(p->se.statistics));
|
|
#endif
|
|
|
|
RB_CLEAR_NODE(&p->dl.rb_node);
|
|
init_dl_task_timer(&p->dl);
|
|
init_dl_inactive_task_timer(&p->dl);
|
|
__dl_clear_params(p);
|
|
|
|
INIT_LIST_HEAD(&p->rt.run_list);
|
|
p->rt.timeout = 0;
|
|
p->rt.time_slice = sched_rr_timeslice;
|
|
p->rt.on_rq = 0;
|
|
p->rt.on_list = 0;
|
|
|
|
#ifdef CONFIG_PREEMPT_NOTIFIERS
|
|
INIT_HLIST_HEAD(&p->preempt_notifiers);
|
|
#endif
|
|
|
|
#ifdef CONFIG_COMPACTION
|
|
p->capture_control = NULL;
|
|
#endif
|
|
init_numa_balancing(clone_flags, p);
|
|
#ifdef CONFIG_SMP
|
|
p->wake_entry.u_flags = CSD_TYPE_TTWU;
|
|
#endif
|
|
}
|
|
|
|
DEFINE_STATIC_KEY_FALSE(sched_numa_balancing);
|
|
|
|
#ifdef CONFIG_NUMA_BALANCING
|
|
|
|
void set_numabalancing_state(bool enabled)
|
|
{
|
|
if (enabled)
|
|
static_branch_enable(&sched_numa_balancing);
|
|
else
|
|
static_branch_disable(&sched_numa_balancing);
|
|
}
|
|
|
|
#ifdef CONFIG_PROC_SYSCTL
|
|
int sysctl_numa_balancing(struct ctl_table *table, int write,
|
|
void *buffer, size_t *lenp, loff_t *ppos)
|
|
{
|
|
struct ctl_table t;
|
|
int err;
|
|
int state = static_branch_likely(&sched_numa_balancing);
|
|
|
|
if (write && !capable(CAP_SYS_ADMIN))
|
|
return -EPERM;
|
|
|
|
t = *table;
|
|
t.data = &state;
|
|
err = proc_dointvec_minmax(&t, write, buffer, lenp, ppos);
|
|
if (err < 0)
|
|
return err;
|
|
if (write)
|
|
set_numabalancing_state(state);
|
|
return err;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef CONFIG_SCHEDSTATS
|
|
|
|
DEFINE_STATIC_KEY_FALSE(sched_schedstats);
|
|
static bool __initdata __sched_schedstats = false;
|
|
|
|
static void set_schedstats(bool enabled)
|
|
{
|
|
if (enabled)
|
|
static_branch_enable(&sched_schedstats);
|
|
else
|
|
static_branch_disable(&sched_schedstats);
|
|
}
|
|
|
|
void force_schedstat_enabled(void)
|
|
{
|
|
if (!schedstat_enabled()) {
|
|
pr_info("kernel profiling enabled schedstats, disable via kernel.sched_schedstats.\n");
|
|
static_branch_enable(&sched_schedstats);
|
|
}
|
|
}
|
|
|
|
static int __init setup_schedstats(char *str)
|
|
{
|
|
int ret = 0;
|
|
if (!str)
|
|
goto out;
|
|
|
|
/*
|
|
* This code is called before jump labels have been set up, so we can't
|
|
* change the static branch directly just yet. Instead set a temporary
|
|
* variable so init_schedstats() can do it later.
|
|
*/
|
|
if (!strcmp(str, "enable")) {
|
|
__sched_schedstats = true;
|
|
ret = 1;
|
|
} else if (!strcmp(str, "disable")) {
|
|
__sched_schedstats = false;
|
|
ret = 1;
|
|
}
|
|
out:
|
|
if (!ret)
|
|
pr_warn("Unable to parse schedstats=\n");
|
|
|
|
return ret;
|
|
}
|
|
__setup("schedstats=", setup_schedstats);
|
|
|
|
static void __init init_schedstats(void)
|
|
{
|
|
set_schedstats(__sched_schedstats);
|
|
}
|
|
|
|
#ifdef CONFIG_PROC_SYSCTL
|
|
int sysctl_schedstats(struct ctl_table *table, int write, void *buffer,
|
|
size_t *lenp, loff_t *ppos)
|
|
{
|
|
struct ctl_table t;
|
|
int err;
|
|
int state = static_branch_likely(&sched_schedstats);
|
|
|
|
if (write && !capable(CAP_SYS_ADMIN))
|
|
return -EPERM;
|
|
|
|
t = *table;
|
|
t.data = &state;
|
|
err = proc_dointvec_minmax(&t, write, buffer, lenp, ppos);
|
|
if (err < 0)
|
|
return err;
|
|
if (write)
|
|
set_schedstats(state);
|
|
return err;
|
|
}
|
|
#endif /* CONFIG_PROC_SYSCTL */
|
|
#else /* !CONFIG_SCHEDSTATS */
|
|
static inline void init_schedstats(void) {}
|
|
#endif /* CONFIG_SCHEDSTATS */
|
|
|
|
/*
|
|
* fork()/clone()-time setup:
|
|
*/
|
|
int sched_fork(unsigned long clone_flags, struct task_struct *p)
|
|
{
|
|
trace_android_rvh_sched_fork(p);
|
|
|
|
__sched_fork(clone_flags, p);
|
|
/*
|
|
* We mark the process as NEW here. This guarantees that
|
|
* nobody will actually run it, and a signal or other external
|
|
* event cannot wake it up and insert it on the runqueue either.
|
|
*/
|
|
p->state = TASK_NEW;
|
|
|
|
/*
|
|
* Make sure we do not leak PI boosting priority to the child.
|
|
*/
|
|
p->prio = current->normal_prio;
|
|
trace_android_rvh_prepare_prio_fork(p);
|
|
|
|
uclamp_fork(p);
|
|
|
|
/*
|
|
* Revert to default priority/policy on fork if requested.
|
|
*/
|
|
if (unlikely(p->sched_reset_on_fork)) {
|
|
if (task_has_dl_policy(p) || task_has_rt_policy(p)) {
|
|
p->policy = SCHED_NORMAL;
|
|
p->static_prio = NICE_TO_PRIO(0);
|
|
p->rt_priority = 0;
|
|
} else if (PRIO_TO_NICE(p->static_prio) < 0)
|
|
p->static_prio = NICE_TO_PRIO(0);
|
|
|
|
p->prio = p->normal_prio = p->static_prio;
|
|
set_load_weight(p, false);
|
|
|
|
/*
|
|
* We don't need the reset flag anymore after the fork. It has
|
|
* fulfilled its duty:
|
|
*/
|
|
p->sched_reset_on_fork = 0;
|
|
}
|
|
|
|
if (dl_prio(p->prio))
|
|
return -EAGAIN;
|
|
else if (rt_prio(p->prio))
|
|
p->sched_class = &rt_sched_class;
|
|
else
|
|
p->sched_class = &fair_sched_class;
|
|
|
|
init_entity_runnable_average(&p->se);
|
|
trace_android_rvh_finish_prio_fork(p);
|
|
|
|
|
|
#ifdef CONFIG_SCHED_INFO
|
|
if (likely(sched_info_on()))
|
|
memset(&p->sched_info, 0, sizeof(p->sched_info));
|
|
#endif
|
|
#if defined(CONFIG_SMP)
|
|
p->on_cpu = 0;
|
|
#endif
|
|
init_task_preempt_count(p);
|
|
#ifdef CONFIG_SMP
|
|
plist_node_init(&p->pushable_tasks, MAX_PRIO);
|
|
RB_CLEAR_NODE(&p->pushable_dl_tasks);
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
void sched_cgroup_fork(struct task_struct *p, struct kernel_clone_args *kargs)
|
|
{
|
|
unsigned long flags;
|
|
|
|
/*
|
|
* Because we're not yet on the pid-hash, p->pi_lock isn't strictly
|
|
* required yet, but lockdep gets upset if rules are violated.
|
|
*/
|
|
raw_spin_lock_irqsave(&p->pi_lock, flags);
|
|
#ifdef CONFIG_CGROUP_SCHED
|
|
if (1) {
|
|
struct task_group *tg;
|
|
|
|
tg = container_of(kargs->cset->subsys[cpu_cgrp_id],
|
|
struct task_group, css);
|
|
tg = autogroup_task_group(p, tg);
|
|
p->sched_task_group = tg;
|
|
}
|
|
#endif
|
|
rseq_migrate(p);
|
|
/*
|
|
* We're setting the CPU for the first time, we don't migrate,
|
|
* so use __set_task_cpu().
|
|
*/
|
|
__set_task_cpu(p, smp_processor_id());
|
|
if (p->sched_class->task_fork)
|
|
p->sched_class->task_fork(p);
|
|
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
|
|
}
|
|
|
|
void sched_post_fork(struct task_struct *p)
|
|
{
|
|
uclamp_post_fork(p);
|
|
}
|
|
|
|
unsigned long to_ratio(u64 period, u64 runtime)
|
|
{
|
|
if (runtime == RUNTIME_INF)
|
|
return BW_UNIT;
|
|
|
|
/*
|
|
* Doing this here saves a lot of checks in all
|
|
* the calling paths, and returning zero seems
|
|
* safe for them anyway.
|
|
*/
|
|
if (period == 0)
|
|
return 0;
|
|
|
|
return div64_u64(runtime << BW_SHIFT, period);
|
|
}
|
|
|
|
/*
|
|
* wake_up_new_task - wake up a newly created task for the first time.
|
|
*
|
|
* This function will do some initial scheduler statistics housekeeping
|
|
* that must be done for every newly created context, then puts the task
|
|
* on the runqueue and wakes it.
|
|
*/
|
|
void wake_up_new_task(struct task_struct *p)
|
|
{
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
trace_android_rvh_wake_up_new_task(p);
|
|
|
|
raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
|
|
p->state = TASK_RUNNING;
|
|
#ifdef CONFIG_SMP
|
|
/*
|
|
* Fork balancing, do it here and not earlier because:
|
|
* - cpus_ptr can change in the fork path
|
|
* - any previously selected CPU might disappear through hotplug
|
|
*
|
|
* Use __set_task_cpu() to avoid calling sched_class::migrate_task_rq,
|
|
* as we're not fully set-up yet.
|
|
*/
|
|
p->recent_used_cpu = task_cpu(p);
|
|
rseq_migrate(p);
|
|
__set_task_cpu(p, select_task_rq(p, task_cpu(p), SD_BALANCE_FORK, 0));
|
|
#endif
|
|
rq = __task_rq_lock(p, &rf);
|
|
update_rq_clock(rq);
|
|
post_init_entity_util_avg(p);
|
|
trace_android_rvh_new_task_stats(p);
|
|
|
|
activate_task(rq, p, ENQUEUE_NOCLOCK);
|
|
trace_sched_wakeup_new(p);
|
|
check_preempt_curr(rq, p, WF_FORK);
|
|
#ifdef CONFIG_SMP
|
|
if (p->sched_class->task_woken) {
|
|
/*
|
|
* Nothing relies on rq->lock after this, so its fine to
|
|
* drop it.
|
|
*/
|
|
rq_unpin_lock(rq, &rf);
|
|
p->sched_class->task_woken(rq, p);
|
|
rq_repin_lock(rq, &rf);
|
|
}
|
|
#endif
|
|
task_rq_unlock(rq, p, &rf);
|
|
}
|
|
|
|
#ifdef CONFIG_PREEMPT_NOTIFIERS
|
|
|
|
static DEFINE_STATIC_KEY_FALSE(preempt_notifier_key);
|
|
|
|
void preempt_notifier_inc(void)
|
|
{
|
|
static_branch_inc(&preempt_notifier_key);
|
|
}
|
|
EXPORT_SYMBOL_GPL(preempt_notifier_inc);
|
|
|
|
void preempt_notifier_dec(void)
|
|
{
|
|
static_branch_dec(&preempt_notifier_key);
|
|
}
|
|
EXPORT_SYMBOL_GPL(preempt_notifier_dec);
|
|
|
|
/**
|
|
* preempt_notifier_register - tell me when current is being preempted & rescheduled
|
|
* @notifier: notifier struct to register
|
|
*/
|
|
void preempt_notifier_register(struct preempt_notifier *notifier)
|
|
{
|
|
if (!static_branch_unlikely(&preempt_notifier_key))
|
|
WARN(1, "registering preempt_notifier while notifiers disabled\n");
|
|
|
|
hlist_add_head(¬ifier->link, ¤t->preempt_notifiers);
|
|
}
|
|
EXPORT_SYMBOL_GPL(preempt_notifier_register);
|
|
|
|
/**
|
|
* preempt_notifier_unregister - no longer interested in preemption notifications
|
|
* @notifier: notifier struct to unregister
|
|
*
|
|
* This is *not* safe to call from within a preemption notifier.
|
|
*/
|
|
void preempt_notifier_unregister(struct preempt_notifier *notifier)
|
|
{
|
|
hlist_del(¬ifier->link);
|
|
}
|
|
EXPORT_SYMBOL_GPL(preempt_notifier_unregister);
|
|
|
|
static void __fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
{
|
|
struct preempt_notifier *notifier;
|
|
|
|
hlist_for_each_entry(notifier, &curr->preempt_notifiers, link)
|
|
notifier->ops->sched_in(notifier, raw_smp_processor_id());
|
|
}
|
|
|
|
static __always_inline void fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
{
|
|
if (static_branch_unlikely(&preempt_notifier_key))
|
|
__fire_sched_in_preempt_notifiers(curr);
|
|
}
|
|
|
|
static void
|
|
__fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|
struct task_struct *next)
|
|
{
|
|
struct preempt_notifier *notifier;
|
|
|
|
hlist_for_each_entry(notifier, &curr->preempt_notifiers, link)
|
|
notifier->ops->sched_out(notifier, next);
|
|
}
|
|
|
|
static __always_inline void
|
|
fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|
struct task_struct *next)
|
|
{
|
|
if (static_branch_unlikely(&preempt_notifier_key))
|
|
__fire_sched_out_preempt_notifiers(curr, next);
|
|
}
|
|
|
|
#else /* !CONFIG_PREEMPT_NOTIFIERS */
|
|
|
|
static inline void fire_sched_in_preempt_notifiers(struct task_struct *curr)
|
|
{
|
|
}
|
|
|
|
static inline void
|
|
fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|
struct task_struct *next)
|
|
{
|
|
}
|
|
|
|
#endif /* CONFIG_PREEMPT_NOTIFIERS */
|
|
|
|
static inline void prepare_task(struct task_struct *next)
|
|
{
|
|
#ifdef CONFIG_SMP
|
|
/*
|
|
* Claim the task as running, we do this before switching to it
|
|
* such that any running task will have this set.
|
|
*
|
|
* See the ttwu() WF_ON_CPU case and its ordering comment.
|
|
*/
|
|
WRITE_ONCE(next->on_cpu, 1);
|
|
#endif
|
|
}
|
|
|
|
static inline void finish_task(struct task_struct *prev)
|
|
{
|
|
#ifdef CONFIG_SMP
|
|
/*
|
|
* This must be the very last reference to @prev from this CPU. After
|
|
* p->on_cpu is cleared, the task can be moved to a different CPU. We
|
|
* must ensure this doesn't happen until the switch is completely
|
|
* finished.
|
|
*
|
|
* In particular, the load of prev->state in finish_task_switch() must
|
|
* happen before this.
|
|
*
|
|
* Pairs with the smp_cond_load_acquire() in try_to_wake_up().
|
|
*/
|
|
smp_store_release(&prev->on_cpu, 0);
|
|
#endif
|
|
}
|
|
|
|
static inline void
|
|
prepare_lock_switch(struct rq *rq, struct task_struct *next, struct rq_flags *rf)
|
|
{
|
|
/*
|
|
* Since the runqueue lock will be released by the next
|
|
* task (which is an invalid locking op but in the case
|
|
* of the scheduler it's an obvious special-case), so we
|
|
* do an early lockdep release here:
|
|
*/
|
|
rq_unpin_lock(rq, rf);
|
|
spin_release(&rq->lock.dep_map, _THIS_IP_);
|
|
#ifdef CONFIG_DEBUG_SPINLOCK
|
|
/* this is a valid case when another task releases the spinlock */
|
|
rq->lock.owner = next;
|
|
#endif
|
|
}
|
|
|
|
static inline void finish_lock_switch(struct rq *rq)
|
|
{
|
|
/*
|
|
* If we are tracking spinlock dependencies then we have to
|
|
* fix up the runqueue lock - which gets 'carried over' from
|
|
* prev into current:
|
|
*/
|
|
spin_acquire(&rq->lock.dep_map, 0, 0, _THIS_IP_);
|
|
raw_spin_unlock_irq(&rq->lock);
|
|
}
|
|
|
|
/*
|
|
* NOP if the arch has not defined these:
|
|
*/
|
|
|
|
#ifndef prepare_arch_switch
|
|
# define prepare_arch_switch(next) do { } while (0)
|
|
#endif
|
|
|
|
#ifndef finish_arch_post_lock_switch
|
|
# define finish_arch_post_lock_switch() do { } while (0)
|
|
#endif
|
|
|
|
/**
|
|
* prepare_task_switch - prepare to switch tasks
|
|
* @rq: the runqueue preparing to switch
|
|
* @prev: the current task that is being switched out
|
|
* @next: the task we are going to switch to.
|
|
*
|
|
* This is called with the rq lock held and interrupts off. It must
|
|
* be paired with a subsequent finish_task_switch after the context
|
|
* switch.
|
|
*
|
|
* prepare_task_switch sets up locking and calls architecture specific
|
|
* hooks.
|
|
*/
|
|
static inline void
|
|
prepare_task_switch(struct rq *rq, struct task_struct *prev,
|
|
struct task_struct *next)
|
|
{
|
|
kcov_prepare_switch(prev);
|
|
sched_info_switch(rq, prev, next);
|
|
perf_event_task_sched_out(prev, next);
|
|
rseq_preempt(prev);
|
|
fire_sched_out_preempt_notifiers(prev, next);
|
|
prepare_task(next);
|
|
prepare_arch_switch(next);
|
|
}
|
|
|
|
/**
|
|
* finish_task_switch - clean up after a task-switch
|
|
* @prev: the thread we just switched away from.
|
|
*
|
|
* finish_task_switch must be called after the context switch, paired
|
|
* with a prepare_task_switch call before the context switch.
|
|
* finish_task_switch will reconcile locking set up by prepare_task_switch,
|
|
* and do any other architecture-specific cleanup actions.
|
|
*
|
|
* Note that we may have delayed dropping an mm in context_switch(). If
|
|
* so, we finish that here outside of the runqueue lock. (Doing it
|
|
* with the lock held can cause deadlocks; see schedule() for
|
|
* details.)
|
|
*
|
|
* The context switch have flipped the stack from under us and restored the
|
|
* local variables which were saved when this task called schedule() in the
|
|
* past. prev == current is still correct but we need to recalculate this_rq
|
|
* because prev may have moved to another CPU.
|
|
*/
|
|
static struct rq *finish_task_switch(struct task_struct *prev)
|
|
__releases(rq->lock)
|
|
{
|
|
struct rq *rq = this_rq();
|
|
struct mm_struct *mm = rq->prev_mm;
|
|
long prev_state;
|
|
|
|
/*
|
|
* The previous task will have left us with a preempt_count of 2
|
|
* because it left us after:
|
|
*
|
|
* schedule()
|
|
* preempt_disable(); // 1
|
|
* __schedule()
|
|
* raw_spin_lock_irq(&rq->lock) // 2
|
|
*
|
|
* Also, see FORK_PREEMPT_COUNT.
|
|
*/
|
|
if (WARN_ONCE(preempt_count() != 2*PREEMPT_DISABLE_OFFSET,
|
|
"corrupted preempt_count: %s/%d/0x%x\n",
|
|
current->comm, current->pid, preempt_count()))
|
|
preempt_count_set(FORK_PREEMPT_COUNT);
|
|
|
|
rq->prev_mm = NULL;
|
|
|
|
/*
|
|
* A task struct has one reference for the use as "current".
|
|
* If a task dies, then it sets TASK_DEAD in tsk->state and calls
|
|
* schedule one last time. The schedule call will never return, and
|
|
* the scheduled task must drop that reference.
|
|
*
|
|
* We must observe prev->state before clearing prev->on_cpu (in
|
|
* finish_task), otherwise a concurrent wakeup can get prev
|
|
* running on another CPU and we could rave with its RUNNING -> DEAD
|
|
* transition, resulting in a double drop.
|
|
*/
|
|
prev_state = prev->state;
|
|
vtime_task_switch(prev);
|
|
perf_event_task_sched_in(prev, current);
|
|
finish_task(prev);
|
|
finish_lock_switch(rq);
|
|
finish_arch_post_lock_switch();
|
|
kcov_finish_switch(current);
|
|
|
|
fire_sched_in_preempt_notifiers(current);
|
|
/*
|
|
* When switching through a kernel thread, the loop in
|
|
* membarrier_{private,global}_expedited() may have observed that
|
|
* kernel thread and not issued an IPI. It is therefore possible to
|
|
* schedule between user->kernel->user threads without passing though
|
|
* switch_mm(). Membarrier requires a barrier after storing to
|
|
* rq->curr, before returning to userspace, so provide them here:
|
|
*
|
|
* - a full memory barrier for {PRIVATE,GLOBAL}_EXPEDITED, implicitly
|
|
* provided by mmdrop(),
|
|
* - a sync_core for SYNC_CORE.
|
|
*/
|
|
if (mm) {
|
|
membarrier_mm_sync_core_before_usermode(mm);
|
|
mmdrop(mm);
|
|
}
|
|
if (unlikely(prev_state == TASK_DEAD)) {
|
|
if (prev->sched_class->task_dead)
|
|
prev->sched_class->task_dead(prev);
|
|
|
|
/*
|
|
* Remove function-return probe instances associated with this
|
|
* task and put them back on the free list.
|
|
*/
|
|
kprobe_flush_task(prev);
|
|
trace_android_rvh_flush_task(prev);
|
|
|
|
/* Task is done with its stack. */
|
|
put_task_stack(prev);
|
|
|
|
put_task_struct_rcu_user(prev);
|
|
}
|
|
|
|
tick_nohz_task_switch();
|
|
return rq;
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* rq->lock is NOT held, but preemption is disabled */
|
|
static void __balance_callback(struct rq *rq)
|
|
{
|
|
struct callback_head *head, *next;
|
|
void (*func)(struct rq *rq);
|
|
unsigned long flags;
|
|
|
|
raw_spin_lock_irqsave(&rq->lock, flags);
|
|
head = rq->balance_callback;
|
|
rq->balance_callback = NULL;
|
|
while (head) {
|
|
func = (void (*)(struct rq *))head->func;
|
|
next = head->next;
|
|
head->next = NULL;
|
|
head = next;
|
|
|
|
func(rq);
|
|
}
|
|
raw_spin_unlock_irqrestore(&rq->lock, flags);
|
|
}
|
|
|
|
static inline void balance_callback(struct rq *rq)
|
|
{
|
|
if (unlikely(rq->balance_callback))
|
|
__balance_callback(rq);
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void balance_callback(struct rq *rq)
|
|
{
|
|
}
|
|
|
|
#endif
|
|
|
|
/**
|
|
* schedule_tail - first thing a freshly forked thread must call.
|
|
* @prev: the thread we just switched away from.
|
|
*/
|
|
asmlinkage __visible void schedule_tail(struct task_struct *prev)
|
|
__releases(rq->lock)
|
|
{
|
|
struct rq *rq;
|
|
|
|
/*
|
|
* New tasks start with FORK_PREEMPT_COUNT, see there and
|
|
* finish_task_switch() for details.
|
|
*
|
|
* finish_task_switch() will drop rq->lock() and lower preempt_count
|
|
* and the preempt_enable() will end up enabling preemption (on
|
|
* PREEMPT_COUNT kernels).
|
|
*/
|
|
|
|
rq = finish_task_switch(prev);
|
|
balance_callback(rq);
|
|
preempt_enable();
|
|
|
|
if (current->set_child_tid)
|
|
put_user(task_pid_vnr(current), current->set_child_tid);
|
|
|
|
calculate_sigpending();
|
|
}
|
|
|
|
/*
|
|
* context_switch - switch to the new MM and the new thread's register state.
|
|
*/
|
|
static __always_inline struct rq *
|
|
context_switch(struct rq *rq, struct task_struct *prev,
|
|
struct task_struct *next, struct rq_flags *rf)
|
|
{
|
|
prepare_task_switch(rq, prev, next);
|
|
|
|
/*
|
|
* For paravirt, this is coupled with an exit in switch_to to
|
|
* combine the page table reload and the switch backend into
|
|
* one hypercall.
|
|
*/
|
|
arch_start_context_switch(prev);
|
|
|
|
/*
|
|
* kernel -> kernel lazy + transfer active
|
|
* user -> kernel lazy + mmgrab() active
|
|
*
|
|
* kernel -> user switch + mmdrop() active
|
|
* user -> user switch
|
|
*/
|
|
if (!next->mm) { // to kernel
|
|
enter_lazy_tlb(prev->active_mm, next);
|
|
|
|
next->active_mm = prev->active_mm;
|
|
if (prev->mm) // from user
|
|
mmgrab(prev->active_mm);
|
|
else
|
|
prev->active_mm = NULL;
|
|
} else { // to user
|
|
membarrier_switch_mm(rq, prev->active_mm, next->mm);
|
|
/*
|
|
* sys_membarrier() requires an smp_mb() between setting
|
|
* rq->curr / membarrier_switch_mm() and returning to userspace.
|
|
*
|
|
* The below provides this either through switch_mm(), or in
|
|
* case 'prev->active_mm == next->mm' through
|
|
* finish_task_switch()'s mmdrop().
|
|
*/
|
|
switch_mm_irqs_off(prev->active_mm, next->mm, next);
|
|
|
|
if (!prev->mm) { // from kernel
|
|
/* will mmdrop() in finish_task_switch(). */
|
|
rq->prev_mm = prev->active_mm;
|
|
prev->active_mm = NULL;
|
|
}
|
|
}
|
|
|
|
rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
|
|
|
|
prepare_lock_switch(rq, next, rf);
|
|
|
|
/* Here we just switch the register state and the stack. */
|
|
switch_to(prev, next, prev);
|
|
barrier();
|
|
|
|
return finish_task_switch(prev);
|
|
}
|
|
|
|
/*
|
|
* nr_running and nr_context_switches:
|
|
*
|
|
* externally visible scheduler statistics: current number of runnable
|
|
* threads, total number of context switches performed since bootup.
|
|
*/
|
|
unsigned long nr_running(void)
|
|
{
|
|
unsigned long i, sum = 0;
|
|
|
|
for_each_online_cpu(i)
|
|
sum += cpu_rq(i)->nr_running;
|
|
|
|
return sum;
|
|
}
|
|
|
|
/*
|
|
* Check if only the current task is running on the CPU.
|
|
*
|
|
* Caution: this function does not check that the caller has disabled
|
|
* preemption, thus the result might have a time-of-check-to-time-of-use
|
|
* race. The caller is responsible to use it correctly, for example:
|
|
*
|
|
* - from a non-preemptible section (of course)
|
|
*
|
|
* - from a thread that is bound to a single CPU
|
|
*
|
|
* - in a loop with very short iterations (e.g. a polling loop)
|
|
*/
|
|
bool single_task_running(void)
|
|
{
|
|
return raw_rq()->nr_running == 1;
|
|
}
|
|
EXPORT_SYMBOL(single_task_running);
|
|
|
|
unsigned long long nr_context_switches(void)
|
|
{
|
|
int i;
|
|
unsigned long long sum = 0;
|
|
|
|
for_each_possible_cpu(i)
|
|
sum += cpu_rq(i)->nr_switches;
|
|
|
|
return sum;
|
|
}
|
|
|
|
/*
|
|
* Consumers of these two interfaces, like for example the cpuidle menu
|
|
* governor, are using nonsensical data. Preferring shallow idle state selection
|
|
* for a CPU that has IO-wait which might not even end up running the task when
|
|
* it does become runnable.
|
|
*/
|
|
|
|
unsigned long nr_iowait_cpu(int cpu)
|
|
{
|
|
return atomic_read(&cpu_rq(cpu)->nr_iowait);
|
|
}
|
|
|
|
/*
|
|
* IO-wait accounting, and how its mostly bollocks (on SMP).
|
|
*
|
|
* The idea behind IO-wait account is to account the idle time that we could
|
|
* have spend running if it were not for IO. That is, if we were to improve the
|
|
* storage performance, we'd have a proportional reduction in IO-wait time.
|
|
*
|
|
* This all works nicely on UP, where, when a task blocks on IO, we account
|
|
* idle time as IO-wait, because if the storage were faster, it could've been
|
|
* running and we'd not be idle.
|
|
*
|
|
* This has been extended to SMP, by doing the same for each CPU. This however
|
|
* is broken.
|
|
*
|
|
* Imagine for instance the case where two tasks block on one CPU, only the one
|
|
* CPU will have IO-wait accounted, while the other has regular idle. Even
|
|
* though, if the storage were faster, both could've ran at the same time,
|
|
* utilising both CPUs.
|
|
*
|
|
* This means, that when looking globally, the current IO-wait accounting on
|
|
* SMP is a lower bound, by reason of under accounting.
|
|
*
|
|
* Worse, since the numbers are provided per CPU, they are sometimes
|
|
* interpreted per CPU, and that is nonsensical. A blocked task isn't strictly
|
|
* associated with any one particular CPU, it can wake to another CPU than it
|
|
* blocked on. This means the per CPU IO-wait number is meaningless.
|
|
*
|
|
* Task CPU affinities can make all that even more 'interesting'.
|
|
*/
|
|
|
|
unsigned long nr_iowait(void)
|
|
{
|
|
unsigned long i, sum = 0;
|
|
|
|
for_each_possible_cpu(i)
|
|
sum += nr_iowait_cpu(i);
|
|
|
|
return sum;
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/*
|
|
* sched_exec - execve() is a valuable balancing opportunity, because at
|
|
* this point the task has the smallest effective memory and cache footprint.
|
|
*/
|
|
void sched_exec(void)
|
|
{
|
|
struct task_struct *p = current;
|
|
unsigned long flags;
|
|
int dest_cpu;
|
|
bool cond = false;
|
|
|
|
trace_android_rvh_sched_exec(&cond);
|
|
if (cond)
|
|
return;
|
|
|
|
raw_spin_lock_irqsave(&p->pi_lock, flags);
|
|
dest_cpu = p->sched_class->select_task_rq(p, task_cpu(p), SD_BALANCE_EXEC, 0);
|
|
if (dest_cpu == smp_processor_id())
|
|
goto unlock;
|
|
|
|
if (likely(cpu_active(dest_cpu))) {
|
|
struct migration_arg arg = { p, dest_cpu };
|
|
|
|
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
|
|
stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg);
|
|
return;
|
|
}
|
|
unlock:
|
|
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
|
|
}
|
|
|
|
#endif
|
|
|
|
DEFINE_PER_CPU(struct kernel_stat, kstat);
|
|
DEFINE_PER_CPU(struct kernel_cpustat, kernel_cpustat);
|
|
|
|
EXPORT_PER_CPU_SYMBOL(kstat);
|
|
EXPORT_PER_CPU_SYMBOL(kernel_cpustat);
|
|
|
|
/*
|
|
* The function fair_sched_class.update_curr accesses the struct curr
|
|
* and its field curr->exec_start; when called from task_sched_runtime(),
|
|
* we observe a high rate of cache misses in practice.
|
|
* Prefetching this data results in improved performance.
|
|
*/
|
|
static inline void prefetch_curr_exec_start(struct task_struct *p)
|
|
{
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
struct sched_entity *curr = (&p->se)->cfs_rq->curr;
|
|
#else
|
|
struct sched_entity *curr = (&task_rq(p)->cfs)->curr;
|
|
#endif
|
|
prefetch(curr);
|
|
prefetch(&curr->exec_start);
|
|
}
|
|
|
|
/*
|
|
* Return accounted runtime for the task.
|
|
* In case the task is currently running, return the runtime plus current's
|
|
* pending runtime that have not been accounted yet.
|
|
*/
|
|
unsigned long long task_sched_runtime(struct task_struct *p)
|
|
{
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
u64 ns;
|
|
|
|
#if defined(CONFIG_64BIT) && defined(CONFIG_SMP)
|
|
/*
|
|
* 64-bit doesn't need locks to atomically read a 64-bit value.
|
|
* So we have a optimization chance when the task's delta_exec is 0.
|
|
* Reading ->on_cpu is racy, but this is ok.
|
|
*
|
|
* If we race with it leaving CPU, we'll take a lock. So we're correct.
|
|
* If we race with it entering CPU, unaccounted time is 0. This is
|
|
* indistinguishable from the read occurring a few cycles earlier.
|
|
* If we see ->on_cpu without ->on_rq, the task is leaving, and has
|
|
* been accounted, so we're correct here as well.
|
|
*/
|
|
if (!p->on_cpu || !task_on_rq_queued(p))
|
|
return p->se.sum_exec_runtime;
|
|
#endif
|
|
|
|
rq = task_rq_lock(p, &rf);
|
|
/*
|
|
* Must be ->curr _and_ ->on_rq. If dequeued, we would
|
|
* project cycles that may never be accounted to this
|
|
* thread, breaking clock_gettime().
|
|
*/
|
|
if (task_current(rq, p) && task_on_rq_queued(p)) {
|
|
prefetch_curr_exec_start(p);
|
|
update_rq_clock(rq);
|
|
p->sched_class->update_curr(rq);
|
|
}
|
|
ns = p->se.sum_exec_runtime;
|
|
task_rq_unlock(rq, p, &rf);
|
|
|
|
return ns;
|
|
}
|
|
EXPORT_SYMBOL_GPL(task_sched_runtime);
|
|
|
|
/*
|
|
* This function gets called by the timer code, with HZ frequency.
|
|
* We call it with interrupts disabled.
|
|
*/
|
|
void scheduler_tick(void)
|
|
{
|
|
int cpu = smp_processor_id();
|
|
struct rq *rq = cpu_rq(cpu);
|
|
struct task_struct *curr = rq->curr;
|
|
struct rq_flags rf;
|
|
unsigned long thermal_pressure;
|
|
|
|
arch_scale_freq_tick();
|
|
sched_clock_tick();
|
|
|
|
rq_lock(rq, &rf);
|
|
|
|
trace_android_rvh_tick_entry(rq);
|
|
update_rq_clock(rq);
|
|
thermal_pressure = arch_scale_thermal_pressure(cpu_of(rq));
|
|
update_thermal_load_avg(rq_clock_thermal(rq), rq, thermal_pressure);
|
|
curr->sched_class->task_tick(rq, curr, 0);
|
|
calc_global_load_tick(rq);
|
|
psi_task_tick(rq);
|
|
|
|
rq_unlock(rq, &rf);
|
|
|
|
perf_event_task_tick();
|
|
|
|
#ifdef CONFIG_SMP
|
|
rq->idle_balance = idle_cpu(cpu);
|
|
trigger_load_balance(rq);
|
|
#endif
|
|
|
|
trace_android_vh_scheduler_tick(rq);
|
|
}
|
|
|
|
#ifdef CONFIG_NO_HZ_FULL
|
|
|
|
struct tick_work {
|
|
int cpu;
|
|
atomic_t state;
|
|
struct delayed_work work;
|
|
};
|
|
/* Values for ->state, see diagram below. */
|
|
#define TICK_SCHED_REMOTE_OFFLINE 0
|
|
#define TICK_SCHED_REMOTE_OFFLINING 1
|
|
#define TICK_SCHED_REMOTE_RUNNING 2
|
|
|
|
/*
|
|
* State diagram for ->state:
|
|
*
|
|
*
|
|
* TICK_SCHED_REMOTE_OFFLINE
|
|
* | ^
|
|
* | |
|
|
* | | sched_tick_remote()
|
|
* | |
|
|
* | |
|
|
* +--TICK_SCHED_REMOTE_OFFLINING
|
|
* | ^
|
|
* | |
|
|
* sched_tick_start() | | sched_tick_stop()
|
|
* | |
|
|
* V |
|
|
* TICK_SCHED_REMOTE_RUNNING
|
|
*
|
|
*
|
|
* Other transitions get WARN_ON_ONCE(), except that sched_tick_remote()
|
|
* and sched_tick_start() are happy to leave the state in RUNNING.
|
|
*/
|
|
|
|
static struct tick_work __percpu *tick_work_cpu;
|
|
|
|
static void sched_tick_remote(struct work_struct *work)
|
|
{
|
|
struct delayed_work *dwork = to_delayed_work(work);
|
|
struct tick_work *twork = container_of(dwork, struct tick_work, work);
|
|
int cpu = twork->cpu;
|
|
struct rq *rq = cpu_rq(cpu);
|
|
struct task_struct *curr;
|
|
struct rq_flags rf;
|
|
u64 delta;
|
|
int os;
|
|
|
|
/*
|
|
* Handle the tick only if it appears the remote CPU is running in full
|
|
* dynticks mode. The check is racy by nature, but missing a tick or
|
|
* having one too much is no big deal because the scheduler tick updates
|
|
* statistics and checks timeslices in a time-independent way, regardless
|
|
* of when exactly it is running.
|
|
*/
|
|
if (!tick_nohz_tick_stopped_cpu(cpu))
|
|
goto out_requeue;
|
|
|
|
rq_lock_irq(rq, &rf);
|
|
curr = rq->curr;
|
|
if (cpu_is_offline(cpu))
|
|
goto out_unlock;
|
|
|
|
update_rq_clock(rq);
|
|
|
|
if (!is_idle_task(curr)) {
|
|
/*
|
|
* Make sure the next tick runs within a reasonable
|
|
* amount of time.
|
|
*/
|
|
delta = rq_clock_task(rq) - curr->se.exec_start;
|
|
WARN_ON_ONCE(delta > (u64)NSEC_PER_SEC * 3);
|
|
}
|
|
curr->sched_class->task_tick(rq, curr, 0);
|
|
|
|
calc_load_nohz_remote(rq);
|
|
out_unlock:
|
|
rq_unlock_irq(rq, &rf);
|
|
out_requeue:
|
|
|
|
/*
|
|
* Run the remote tick once per second (1Hz). This arbitrary
|
|
* frequency is large enough to avoid overload but short enough
|
|
* to keep scheduler internal stats reasonably up to date. But
|
|
* first update state to reflect hotplug activity if required.
|
|
*/
|
|
os = atomic_fetch_add_unless(&twork->state, -1, TICK_SCHED_REMOTE_RUNNING);
|
|
WARN_ON_ONCE(os == TICK_SCHED_REMOTE_OFFLINE);
|
|
if (os == TICK_SCHED_REMOTE_RUNNING)
|
|
queue_delayed_work(system_unbound_wq, dwork, HZ);
|
|
}
|
|
|
|
static void sched_tick_start(int cpu)
|
|
{
|
|
int os;
|
|
struct tick_work *twork;
|
|
|
|
if (housekeeping_cpu(cpu, HK_FLAG_TICK))
|
|
return;
|
|
|
|
WARN_ON_ONCE(!tick_work_cpu);
|
|
|
|
twork = per_cpu_ptr(tick_work_cpu, cpu);
|
|
os = atomic_xchg(&twork->state, TICK_SCHED_REMOTE_RUNNING);
|
|
WARN_ON_ONCE(os == TICK_SCHED_REMOTE_RUNNING);
|
|
if (os == TICK_SCHED_REMOTE_OFFLINE) {
|
|
twork->cpu = cpu;
|
|
INIT_DELAYED_WORK(&twork->work, sched_tick_remote);
|
|
queue_delayed_work(system_unbound_wq, &twork->work, HZ);
|
|
}
|
|
}
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
static void sched_tick_stop(int cpu)
|
|
{
|
|
struct tick_work *twork;
|
|
int os;
|
|
|
|
if (housekeeping_cpu(cpu, HK_FLAG_TICK))
|
|
return;
|
|
|
|
WARN_ON_ONCE(!tick_work_cpu);
|
|
|
|
twork = per_cpu_ptr(tick_work_cpu, cpu);
|
|
/* There cannot be competing actions, but don't rely on stop-machine. */
|
|
os = atomic_xchg(&twork->state, TICK_SCHED_REMOTE_OFFLINING);
|
|
WARN_ON_ONCE(os != TICK_SCHED_REMOTE_RUNNING);
|
|
/* Don't cancel, as this would mess up the state machine. */
|
|
}
|
|
#endif /* CONFIG_HOTPLUG_CPU */
|
|
|
|
int __init sched_tick_offload_init(void)
|
|
{
|
|
tick_work_cpu = alloc_percpu(struct tick_work);
|
|
BUG_ON(!tick_work_cpu);
|
|
return 0;
|
|
}
|
|
|
|
#else /* !CONFIG_NO_HZ_FULL */
|
|
static inline void sched_tick_start(int cpu) { }
|
|
static inline void sched_tick_stop(int cpu) { }
|
|
#endif
|
|
|
|
#if defined(CONFIG_PREEMPTION) && (defined(CONFIG_DEBUG_PREEMPT) || \
|
|
defined(CONFIG_TRACE_PREEMPT_TOGGLE))
|
|
/*
|
|
* If the value passed in is equal to the current preempt count
|
|
* then we just disabled preemption. Start timing the latency.
|
|
*/
|
|
static inline void preempt_latency_start(int val)
|
|
{
|
|
if (preempt_count() == val) {
|
|
unsigned long ip = get_lock_parent_ip();
|
|
#ifdef CONFIG_DEBUG_PREEMPT
|
|
current->preempt_disable_ip = ip;
|
|
#endif
|
|
trace_preempt_off(CALLER_ADDR0, ip);
|
|
}
|
|
}
|
|
|
|
void preempt_count_add(int val)
|
|
{
|
|
#ifdef CONFIG_DEBUG_PREEMPT
|
|
/*
|
|
* Underflow?
|
|
*/
|
|
if (DEBUG_LOCKS_WARN_ON((preempt_count() < 0)))
|
|
return;
|
|
#endif
|
|
__preempt_count_add(val);
|
|
#ifdef CONFIG_DEBUG_PREEMPT
|
|
/*
|
|
* Spinlock count overflowing soon?
|
|
*/
|
|
DEBUG_LOCKS_WARN_ON((preempt_count() & PREEMPT_MASK) >=
|
|
PREEMPT_MASK - 10);
|
|
#endif
|
|
preempt_latency_start(val);
|
|
}
|
|
EXPORT_SYMBOL(preempt_count_add);
|
|
NOKPROBE_SYMBOL(preempt_count_add);
|
|
|
|
/*
|
|
* If the value passed in equals to the current preempt count
|
|
* then we just enabled preemption. Stop timing the latency.
|
|
*/
|
|
static inline void preempt_latency_stop(int val)
|
|
{
|
|
if (preempt_count() == val)
|
|
trace_preempt_on(CALLER_ADDR0, get_lock_parent_ip());
|
|
}
|
|
|
|
void preempt_count_sub(int val)
|
|
{
|
|
#ifdef CONFIG_DEBUG_PREEMPT
|
|
/*
|
|
* Underflow?
|
|
*/
|
|
if (DEBUG_LOCKS_WARN_ON(val > preempt_count()))
|
|
return;
|
|
/*
|
|
* Is the spinlock portion underflowing?
|
|
*/
|
|
if (DEBUG_LOCKS_WARN_ON((val < PREEMPT_MASK) &&
|
|
!(preempt_count() & PREEMPT_MASK)))
|
|
return;
|
|
#endif
|
|
|
|
preempt_latency_stop(val);
|
|
__preempt_count_sub(val);
|
|
}
|
|
EXPORT_SYMBOL(preempt_count_sub);
|
|
NOKPROBE_SYMBOL(preempt_count_sub);
|
|
|
|
#else
|
|
static inline void preempt_latency_start(int val) { }
|
|
static inline void preempt_latency_stop(int val) { }
|
|
#endif
|
|
|
|
static inline unsigned long get_preempt_disable_ip(struct task_struct *p)
|
|
{
|
|
#ifdef CONFIG_DEBUG_PREEMPT
|
|
return p->preempt_disable_ip;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
* Print scheduling while atomic bug:
|
|
*/
|
|
static noinline void __schedule_bug(struct task_struct *prev)
|
|
{
|
|
/* Save this before calling printk(), since that will clobber it */
|
|
unsigned long preempt_disable_ip = get_preempt_disable_ip(current);
|
|
|
|
if (oops_in_progress)
|
|
return;
|
|
|
|
printk(KERN_ERR "BUG: scheduling while atomic: %s/%d/0x%08x\n",
|
|
prev->comm, prev->pid, preempt_count());
|
|
|
|
debug_show_held_locks(prev);
|
|
print_modules();
|
|
if (irqs_disabled())
|
|
print_irqtrace_events(prev);
|
|
if (IS_ENABLED(CONFIG_DEBUG_PREEMPT)
|
|
&& in_atomic_preempt_off()) {
|
|
pr_err("Preemption disabled at:");
|
|
print_ip_sym(KERN_ERR, preempt_disable_ip);
|
|
}
|
|
if (panic_on_warn)
|
|
panic("scheduling while atomic\n");
|
|
|
|
trace_android_rvh_schedule_bug(prev);
|
|
|
|
dump_stack();
|
|
add_taint(TAINT_WARN, LOCKDEP_STILL_OK);
|
|
}
|
|
|
|
/*
|
|
* Various schedule()-time debugging checks and statistics:
|
|
*/
|
|
static inline void schedule_debug(struct task_struct *prev, bool preempt)
|
|
{
|
|
#ifdef CONFIG_SCHED_STACK_END_CHECK
|
|
if (task_stack_end_corrupted(prev))
|
|
panic("corrupted stack end detected inside scheduler\n");
|
|
|
|
if (task_scs_end_corrupted(prev))
|
|
panic("corrupted shadow stack detected inside scheduler\n");
|
|
#endif
|
|
|
|
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
|
|
if (!preempt && prev->state && prev->non_block_count) {
|
|
printk(KERN_ERR "BUG: scheduling in a non-blocking section: %s/%d/%i\n",
|
|
prev->comm, prev->pid, prev->non_block_count);
|
|
dump_stack();
|
|
add_taint(TAINT_WARN, LOCKDEP_STILL_OK);
|
|
}
|
|
#endif
|
|
|
|
if (unlikely(in_atomic_preempt_off())) {
|
|
__schedule_bug(prev);
|
|
preempt_count_set(PREEMPT_DISABLED);
|
|
}
|
|
rcu_sleep_check();
|
|
|
|
profile_hit(SCHED_PROFILING, __builtin_return_address(0));
|
|
|
|
schedstat_inc(this_rq()->sched_count);
|
|
}
|
|
|
|
static void put_prev_task_balance(struct rq *rq, struct task_struct *prev,
|
|
struct rq_flags *rf)
|
|
{
|
|
#ifdef CONFIG_SMP
|
|
const struct sched_class *class;
|
|
/*
|
|
* We must do the balancing pass before put_prev_task(), such
|
|
* that when we release the rq->lock the task is in the same
|
|
* state as before we took rq->lock.
|
|
*
|
|
* We can terminate the balance pass as soon as we know there is
|
|
* a runnable task of @class priority or higher.
|
|
*/
|
|
for_class_range(class, prev->sched_class, &idle_sched_class) {
|
|
if (class->balance(rq, prev, rf))
|
|
break;
|
|
}
|
|
#endif
|
|
|
|
put_prev_task(rq, prev);
|
|
}
|
|
|
|
/*
|
|
* Pick up the highest-prio task:
|
|
*/
|
|
static inline struct task_struct *
|
|
pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
|
|
{
|
|
const struct sched_class *class;
|
|
struct task_struct *p;
|
|
|
|
/*
|
|
* Optimization: we know that if all tasks are in the fair class we can
|
|
* call that function directly, but only if the @prev task wasn't of a
|
|
* higher scheduling class, because otherwise those loose the
|
|
* opportunity to pull in more work from other CPUs.
|
|
*/
|
|
if (likely(prev->sched_class <= &fair_sched_class &&
|
|
rq->nr_running == rq->cfs.h_nr_running)) {
|
|
|
|
p = pick_next_task_fair(rq, prev, rf);
|
|
if (unlikely(p == RETRY_TASK))
|
|
goto restart;
|
|
|
|
/* Assumes fair_sched_class->next == idle_sched_class */
|
|
if (!p) {
|
|
put_prev_task(rq, prev);
|
|
p = pick_next_task_idle(rq);
|
|
}
|
|
|
|
return p;
|
|
}
|
|
|
|
restart:
|
|
put_prev_task_balance(rq, prev, rf);
|
|
|
|
for_each_class(class) {
|
|
p = class->pick_next_task(rq);
|
|
if (p)
|
|
return p;
|
|
}
|
|
|
|
/* The idle class should always have a runnable task: */
|
|
BUG();
|
|
}
|
|
|
|
/*
|
|
* __schedule() is the main scheduler function.
|
|
*
|
|
* The main means of driving the scheduler and thus entering this function are:
|
|
*
|
|
* 1. Explicit blocking: mutex, semaphore, waitqueue, etc.
|
|
*
|
|
* 2. TIF_NEED_RESCHED flag is checked on interrupt and userspace return
|
|
* paths. For example, see arch/x86/entry_64.S.
|
|
*
|
|
* To drive preemption between tasks, the scheduler sets the flag in timer
|
|
* interrupt handler scheduler_tick().
|
|
*
|
|
* 3. Wakeups don't really cause entry into schedule(). They add a
|
|
* task to the run-queue and that's it.
|
|
*
|
|
* Now, if the new task added to the run-queue preempts the current
|
|
* task, then the wakeup sets TIF_NEED_RESCHED and schedule() gets
|
|
* called on the nearest possible occasion:
|
|
*
|
|
* - If the kernel is preemptible (CONFIG_PREEMPTION=y):
|
|
*
|
|
* - in syscall or exception context, at the next outmost
|
|
* preempt_enable(). (this might be as soon as the wake_up()'s
|
|
* spin_unlock()!)
|
|
*
|
|
* - in IRQ context, return from interrupt-handler to
|
|
* preemptible context
|
|
*
|
|
* - If the kernel is not preemptible (CONFIG_PREEMPTION is not set)
|
|
* then at the next:
|
|
*
|
|
* - cond_resched() call
|
|
* - explicit schedule() call
|
|
* - return from syscall or exception to user-space
|
|
* - return from interrupt-handler to user-space
|
|
*
|
|
* WARNING: must be called with preemption disabled!
|
|
*/
|
|
static void __sched notrace __schedule(bool preempt)
|
|
{
|
|
struct task_struct *prev, *next;
|
|
unsigned long *switch_count;
|
|
unsigned long prev_state;
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
int cpu;
|
|
|
|
cpu = smp_processor_id();
|
|
rq = cpu_rq(cpu);
|
|
prev = rq->curr;
|
|
|
|
schedule_debug(prev, preempt);
|
|
|
|
if (sched_feat(HRTICK))
|
|
hrtick_clear(rq);
|
|
|
|
local_irq_disable();
|
|
rcu_note_context_switch(preempt);
|
|
|
|
/*
|
|
* Make sure that signal_pending_state()->signal_pending() below
|
|
* can't be reordered with __set_current_state(TASK_INTERRUPTIBLE)
|
|
* done by the caller to avoid the race with signal_wake_up():
|
|
*
|
|
* __set_current_state(@state) signal_wake_up()
|
|
* schedule() set_tsk_thread_flag(p, TIF_SIGPENDING)
|
|
* wake_up_state(p, state)
|
|
* LOCK rq->lock LOCK p->pi_state
|
|
* smp_mb__after_spinlock() smp_mb__after_spinlock()
|
|
* if (signal_pending_state()) if (p->state & @state)
|
|
*
|
|
* Also, the membarrier system call requires a full memory barrier
|
|
* after coming from user-space, before storing to rq->curr.
|
|
*/
|
|
rq_lock(rq, &rf);
|
|
smp_mb__after_spinlock();
|
|
|
|
/* Promote REQ to ACT */
|
|
rq->clock_update_flags <<= 1;
|
|
update_rq_clock(rq);
|
|
|
|
switch_count = &prev->nivcsw;
|
|
|
|
/*
|
|
* We must load prev->state once (task_struct::state is volatile), such
|
|
* that:
|
|
*
|
|
* - we form a control dependency vs deactivate_task() below.
|
|
* - ptrace_{,un}freeze_traced() can change ->state underneath us.
|
|
*/
|
|
prev_state = prev->state;
|
|
if (!preempt && prev_state) {
|
|
if (signal_pending_state(prev_state, prev)) {
|
|
prev->state = TASK_RUNNING;
|
|
} else {
|
|
prev->sched_contributes_to_load =
|
|
(prev_state & TASK_UNINTERRUPTIBLE) &&
|
|
!(prev_state & TASK_NOLOAD) &&
|
|
!(prev->flags & PF_FROZEN);
|
|
|
|
if (prev->sched_contributes_to_load)
|
|
rq->nr_uninterruptible++;
|
|
|
|
/*
|
|
* __schedule() ttwu()
|
|
* prev_state = prev->state; if (p->on_rq && ...)
|
|
* if (prev_state) goto out;
|
|
* p->on_rq = 0; smp_acquire__after_ctrl_dep();
|
|
* p->state = TASK_WAKING
|
|
*
|
|
* Where __schedule() and ttwu() have matching control dependencies.
|
|
*
|
|
* After this, schedule() must not care about p->state any more.
|
|
*/
|
|
deactivate_task(rq, prev, DEQUEUE_SLEEP | DEQUEUE_NOCLOCK);
|
|
|
|
if (prev->in_iowait) {
|
|
atomic_inc(&rq->nr_iowait);
|
|
delayacct_blkio_start();
|
|
}
|
|
}
|
|
switch_count = &prev->nvcsw;
|
|
}
|
|
|
|
next = pick_next_task(rq, prev, &rf);
|
|
clear_tsk_need_resched(prev);
|
|
clear_preempt_need_resched();
|
|
|
|
trace_android_rvh_schedule(prev, next, rq);
|
|
if (likely(prev != next)) {
|
|
rq->nr_switches++;
|
|
/*
|
|
* RCU users of rcu_dereference(rq->curr) may not see
|
|
* changes to task_struct made by pick_next_task().
|
|
*/
|
|
RCU_INIT_POINTER(rq->curr, next);
|
|
/*
|
|
* The membarrier system call requires each architecture
|
|
* to have a full memory barrier after updating
|
|
* rq->curr, before returning to user-space.
|
|
*
|
|
* Here are the schemes providing that barrier on the
|
|
* various architectures:
|
|
* - mm ? switch_mm() : mmdrop() for x86, s390, sparc, PowerPC.
|
|
* switch_mm() rely on membarrier_arch_switch_mm() on PowerPC.
|
|
* - finish_lock_switch() for weakly-ordered
|
|
* architectures where spin_unlock is a full barrier,
|
|
* - switch_to() for arm64 (weakly-ordered, spin_unlock
|
|
* is a RELEASE barrier),
|
|
*/
|
|
++*switch_count;
|
|
|
|
psi_sched_switch(prev, next, !task_on_rq_queued(prev));
|
|
|
|
trace_sched_switch(preempt, prev, next);
|
|
|
|
/* Also unlocks the rq: */
|
|
rq = context_switch(rq, prev, next, &rf);
|
|
} else {
|
|
rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
|
|
rq_unlock_irq(rq, &rf);
|
|
}
|
|
|
|
balance_callback(rq);
|
|
}
|
|
|
|
void __noreturn do_task_dead(void)
|
|
{
|
|
/* Causes final put_task_struct in finish_task_switch(): */
|
|
set_special_state(TASK_DEAD);
|
|
|
|
/* Tell freezer to ignore us: */
|
|
current->flags |= PF_NOFREEZE;
|
|
|
|
__schedule(false);
|
|
BUG();
|
|
|
|
/* Avoid "noreturn function does return" - but don't continue if BUG() is a NOP: */
|
|
for (;;)
|
|
cpu_relax();
|
|
}
|
|
|
|
static inline void sched_submit_work(struct task_struct *tsk)
|
|
{
|
|
unsigned int task_flags;
|
|
|
|
if (!tsk->state)
|
|
return;
|
|
|
|
task_flags = tsk->flags;
|
|
/*
|
|
* If a worker went to sleep, notify and ask workqueue whether
|
|
* it wants to wake up a task to maintain concurrency.
|
|
* As this function is called inside the schedule() context,
|
|
* we disable preemption to avoid it calling schedule() again
|
|
* in the possible wakeup of a kworker and because wq_worker_sleeping()
|
|
* requires it.
|
|
*/
|
|
if (task_flags & (PF_WQ_WORKER | PF_IO_WORKER)) {
|
|
preempt_disable();
|
|
if (task_flags & PF_WQ_WORKER)
|
|
wq_worker_sleeping(tsk);
|
|
else
|
|
io_wq_worker_sleeping(tsk);
|
|
preempt_enable_no_resched();
|
|
}
|
|
|
|
if (tsk_is_pi_blocked(tsk))
|
|
return;
|
|
|
|
/*
|
|
* If we are going to sleep and we have plugged IO queued,
|
|
* make sure to submit it to avoid deadlocks.
|
|
*/
|
|
if (blk_needs_flush_plug(tsk))
|
|
blk_schedule_flush_plug(tsk);
|
|
}
|
|
|
|
static void sched_update_worker(struct task_struct *tsk)
|
|
{
|
|
if (tsk->flags & (PF_WQ_WORKER | PF_IO_WORKER)) {
|
|
if (tsk->flags & PF_WQ_WORKER)
|
|
wq_worker_running(tsk);
|
|
else
|
|
io_wq_worker_running(tsk);
|
|
}
|
|
}
|
|
|
|
asmlinkage __visible void __sched schedule(void)
|
|
{
|
|
struct task_struct *tsk = current;
|
|
|
|
sched_submit_work(tsk);
|
|
do {
|
|
preempt_disable();
|
|
__schedule(false);
|
|
sched_preempt_enable_no_resched();
|
|
} while (need_resched());
|
|
sched_update_worker(tsk);
|
|
}
|
|
EXPORT_SYMBOL(schedule);
|
|
|
|
/*
|
|
* synchronize_rcu_tasks() makes sure that no task is stuck in preempted
|
|
* state (have scheduled out non-voluntarily) by making sure that all
|
|
* tasks have either left the run queue or have gone into user space.
|
|
* As idle tasks do not do either, they must not ever be preempted
|
|
* (schedule out non-voluntarily).
|
|
*
|
|
* schedule_idle() is similar to schedule_preempt_disable() except that it
|
|
* never enables preemption because it does not call sched_submit_work().
|
|
*/
|
|
void __sched schedule_idle(void)
|
|
{
|
|
/*
|
|
* As this skips calling sched_submit_work(), which the idle task does
|
|
* regardless because that function is a nop when the task is in a
|
|
* TASK_RUNNING state, make sure this isn't used someplace that the
|
|
* current task can be in any other state. Note, idle is always in the
|
|
* TASK_RUNNING state.
|
|
*/
|
|
WARN_ON_ONCE(current->state);
|
|
do {
|
|
__schedule(false);
|
|
} while (need_resched());
|
|
}
|
|
|
|
#ifdef CONFIG_CONTEXT_TRACKING
|
|
asmlinkage __visible void __sched schedule_user(void)
|
|
{
|
|
/*
|
|
* If we come here after a random call to set_need_resched(),
|
|
* or we have been woken up remotely but the IPI has not yet arrived,
|
|
* we haven't yet exited the RCU idle mode. Do it here manually until
|
|
* we find a better solution.
|
|
*
|
|
* NB: There are buggy callers of this function. Ideally we
|
|
* should warn if prev_state != CONTEXT_USER, but that will trigger
|
|
* too frequently to make sense yet.
|
|
*/
|
|
enum ctx_state prev_state = exception_enter();
|
|
schedule();
|
|
exception_exit(prev_state);
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* schedule_preempt_disabled - called with preemption disabled
|
|
*
|
|
* Returns with preemption disabled. Note: preempt_count must be 1
|
|
*/
|
|
void __sched schedule_preempt_disabled(void)
|
|
{
|
|
sched_preempt_enable_no_resched();
|
|
schedule();
|
|
preempt_disable();
|
|
}
|
|
|
|
static void __sched notrace preempt_schedule_common(void)
|
|
{
|
|
do {
|
|
/*
|
|
* Because the function tracer can trace preempt_count_sub()
|
|
* and it also uses preempt_enable/disable_notrace(), if
|
|
* NEED_RESCHED is set, the preempt_enable_notrace() called
|
|
* by the function tracer will call this function again and
|
|
* cause infinite recursion.
|
|
*
|
|
* Preemption must be disabled here before the function
|
|
* tracer can trace. Break up preempt_disable() into two
|
|
* calls. One to disable preemption without fear of being
|
|
* traced. The other to still record the preemption latency,
|
|
* which can also be traced by the function tracer.
|
|
*/
|
|
preempt_disable_notrace();
|
|
preempt_latency_start(1);
|
|
__schedule(true);
|
|
preempt_latency_stop(1);
|
|
preempt_enable_no_resched_notrace();
|
|
|
|
/*
|
|
* Check again in case we missed a preemption opportunity
|
|
* between schedule and now.
|
|
*/
|
|
} while (need_resched());
|
|
}
|
|
|
|
#ifdef CONFIG_PREEMPTION
|
|
/*
|
|
* This is the entry point to schedule() from in-kernel preemption
|
|
* off of preempt_enable.
|
|
*/
|
|
asmlinkage __visible void __sched notrace preempt_schedule(void)
|
|
{
|
|
/*
|
|
* If there is a non-zero preempt_count or interrupts are disabled,
|
|
* we do not want to preempt the current task. Just return..
|
|
*/
|
|
if (likely(!preemptible()))
|
|
return;
|
|
|
|
preempt_schedule_common();
|
|
}
|
|
NOKPROBE_SYMBOL(preempt_schedule);
|
|
EXPORT_SYMBOL(preempt_schedule);
|
|
|
|
/**
|
|
* preempt_schedule_notrace - preempt_schedule called by tracing
|
|
*
|
|
* The tracing infrastructure uses preempt_enable_notrace to prevent
|
|
* recursion and tracing preempt enabling caused by the tracing
|
|
* infrastructure itself. But as tracing can happen in areas coming
|
|
* from userspace or just about to enter userspace, a preempt enable
|
|
* can occur before user_exit() is called. This will cause the scheduler
|
|
* to be called when the system is still in usermode.
|
|
*
|
|
* To prevent this, the preempt_enable_notrace will use this function
|
|
* instead of preempt_schedule() to exit user context if needed before
|
|
* calling the scheduler.
|
|
*/
|
|
asmlinkage __visible void __sched notrace preempt_schedule_notrace(void)
|
|
{
|
|
enum ctx_state prev_ctx;
|
|
|
|
if (likely(!preemptible()))
|
|
return;
|
|
|
|
do {
|
|
/*
|
|
* Because the function tracer can trace preempt_count_sub()
|
|
* and it also uses preempt_enable/disable_notrace(), if
|
|
* NEED_RESCHED is set, the preempt_enable_notrace() called
|
|
* by the function tracer will call this function again and
|
|
* cause infinite recursion.
|
|
*
|
|
* Preemption must be disabled here before the function
|
|
* tracer can trace. Break up preempt_disable() into two
|
|
* calls. One to disable preemption without fear of being
|
|
* traced. The other to still record the preemption latency,
|
|
* which can also be traced by the function tracer.
|
|
*/
|
|
preempt_disable_notrace();
|
|
preempt_latency_start(1);
|
|
/*
|
|
* Needs preempt disabled in case user_exit() is traced
|
|
* and the tracer calls preempt_enable_notrace() causing
|
|
* an infinite recursion.
|
|
*/
|
|
prev_ctx = exception_enter();
|
|
__schedule(true);
|
|
exception_exit(prev_ctx);
|
|
|
|
preempt_latency_stop(1);
|
|
preempt_enable_no_resched_notrace();
|
|
} while (need_resched());
|
|
}
|
|
EXPORT_SYMBOL_GPL(preempt_schedule_notrace);
|
|
|
|
#endif /* CONFIG_PREEMPTION */
|
|
|
|
/*
|
|
* This is the entry point to schedule() from kernel preemption
|
|
* off of irq context.
|
|
* Note, that this is called and return with irqs disabled. This will
|
|
* protect us against recursive calling from irq.
|
|
*/
|
|
asmlinkage __visible void __sched preempt_schedule_irq(void)
|
|
{
|
|
enum ctx_state prev_state;
|
|
|
|
/* Catch callers which need to be fixed */
|
|
BUG_ON(preempt_count() || !irqs_disabled());
|
|
|
|
prev_state = exception_enter();
|
|
|
|
do {
|
|
preempt_disable();
|
|
local_irq_enable();
|
|
__schedule(true);
|
|
local_irq_disable();
|
|
sched_preempt_enable_no_resched();
|
|
} while (need_resched());
|
|
|
|
exception_exit(prev_state);
|
|
}
|
|
|
|
int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flags,
|
|
void *key)
|
|
{
|
|
WARN_ON_ONCE(IS_ENABLED(CONFIG_SCHED_DEBUG) && wake_flags & ~(WF_SYNC | WF_ANDROID_VENDOR));
|
|
return try_to_wake_up(curr->private, mode, wake_flags);
|
|
}
|
|
EXPORT_SYMBOL(default_wake_function);
|
|
|
|
static void __setscheduler_prio(struct task_struct *p, int prio)
|
|
{
|
|
if (dl_prio(prio))
|
|
p->sched_class = &dl_sched_class;
|
|
else if (rt_prio(prio))
|
|
p->sched_class = &rt_sched_class;
|
|
else
|
|
p->sched_class = &fair_sched_class;
|
|
|
|
p->prio = prio;
|
|
}
|
|
|
|
#ifdef CONFIG_RT_MUTEXES
|
|
|
|
static inline int __rt_effective_prio(struct task_struct *pi_task, int prio)
|
|
{
|
|
if (pi_task)
|
|
prio = min(prio, pi_task->prio);
|
|
|
|
return prio;
|
|
}
|
|
|
|
static inline int rt_effective_prio(struct task_struct *p, int prio)
|
|
{
|
|
struct task_struct *pi_task = rt_mutex_get_top_task(p);
|
|
|
|
return __rt_effective_prio(pi_task, prio);
|
|
}
|
|
|
|
/*
|
|
* rt_mutex_setprio - set the current priority of a task
|
|
* @p: task to boost
|
|
* @pi_task: donor task
|
|
*
|
|
* This function changes the 'effective' priority of a task. It does
|
|
* not touch ->normal_prio like __setscheduler().
|
|
*
|
|
* Used by the rt_mutex code to implement priority inheritance
|
|
* logic. Call site only calls if the priority of the task changed.
|
|
*/
|
|
void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task)
|
|
{
|
|
int prio, oldprio, queued, running, queue_flag =
|
|
DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK;
|
|
const struct sched_class *prev_class;
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
trace_android_rvh_rtmutex_prepare_setprio(p, pi_task);
|
|
/* XXX used to be waiter->prio, not waiter->task->prio */
|
|
prio = __rt_effective_prio(pi_task, p->normal_prio);
|
|
|
|
/*
|
|
* If nothing changed; bail early.
|
|
*/
|
|
if (p->pi_top_task == pi_task && prio == p->prio && !dl_prio(prio))
|
|
return;
|
|
|
|
rq = __task_rq_lock(p, &rf);
|
|
update_rq_clock(rq);
|
|
/*
|
|
* Set under pi_lock && rq->lock, such that the value can be used under
|
|
* either lock.
|
|
*
|
|
* Note that there is loads of tricky to make this pointer cache work
|
|
* right. rt_mutex_slowunlock()+rt_mutex_postunlock() work together to
|
|
* ensure a task is de-boosted (pi_task is set to NULL) before the
|
|
* task is allowed to run again (and can exit). This ensures the pointer
|
|
* points to a blocked task -- which guaratees the task is present.
|
|
*/
|
|
p->pi_top_task = pi_task;
|
|
|
|
/*
|
|
* For FIFO/RR we only need to set prio, if that matches we're done.
|
|
*/
|
|
if (prio == p->prio && !dl_prio(prio))
|
|
goto out_unlock;
|
|
|
|
/*
|
|
* Idle task boosting is a nono in general. There is one
|
|
* exception, when PREEMPT_RT and NOHZ is active:
|
|
*
|
|
* The idle task calls get_next_timer_interrupt() and holds
|
|
* the timer wheel base->lock on the CPU and another CPU wants
|
|
* to access the timer (probably to cancel it). We can safely
|
|
* ignore the boosting request, as the idle CPU runs this code
|
|
* with interrupts disabled and will complete the lock
|
|
* protected section without being interrupted. So there is no
|
|
* real need to boost.
|
|
*/
|
|
if (unlikely(p == rq->idle)) {
|
|
WARN_ON(p != rq->curr);
|
|
WARN_ON(p->pi_blocked_on);
|
|
goto out_unlock;
|
|
}
|
|
|
|
trace_sched_pi_setprio(p, pi_task);
|
|
oldprio = p->prio;
|
|
|
|
if (oldprio == prio)
|
|
queue_flag &= ~DEQUEUE_MOVE;
|
|
|
|
prev_class = p->sched_class;
|
|
queued = task_on_rq_queued(p);
|
|
running = task_current(rq, p);
|
|
if (queued)
|
|
dequeue_task(rq, p, queue_flag);
|
|
if (running)
|
|
put_prev_task(rq, p);
|
|
|
|
/*
|
|
* Boosting condition are:
|
|
* 1. -rt task is running and holds mutex A
|
|
* --> -dl task blocks on mutex A
|
|
*
|
|
* 2. -dl task is running and holds mutex A
|
|
* --> -dl task blocks on mutex A and could preempt the
|
|
* running task
|
|
*/
|
|
if (dl_prio(prio)) {
|
|
if (!dl_prio(p->normal_prio) ||
|
|
(pi_task && dl_prio(pi_task->prio) &&
|
|
dl_entity_preempt(&pi_task->dl, &p->dl))) {
|
|
p->dl.pi_se = pi_task->dl.pi_se;
|
|
queue_flag |= ENQUEUE_REPLENISH;
|
|
} else {
|
|
p->dl.pi_se = &p->dl;
|
|
}
|
|
} else if (rt_prio(prio)) {
|
|
if (dl_prio(oldprio))
|
|
p->dl.pi_se = &p->dl;
|
|
if (oldprio < prio)
|
|
queue_flag |= ENQUEUE_HEAD;
|
|
} else {
|
|
if (dl_prio(oldprio))
|
|
p->dl.pi_se = &p->dl;
|
|
if (rt_prio(oldprio))
|
|
p->rt.timeout = 0;
|
|
}
|
|
|
|
__setscheduler_prio(p, prio);
|
|
|
|
if (queued)
|
|
enqueue_task(rq, p, queue_flag);
|
|
if (running)
|
|
set_next_task(rq, p);
|
|
|
|
check_class_changed(rq, p, prev_class, oldprio);
|
|
out_unlock:
|
|
/* Avoid rq from going away on us: */
|
|
preempt_disable();
|
|
__task_rq_unlock(rq, &rf);
|
|
|
|
balance_callback(rq);
|
|
preempt_enable();
|
|
}
|
|
#else
|
|
static inline int rt_effective_prio(struct task_struct *p, int prio)
|
|
{
|
|
return prio;
|
|
}
|
|
#endif
|
|
|
|
void set_user_nice(struct task_struct *p, long nice)
|
|
{
|
|
bool queued, running, allowed = false;
|
|
int old_prio;
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
trace_android_rvh_set_user_nice(p, &nice, &allowed);
|
|
if ((task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE) && !allowed)
|
|
return;
|
|
/*
|
|
* We have to be careful, if called from sys_setpriority(),
|
|
* the task might be in the middle of scheduling on another CPU.
|
|
*/
|
|
rq = task_rq_lock(p, &rf);
|
|
update_rq_clock(rq);
|
|
|
|
/*
|
|
* The RT priorities are set via sched_setscheduler(), but we still
|
|
* allow the 'normal' nice value to be set - but as expected
|
|
* it wont have any effect on scheduling until the task is
|
|
* SCHED_DEADLINE, SCHED_FIFO or SCHED_RR:
|
|
*/
|
|
if (task_has_dl_policy(p) || task_has_rt_policy(p)) {
|
|
p->static_prio = NICE_TO_PRIO(nice);
|
|
goto out_unlock;
|
|
}
|
|
queued = task_on_rq_queued(p);
|
|
running = task_current(rq, p);
|
|
if (queued)
|
|
dequeue_task(rq, p, DEQUEUE_SAVE | DEQUEUE_NOCLOCK);
|
|
if (running)
|
|
put_prev_task(rq, p);
|
|
|
|
p->static_prio = NICE_TO_PRIO(nice);
|
|
set_load_weight(p, true);
|
|
old_prio = p->prio;
|
|
p->prio = effective_prio(p);
|
|
|
|
if (queued)
|
|
enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK);
|
|
if (running)
|
|
set_next_task(rq, p);
|
|
|
|
/*
|
|
* If the task increased its priority or is running and
|
|
* lowered its priority, then reschedule its CPU:
|
|
*/
|
|
p->sched_class->prio_changed(rq, p, old_prio);
|
|
|
|
out_unlock:
|
|
task_rq_unlock(rq, p, &rf);
|
|
}
|
|
EXPORT_SYMBOL(set_user_nice);
|
|
|
|
/*
|
|
* can_nice - check if a task can reduce its nice value
|
|
* @p: task
|
|
* @nice: nice value
|
|
*/
|
|
int can_nice(const struct task_struct *p, const int nice)
|
|
{
|
|
/* Convert nice value [19,-20] to rlimit style value [1,40]: */
|
|
int nice_rlim = nice_to_rlimit(nice);
|
|
|
|
return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
|
|
capable(CAP_SYS_NICE));
|
|
}
|
|
|
|
#ifdef __ARCH_WANT_SYS_NICE
|
|
|
|
/*
|
|
* sys_nice - change the priority of the current process.
|
|
* @increment: priority increment
|
|
*
|
|
* sys_setpriority is a more generic, but much slower function that
|
|
* does similar things.
|
|
*/
|
|
SYSCALL_DEFINE1(nice, int, increment)
|
|
{
|
|
long nice, retval;
|
|
|
|
/*
|
|
* Setpriority might change our priority at the same moment.
|
|
* We don't have to worry. Conceptually one call occurs first
|
|
* and we have a single winner.
|
|
*/
|
|
increment = clamp(increment, -NICE_WIDTH, NICE_WIDTH);
|
|
nice = task_nice(current) + increment;
|
|
|
|
nice = clamp_val(nice, MIN_NICE, MAX_NICE);
|
|
if (increment < 0 && !can_nice(current, nice))
|
|
return -EPERM;
|
|
|
|
retval = security_task_setnice(current, nice);
|
|
if (retval)
|
|
return retval;
|
|
|
|
set_user_nice(current, nice);
|
|
return 0;
|
|
}
|
|
|
|
#endif
|
|
|
|
/**
|
|
* task_prio - return the priority value of a given task.
|
|
* @p: the task in question.
|
|
*
|
|
* Return: The priority value as seen by users in /proc.
|
|
* RT tasks are offset by -200. Normal tasks are centered
|
|
* around 0, value goes from -16 to +15.
|
|
*/
|
|
int task_prio(const struct task_struct *p)
|
|
{
|
|
return p->prio - MAX_RT_PRIO;
|
|
}
|
|
|
|
/**
|
|
* idle_cpu - is a given CPU idle currently?
|
|
* @cpu: the processor in question.
|
|
*
|
|
* Return: 1 if the CPU is currently idle. 0 otherwise.
|
|
*/
|
|
int idle_cpu(int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
|
|
if (rq->curr != rq->idle)
|
|
return 0;
|
|
|
|
if (rq->nr_running)
|
|
return 0;
|
|
|
|
#ifdef CONFIG_SMP
|
|
if (rq->ttwu_pending)
|
|
return 0;
|
|
#endif
|
|
|
|
return 1;
|
|
}
|
|
|
|
/**
|
|
* available_idle_cpu - is a given CPU idle for enqueuing work.
|
|
* @cpu: the CPU in question.
|
|
*
|
|
* Return: 1 if the CPU is currently idle. 0 otherwise.
|
|
*/
|
|
int available_idle_cpu(int cpu)
|
|
{
|
|
if (!idle_cpu(cpu))
|
|
return 0;
|
|
|
|
if (vcpu_is_preempted(cpu))
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
EXPORT_SYMBOL_GPL(available_idle_cpu);
|
|
|
|
/**
|
|
* idle_task - return the idle task for a given CPU.
|
|
* @cpu: the processor in question.
|
|
*
|
|
* Return: The idle task for the CPU @cpu.
|
|
*/
|
|
struct task_struct *idle_task(int cpu)
|
|
{
|
|
return cpu_rq(cpu)->idle;
|
|
}
|
|
|
|
/**
|
|
* find_process_by_pid - find a process with a matching PID value.
|
|
* @pid: the pid in question.
|
|
*
|
|
* The task of @pid, if found. %NULL otherwise.
|
|
*/
|
|
static struct task_struct *find_process_by_pid(pid_t pid)
|
|
{
|
|
return pid ? find_task_by_vpid(pid) : current;
|
|
}
|
|
|
|
/*
|
|
* sched_setparam() passes in -1 for its policy, to let the functions
|
|
* it calls know not to change it.
|
|
*/
|
|
#define SETPARAM_POLICY -1
|
|
|
|
static void __setscheduler_params(struct task_struct *p,
|
|
const struct sched_attr *attr)
|
|
{
|
|
int policy = attr->sched_policy;
|
|
|
|
if (policy == SETPARAM_POLICY)
|
|
policy = p->policy;
|
|
|
|
p->policy = policy;
|
|
|
|
if (dl_policy(policy))
|
|
__setparam_dl(p, attr);
|
|
else if (fair_policy(policy))
|
|
p->static_prio = NICE_TO_PRIO(attr->sched_nice);
|
|
|
|
/*
|
|
* __sched_setscheduler() ensures attr->sched_priority == 0 when
|
|
* !rt_policy. Always setting this ensures that things like
|
|
* getparam()/getattr() don't report silly values for !rt tasks.
|
|
*/
|
|
p->rt_priority = attr->sched_priority;
|
|
p->normal_prio = normal_prio(p);
|
|
set_load_weight(p, true);
|
|
}
|
|
|
|
/*
|
|
* Check the target process has a UID that matches the current process's:
|
|
*/
|
|
static bool check_same_owner(struct task_struct *p)
|
|
{
|
|
const struct cred *cred = current_cred(), *pcred;
|
|
bool match;
|
|
|
|
rcu_read_lock();
|
|
pcred = __task_cred(p);
|
|
match = (uid_eq(cred->euid, pcred->euid) ||
|
|
uid_eq(cred->euid, pcred->uid));
|
|
rcu_read_unlock();
|
|
return match;
|
|
}
|
|
|
|
static int __sched_setscheduler(struct task_struct *p,
|
|
const struct sched_attr *attr,
|
|
bool user, bool pi)
|
|
{
|
|
int oldpolicy = -1, policy = attr->sched_policy;
|
|
int retval, oldprio, newprio, queued, running;
|
|
const struct sched_class *prev_class;
|
|
struct rq_flags rf;
|
|
int reset_on_fork;
|
|
int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK;
|
|
struct rq *rq;
|
|
|
|
/* The pi code expects interrupts enabled */
|
|
BUG_ON(pi && in_interrupt());
|
|
recheck:
|
|
/* Double check policy once rq lock held: */
|
|
if (policy < 0) {
|
|
reset_on_fork = p->sched_reset_on_fork;
|
|
policy = oldpolicy = p->policy;
|
|
} else {
|
|
reset_on_fork = !!(attr->sched_flags & SCHED_FLAG_RESET_ON_FORK);
|
|
|
|
if (!valid_policy(policy))
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (attr->sched_flags & ~(SCHED_FLAG_ALL | SCHED_FLAG_SUGOV))
|
|
return -EINVAL;
|
|
|
|
/*
|
|
* Valid priorities for SCHED_FIFO and SCHED_RR are
|
|
* 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL,
|
|
* SCHED_BATCH and SCHED_IDLE is 0.
|
|
*/
|
|
if ((p->mm && attr->sched_priority > MAX_USER_RT_PRIO-1) ||
|
|
(!p->mm && attr->sched_priority > MAX_RT_PRIO-1))
|
|
return -EINVAL;
|
|
if ((dl_policy(policy) && !__checkparam_dl(attr)) ||
|
|
(rt_policy(policy) != (attr->sched_priority != 0)))
|
|
return -EINVAL;
|
|
|
|
/*
|
|
* Allow unprivileged RT tasks to decrease priority:
|
|
*/
|
|
if (user && !capable(CAP_SYS_NICE)) {
|
|
if (fair_policy(policy)) {
|
|
if (attr->sched_nice < task_nice(p) &&
|
|
!can_nice(p, attr->sched_nice))
|
|
return -EPERM;
|
|
}
|
|
|
|
if (rt_policy(policy)) {
|
|
unsigned long rlim_rtprio =
|
|
task_rlimit(p, RLIMIT_RTPRIO);
|
|
|
|
/* Can't set/change the rt policy: */
|
|
if (policy != p->policy && !rlim_rtprio)
|
|
return -EPERM;
|
|
|
|
/* Can't increase priority: */
|
|
if (attr->sched_priority > p->rt_priority &&
|
|
attr->sched_priority > rlim_rtprio)
|
|
return -EPERM;
|
|
}
|
|
|
|
/*
|
|
* Can't set/change SCHED_DEADLINE policy at all for now
|
|
* (safest behavior); in the future we would like to allow
|
|
* unprivileged DL tasks to increase their relative deadline
|
|
* or reduce their runtime (both ways reducing utilization)
|
|
*/
|
|
if (dl_policy(policy))
|
|
return -EPERM;
|
|
|
|
/*
|
|
* Treat SCHED_IDLE as nice 20. Only allow a switch to
|
|
* SCHED_NORMAL if the RLIMIT_NICE would normally permit it.
|
|
*/
|
|
if (task_has_idle_policy(p) && !idle_policy(policy)) {
|
|
if (!can_nice(p, task_nice(p)))
|
|
return -EPERM;
|
|
}
|
|
|
|
/* Can't change other user's priorities: */
|
|
if (!check_same_owner(p))
|
|
return -EPERM;
|
|
|
|
/* Normal users shall not reset the sched_reset_on_fork flag: */
|
|
if (p->sched_reset_on_fork && !reset_on_fork)
|
|
return -EPERM;
|
|
|
|
/* Can't change util-clamps */
|
|
if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP)
|
|
return -EPERM;
|
|
}
|
|
|
|
if (user) {
|
|
if (attr->sched_flags & SCHED_FLAG_SUGOV)
|
|
return -EINVAL;
|
|
|
|
retval = security_task_setscheduler(p);
|
|
if (retval)
|
|
return retval;
|
|
}
|
|
|
|
/* Update task specific "requested" clamps */
|
|
if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP) {
|
|
retval = uclamp_validate(p, attr);
|
|
if (retval)
|
|
return retval;
|
|
}
|
|
|
|
/*
|
|
* Make sure no PI-waiters arrive (or leave) while we are
|
|
* changing the priority of the task:
|
|
*
|
|
* To be able to change p->policy safely, the appropriate
|
|
* runqueue lock must be held.
|
|
*/
|
|
rq = task_rq_lock(p, &rf);
|
|
update_rq_clock(rq);
|
|
|
|
/*
|
|
* Changing the policy of the stop threads its a very bad idea:
|
|
*/
|
|
if (p == rq->stop) {
|
|
retval = -EINVAL;
|
|
goto unlock;
|
|
}
|
|
|
|
/*
|
|
* If not changing anything there's no need to proceed further,
|
|
* but store a possible modification of reset_on_fork.
|
|
*/
|
|
if (unlikely(policy == p->policy)) {
|
|
if (fair_policy(policy) && attr->sched_nice != task_nice(p))
|
|
goto change;
|
|
if (rt_policy(policy) && attr->sched_priority != p->rt_priority)
|
|
goto change;
|
|
if (dl_policy(policy) && dl_param_changed(p, attr))
|
|
goto change;
|
|
if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP)
|
|
goto change;
|
|
|
|
p->sched_reset_on_fork = reset_on_fork;
|
|
retval = 0;
|
|
goto unlock;
|
|
}
|
|
change:
|
|
|
|
if (user) {
|
|
#ifdef CONFIG_RT_GROUP_SCHED
|
|
/*
|
|
* Do not allow realtime tasks into groups that have no runtime
|
|
* assigned.
|
|
*/
|
|
if (rt_bandwidth_enabled() && rt_policy(policy) &&
|
|
task_group(p)->rt_bandwidth.rt_runtime == 0 &&
|
|
!task_group_is_autogroup(task_group(p))) {
|
|
retval = -EPERM;
|
|
goto unlock;
|
|
}
|
|
#endif
|
|
#ifdef CONFIG_SMP
|
|
if (dl_bandwidth_enabled() && dl_policy(policy) &&
|
|
!(attr->sched_flags & SCHED_FLAG_SUGOV)) {
|
|
cpumask_t *span = rq->rd->span;
|
|
|
|
/*
|
|
* Don't allow tasks with an affinity mask smaller than
|
|
* the entire root_domain to become SCHED_DEADLINE. We
|
|
* will also fail if there's no bandwidth available.
|
|
*/
|
|
if (!cpumask_subset(span, p->cpus_ptr) ||
|
|
rq->rd->dl_bw.bw == 0) {
|
|
retval = -EPERM;
|
|
goto unlock;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
/* Re-check policy now with rq lock held: */
|
|
if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) {
|
|
policy = oldpolicy = -1;
|
|
task_rq_unlock(rq, p, &rf);
|
|
goto recheck;
|
|
}
|
|
|
|
/*
|
|
* If setscheduling to SCHED_DEADLINE (or changing the parameters
|
|
* of a SCHED_DEADLINE task) we need to check if enough bandwidth
|
|
* is available.
|
|
*/
|
|
if ((dl_policy(policy) || dl_task(p)) && sched_dl_overflow(p, policy, attr)) {
|
|
retval = -EBUSY;
|
|
goto unlock;
|
|
}
|
|
|
|
p->sched_reset_on_fork = reset_on_fork;
|
|
oldprio = p->prio;
|
|
|
|
newprio = __normal_prio(policy, attr->sched_priority, attr->sched_nice);
|
|
if (pi) {
|
|
/*
|
|
* Take priority boosted tasks into account. If the new
|
|
* effective priority is unchanged, we just store the new
|
|
* normal parameters and do not touch the scheduler class and
|
|
* the runqueue. This will be done when the task deboost
|
|
* itself.
|
|
*/
|
|
newprio = rt_effective_prio(p, newprio);
|
|
if (newprio == oldprio)
|
|
queue_flags &= ~DEQUEUE_MOVE;
|
|
}
|
|
|
|
queued = task_on_rq_queued(p);
|
|
running = task_current(rq, p);
|
|
if (queued)
|
|
dequeue_task(rq, p, queue_flags);
|
|
if (running)
|
|
put_prev_task(rq, p);
|
|
|
|
prev_class = p->sched_class;
|
|
|
|
if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS)) {
|
|
__setscheduler_params(p, attr);
|
|
__setscheduler_prio(p, newprio);
|
|
trace_android_rvh_setscheduler(p);
|
|
}
|
|
__setscheduler_uclamp(p, attr);
|
|
|
|
if (queued) {
|
|
/*
|
|
* We enqueue to tail when the priority of a task is
|
|
* increased (user space view).
|
|
*/
|
|
if (oldprio < p->prio)
|
|
queue_flags |= ENQUEUE_HEAD;
|
|
|
|
enqueue_task(rq, p, queue_flags);
|
|
}
|
|
if (running)
|
|
set_next_task(rq, p);
|
|
|
|
check_class_changed(rq, p, prev_class, oldprio);
|
|
|
|
/* Avoid rq from going away on us: */
|
|
preempt_disable();
|
|
task_rq_unlock(rq, p, &rf);
|
|
|
|
if (pi)
|
|
rt_mutex_adjust_pi(p);
|
|
|
|
/* Run balance callbacks after we've adjusted the PI chain: */
|
|
balance_callback(rq);
|
|
preempt_enable();
|
|
|
|
return 0;
|
|
|
|
unlock:
|
|
task_rq_unlock(rq, p, &rf);
|
|
return retval;
|
|
}
|
|
|
|
static int _sched_setscheduler(struct task_struct *p, int policy,
|
|
const struct sched_param *param, bool check)
|
|
{
|
|
struct sched_attr attr = {
|
|
.sched_policy = policy,
|
|
.sched_priority = param->sched_priority,
|
|
.sched_nice = PRIO_TO_NICE(p->static_prio),
|
|
};
|
|
|
|
/* Fixup the legacy SCHED_RESET_ON_FORK hack. */
|
|
if ((policy != SETPARAM_POLICY) && (policy & SCHED_RESET_ON_FORK)) {
|
|
attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
|
|
policy &= ~SCHED_RESET_ON_FORK;
|
|
attr.sched_policy = policy;
|
|
}
|
|
|
|
return __sched_setscheduler(p, &attr, check, true);
|
|
}
|
|
/**
|
|
* sched_setscheduler - change the scheduling policy and/or RT priority of a thread.
|
|
* @p: the task in question.
|
|
* @policy: new policy.
|
|
* @param: structure containing the new RT priority.
|
|
*
|
|
* Use sched_set_fifo(), read its comment.
|
|
*
|
|
* Return: 0 on success. An error code otherwise.
|
|
*
|
|
* NOTE that the task may be already dead.
|
|
*/
|
|
int sched_setscheduler(struct task_struct *p, int policy,
|
|
const struct sched_param *param)
|
|
{
|
|
return _sched_setscheduler(p, policy, param, true);
|
|
}
|
|
EXPORT_SYMBOL_GPL(sched_setscheduler);
|
|
|
|
int sched_setattr(struct task_struct *p, const struct sched_attr *attr)
|
|
{
|
|
return __sched_setscheduler(p, attr, true, true);
|
|
}
|
|
EXPORT_SYMBOL_GPL(sched_setattr);
|
|
|
|
int sched_setattr_nocheck(struct task_struct *p, const struct sched_attr *attr)
|
|
{
|
|
return __sched_setscheduler(p, attr, false, true);
|
|
}
|
|
EXPORT_SYMBOL_GPL(sched_setattr_nocheck);
|
|
|
|
/**
|
|
* sched_setscheduler_nocheck - change the scheduling policy and/or RT priority of a thread from kernelspace.
|
|
* @p: the task in question.
|
|
* @policy: new policy.
|
|
* @param: structure containing the new RT priority.
|
|
*
|
|
* Just like sched_setscheduler, only don't bother checking if the
|
|
* current context has permission. For example, this is needed in
|
|
* stop_machine(): we create temporary high priority worker threads,
|
|
* but our caller might not have that capability.
|
|
*
|
|
* Return: 0 on success. An error code otherwise.
|
|
*/
|
|
int sched_setscheduler_nocheck(struct task_struct *p, int policy,
|
|
const struct sched_param *param)
|
|
{
|
|
return _sched_setscheduler(p, policy, param, false);
|
|
}
|
|
EXPORT_SYMBOL_GPL(sched_setscheduler_nocheck);
|
|
|
|
/*
|
|
* SCHED_FIFO is a broken scheduler model; that is, it is fundamentally
|
|
* incapable of resource management, which is the one thing an OS really should
|
|
* be doing.
|
|
*
|
|
* This is of course the reason it is limited to privileged users only.
|
|
*
|
|
* Worse still; it is fundamentally impossible to compose static priority
|
|
* workloads. You cannot take two correctly working static prio workloads
|
|
* and smash them together and still expect them to work.
|
|
*
|
|
* For this reason 'all' FIFO tasks the kernel creates are basically at:
|
|
*
|
|
* MAX_RT_PRIO / 2
|
|
*
|
|
* The administrator _MUST_ configure the system, the kernel simply doesn't
|
|
* know enough information to make a sensible choice.
|
|
*/
|
|
void sched_set_fifo(struct task_struct *p)
|
|
{
|
|
struct sched_param sp = { .sched_priority = MAX_RT_PRIO / 2 };
|
|
WARN_ON_ONCE(sched_setscheduler_nocheck(p, SCHED_FIFO, &sp) != 0);
|
|
}
|
|
EXPORT_SYMBOL_GPL(sched_set_fifo);
|
|
|
|
/*
|
|
* For when you don't much care about FIFO, but want to be above SCHED_NORMAL.
|
|
*/
|
|
void sched_set_fifo_low(struct task_struct *p)
|
|
{
|
|
struct sched_param sp = { .sched_priority = 1 };
|
|
WARN_ON_ONCE(sched_setscheduler_nocheck(p, SCHED_FIFO, &sp) != 0);
|
|
}
|
|
EXPORT_SYMBOL_GPL(sched_set_fifo_low);
|
|
|
|
void sched_set_normal(struct task_struct *p, int nice)
|
|
{
|
|
struct sched_attr attr = {
|
|
.sched_policy = SCHED_NORMAL,
|
|
.sched_nice = nice,
|
|
};
|
|
WARN_ON_ONCE(sched_setattr_nocheck(p, &attr) != 0);
|
|
}
|
|
EXPORT_SYMBOL_GPL(sched_set_normal);
|
|
|
|
static int
|
|
do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
|
|
{
|
|
struct sched_param lparam;
|
|
struct task_struct *p;
|
|
int retval;
|
|
|
|
if (!param || pid < 0)
|
|
return -EINVAL;
|
|
if (copy_from_user(&lparam, param, sizeof(struct sched_param)))
|
|
return -EFAULT;
|
|
|
|
rcu_read_lock();
|
|
retval = -ESRCH;
|
|
p = find_process_by_pid(pid);
|
|
if (p != NULL)
|
|
retval = sched_setscheduler(p, policy, &lparam);
|
|
rcu_read_unlock();
|
|
|
|
return retval;
|
|
}
|
|
|
|
/*
|
|
* Mimics kernel/events/core.c perf_copy_attr().
|
|
*/
|
|
static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr *attr)
|
|
{
|
|
u32 size;
|
|
int ret;
|
|
|
|
/* Zero the full structure, so that a short copy will be nice: */
|
|
memset(attr, 0, sizeof(*attr));
|
|
|
|
ret = get_user(size, &uattr->size);
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* ABI compatibility quirk: */
|
|
if (!size)
|
|
size = SCHED_ATTR_SIZE_VER0;
|
|
if (size < SCHED_ATTR_SIZE_VER0 || size > PAGE_SIZE)
|
|
goto err_size;
|
|
|
|
ret = copy_struct_from_user(attr, sizeof(*attr), uattr, size);
|
|
if (ret) {
|
|
if (ret == -E2BIG)
|
|
goto err_size;
|
|
return ret;
|
|
}
|
|
|
|
if ((attr->sched_flags & SCHED_FLAG_UTIL_CLAMP) &&
|
|
size < SCHED_ATTR_SIZE_VER1)
|
|
return -EINVAL;
|
|
|
|
/*
|
|
* XXX: Do we want to be lenient like existing syscalls; or do we want
|
|
* to be strict and return an error on out-of-bounds values?
|
|
*/
|
|
attr->sched_nice = clamp(attr->sched_nice, MIN_NICE, MAX_NICE);
|
|
|
|
return 0;
|
|
|
|
err_size:
|
|
put_user(sizeof(*attr), &uattr->size);
|
|
return -E2BIG;
|
|
}
|
|
|
|
static void get_params(struct task_struct *p, struct sched_attr *attr)
|
|
{
|
|
if (task_has_dl_policy(p))
|
|
__getparam_dl(p, attr);
|
|
else if (task_has_rt_policy(p))
|
|
attr->sched_priority = p->rt_priority;
|
|
else
|
|
attr->sched_nice = task_nice(p);
|
|
}
|
|
|
|
/**
|
|
* sys_sched_setscheduler - set/change the scheduler policy and RT priority
|
|
* @pid: the pid in question.
|
|
* @policy: new policy.
|
|
* @param: structure containing the new RT priority.
|
|
*
|
|
* Return: 0 on success. An error code otherwise.
|
|
*/
|
|
SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy, struct sched_param __user *, param)
|
|
{
|
|
if (policy < 0)
|
|
return -EINVAL;
|
|
|
|
return do_sched_setscheduler(pid, policy, param);
|
|
}
|
|
|
|
/**
|
|
* sys_sched_setparam - set/change the RT priority of a thread
|
|
* @pid: the pid in question.
|
|
* @param: structure containing the new RT priority.
|
|
*
|
|
* Return: 0 on success. An error code otherwise.
|
|
*/
|
|
SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
|
|
{
|
|
return do_sched_setscheduler(pid, SETPARAM_POLICY, param);
|
|
}
|
|
|
|
/**
|
|
* sys_sched_setattr - same as above, but with extended sched_attr
|
|
* @pid: the pid in question.
|
|
* @uattr: structure containing the extended parameters.
|
|
* @flags: for future extension.
|
|
*/
|
|
SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
|
|
unsigned int, flags)
|
|
{
|
|
struct sched_attr attr;
|
|
struct task_struct *p;
|
|
int retval;
|
|
|
|
if (!uattr || pid < 0 || flags)
|
|
return -EINVAL;
|
|
|
|
retval = sched_copy_attr(uattr, &attr);
|
|
if (retval)
|
|
return retval;
|
|
|
|
if ((int)attr.sched_policy < 0)
|
|
return -EINVAL;
|
|
if (attr.sched_flags & SCHED_FLAG_KEEP_POLICY)
|
|
attr.sched_policy = SETPARAM_POLICY;
|
|
|
|
rcu_read_lock();
|
|
retval = -ESRCH;
|
|
p = find_process_by_pid(pid);
|
|
if (likely(p))
|
|
get_task_struct(p);
|
|
rcu_read_unlock();
|
|
|
|
if (likely(p)) {
|
|
if (attr.sched_flags & SCHED_FLAG_KEEP_PARAMS)
|
|
get_params(p, &attr);
|
|
retval = sched_setattr(p, &attr);
|
|
put_task_struct(p);
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
|
|
/**
|
|
* sys_sched_getscheduler - get the policy (scheduling class) of a thread
|
|
* @pid: the pid in question.
|
|
*
|
|
* Return: On success, the policy of the thread. Otherwise, a negative error
|
|
* code.
|
|
*/
|
|
SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
|
|
{
|
|
struct task_struct *p;
|
|
int retval;
|
|
|
|
if (pid < 0)
|
|
return -EINVAL;
|
|
|
|
retval = -ESRCH;
|
|
rcu_read_lock();
|
|
p = find_process_by_pid(pid);
|
|
if (p) {
|
|
retval = security_task_getscheduler(p);
|
|
if (!retval)
|
|
retval = p->policy
|
|
| (p->sched_reset_on_fork ? SCHED_RESET_ON_FORK : 0);
|
|
}
|
|
rcu_read_unlock();
|
|
return retval;
|
|
}
|
|
|
|
/**
|
|
* sys_sched_getparam - get the RT priority of a thread
|
|
* @pid: the pid in question.
|
|
* @param: structure containing the RT priority.
|
|
*
|
|
* Return: On success, 0 and the RT priority is in @param. Otherwise, an error
|
|
* code.
|
|
*/
|
|
SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
|
|
{
|
|
struct sched_param lp = { .sched_priority = 0 };
|
|
struct task_struct *p;
|
|
int retval;
|
|
|
|
if (!param || pid < 0)
|
|
return -EINVAL;
|
|
|
|
rcu_read_lock();
|
|
p = find_process_by_pid(pid);
|
|
retval = -ESRCH;
|
|
if (!p)
|
|
goto out_unlock;
|
|
|
|
retval = security_task_getscheduler(p);
|
|
if (retval)
|
|
goto out_unlock;
|
|
|
|
if (task_has_rt_policy(p))
|
|
lp.sched_priority = p->rt_priority;
|
|
rcu_read_unlock();
|
|
|
|
/*
|
|
* This one might sleep, we cannot do it with a spinlock held ...
|
|
*/
|
|
retval = copy_to_user(param, &lp, sizeof(*param)) ? -EFAULT : 0;
|
|
|
|
return retval;
|
|
|
|
out_unlock:
|
|
rcu_read_unlock();
|
|
return retval;
|
|
}
|
|
|
|
/*
|
|
* Copy the kernel size attribute structure (which might be larger
|
|
* than what user-space knows about) to user-space.
|
|
*
|
|
* Note that all cases are valid: user-space buffer can be larger or
|
|
* smaller than the kernel-space buffer. The usual case is that both
|
|
* have the same size.
|
|
*/
|
|
static int
|
|
sched_attr_copy_to_user(struct sched_attr __user *uattr,
|
|
struct sched_attr *kattr,
|
|
unsigned int usize)
|
|
{
|
|
unsigned int ksize = sizeof(*kattr);
|
|
|
|
if (!access_ok(uattr, usize))
|
|
return -EFAULT;
|
|
|
|
/*
|
|
* sched_getattr() ABI forwards and backwards compatibility:
|
|
*
|
|
* If usize == ksize then we just copy everything to user-space and all is good.
|
|
*
|
|
* If usize < ksize then we only copy as much as user-space has space for,
|
|
* this keeps ABI compatibility as well. We skip the rest.
|
|
*
|
|
* If usize > ksize then user-space is using a newer version of the ABI,
|
|
* which part the kernel doesn't know about. Just ignore it - tooling can
|
|
* detect the kernel's knowledge of attributes from the attr->size value
|
|
* which is set to ksize in this case.
|
|
*/
|
|
kattr->size = min(usize, ksize);
|
|
|
|
if (copy_to_user(uattr, kattr, kattr->size))
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* sys_sched_getattr - similar to sched_getparam, but with sched_attr
|
|
* @pid: the pid in question.
|
|
* @uattr: structure containing the extended parameters.
|
|
* @usize: sizeof(attr) for fwd/bwd comp.
|
|
* @flags: for future extension.
|
|
*/
|
|
SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr,
|
|
unsigned int, usize, unsigned int, flags)
|
|
{
|
|
struct sched_attr kattr = { };
|
|
struct task_struct *p;
|
|
int retval;
|
|
|
|
if (!uattr || pid < 0 || usize > PAGE_SIZE ||
|
|
usize < SCHED_ATTR_SIZE_VER0 || flags)
|
|
return -EINVAL;
|
|
|
|
rcu_read_lock();
|
|
p = find_process_by_pid(pid);
|
|
retval = -ESRCH;
|
|
if (!p)
|
|
goto out_unlock;
|
|
|
|
retval = security_task_getscheduler(p);
|
|
if (retval)
|
|
goto out_unlock;
|
|
|
|
kattr.sched_policy = p->policy;
|
|
if (p->sched_reset_on_fork)
|
|
kattr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
|
|
get_params(p, &kattr);
|
|
kattr.sched_flags &= SCHED_FLAG_ALL;
|
|
|
|
#ifdef CONFIG_UCLAMP_TASK
|
|
/*
|
|
* This could race with another potential updater, but this is fine
|
|
* because it'll correctly read the old or the new value. We don't need
|
|
* to guarantee who wins the race as long as it doesn't return garbage.
|
|
*/
|
|
kattr.sched_util_min = p->uclamp_req[UCLAMP_MIN].value;
|
|
kattr.sched_util_max = p->uclamp_req[UCLAMP_MAX].value;
|
|
#endif
|
|
|
|
rcu_read_unlock();
|
|
|
|
return sched_attr_copy_to_user(uattr, &kattr, usize);
|
|
|
|
out_unlock:
|
|
rcu_read_unlock();
|
|
return retval;
|
|
}
|
|
|
|
long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
|
|
{
|
|
cpumask_var_t cpus_allowed, new_mask;
|
|
struct task_struct *p;
|
|
int retval;
|
|
int skip = 0;
|
|
|
|
rcu_read_lock();
|
|
|
|
p = find_process_by_pid(pid);
|
|
if (!p) {
|
|
rcu_read_unlock();
|
|
return -ESRCH;
|
|
}
|
|
|
|
/* Prevent p going away */
|
|
get_task_struct(p);
|
|
rcu_read_unlock();
|
|
|
|
if (p->flags & PF_NO_SETAFFINITY) {
|
|
retval = -EINVAL;
|
|
goto out_put_task;
|
|
}
|
|
if (!alloc_cpumask_var(&cpus_allowed, GFP_KERNEL)) {
|
|
retval = -ENOMEM;
|
|
goto out_put_task;
|
|
}
|
|
if (!alloc_cpumask_var(&new_mask, GFP_KERNEL)) {
|
|
retval = -ENOMEM;
|
|
goto out_free_cpus_allowed;
|
|
}
|
|
retval = -EPERM;
|
|
if (!check_same_owner(p)) {
|
|
rcu_read_lock();
|
|
if (!ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE)) {
|
|
rcu_read_unlock();
|
|
goto out_free_new_mask;
|
|
}
|
|
rcu_read_unlock();
|
|
}
|
|
|
|
trace_android_vh_sched_setaffinity_early(p, in_mask, &skip);
|
|
if (skip)
|
|
goto out_free_new_mask;
|
|
retval = security_task_setscheduler(p);
|
|
if (retval)
|
|
goto out_free_new_mask;
|
|
|
|
|
|
cpuset_cpus_allowed(p, cpus_allowed);
|
|
cpumask_and(new_mask, in_mask, cpus_allowed);
|
|
|
|
/*
|
|
* Since bandwidth control happens on root_domain basis,
|
|
* if admission test is enabled, we only admit -deadline
|
|
* tasks allowed to run on all the CPUs in the task's
|
|
* root_domain.
|
|
*/
|
|
#ifdef CONFIG_SMP
|
|
if (task_has_dl_policy(p) && dl_bandwidth_enabled()) {
|
|
rcu_read_lock();
|
|
if (!cpumask_subset(task_rq(p)->rd->span, new_mask)) {
|
|
retval = -EBUSY;
|
|
rcu_read_unlock();
|
|
goto out_free_new_mask;
|
|
}
|
|
rcu_read_unlock();
|
|
}
|
|
#endif
|
|
again:
|
|
retval = __set_cpus_allowed_ptr(p, new_mask, true);
|
|
|
|
if (!retval) {
|
|
cpuset_cpus_allowed(p, cpus_allowed);
|
|
if (!cpumask_subset(new_mask, cpus_allowed)) {
|
|
/*
|
|
* We must have raced with a concurrent cpuset
|
|
* update. Just reset the cpus_allowed to the
|
|
* cpuset's cpus_allowed
|
|
*/
|
|
cpumask_copy(new_mask, cpus_allowed);
|
|
goto again;
|
|
}
|
|
}
|
|
|
|
trace_android_rvh_sched_setaffinity(p, in_mask, &retval);
|
|
|
|
out_free_new_mask:
|
|
free_cpumask_var(new_mask);
|
|
out_free_cpus_allowed:
|
|
free_cpumask_var(cpus_allowed);
|
|
out_put_task:
|
|
put_task_struct(p);
|
|
return retval;
|
|
}
|
|
|
|
static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len,
|
|
struct cpumask *new_mask)
|
|
{
|
|
if (len < cpumask_size())
|
|
cpumask_clear(new_mask);
|
|
else if (len > cpumask_size())
|
|
len = cpumask_size();
|
|
|
|
return copy_from_user(new_mask, user_mask_ptr, len) ? -EFAULT : 0;
|
|
}
|
|
|
|
/**
|
|
* sys_sched_setaffinity - set the CPU affinity of a process
|
|
* @pid: pid of the process
|
|
* @len: length in bytes of the bitmask pointed to by user_mask_ptr
|
|
* @user_mask_ptr: user-space pointer to the new CPU mask
|
|
*
|
|
* Return: 0 on success. An error code otherwise.
|
|
*/
|
|
SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len,
|
|
unsigned long __user *, user_mask_ptr)
|
|
{
|
|
cpumask_var_t new_mask;
|
|
int retval;
|
|
|
|
if (!alloc_cpumask_var(&new_mask, GFP_KERNEL))
|
|
return -ENOMEM;
|
|
|
|
retval = get_user_cpu_mask(user_mask_ptr, len, new_mask);
|
|
if (retval == 0)
|
|
retval = sched_setaffinity(pid, new_mask);
|
|
free_cpumask_var(new_mask);
|
|
return retval;
|
|
}
|
|
|
|
long sched_getaffinity(pid_t pid, struct cpumask *mask)
|
|
{
|
|
struct task_struct *p;
|
|
unsigned long flags;
|
|
int retval;
|
|
|
|
rcu_read_lock();
|
|
|
|
retval = -ESRCH;
|
|
p = find_process_by_pid(pid);
|
|
if (!p)
|
|
goto out_unlock;
|
|
|
|
retval = security_task_getscheduler(p);
|
|
if (retval)
|
|
goto out_unlock;
|
|
|
|
raw_spin_lock_irqsave(&p->pi_lock, flags);
|
|
cpumask_and(mask, &p->cpus_mask, cpu_active_mask);
|
|
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
|
|
|
|
out_unlock:
|
|
rcu_read_unlock();
|
|
|
|
return retval;
|
|
}
|
|
|
|
/**
|
|
* sys_sched_getaffinity - get the CPU affinity of a process
|
|
* @pid: pid of the process
|
|
* @len: length in bytes of the bitmask pointed to by user_mask_ptr
|
|
* @user_mask_ptr: user-space pointer to hold the current CPU mask
|
|
*
|
|
* Return: size of CPU mask copied to user_mask_ptr on success. An
|
|
* error code otherwise.
|
|
*/
|
|
SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
|
|
unsigned long __user *, user_mask_ptr)
|
|
{
|
|
int ret;
|
|
cpumask_var_t mask;
|
|
|
|
if ((len * BITS_PER_BYTE) < nr_cpu_ids)
|
|
return -EINVAL;
|
|
if (len & (sizeof(unsigned long)-1))
|
|
return -EINVAL;
|
|
|
|
if (!alloc_cpumask_var(&mask, GFP_KERNEL))
|
|
return -ENOMEM;
|
|
|
|
ret = sched_getaffinity(pid, mask);
|
|
if (ret == 0) {
|
|
unsigned int retlen = min(len, cpumask_size());
|
|
|
|
if (copy_to_user(user_mask_ptr, mask, retlen))
|
|
ret = -EFAULT;
|
|
else
|
|
ret = retlen;
|
|
}
|
|
free_cpumask_var(mask);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* sys_sched_yield - yield the current processor to other threads.
|
|
*
|
|
* This function yields the current CPU to other tasks. If there are no
|
|
* other threads running on this CPU then this function will return.
|
|
*
|
|
* Return: 0.
|
|
*/
|
|
static void do_sched_yield(void)
|
|
{
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
rq = this_rq_lock_irq(&rf);
|
|
|
|
schedstat_inc(rq->yld_count);
|
|
current->sched_class->yield_task(rq);
|
|
|
|
trace_android_rvh_do_sched_yield(rq);
|
|
|
|
preempt_disable();
|
|
rq_unlock_irq(rq, &rf);
|
|
sched_preempt_enable_no_resched();
|
|
|
|
schedule();
|
|
}
|
|
|
|
SYSCALL_DEFINE0(sched_yield)
|
|
{
|
|
do_sched_yield();
|
|
return 0;
|
|
}
|
|
|
|
#ifndef CONFIG_PREEMPTION
|
|
int __sched _cond_resched(void)
|
|
{
|
|
if (should_resched(0)) {
|
|
preempt_schedule_common();
|
|
return 1;
|
|
}
|
|
rcu_all_qs();
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(_cond_resched);
|
|
#endif
|
|
|
|
/*
|
|
* __cond_resched_lock() - if a reschedule is pending, drop the given lock,
|
|
* call schedule, and on return reacquire the lock.
|
|
*
|
|
* This works OK both with and without CONFIG_PREEMPTION. We do strange low-level
|
|
* operations here to prevent schedule() from being called twice (once via
|
|
* spin_unlock(), once by hand).
|
|
*/
|
|
int __cond_resched_lock(spinlock_t *lock)
|
|
{
|
|
int resched = should_resched(PREEMPT_LOCK_OFFSET);
|
|
int ret = 0;
|
|
|
|
lockdep_assert_held(lock);
|
|
|
|
if (spin_needbreak(lock) || resched) {
|
|
spin_unlock(lock);
|
|
if (resched)
|
|
preempt_schedule_common();
|
|
else
|
|
cpu_relax();
|
|
ret = 1;
|
|
spin_lock(lock);
|
|
}
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(__cond_resched_lock);
|
|
|
|
/**
|
|
* yield - yield the current processor to other threads.
|
|
*
|
|
* Do not ever use this function, there's a 99% chance you're doing it wrong.
|
|
*
|
|
* The scheduler is at all times free to pick the calling task as the most
|
|
* eligible task to run, if removing the yield() call from your code breaks
|
|
* it, its already broken.
|
|
*
|
|
* Typical broken usage is:
|
|
*
|
|
* while (!event)
|
|
* yield();
|
|
*
|
|
* where one assumes that yield() will let 'the other' process run that will
|
|
* make event true. If the current task is a SCHED_FIFO task that will never
|
|
* happen. Never use yield() as a progress guarantee!!
|
|
*
|
|
* If you want to use yield() to wait for something, use wait_event().
|
|
* If you want to use yield() to be 'nice' for others, use cond_resched().
|
|
* If you still want to use yield(), do not!
|
|
*/
|
|
void __sched yield(void)
|
|
{
|
|
set_current_state(TASK_RUNNING);
|
|
do_sched_yield();
|
|
}
|
|
EXPORT_SYMBOL(yield);
|
|
|
|
/**
|
|
* yield_to - yield the current processor to another thread in
|
|
* your thread group, or accelerate that thread toward the
|
|
* processor it's on.
|
|
* @p: target task
|
|
* @preempt: whether task preemption is allowed or not
|
|
*
|
|
* It's the caller's job to ensure that the target task struct
|
|
* can't go away on us before we can do any checks.
|
|
*
|
|
* Return:
|
|
* true (>0) if we indeed boosted the target task.
|
|
* false (0) if we failed to boost the target.
|
|
* -ESRCH if there's no task to yield to.
|
|
*/
|
|
int __sched yield_to(struct task_struct *p, bool preempt)
|
|
{
|
|
struct task_struct *curr = current;
|
|
struct rq *rq, *p_rq;
|
|
unsigned long flags;
|
|
int yielded = 0;
|
|
|
|
local_irq_save(flags);
|
|
rq = this_rq();
|
|
|
|
again:
|
|
p_rq = task_rq(p);
|
|
/*
|
|
* If we're the only runnable task on the rq and target rq also
|
|
* has only one task, there's absolutely no point in yielding.
|
|
*/
|
|
if (rq->nr_running == 1 && p_rq->nr_running == 1) {
|
|
yielded = -ESRCH;
|
|
goto out_irq;
|
|
}
|
|
|
|
double_rq_lock(rq, p_rq);
|
|
if (task_rq(p) != p_rq) {
|
|
double_rq_unlock(rq, p_rq);
|
|
goto again;
|
|
}
|
|
|
|
if (!curr->sched_class->yield_to_task)
|
|
goto out_unlock;
|
|
|
|
if (curr->sched_class != p->sched_class)
|
|
goto out_unlock;
|
|
|
|
if (task_running(p_rq, p) || p->state)
|
|
goto out_unlock;
|
|
|
|
yielded = curr->sched_class->yield_to_task(rq, p);
|
|
if (yielded) {
|
|
schedstat_inc(rq->yld_count);
|
|
/*
|
|
* Make p's CPU reschedule; pick_next_entity takes care of
|
|
* fairness.
|
|
*/
|
|
if (preempt && rq != p_rq)
|
|
resched_curr(p_rq);
|
|
}
|
|
|
|
out_unlock:
|
|
double_rq_unlock(rq, p_rq);
|
|
out_irq:
|
|
local_irq_restore(flags);
|
|
|
|
if (yielded > 0)
|
|
schedule();
|
|
|
|
return yielded;
|
|
}
|
|
EXPORT_SYMBOL_GPL(yield_to);
|
|
|
|
int io_schedule_prepare(void)
|
|
{
|
|
int old_iowait = current->in_iowait;
|
|
|
|
current->in_iowait = 1;
|
|
blk_schedule_flush_plug(current);
|
|
|
|
return old_iowait;
|
|
}
|
|
|
|
void io_schedule_finish(int token)
|
|
{
|
|
current->in_iowait = token;
|
|
}
|
|
|
|
/*
|
|
* This task is about to go to sleep on IO. Increment rq->nr_iowait so
|
|
* that process accounting knows that this is a task in IO wait state.
|
|
*/
|
|
long __sched io_schedule_timeout(long timeout)
|
|
{
|
|
int token;
|
|
long ret;
|
|
|
|
token = io_schedule_prepare();
|
|
ret = schedule_timeout(timeout);
|
|
io_schedule_finish(token);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(io_schedule_timeout);
|
|
|
|
void __sched io_schedule(void)
|
|
{
|
|
int token;
|
|
|
|
token = io_schedule_prepare();
|
|
schedule();
|
|
io_schedule_finish(token);
|
|
}
|
|
EXPORT_SYMBOL(io_schedule);
|
|
|
|
/**
|
|
* sys_sched_get_priority_max - return maximum RT priority.
|
|
* @policy: scheduling class.
|
|
*
|
|
* Return: On success, this syscall returns the maximum
|
|
* rt_priority that can be used by a given scheduling class.
|
|
* On failure, a negative error code is returned.
|
|
*/
|
|
SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
|
|
{
|
|
int ret = -EINVAL;
|
|
|
|
switch (policy) {
|
|
case SCHED_FIFO:
|
|
case SCHED_RR:
|
|
ret = MAX_USER_RT_PRIO-1;
|
|
break;
|
|
case SCHED_DEADLINE:
|
|
case SCHED_NORMAL:
|
|
case SCHED_BATCH:
|
|
case SCHED_IDLE:
|
|
ret = 0;
|
|
break;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* sys_sched_get_priority_min - return minimum RT priority.
|
|
* @policy: scheduling class.
|
|
*
|
|
* Return: On success, this syscall returns the minimum
|
|
* rt_priority that can be used by a given scheduling class.
|
|
* On failure, a negative error code is returned.
|
|
*/
|
|
SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
|
|
{
|
|
int ret = -EINVAL;
|
|
|
|
switch (policy) {
|
|
case SCHED_FIFO:
|
|
case SCHED_RR:
|
|
ret = 1;
|
|
break;
|
|
case SCHED_DEADLINE:
|
|
case SCHED_NORMAL:
|
|
case SCHED_BATCH:
|
|
case SCHED_IDLE:
|
|
ret = 0;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static int sched_rr_get_interval(pid_t pid, struct timespec64 *t)
|
|
{
|
|
struct task_struct *p;
|
|
unsigned int time_slice;
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
int retval;
|
|
|
|
if (pid < 0)
|
|
return -EINVAL;
|
|
|
|
retval = -ESRCH;
|
|
rcu_read_lock();
|
|
p = find_process_by_pid(pid);
|
|
if (!p)
|
|
goto out_unlock;
|
|
|
|
retval = security_task_getscheduler(p);
|
|
if (retval)
|
|
goto out_unlock;
|
|
|
|
rq = task_rq_lock(p, &rf);
|
|
time_slice = 0;
|
|
if (p->sched_class->get_rr_interval)
|
|
time_slice = p->sched_class->get_rr_interval(rq, p);
|
|
task_rq_unlock(rq, p, &rf);
|
|
|
|
rcu_read_unlock();
|
|
jiffies_to_timespec64(time_slice, t);
|
|
return 0;
|
|
|
|
out_unlock:
|
|
rcu_read_unlock();
|
|
return retval;
|
|
}
|
|
|
|
/**
|
|
* sys_sched_rr_get_interval - return the default timeslice of a process.
|
|
* @pid: pid of the process.
|
|
* @interval: userspace pointer to the timeslice value.
|
|
*
|
|
* this syscall writes the default timeslice value of a given process
|
|
* into the user-space timespec buffer. A value of '0' means infinity.
|
|
*
|
|
* Return: On success, 0 and the timeslice is in @interval. Otherwise,
|
|
* an error code.
|
|
*/
|
|
SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
|
|
struct __kernel_timespec __user *, interval)
|
|
{
|
|
struct timespec64 t;
|
|
int retval = sched_rr_get_interval(pid, &t);
|
|
|
|
if (retval == 0)
|
|
retval = put_timespec64(&t, interval);
|
|
|
|
return retval;
|
|
}
|
|
|
|
#ifdef CONFIG_COMPAT_32BIT_TIME
|
|
SYSCALL_DEFINE2(sched_rr_get_interval_time32, pid_t, pid,
|
|
struct old_timespec32 __user *, interval)
|
|
{
|
|
struct timespec64 t;
|
|
int retval = sched_rr_get_interval(pid, &t);
|
|
|
|
if (retval == 0)
|
|
retval = put_old_timespec32(&t, interval);
|
|
return retval;
|
|
}
|
|
#endif
|
|
|
|
void sched_show_task(struct task_struct *p)
|
|
{
|
|
unsigned long free = 0;
|
|
int ppid;
|
|
|
|
if (!try_get_task_stack(p))
|
|
return;
|
|
|
|
pr_info("task:%-15.15s state:%c", p->comm, task_state_to_char(p));
|
|
|
|
if (p->state == TASK_RUNNING)
|
|
pr_cont(" running task ");
|
|
#ifdef CONFIG_DEBUG_STACK_USAGE
|
|
free = stack_not_used(p);
|
|
#endif
|
|
ppid = 0;
|
|
rcu_read_lock();
|
|
if (pid_alive(p))
|
|
ppid = task_pid_nr(rcu_dereference(p->real_parent));
|
|
rcu_read_unlock();
|
|
pr_cont(" stack:%5lu pid:%5d ppid:%6d flags:0x%08lx\n",
|
|
free, task_pid_nr(p), ppid,
|
|
(unsigned long)task_thread_info(p)->flags);
|
|
|
|
print_worker_info(KERN_INFO, p);
|
|
trace_android_vh_sched_show_task(p);
|
|
show_stack(p, NULL, KERN_INFO);
|
|
put_task_stack(p);
|
|
}
|
|
EXPORT_SYMBOL_GPL(sched_show_task);
|
|
|
|
static inline bool
|
|
state_filter_match(unsigned long state_filter, struct task_struct *p)
|
|
{
|
|
/* no filter, everything matches */
|
|
if (!state_filter)
|
|
return true;
|
|
|
|
/* filter, but doesn't match */
|
|
if (!(p->state & state_filter))
|
|
return false;
|
|
|
|
/*
|
|
* When looking for TASK_UNINTERRUPTIBLE skip TASK_IDLE (allows
|
|
* TASK_KILLABLE).
|
|
*/
|
|
if (state_filter == TASK_UNINTERRUPTIBLE && p->state == TASK_IDLE)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
void show_state_filter(unsigned long state_filter)
|
|
{
|
|
struct task_struct *g, *p;
|
|
|
|
rcu_read_lock();
|
|
for_each_process_thread(g, p) {
|
|
/*
|
|
* reset the NMI-timeout, listing all files on a slow
|
|
* console might take a lot of time:
|
|
* Also, reset softlockup watchdogs on all CPUs, because
|
|
* another CPU might be blocked waiting for us to process
|
|
* an IPI.
|
|
*/
|
|
touch_nmi_watchdog();
|
|
touch_all_softlockup_watchdogs();
|
|
if (state_filter_match(state_filter, p))
|
|
sched_show_task(p);
|
|
}
|
|
|
|
#ifdef CONFIG_SCHED_DEBUG
|
|
if (!state_filter)
|
|
sysrq_sched_debug_show();
|
|
#endif
|
|
rcu_read_unlock();
|
|
/*
|
|
* Only show locks if all tasks are dumped:
|
|
*/
|
|
if (!state_filter)
|
|
debug_show_all_locks();
|
|
}
|
|
|
|
/**
|
|
* init_idle - set up an idle thread for a given CPU
|
|
* @idle: task in question
|
|
* @cpu: CPU the idle task belongs to
|
|
*
|
|
* NOTE: this function does not set the idle thread's NEED_RESCHED
|
|
* flag, to make booting more robust.
|
|
*/
|
|
void __init init_idle(struct task_struct *idle, int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
unsigned long flags;
|
|
|
|
__sched_fork(0, idle);
|
|
|
|
raw_spin_lock_irqsave(&idle->pi_lock, flags);
|
|
raw_spin_lock(&rq->lock);
|
|
|
|
idle->state = TASK_RUNNING;
|
|
idle->se.exec_start = sched_clock();
|
|
idle->flags |= PF_IDLE;
|
|
|
|
#ifdef CONFIG_SMP
|
|
/*
|
|
* Its possible that init_idle() gets called multiple times on a task,
|
|
* in that case do_set_cpus_allowed() will not do the right thing.
|
|
*
|
|
* And since this is boot we can forgo the serialization.
|
|
*/
|
|
set_cpus_allowed_common(idle, cpumask_of(cpu));
|
|
#endif
|
|
/*
|
|
* We're having a chicken and egg problem, even though we are
|
|
* holding rq->lock, the CPU isn't yet set to this CPU so the
|
|
* lockdep check in task_group() will fail.
|
|
*
|
|
* Similar case to sched_fork(). / Alternatively we could
|
|
* use task_rq_lock() here and obtain the other rq->lock.
|
|
*
|
|
* Silence PROVE_RCU
|
|
*/
|
|
rcu_read_lock();
|
|
__set_task_cpu(idle, cpu);
|
|
rcu_read_unlock();
|
|
|
|
rq->idle = idle;
|
|
rcu_assign_pointer(rq->curr, idle);
|
|
idle->on_rq = TASK_ON_RQ_QUEUED;
|
|
#ifdef CONFIG_SMP
|
|
idle->on_cpu = 1;
|
|
#endif
|
|
raw_spin_unlock(&rq->lock);
|
|
raw_spin_unlock_irqrestore(&idle->pi_lock, flags);
|
|
|
|
/* Set the preempt count _outside_ the spinlocks! */
|
|
init_idle_preempt_count(idle, cpu);
|
|
|
|
/*
|
|
* The idle tasks have their own, simple scheduling class:
|
|
*/
|
|
idle->sched_class = &idle_sched_class;
|
|
ftrace_graph_init_idle_task(idle, cpu);
|
|
vtime_init_idle(idle, cpu);
|
|
#ifdef CONFIG_SMP
|
|
sprintf(idle->comm, "%s/%d", INIT_TASK_COMM, cpu);
|
|
#endif
|
|
}
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
int cpuset_cpumask_can_shrink(const struct cpumask *cur,
|
|
const struct cpumask *trial)
|
|
{
|
|
int ret = 1;
|
|
|
|
if (!cpumask_weight(cur))
|
|
return ret;
|
|
|
|
ret = dl_cpuset_cpumask_can_shrink(cur, trial);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int task_can_attach(struct task_struct *p,
|
|
const struct cpumask *cs_cpus_allowed)
|
|
{
|
|
int ret = 0;
|
|
|
|
/*
|
|
* Kthreads which disallow setaffinity shouldn't be moved
|
|
* to a new cpuset; we don't want to change their CPU
|
|
* affinity and isolating such threads by their set of
|
|
* allowed nodes is unnecessary. Thus, cpusets are not
|
|
* applicable for such threads. This prevents checking for
|
|
* success of set_cpus_allowed_ptr() on all attached tasks
|
|
* before cpus_mask may be changed.
|
|
*/
|
|
if (p->flags & PF_NO_SETAFFINITY) {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
if (dl_task(p) && !cpumask_intersects(task_rq(p)->rd->span,
|
|
cs_cpus_allowed))
|
|
ret = dl_task_can_attach(p, cs_cpus_allowed);
|
|
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
bool sched_smp_initialized __read_mostly;
|
|
|
|
#ifdef CONFIG_NUMA_BALANCING
|
|
/* Migrate current task p to target_cpu */
|
|
int migrate_task_to(struct task_struct *p, int target_cpu)
|
|
{
|
|
struct migration_arg arg = { p, target_cpu };
|
|
int curr_cpu = task_cpu(p);
|
|
|
|
if (curr_cpu == target_cpu)
|
|
return 0;
|
|
|
|
if (!cpumask_test_cpu(target_cpu, p->cpus_ptr))
|
|
return -EINVAL;
|
|
|
|
/* TODO: This is not properly updating schedstats */
|
|
|
|
trace_sched_move_numa(p, curr_cpu, target_cpu);
|
|
return stop_one_cpu(curr_cpu, migration_cpu_stop, &arg);
|
|
}
|
|
|
|
/*
|
|
* Requeue a task on a given node and accurately track the number of NUMA
|
|
* tasks on the runqueues
|
|
*/
|
|
void sched_setnuma(struct task_struct *p, int nid)
|
|
{
|
|
bool queued, running;
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
rq = task_rq_lock(p, &rf);
|
|
queued = task_on_rq_queued(p);
|
|
running = task_current(rq, p);
|
|
|
|
if (queued)
|
|
dequeue_task(rq, p, DEQUEUE_SAVE);
|
|
if (running)
|
|
put_prev_task(rq, p);
|
|
|
|
p->numa_preferred_nid = nid;
|
|
|
|
if (queued)
|
|
enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK);
|
|
if (running)
|
|
set_next_task(rq, p);
|
|
task_rq_unlock(rq, p, &rf);
|
|
}
|
|
#endif /* CONFIG_NUMA_BALANCING */
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
/*
|
|
* Ensure that the idle task is using init_mm right before its CPU goes
|
|
* offline.
|
|
*/
|
|
void idle_task_exit(void)
|
|
{
|
|
struct mm_struct *mm = current->active_mm;
|
|
|
|
BUG_ON(cpu_online(smp_processor_id()));
|
|
BUG_ON(current != this_rq()->idle);
|
|
|
|
if (mm != &init_mm) {
|
|
switch_mm(mm, &init_mm, current);
|
|
finish_arch_post_lock_switch();
|
|
}
|
|
|
|
/* finish_cpu(), as ran on the BP, will clean up the active_mm state */
|
|
}
|
|
|
|
/*
|
|
* Since this CPU is going 'away' for a while, fold any nr_active delta
|
|
* we might have. Assumes we're called after migrate_tasks() so that the
|
|
* nr_active count is stable. We need to take the teardown thread which
|
|
* is calling this into account, so we hand in adjust = 1 to the load
|
|
* calculation.
|
|
*
|
|
* Also see the comment "Global load-average calculations".
|
|
*/
|
|
static void calc_load_migrate(struct rq *rq)
|
|
{
|
|
long delta = calc_load_fold_active(rq, 1);
|
|
if (delta)
|
|
atomic_long_add(delta, &calc_load_tasks);
|
|
}
|
|
|
|
static struct task_struct *__pick_migrate_task(struct rq *rq)
|
|
{
|
|
const struct sched_class *class;
|
|
struct task_struct *next;
|
|
|
|
for_each_class(class) {
|
|
next = class->pick_next_task(rq);
|
|
if (next) {
|
|
next->sched_class->put_prev_task(rq, next);
|
|
return next;
|
|
}
|
|
}
|
|
|
|
/* The idle class should always have a runnable task */
|
|
BUG();
|
|
}
|
|
|
|
/*
|
|
* Migrate all tasks from the rq, sleeping tasks will be migrated by
|
|
* try_to_wake_up()->select_task_rq().
|
|
*
|
|
* Called with rq->lock held even though we'er in stop_machine() and
|
|
* there's no concurrency possible, we hold the required locks anyway
|
|
* because of lock validation efforts.
|
|
*
|
|
* force: if false, the function will skip CPU pinned kthreads.
|
|
*/
|
|
static void migrate_tasks(struct rq *dead_rq, struct rq_flags *rf, bool force)
|
|
{
|
|
struct rq *rq = dead_rq;
|
|
struct task_struct *next, *tmp, *stop = rq->stop;
|
|
LIST_HEAD(percpu_kthreads);
|
|
struct rq_flags orf = *rf;
|
|
int dest_cpu;
|
|
|
|
/*
|
|
* Fudge the rq selection such that the below task selection loop
|
|
* doesn't get stuck on the currently eligible stop task.
|
|
*
|
|
* We're currently inside stop_machine() and the rq is either stuck
|
|
* in the stop_machine_cpu_stop() loop, or we're executing this code,
|
|
* either way we should never end up calling schedule() until we're
|
|
* done here.
|
|
*/
|
|
rq->stop = NULL;
|
|
|
|
/*
|
|
* put_prev_task() and pick_next_task() sched
|
|
* class method both need to have an up-to-date
|
|
* value of rq->clock[_task]
|
|
*/
|
|
update_rq_clock(rq);
|
|
|
|
#ifdef CONFIG_SCHED_DEBUG
|
|
/* note the clock update in orf */
|
|
orf.clock_update_flags |= RQCF_UPDATED;
|
|
#endif
|
|
|
|
for (;;) {
|
|
/*
|
|
* There's this thread running, bail when that's the only
|
|
* remaining thread:
|
|
*/
|
|
if (rq->nr_running == 1)
|
|
break;
|
|
|
|
next = __pick_migrate_task(rq);
|
|
|
|
/*
|
|
* Argh ... no iterator for tasks, we need to remove the
|
|
* kthread from the run-queue to continue.
|
|
*/
|
|
if (!force && is_per_cpu_kthread(next)) {
|
|
INIT_LIST_HEAD(&next->percpu_kthread_node);
|
|
list_add(&next->percpu_kthread_node, &percpu_kthreads);
|
|
|
|
/* DEQUEUE_SAVE not used due to move_entity in rt */
|
|
deactivate_task(rq, next,
|
|
DEQUEUE_NOCLOCK);
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* Rules for changing task_struct::cpus_mask are holding
|
|
* both pi_lock and rq->lock, such that holding either
|
|
* stabilizes the mask.
|
|
*
|
|
* Drop rq->lock is not quite as disastrous as it usually is
|
|
* because !cpu_active at this point, which means load-balance
|
|
* will not interfere. Also, stop-machine.
|
|
*/
|
|
rq_unlock(rq, rf);
|
|
raw_spin_lock(&next->pi_lock);
|
|
rq_relock(rq, rf);
|
|
|
|
/*
|
|
* Since we're inside stop-machine, _nothing_ should have
|
|
* changed the task, WARN if weird stuff happened, because in
|
|
* that case the above rq->lock drop is a fail too.
|
|
*/
|
|
if (task_rq(next) != rq || !task_on_rq_queued(next)) {
|
|
/*
|
|
* In the !force case, there is a hole between
|
|
* rq_unlock() and rq_relock(), where another CPU might
|
|
* not observe an up to date cpu_active_mask and try to
|
|
* move tasks around.
|
|
*/
|
|
WARN_ON(force);
|
|
raw_spin_unlock(&next->pi_lock);
|
|
continue;
|
|
}
|
|
|
|
/* Find suitable destination for @next, with force if needed. */
|
|
dest_cpu = select_fallback_rq(dead_rq->cpu, next);
|
|
rq = __migrate_task(rq, rf, next, dest_cpu);
|
|
if (rq != dead_rq) {
|
|
rq_unlock(rq, rf);
|
|
rq = dead_rq;
|
|
*rf = orf;
|
|
rq_relock(rq, rf);
|
|
}
|
|
raw_spin_unlock(&next->pi_lock);
|
|
}
|
|
|
|
list_for_each_entry_safe(next, tmp, &percpu_kthreads,
|
|
percpu_kthread_node) {
|
|
|
|
/* ENQUEUE_RESTORE not used due to move_entity in rt */
|
|
activate_task(rq, next, ENQUEUE_NOCLOCK);
|
|
list_del(&next->percpu_kthread_node);
|
|
}
|
|
|
|
rq->stop = stop;
|
|
}
|
|
|
|
static int drain_rq_cpu_stop(void *data)
|
|
{
|
|
struct rq *rq = this_rq();
|
|
struct rq_flags rf;
|
|
|
|
rq_lock_irqsave(rq, &rf);
|
|
migrate_tasks(rq, &rf, false);
|
|
rq_unlock_irqrestore(rq, &rf);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int sched_cpu_drain_rq(unsigned int cpu)
|
|
{
|
|
struct cpu_stop_work *rq_drain = &(cpu_rq(cpu)->drain);
|
|
struct cpu_stop_done *rq_drain_done = &(cpu_rq(cpu)->drain_done);
|
|
|
|
if (idle_cpu(cpu)) {
|
|
rq_drain->done = NULL;
|
|
return 0;
|
|
}
|
|
|
|
return stop_one_cpu_async(cpu, drain_rq_cpu_stop, NULL, rq_drain,
|
|
rq_drain_done);
|
|
}
|
|
|
|
void sched_cpu_drain_rq_wait(unsigned int cpu)
|
|
{
|
|
struct cpu_stop_work *rq_drain = &(cpu_rq(cpu)->drain);
|
|
|
|
if (rq_drain->done)
|
|
cpu_stop_work_wait(rq_drain);
|
|
}
|
|
#endif /* CONFIG_HOTPLUG_CPU */
|
|
|
|
void set_rq_online(struct rq *rq)
|
|
{
|
|
if (!rq->online) {
|
|
const struct sched_class *class;
|
|
|
|
cpumask_set_cpu(rq->cpu, rq->rd->online);
|
|
rq->online = 1;
|
|
|
|
for_each_class(class) {
|
|
if (class->rq_online)
|
|
class->rq_online(rq);
|
|
}
|
|
}
|
|
}
|
|
|
|
void set_rq_offline(struct rq *rq)
|
|
{
|
|
if (rq->online) {
|
|
const struct sched_class *class;
|
|
|
|
for_each_class(class) {
|
|
if (class->rq_offline)
|
|
class->rq_offline(rq);
|
|
}
|
|
|
|
cpumask_clear_cpu(rq->cpu, rq->rd->online);
|
|
rq->online = 0;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* used to mark begin/end of suspend/resume:
|
|
*/
|
|
static int num_cpus_frozen;
|
|
|
|
/*
|
|
* Update cpusets according to cpu_active mask. If cpusets are
|
|
* disabled, cpuset_update_active_cpus() becomes a simple wrapper
|
|
* around partition_sched_domains().
|
|
*
|
|
* If we come here as part of a suspend/resume, don't touch cpusets because we
|
|
* want to restore it back to its original state upon resume anyway.
|
|
*/
|
|
static void cpuset_cpu_active(void)
|
|
{
|
|
if (cpuhp_tasks_frozen) {
|
|
/*
|
|
* num_cpus_frozen tracks how many CPUs are involved in suspend
|
|
* resume sequence. As long as this is not the last online
|
|
* operation in the resume sequence, just build a single sched
|
|
* domain, ignoring cpusets.
|
|
*/
|
|
partition_sched_domains(1, NULL, NULL);
|
|
if (--num_cpus_frozen)
|
|
return;
|
|
/*
|
|
* This is the last CPU online operation. So fall through and
|
|
* restore the original sched domains by considering the
|
|
* cpuset configurations.
|
|
*/
|
|
cpuset_force_rebuild();
|
|
}
|
|
cpuset_update_active_cpus();
|
|
}
|
|
|
|
static int cpuset_cpu_inactive(unsigned int cpu)
|
|
{
|
|
if (!cpuhp_tasks_frozen) {
|
|
if (dl_cpu_busy(cpu))
|
|
return -EBUSY;
|
|
cpuset_update_active_cpus();
|
|
} else {
|
|
num_cpus_frozen++;
|
|
partition_sched_domains(1, NULL, NULL);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int sched_cpu_activate(unsigned int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
struct rq_flags rf;
|
|
|
|
#ifdef CONFIG_SCHED_SMT
|
|
/*
|
|
* When going up, increment the number of cores with SMT present.
|
|
*/
|
|
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
|
|
static_branch_inc_cpuslocked(&sched_smt_present);
|
|
#endif
|
|
set_cpu_active(cpu, true);
|
|
|
|
if (sched_smp_initialized) {
|
|
sched_domains_numa_masks_set(cpu);
|
|
cpuset_cpu_active();
|
|
}
|
|
|
|
/*
|
|
* Put the rq online, if not already. This happens:
|
|
*
|
|
* 1) In the early boot process, because we build the real domains
|
|
* after all CPUs have been brought up.
|
|
*
|
|
* 2) At runtime, if cpuset_cpu_active() fails to rebuild the
|
|
* domains.
|
|
*/
|
|
rq_lock_irqsave(rq, &rf);
|
|
if (rq->rd) {
|
|
BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
|
|
set_rq_online(rq);
|
|
}
|
|
rq_unlock_irqrestore(rq, &rf);
|
|
|
|
update_max_interval();
|
|
|
|
return 0;
|
|
}
|
|
|
|
int sched_cpus_activate(struct cpumask *cpus)
|
|
{
|
|
unsigned int cpu;
|
|
|
|
for_each_cpu(cpu, cpus) {
|
|
if (sched_cpu_activate(cpu)) {
|
|
for_each_cpu_and(cpu, cpus, cpu_active_mask)
|
|
sched_cpu_deactivate(cpu);
|
|
|
|
return -EBUSY;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int _sched_cpu_deactivate(unsigned int cpu)
|
|
{
|
|
int ret;
|
|
|
|
set_cpu_active(cpu, false);
|
|
|
|
#ifdef CONFIG_SCHED_SMT
|
|
/*
|
|
* When going down, decrement the number of cores with SMT present.
|
|
*/
|
|
if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
|
|
static_branch_dec_cpuslocked(&sched_smt_present);
|
|
#endif
|
|
|
|
if (!sched_smp_initialized)
|
|
return 0;
|
|
|
|
ret = cpuset_cpu_inactive(cpu);
|
|
if (ret) {
|
|
set_cpu_active(cpu, true);
|
|
return ret;
|
|
}
|
|
sched_domains_numa_masks_clear(cpu);
|
|
|
|
update_max_interval();
|
|
|
|
return 0;
|
|
}
|
|
|
|
int sched_cpu_deactivate(unsigned int cpu)
|
|
{
|
|
int ret = _sched_cpu_deactivate(cpu);
|
|
|
|
if (ret)
|
|
return ret;
|
|
|
|
/*
|
|
* We've cleared cpu_active_mask, wait for all preempt-disabled and RCU
|
|
* users of this state to go away such that all new such users will
|
|
* observe it.
|
|
*
|
|
* Do sync before park smpboot threads to take care the rcu boost case.
|
|
*/
|
|
synchronize_rcu();
|
|
|
|
return 0;
|
|
}
|
|
|
|
int sched_cpus_deactivate_nosync(struct cpumask *cpus)
|
|
{
|
|
unsigned int cpu;
|
|
|
|
for_each_cpu(cpu, cpus) {
|
|
if (_sched_cpu_deactivate(cpu)) {
|
|
for_each_cpu(cpu, cpus) {
|
|
if (!cpu_active(cpu))
|
|
sched_cpu_activate(cpu);
|
|
}
|
|
|
|
return -EBUSY;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void sched_rq_cpu_starting(unsigned int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
|
|
rq->calc_load_update = calc_load_update;
|
|
}
|
|
|
|
int sched_cpu_starting(unsigned int cpu)
|
|
{
|
|
sched_rq_cpu_starting(cpu);
|
|
sched_tick_start(cpu);
|
|
trace_android_rvh_sched_cpu_starting(cpu);
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
int sched_cpu_dying(unsigned int cpu)
|
|
{
|
|
struct rq *rq = cpu_rq(cpu);
|
|
struct rq_flags rf;
|
|
|
|
/* Handle pending wakeups and then migrate everything off */
|
|
sched_tick_stop(cpu);
|
|
|
|
rq_lock_irqsave(rq, &rf);
|
|
if (rq->rd) {
|
|
BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
|
|
set_rq_offline(rq);
|
|
}
|
|
migrate_tasks(rq, &rf, true);
|
|
BUG_ON(rq->nr_running != 1);
|
|
rq_unlock_irqrestore(rq, &rf);
|
|
|
|
trace_android_rvh_sched_cpu_dying(cpu);
|
|
|
|
calc_load_migrate(rq);
|
|
nohz_balance_exit_idle(rq);
|
|
hrtick_clear(rq);
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
void __init sched_init_smp(void)
|
|
{
|
|
sched_init_numa();
|
|
|
|
/*
|
|
* There's no userspace yet to cause hotplug operations; hence all the
|
|
* CPU masks are stable and all blatant races in the below code cannot
|
|
* happen.
|
|
*/
|
|
mutex_lock(&sched_domains_mutex);
|
|
sched_init_domains(cpu_active_mask);
|
|
mutex_unlock(&sched_domains_mutex);
|
|
|
|
/* Move init over to a non-isolated CPU */
|
|
if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0)
|
|
BUG();
|
|
|
|
sched_init_granularity();
|
|
|
|
init_sched_rt_class();
|
|
init_sched_dl_class();
|
|
|
|
sched_smp_initialized = true;
|
|
}
|
|
|
|
static int __init migration_init(void)
|
|
{
|
|
sched_cpu_starting(smp_processor_id());
|
|
return 0;
|
|
}
|
|
early_initcall(migration_init);
|
|
|
|
#else
|
|
void __init sched_init_smp(void)
|
|
{
|
|
sched_init_granularity();
|
|
}
|
|
#endif /* CONFIG_SMP */
|
|
|
|
int in_sched_functions(unsigned long addr)
|
|
{
|
|
return in_lock_functions(addr) ||
|
|
(addr >= (unsigned long)__sched_text_start
|
|
&& addr < (unsigned long)__sched_text_end);
|
|
}
|
|
|
|
#ifdef CONFIG_CGROUP_SCHED
|
|
/*
|
|
* Default task group.
|
|
* Every task in system belongs to this group at bootup.
|
|
*/
|
|
struct task_group root_task_group;
|
|
EXPORT_SYMBOL_GPL(root_task_group);
|
|
LIST_HEAD(task_groups);
|
|
EXPORT_SYMBOL_GPL(task_groups);
|
|
|
|
/* Cacheline aligned slab cache for task_group */
|
|
static struct kmem_cache *task_group_cache __read_mostly;
|
|
#endif
|
|
|
|
DECLARE_PER_CPU(cpumask_var_t, load_balance_mask);
|
|
DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
|
|
|
|
void __init sched_init(void)
|
|
{
|
|
unsigned long ptr = 0;
|
|
int i;
|
|
|
|
/* Make sure the linker didn't screw up */
|
|
BUG_ON(&idle_sched_class + 1 != &fair_sched_class ||
|
|
&fair_sched_class + 1 != &rt_sched_class ||
|
|
&rt_sched_class + 1 != &dl_sched_class);
|
|
#ifdef CONFIG_SMP
|
|
BUG_ON(&dl_sched_class + 1 != &stop_sched_class);
|
|
#endif
|
|
|
|
wait_bit_init();
|
|
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
ptr += 2 * nr_cpu_ids * sizeof(void **);
|
|
#endif
|
|
#ifdef CONFIG_RT_GROUP_SCHED
|
|
ptr += 2 * nr_cpu_ids * sizeof(void **);
|
|
#endif
|
|
if (ptr) {
|
|
ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
|
|
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
root_task_group.se = (struct sched_entity **)ptr;
|
|
ptr += nr_cpu_ids * sizeof(void **);
|
|
|
|
root_task_group.cfs_rq = (struct cfs_rq **)ptr;
|
|
ptr += nr_cpu_ids * sizeof(void **);
|
|
|
|
root_task_group.shares = ROOT_TASK_GROUP_LOAD;
|
|
init_cfs_bandwidth(&root_task_group.cfs_bandwidth);
|
|
#endif /* CONFIG_FAIR_GROUP_SCHED */
|
|
#ifdef CONFIG_RT_GROUP_SCHED
|
|
root_task_group.rt_se = (struct sched_rt_entity **)ptr;
|
|
ptr += nr_cpu_ids * sizeof(void **);
|
|
|
|
root_task_group.rt_rq = (struct rt_rq **)ptr;
|
|
ptr += nr_cpu_ids * sizeof(void **);
|
|
|
|
#endif /* CONFIG_RT_GROUP_SCHED */
|
|
}
|
|
#ifdef CONFIG_CPUMASK_OFFSTACK
|
|
for_each_possible_cpu(i) {
|
|
per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node(
|
|
cpumask_size(), GFP_KERNEL, cpu_to_node(i));
|
|
per_cpu(select_idle_mask, i) = (cpumask_var_t)kzalloc_node(
|
|
cpumask_size(), GFP_KERNEL, cpu_to_node(i));
|
|
}
|
|
#endif /* CONFIG_CPUMASK_OFFSTACK */
|
|
|
|
init_rt_bandwidth(&def_rt_bandwidth, global_rt_period(), global_rt_runtime());
|
|
init_dl_bandwidth(&def_dl_bandwidth, global_rt_period(), global_rt_runtime());
|
|
|
|
#ifdef CONFIG_SMP
|
|
init_defrootdomain();
|
|
#endif
|
|
|
|
#ifdef CONFIG_RT_GROUP_SCHED
|
|
init_rt_bandwidth(&root_task_group.rt_bandwidth,
|
|
global_rt_period(), global_rt_runtime());
|
|
#endif /* CONFIG_RT_GROUP_SCHED */
|
|
|
|
#ifdef CONFIG_CGROUP_SCHED
|
|
task_group_cache = KMEM_CACHE(task_group, 0);
|
|
|
|
list_add(&root_task_group.list, &task_groups);
|
|
INIT_LIST_HEAD(&root_task_group.children);
|
|
INIT_LIST_HEAD(&root_task_group.siblings);
|
|
autogroup_init(&init_task);
|
|
#endif /* CONFIG_CGROUP_SCHED */
|
|
|
|
for_each_possible_cpu(i) {
|
|
struct rq *rq;
|
|
|
|
rq = cpu_rq(i);
|
|
raw_spin_lock_init(&rq->lock);
|
|
rq->nr_running = 0;
|
|
rq->calc_load_active = 0;
|
|
rq->calc_load_update = jiffies + LOAD_FREQ;
|
|
init_cfs_rq(&rq->cfs);
|
|
init_rt_rq(&rq->rt);
|
|
init_dl_rq(&rq->dl);
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
|
|
rq->tmp_alone_branch = &rq->leaf_cfs_rq_list;
|
|
/*
|
|
* How much CPU bandwidth does root_task_group get?
|
|
*
|
|
* In case of task-groups formed thr' the cgroup filesystem, it
|
|
* gets 100% of the CPU resources in the system. This overall
|
|
* system CPU resource is divided among the tasks of
|
|
* root_task_group and its child task-groups in a fair manner,
|
|
* based on each entity's (task or task-group's) weight
|
|
* (se->load.weight).
|
|
*
|
|
* In other words, if root_task_group has 10 tasks of weight
|
|
* 1024) and two child groups A0 and A1 (of weight 1024 each),
|
|
* then A0's share of the CPU resource is:
|
|
*
|
|
* A0's bandwidth = 1024 / (10*1024 + 1024 + 1024) = 8.33%
|
|
*
|
|
* We achieve this by letting root_task_group's tasks sit
|
|
* directly in rq->cfs (i.e root_task_group->se[] = NULL).
|
|
*/
|
|
init_tg_cfs_entry(&root_task_group, &rq->cfs, NULL, i, NULL);
|
|
#endif /* CONFIG_FAIR_GROUP_SCHED */
|
|
|
|
rq->rt.rt_runtime = def_rt_bandwidth.rt_runtime;
|
|
#ifdef CONFIG_RT_GROUP_SCHED
|
|
init_tg_rt_entry(&root_task_group, &rq->rt, NULL, i, NULL);
|
|
#endif
|
|
#ifdef CONFIG_SMP
|
|
rq->sd = NULL;
|
|
rq->rd = NULL;
|
|
rq->cpu_capacity = rq->cpu_capacity_orig = SCHED_CAPACITY_SCALE;
|
|
rq->balance_callback = NULL;
|
|
rq->active_balance = 0;
|
|
rq->next_balance = jiffies;
|
|
rq->push_cpu = 0;
|
|
rq->cpu = i;
|
|
rq->online = 0;
|
|
rq->idle_stamp = 0;
|
|
rq->avg_idle = 2*sysctl_sched_migration_cost;
|
|
rq->max_idle_balance_cost = sysctl_sched_migration_cost;
|
|
|
|
INIT_LIST_HEAD(&rq->cfs_tasks);
|
|
|
|
rq_attach_root(rq, &def_root_domain);
|
|
#ifdef CONFIG_NO_HZ_COMMON
|
|
rq->last_blocked_load_update_tick = jiffies;
|
|
atomic_set(&rq->nohz_flags, 0);
|
|
|
|
rq_csd_init(rq, &rq->nohz_csd, nohz_csd_func);
|
|
#endif
|
|
#endif /* CONFIG_SMP */
|
|
hrtick_rq_init(rq);
|
|
atomic_set(&rq->nr_iowait, 0);
|
|
}
|
|
|
|
set_load_weight(&init_task, false);
|
|
|
|
/*
|
|
* The boot idle thread does lazy MMU switching as well:
|
|
*/
|
|
mmgrab(&init_mm);
|
|
enter_lazy_tlb(&init_mm, current);
|
|
|
|
/*
|
|
* Make us the idle thread. Technically, schedule() should not be
|
|
* called from this thread, however somewhere below it might be,
|
|
* but because we are the idle thread, we just pick up running again
|
|
* when this runqueue becomes "idle".
|
|
*/
|
|
init_idle(current, smp_processor_id());
|
|
|
|
calc_load_update = jiffies + LOAD_FREQ;
|
|
|
|
#ifdef CONFIG_SMP
|
|
idle_thread_set_boot_cpu();
|
|
#endif
|
|
init_sched_fair_class();
|
|
|
|
init_schedstats();
|
|
|
|
psi_init();
|
|
|
|
init_uclamp();
|
|
|
|
scheduler_running = 1;
|
|
}
|
|
|
|
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
|
|
static inline int preempt_count_equals(int preempt_offset)
|
|
{
|
|
int nested = preempt_count() + rcu_preempt_depth();
|
|
|
|
return (nested == preempt_offset);
|
|
}
|
|
|
|
void __might_sleep(const char *file, int line, int preempt_offset)
|
|
{
|
|
/*
|
|
* Blocking primitives will set (and therefore destroy) current->state,
|
|
* since we will exit with TASK_RUNNING make sure we enter with it,
|
|
* otherwise we will destroy state.
|
|
*/
|
|
WARN_ONCE(current->state != TASK_RUNNING && current->task_state_change,
|
|
"do not call blocking ops when !TASK_RUNNING; "
|
|
"state=%lx set at [<%p>] %pS\n",
|
|
current->state,
|
|
(void *)current->task_state_change,
|
|
(void *)current->task_state_change);
|
|
|
|
___might_sleep(file, line, preempt_offset);
|
|
}
|
|
EXPORT_SYMBOL(__might_sleep);
|
|
|
|
void ___might_sleep(const char *file, int line, int preempt_offset)
|
|
{
|
|
/* Ratelimiting timestamp: */
|
|
static unsigned long prev_jiffy;
|
|
|
|
unsigned long preempt_disable_ip;
|
|
|
|
/* WARN_ON_ONCE() by default, no rate limit required: */
|
|
rcu_sleep_check();
|
|
|
|
if ((preempt_count_equals(preempt_offset) && !irqs_disabled() &&
|
|
!is_idle_task(current) && !current->non_block_count) ||
|
|
system_state == SYSTEM_BOOTING || system_state > SYSTEM_RUNNING ||
|
|
oops_in_progress)
|
|
return;
|
|
|
|
if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
|
|
return;
|
|
prev_jiffy = jiffies;
|
|
|
|
/* Save this before calling printk(), since that will clobber it: */
|
|
preempt_disable_ip = get_preempt_disable_ip(current);
|
|
|
|
printk(KERN_ERR
|
|
"BUG: sleeping function called from invalid context at %s:%d\n",
|
|
file, line);
|
|
printk(KERN_ERR
|
|
"in_atomic(): %d, irqs_disabled(): %d, non_block: %d, pid: %d, name: %s\n",
|
|
in_atomic(), irqs_disabled(), current->non_block_count,
|
|
current->pid, current->comm);
|
|
|
|
if (task_stack_end_corrupted(current))
|
|
printk(KERN_EMERG "Thread overran stack, or stack corrupted\n");
|
|
|
|
debug_show_held_locks(current);
|
|
if (irqs_disabled())
|
|
print_irqtrace_events(current);
|
|
if (IS_ENABLED(CONFIG_DEBUG_PREEMPT)
|
|
&& !preempt_count_equals(preempt_offset)) {
|
|
pr_err("Preemption disabled at:");
|
|
print_ip_sym(KERN_ERR, preempt_disable_ip);
|
|
}
|
|
|
|
trace_android_rvh_schedule_bug(NULL);
|
|
|
|
dump_stack();
|
|
add_taint(TAINT_WARN, LOCKDEP_STILL_OK);
|
|
}
|
|
EXPORT_SYMBOL(___might_sleep);
|
|
|
|
void __cant_sleep(const char *file, int line, int preempt_offset)
|
|
{
|
|
static unsigned long prev_jiffy;
|
|
|
|
if (irqs_disabled())
|
|
return;
|
|
|
|
if (!IS_ENABLED(CONFIG_PREEMPT_COUNT))
|
|
return;
|
|
|
|
if (preempt_count() > preempt_offset)
|
|
return;
|
|
|
|
if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
|
|
return;
|
|
prev_jiffy = jiffies;
|
|
|
|
printk(KERN_ERR "BUG: assuming atomic context at %s:%d\n", file, line);
|
|
printk(KERN_ERR "in_atomic(): %d, irqs_disabled(): %d, pid: %d, name: %s\n",
|
|
in_atomic(), irqs_disabled(),
|
|
current->pid, current->comm);
|
|
|
|
debug_show_held_locks(current);
|
|
dump_stack();
|
|
add_taint(TAINT_WARN, LOCKDEP_STILL_OK);
|
|
}
|
|
EXPORT_SYMBOL_GPL(__cant_sleep);
|
|
#endif
|
|
|
|
#ifdef CONFIG_MAGIC_SYSRQ
|
|
void normalize_rt_tasks(void)
|
|
{
|
|
struct task_struct *g, *p;
|
|
struct sched_attr attr = {
|
|
.sched_policy = SCHED_NORMAL,
|
|
};
|
|
|
|
read_lock(&tasklist_lock);
|
|
for_each_process_thread(g, p) {
|
|
/*
|
|
* Only normalize user tasks:
|
|
*/
|
|
if (p->flags & PF_KTHREAD)
|
|
continue;
|
|
|
|
p->se.exec_start = 0;
|
|
schedstat_set(p->se.statistics.wait_start, 0);
|
|
schedstat_set(p->se.statistics.sleep_start, 0);
|
|
schedstat_set(p->se.statistics.block_start, 0);
|
|
|
|
if (!dl_task(p) && !rt_task(p)) {
|
|
/*
|
|
* Renice negative nice level userspace
|
|
* tasks back to 0:
|
|
*/
|
|
if (task_nice(p) < 0)
|
|
set_user_nice(p, 0);
|
|
continue;
|
|
}
|
|
|
|
__sched_setscheduler(p, &attr, false, false);
|
|
}
|
|
read_unlock(&tasklist_lock);
|
|
}
|
|
|
|
#endif /* CONFIG_MAGIC_SYSRQ */
|
|
|
|
#if defined(CONFIG_IA64) || defined(CONFIG_KGDB_KDB)
|
|
/*
|
|
* These functions are only useful for the IA64 MCA handling, or kdb.
|
|
*
|
|
* They can only be called when the whole system has been
|
|
* stopped - every CPU needs to be quiescent, and no scheduling
|
|
* activity can take place. Using them for anything else would
|
|
* be a serious bug, and as a result, they aren't even visible
|
|
* under any other configuration.
|
|
*/
|
|
|
|
/**
|
|
* curr_task - return the current task for a given CPU.
|
|
* @cpu: the processor in question.
|
|
*
|
|
* ONLY VALID WHEN THE WHOLE SYSTEM IS STOPPED!
|
|
*
|
|
* Return: The current task for @cpu.
|
|
*/
|
|
struct task_struct *curr_task(int cpu)
|
|
{
|
|
return cpu_curr(cpu);
|
|
}
|
|
|
|
#endif /* defined(CONFIG_IA64) || defined(CONFIG_KGDB_KDB) */
|
|
|
|
#ifdef CONFIG_IA64
|
|
/**
|
|
* ia64_set_curr_task - set the current task for a given CPU.
|
|
* @cpu: the processor in question.
|
|
* @p: the task pointer to set.
|
|
*
|
|
* Description: This function must only be used when non-maskable interrupts
|
|
* are serviced on a separate stack. It allows the architecture to switch the
|
|
* notion of the current task on a CPU in a non-blocking manner. This function
|
|
* must be called with all CPU's synchronized, and interrupts disabled, the
|
|
* and caller must save the original value of the current task (see
|
|
* curr_task() above) and restore that value before reenabling interrupts and
|
|
* re-starting the system.
|
|
*
|
|
* ONLY VALID WHEN THE WHOLE SYSTEM IS STOPPED!
|
|
*/
|
|
void ia64_set_curr_task(int cpu, struct task_struct *p)
|
|
{
|
|
cpu_curr(cpu) = p;
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CGROUP_SCHED
|
|
/* task_group_lock serializes the addition/removal of task groups */
|
|
static DEFINE_SPINLOCK(task_group_lock);
|
|
|
|
static inline void alloc_uclamp_sched_group(struct task_group *tg,
|
|
struct task_group *parent)
|
|
{
|
|
#ifdef CONFIG_UCLAMP_TASK_GROUP
|
|
enum uclamp_id clamp_id;
|
|
|
|
for_each_clamp_id(clamp_id) {
|
|
uclamp_se_set(&tg->uclamp_req[clamp_id],
|
|
uclamp_none(clamp_id), false);
|
|
tg->uclamp[clamp_id] = parent->uclamp[clamp_id];
|
|
}
|
|
#endif
|
|
}
|
|
|
|
static void sched_free_group(struct task_group *tg)
|
|
{
|
|
free_fair_sched_group(tg);
|
|
free_rt_sched_group(tg);
|
|
autogroup_free(tg);
|
|
kmem_cache_free(task_group_cache, tg);
|
|
}
|
|
|
|
/* allocate runqueue etc for a new task group */
|
|
struct task_group *sched_create_group(struct task_group *parent)
|
|
{
|
|
struct task_group *tg;
|
|
|
|
tg = kmem_cache_alloc(task_group_cache, GFP_KERNEL | __GFP_ZERO);
|
|
if (!tg)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
if (!alloc_fair_sched_group(tg, parent))
|
|
goto err;
|
|
|
|
if (!alloc_rt_sched_group(tg, parent))
|
|
goto err;
|
|
|
|
alloc_uclamp_sched_group(tg, parent);
|
|
|
|
return tg;
|
|
|
|
err:
|
|
sched_free_group(tg);
|
|
return ERR_PTR(-ENOMEM);
|
|
}
|
|
|
|
void sched_online_group(struct task_group *tg, struct task_group *parent)
|
|
{
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&task_group_lock, flags);
|
|
list_add_rcu(&tg->list, &task_groups);
|
|
|
|
/* Root should already exist: */
|
|
WARN_ON(!parent);
|
|
|
|
tg->parent = parent;
|
|
INIT_LIST_HEAD(&tg->children);
|
|
list_add_rcu(&tg->siblings, &parent->children);
|
|
spin_unlock_irqrestore(&task_group_lock, flags);
|
|
|
|
online_fair_sched_group(tg);
|
|
}
|
|
|
|
/* rcu callback to free various structures associated with a task group */
|
|
static void sched_free_group_rcu(struct rcu_head *rhp)
|
|
{
|
|
/* Now it should be safe to free those cfs_rqs: */
|
|
sched_free_group(container_of(rhp, struct task_group, rcu));
|
|
}
|
|
|
|
void sched_destroy_group(struct task_group *tg)
|
|
{
|
|
/* Wait for possible concurrent references to cfs_rqs complete: */
|
|
call_rcu(&tg->rcu, sched_free_group_rcu);
|
|
}
|
|
|
|
void sched_offline_group(struct task_group *tg)
|
|
{
|
|
unsigned long flags;
|
|
|
|
/* End participation in shares distribution: */
|
|
unregister_fair_sched_group(tg);
|
|
|
|
spin_lock_irqsave(&task_group_lock, flags);
|
|
list_del_rcu(&tg->list);
|
|
list_del_rcu(&tg->siblings);
|
|
spin_unlock_irqrestore(&task_group_lock, flags);
|
|
}
|
|
|
|
static void sched_change_group(struct task_struct *tsk, int type)
|
|
{
|
|
struct task_group *tg;
|
|
|
|
/*
|
|
* All callers are synchronized by task_rq_lock(); we do not use RCU
|
|
* which is pointless here. Thus, we pass "true" to task_css_check()
|
|
* to prevent lockdep warnings.
|
|
*/
|
|
tg = container_of(task_css_check(tsk, cpu_cgrp_id, true),
|
|
struct task_group, css);
|
|
tg = autogroup_task_group(tsk, tg);
|
|
tsk->sched_task_group = tg;
|
|
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
if (tsk->sched_class->task_change_group)
|
|
tsk->sched_class->task_change_group(tsk, type);
|
|
else
|
|
#endif
|
|
set_task_rq(tsk, task_cpu(tsk));
|
|
}
|
|
|
|
/*
|
|
* Change task's runqueue when it moves between groups.
|
|
*
|
|
* The caller of this function should have put the task in its new group by
|
|
* now. This function just updates tsk->se.cfs_rq and tsk->se.parent to reflect
|
|
* its new group.
|
|
*/
|
|
void sched_move_task(struct task_struct *tsk)
|
|
{
|
|
int queued, running, queue_flags =
|
|
DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK;
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
rq = task_rq_lock(tsk, &rf);
|
|
update_rq_clock(rq);
|
|
|
|
running = task_current(rq, tsk);
|
|
queued = task_on_rq_queued(tsk);
|
|
|
|
if (queued)
|
|
dequeue_task(rq, tsk, queue_flags);
|
|
if (running)
|
|
put_prev_task(rq, tsk);
|
|
|
|
sched_change_group(tsk, TASK_MOVE_GROUP);
|
|
|
|
if (queued)
|
|
enqueue_task(rq, tsk, queue_flags);
|
|
if (running) {
|
|
set_next_task(rq, tsk);
|
|
/*
|
|
* After changing group, the running task may have joined a
|
|
* throttled one but it's still the running task. Trigger a
|
|
* resched to make sure that task can still run.
|
|
*/
|
|
resched_curr(rq);
|
|
}
|
|
|
|
task_rq_unlock(rq, tsk, &rf);
|
|
}
|
|
|
|
static inline struct task_group *css_tg(struct cgroup_subsys_state *css)
|
|
{
|
|
return css ? container_of(css, struct task_group, css) : NULL;
|
|
}
|
|
|
|
static struct cgroup_subsys_state *
|
|
cpu_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
|
|
{
|
|
struct task_group *parent = css_tg(parent_css);
|
|
struct task_group *tg;
|
|
|
|
if (!parent) {
|
|
/* This is early initialization for the top cgroup */
|
|
return &root_task_group.css;
|
|
}
|
|
|
|
tg = sched_create_group(parent);
|
|
if (IS_ERR(tg))
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
return &tg->css;
|
|
}
|
|
|
|
/* Expose task group only after completing cgroup initialization */
|
|
static int cpu_cgroup_css_online(struct cgroup_subsys_state *css)
|
|
{
|
|
struct task_group *tg = css_tg(css);
|
|
struct task_group *parent = css_tg(css->parent);
|
|
|
|
if (parent)
|
|
sched_online_group(tg, parent);
|
|
|
|
#ifdef CONFIG_UCLAMP_TASK_GROUP
|
|
/* Propagate the effective uclamp value for the new group */
|
|
mutex_lock(&uclamp_mutex);
|
|
rcu_read_lock();
|
|
cpu_util_update_eff(css);
|
|
rcu_read_unlock();
|
|
mutex_unlock(&uclamp_mutex);
|
|
#endif
|
|
|
|
trace_android_rvh_cpu_cgroup_online(css);
|
|
return 0;
|
|
}
|
|
|
|
static void cpu_cgroup_css_released(struct cgroup_subsys_state *css)
|
|
{
|
|
struct task_group *tg = css_tg(css);
|
|
|
|
sched_offline_group(tg);
|
|
}
|
|
|
|
static void cpu_cgroup_css_free(struct cgroup_subsys_state *css)
|
|
{
|
|
struct task_group *tg = css_tg(css);
|
|
|
|
/*
|
|
* Relies on the RCU grace period between css_released() and this.
|
|
*/
|
|
sched_free_group(tg);
|
|
}
|
|
|
|
/*
|
|
* This is called before wake_up_new_task(), therefore we really only
|
|
* have to set its group bits, all the other stuff does not apply.
|
|
*/
|
|
static void cpu_cgroup_fork(struct task_struct *task)
|
|
{
|
|
struct rq_flags rf;
|
|
struct rq *rq;
|
|
|
|
rq = task_rq_lock(task, &rf);
|
|
|
|
update_rq_clock(rq);
|
|
sched_change_group(task, TASK_SET_GROUP);
|
|
|
|
task_rq_unlock(rq, task, &rf);
|
|
}
|
|
|
|
static int cpu_cgroup_can_attach(struct cgroup_taskset *tset)
|
|
{
|
|
struct task_struct *task;
|
|
struct cgroup_subsys_state *css;
|
|
int ret = 0;
|
|
|
|
cgroup_taskset_for_each(task, css, tset) {
|
|
#ifdef CONFIG_RT_GROUP_SCHED
|
|
if (!sched_rt_can_attach(css_tg(css), task))
|
|
return -EINVAL;
|
|
#endif
|
|
/*
|
|
* Serialize against wake_up_new_task() such that if its
|
|
* running, we're sure to observe its full state.
|
|
*/
|
|
raw_spin_lock_irq(&task->pi_lock);
|
|
/*
|
|
* Avoid calling sched_move_task() before wake_up_new_task()
|
|
* has happened. This would lead to problems with PELT, due to
|
|
* move wanting to detach+attach while we're not attached yet.
|
|
*/
|
|
if (task->state == TASK_NEW)
|
|
ret = -EINVAL;
|
|
raw_spin_unlock_irq(&task->pi_lock);
|
|
|
|
if (ret)
|
|
break;
|
|
}
|
|
|
|
trace_android_rvh_cpu_cgroup_can_attach(tset, &ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void cpu_cgroup_attach(struct cgroup_taskset *tset)
|
|
{
|
|
struct task_struct *task;
|
|
struct cgroup_subsys_state *css;
|
|
|
|
cgroup_taskset_for_each(task, css, tset)
|
|
sched_move_task(task);
|
|
|
|
trace_android_rvh_cpu_cgroup_attach(tset);
|
|
}
|
|
|
|
#ifdef CONFIG_UCLAMP_TASK_GROUP
|
|
static void cpu_util_update_eff(struct cgroup_subsys_state *css)
|
|
{
|
|
struct cgroup_subsys_state *top_css = css;
|
|
struct uclamp_se *uc_parent = NULL;
|
|
struct uclamp_se *uc_se = NULL;
|
|
unsigned int eff[UCLAMP_CNT];
|
|
enum uclamp_id clamp_id;
|
|
unsigned int clamps;
|
|
|
|
lockdep_assert_held(&uclamp_mutex);
|
|
SCHED_WARN_ON(!rcu_read_lock_held());
|
|
|
|
css_for_each_descendant_pre(css, top_css) {
|
|
uc_parent = css_tg(css)->parent
|
|
? css_tg(css)->parent->uclamp : NULL;
|
|
|
|
for_each_clamp_id(clamp_id) {
|
|
/* Assume effective clamps matches requested clamps */
|
|
eff[clamp_id] = css_tg(css)->uclamp_req[clamp_id].value;
|
|
/* Cap effective clamps with parent's effective clamps */
|
|
if (uc_parent &&
|
|
eff[clamp_id] > uc_parent[clamp_id].value) {
|
|
eff[clamp_id] = uc_parent[clamp_id].value;
|
|
}
|
|
}
|
|
/* Ensure protection is always capped by limit */
|
|
eff[UCLAMP_MIN] = min(eff[UCLAMP_MIN], eff[UCLAMP_MAX]);
|
|
|
|
/* Propagate most restrictive effective clamps */
|
|
clamps = 0x0;
|
|
uc_se = css_tg(css)->uclamp;
|
|
for_each_clamp_id(clamp_id) {
|
|
if (eff[clamp_id] == uc_se[clamp_id].value)
|
|
continue;
|
|
uc_se[clamp_id].value = eff[clamp_id];
|
|
uc_se[clamp_id].bucket_id = uclamp_bucket_id(eff[clamp_id]);
|
|
clamps |= (0x1 << clamp_id);
|
|
}
|
|
if (!clamps) {
|
|
css = css_rightmost_descendant(css);
|
|
continue;
|
|
}
|
|
|
|
/* Immediately update descendants RUNNABLE tasks */
|
|
uclamp_update_active_tasks(css);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Integer 10^N with a given N exponent by casting to integer the literal "1eN"
|
|
* C expression. Since there is no way to convert a macro argument (N) into a
|
|
* character constant, use two levels of macros.
|
|
*/
|
|
#define _POW10(exp) ((unsigned int)1e##exp)
|
|
#define POW10(exp) _POW10(exp)
|
|
|
|
struct uclamp_request {
|
|
#define UCLAMP_PERCENT_SHIFT 2
|
|
#define UCLAMP_PERCENT_SCALE (100 * POW10(UCLAMP_PERCENT_SHIFT))
|
|
s64 percent;
|
|
u64 util;
|
|
int ret;
|
|
};
|
|
|
|
static inline struct uclamp_request
|
|
capacity_from_percent(char *buf)
|
|
{
|
|
struct uclamp_request req = {
|
|
.percent = UCLAMP_PERCENT_SCALE,
|
|
.util = SCHED_CAPACITY_SCALE,
|
|
.ret = 0,
|
|
};
|
|
|
|
buf = strim(buf);
|
|
if (strcmp(buf, "max")) {
|
|
req.ret = cgroup_parse_float(buf, UCLAMP_PERCENT_SHIFT,
|
|
&req.percent);
|
|
if (req.ret)
|
|
return req;
|
|
if ((u64)req.percent > UCLAMP_PERCENT_SCALE) {
|
|
req.ret = -ERANGE;
|
|
return req;
|
|
}
|
|
|
|
req.util = req.percent << SCHED_CAPACITY_SHIFT;
|
|
req.util = DIV_ROUND_CLOSEST_ULL(req.util, UCLAMP_PERCENT_SCALE);
|
|
}
|
|
|
|
return req;
|
|
}
|
|
|
|
static ssize_t cpu_uclamp_write(struct kernfs_open_file *of, char *buf,
|
|
size_t nbytes, loff_t off,
|
|
enum uclamp_id clamp_id)
|
|
{
|
|
struct uclamp_request req;
|
|
struct task_group *tg;
|
|
|
|
req = capacity_from_percent(buf);
|
|
if (req.ret)
|
|
return req.ret;
|
|
|
|
static_branch_enable(&sched_uclamp_used);
|
|
|
|
mutex_lock(&uclamp_mutex);
|
|
rcu_read_lock();
|
|
|
|
tg = css_tg(of_css(of));
|
|
if (tg->uclamp_req[clamp_id].value != req.util)
|
|
uclamp_se_set(&tg->uclamp_req[clamp_id], req.util, false);
|
|
|
|
/*
|
|
* Because of not recoverable conversion rounding we keep track of the
|
|
* exact requested value
|
|
*/
|
|
tg->uclamp_pct[clamp_id] = req.percent;
|
|
|
|
/* Update effective clamps to track the most restrictive value */
|
|
cpu_util_update_eff(of_css(of));
|
|
|
|
rcu_read_unlock();
|
|
mutex_unlock(&uclamp_mutex);
|
|
|
|
return nbytes;
|
|
}
|
|
|
|
static ssize_t cpu_uclamp_min_write(struct kernfs_open_file *of,
|
|
char *buf, size_t nbytes,
|
|
loff_t off)
|
|
{
|
|
return cpu_uclamp_write(of, buf, nbytes, off, UCLAMP_MIN);
|
|
}
|
|
|
|
static ssize_t cpu_uclamp_max_write(struct kernfs_open_file *of,
|
|
char *buf, size_t nbytes,
|
|
loff_t off)
|
|
{
|
|
return cpu_uclamp_write(of, buf, nbytes, off, UCLAMP_MAX);
|
|
}
|
|
|
|
static inline void cpu_uclamp_print(struct seq_file *sf,
|
|
enum uclamp_id clamp_id)
|
|
{
|
|
struct task_group *tg;
|
|
u64 util_clamp;
|
|
u64 percent;
|
|
u32 rem;
|
|
|
|
rcu_read_lock();
|
|
tg = css_tg(seq_css(sf));
|
|
util_clamp = tg->uclamp_req[clamp_id].value;
|
|
rcu_read_unlock();
|
|
|
|
if (util_clamp == SCHED_CAPACITY_SCALE) {
|
|
seq_puts(sf, "max\n");
|
|
return;
|
|
}
|
|
|
|
percent = tg->uclamp_pct[clamp_id];
|
|
percent = div_u64_rem(percent, POW10(UCLAMP_PERCENT_SHIFT), &rem);
|
|
seq_printf(sf, "%llu.%0*u\n", percent, UCLAMP_PERCENT_SHIFT, rem);
|
|
}
|
|
|
|
static int cpu_uclamp_min_show(struct seq_file *sf, void *v)
|
|
{
|
|
cpu_uclamp_print(sf, UCLAMP_MIN);
|
|
return 0;
|
|
}
|
|
|
|
static int cpu_uclamp_max_show(struct seq_file *sf, void *v)
|
|
{
|
|
cpu_uclamp_print(sf, UCLAMP_MAX);
|
|
return 0;
|
|
}
|
|
|
|
static int cpu_uclamp_ls_write_u64(struct cgroup_subsys_state *css,
|
|
struct cftype *cftype, u64 ls)
|
|
{
|
|
struct task_group *tg;
|
|
|
|
if (ls > 1)
|
|
return -EINVAL;
|
|
tg = css_tg(css);
|
|
tg->latency_sensitive = (unsigned int) ls;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static u64 cpu_uclamp_ls_read_u64(struct cgroup_subsys_state *css,
|
|
struct cftype *cft)
|
|
{
|
|
struct task_group *tg = css_tg(css);
|
|
|
|
return (u64) tg->latency_sensitive;
|
|
}
|
|
#endif /* CONFIG_UCLAMP_TASK_GROUP */
|
|
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
static int cpu_shares_write_u64(struct cgroup_subsys_state *css,
|
|
struct cftype *cftype, u64 shareval)
|
|
{
|
|
if (shareval > scale_load_down(ULONG_MAX))
|
|
shareval = MAX_SHARES;
|
|
return sched_group_set_shares(css_tg(css), scale_load(shareval));
|
|
}
|
|
|
|
static u64 cpu_shares_read_u64(struct cgroup_subsys_state *css,
|
|
struct cftype *cft)
|
|
{
|
|
struct task_group *tg = css_tg(css);
|
|
|
|
return (u64) scale_load_down(tg->shares);
|
|
}
|
|
|
|
#ifdef CONFIG_CFS_BANDWIDTH
|
|
static DEFINE_MUTEX(cfs_constraints_mutex);
|
|
|
|
const u64 max_cfs_quota_period = 1 * NSEC_PER_SEC; /* 1s */
|
|
static const u64 min_cfs_quota_period = 1 * NSEC_PER_MSEC; /* 1ms */
|
|
/* More than 203 days if BW_SHIFT equals 20. */
|
|
static const u64 max_cfs_runtime = MAX_BW * NSEC_PER_USEC;
|
|
|
|
static int __cfs_schedulable(struct task_group *tg, u64 period, u64 runtime);
|
|
|
|
static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota)
|
|
{
|
|
int i, ret = 0, runtime_enabled, runtime_was_enabled;
|
|
struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
|
|
|
|
if (tg == &root_task_group)
|
|
return -EINVAL;
|
|
|
|
/*
|
|
* Ensure we have at some amount of bandwidth every period. This is
|
|
* to prevent reaching a state of large arrears when throttled via
|
|
* entity_tick() resulting in prolonged exit starvation.
|
|
*/
|
|
if (quota < min_cfs_quota_period || period < min_cfs_quota_period)
|
|
return -EINVAL;
|
|
|
|
/*
|
|
* Likewise, bound things on the otherside by preventing insane quota
|
|
* periods. This also allows us to normalize in computing quota
|
|
* feasibility.
|
|
*/
|
|
if (period > max_cfs_quota_period)
|
|
return -EINVAL;
|
|
|
|
/*
|
|
* Bound quota to defend quota against overflow during bandwidth shift.
|
|
*/
|
|
if (quota != RUNTIME_INF && quota > max_cfs_runtime)
|
|
return -EINVAL;
|
|
|
|
/*
|
|
* Prevent race between setting of cfs_rq->runtime_enabled and
|
|
* unthrottle_offline_cfs_rqs().
|
|
*/
|
|
get_online_cpus();
|
|
mutex_lock(&cfs_constraints_mutex);
|
|
ret = __cfs_schedulable(tg, period, quota);
|
|
if (ret)
|
|
goto out_unlock;
|
|
|
|
runtime_enabled = quota != RUNTIME_INF;
|
|
runtime_was_enabled = cfs_b->quota != RUNTIME_INF;
|
|
/*
|
|
* If we need to toggle cfs_bandwidth_used, off->on must occur
|
|
* before making related changes, and on->off must occur afterwards
|
|
*/
|
|
if (runtime_enabled && !runtime_was_enabled)
|
|
cfs_bandwidth_usage_inc();
|
|
raw_spin_lock_irq(&cfs_b->lock);
|
|
cfs_b->period = ns_to_ktime(period);
|
|
cfs_b->quota = quota;
|
|
|
|
__refill_cfs_bandwidth_runtime(cfs_b);
|
|
|
|
/* Restart the period timer (if active) to handle new period expiry: */
|
|
if (runtime_enabled)
|
|
start_cfs_bandwidth(cfs_b);
|
|
|
|
raw_spin_unlock_irq(&cfs_b->lock);
|
|
|
|
for_each_online_cpu(i) {
|
|
struct cfs_rq *cfs_rq = tg->cfs_rq[i];
|
|
struct rq *rq = cfs_rq->rq;
|
|
struct rq_flags rf;
|
|
|
|
rq_lock_irq(rq, &rf);
|
|
cfs_rq->runtime_enabled = runtime_enabled;
|
|
cfs_rq->runtime_remaining = 0;
|
|
|
|
if (cfs_rq->throttled)
|
|
unthrottle_cfs_rq(cfs_rq);
|
|
rq_unlock_irq(rq, &rf);
|
|
}
|
|
if (runtime_was_enabled && !runtime_enabled)
|
|
cfs_bandwidth_usage_dec();
|
|
out_unlock:
|
|
mutex_unlock(&cfs_constraints_mutex);
|
|
put_online_cpus();
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us)
|
|
{
|
|
u64 quota, period;
|
|
|
|
period = ktime_to_ns(tg->cfs_bandwidth.period);
|
|
if (cfs_quota_us < 0)
|
|
quota = RUNTIME_INF;
|
|
else if ((u64)cfs_quota_us <= U64_MAX / NSEC_PER_USEC)
|
|
quota = (u64)cfs_quota_us * NSEC_PER_USEC;
|
|
else
|
|
return -EINVAL;
|
|
|
|
return tg_set_cfs_bandwidth(tg, period, quota);
|
|
}
|
|
|
|
static long tg_get_cfs_quota(struct task_group *tg)
|
|
{
|
|
u64 quota_us;
|
|
|
|
if (tg->cfs_bandwidth.quota == RUNTIME_INF)
|
|
return -1;
|
|
|
|
quota_us = tg->cfs_bandwidth.quota;
|
|
do_div(quota_us, NSEC_PER_USEC);
|
|
|
|
return quota_us;
|
|
}
|
|
|
|
static int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
|
|
{
|
|
u64 quota, period;
|
|
|
|
if ((u64)cfs_period_us > U64_MAX / NSEC_PER_USEC)
|
|
return -EINVAL;
|
|
|
|
period = (u64)cfs_period_us * NSEC_PER_USEC;
|
|
quota = tg->cfs_bandwidth.quota;
|
|
|
|
return tg_set_cfs_bandwidth(tg, period, quota);
|
|
}
|
|
|
|
static long tg_get_cfs_period(struct task_group *tg)
|
|
{
|
|
u64 cfs_period_us;
|
|
|
|
cfs_period_us = ktime_to_ns(tg->cfs_bandwidth.period);
|
|
do_div(cfs_period_us, NSEC_PER_USEC);
|
|
|
|
return cfs_period_us;
|
|
}
|
|
|
|
static s64 cpu_cfs_quota_read_s64(struct cgroup_subsys_state *css,
|
|
struct cftype *cft)
|
|
{
|
|
return tg_get_cfs_quota(css_tg(css));
|
|
}
|
|
|
|
static int cpu_cfs_quota_write_s64(struct cgroup_subsys_state *css,
|
|
struct cftype *cftype, s64 cfs_quota_us)
|
|
{
|
|
return tg_set_cfs_quota(css_tg(css), cfs_quota_us);
|
|
}
|
|
|
|
static u64 cpu_cfs_period_read_u64(struct cgroup_subsys_state *css,
|
|
struct cftype *cft)
|
|
{
|
|
return tg_get_cfs_period(css_tg(css));
|
|
}
|
|
|
|
static int cpu_cfs_period_write_u64(struct cgroup_subsys_state *css,
|
|
struct cftype *cftype, u64 cfs_period_us)
|
|
{
|
|
return tg_set_cfs_period(css_tg(css), cfs_period_us);
|
|
}
|
|
|
|
struct cfs_schedulable_data {
|
|
struct task_group *tg;
|
|
u64 period, quota;
|
|
};
|
|
|
|
/*
|
|
* normalize group quota/period to be quota/max_period
|
|
* note: units are usecs
|
|
*/
|
|
static u64 normalize_cfs_quota(struct task_group *tg,
|
|
struct cfs_schedulable_data *d)
|
|
{
|
|
u64 quota, period;
|
|
|
|
if (tg == d->tg) {
|
|
period = d->period;
|
|
quota = d->quota;
|
|
} else {
|
|
period = tg_get_cfs_period(tg);
|
|
quota = tg_get_cfs_quota(tg);
|
|
}
|
|
|
|
/* note: these should typically be equivalent */
|
|
if (quota == RUNTIME_INF || quota == -1)
|
|
return RUNTIME_INF;
|
|
|
|
return to_ratio(period, quota);
|
|
}
|
|
|
|
static int tg_cfs_schedulable_down(struct task_group *tg, void *data)
|
|
{
|
|
struct cfs_schedulable_data *d = data;
|
|
struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
|
|
s64 quota = 0, parent_quota = -1;
|
|
|
|
if (!tg->parent) {
|
|
quota = RUNTIME_INF;
|
|
} else {
|
|
struct cfs_bandwidth *parent_b = &tg->parent->cfs_bandwidth;
|
|
|
|
quota = normalize_cfs_quota(tg, d);
|
|
parent_quota = parent_b->hierarchical_quota;
|
|
|
|
/*
|
|
* Ensure max(child_quota) <= parent_quota. On cgroup2,
|
|
* always take the min. On cgroup1, only inherit when no
|
|
* limit is set:
|
|
*/
|
|
if (cgroup_subsys_on_dfl(cpu_cgrp_subsys)) {
|
|
quota = min(quota, parent_quota);
|
|
} else {
|
|
if (quota == RUNTIME_INF)
|
|
quota = parent_quota;
|
|
else if (parent_quota != RUNTIME_INF && quota > parent_quota)
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
cfs_b->hierarchical_quota = quota;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int __cfs_schedulable(struct task_group *tg, u64 period, u64 quota)
|
|
{
|
|
int ret;
|
|
struct cfs_schedulable_data data = {
|
|
.tg = tg,
|
|
.period = period,
|
|
.quota = quota,
|
|
};
|
|
|
|
if (quota != RUNTIME_INF) {
|
|
do_div(data.period, NSEC_PER_USEC);
|
|
do_div(data.quota, NSEC_PER_USEC);
|
|
}
|
|
|
|
rcu_read_lock();
|
|
ret = walk_tg_tree(tg_cfs_schedulable_down, tg_nop, &data);
|
|
rcu_read_unlock();
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int cpu_cfs_stat_show(struct seq_file *sf, void *v)
|
|
{
|
|
struct task_group *tg = css_tg(seq_css(sf));
|
|
struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
|
|
|
|
seq_printf(sf, "nr_periods %d\n", cfs_b->nr_periods);
|
|
seq_printf(sf, "nr_throttled %d\n", cfs_b->nr_throttled);
|
|
seq_printf(sf, "throttled_time %llu\n", cfs_b->throttled_time);
|
|
|
|
if (schedstat_enabled() && tg != &root_task_group) {
|
|
u64 ws = 0;
|
|
int i;
|
|
|
|
for_each_possible_cpu(i)
|
|
ws += schedstat_val(tg->se[i]->statistics.wait_sum);
|
|
|
|
seq_printf(sf, "wait_sum %llu\n", ws);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
#endif /* CONFIG_CFS_BANDWIDTH */
|
|
#endif /* CONFIG_FAIR_GROUP_SCHED */
|
|
|
|
#ifdef CONFIG_RT_GROUP_SCHED
|
|
static int cpu_rt_runtime_write(struct cgroup_subsys_state *css,
|
|
struct cftype *cft, s64 val)
|
|
{
|
|
return sched_group_set_rt_runtime(css_tg(css), val);
|
|
}
|
|
|
|
static s64 cpu_rt_runtime_read(struct cgroup_subsys_state *css,
|
|
struct cftype *cft)
|
|
{
|
|
return sched_group_rt_runtime(css_tg(css));
|
|
}
|
|
|
|
static int cpu_rt_period_write_uint(struct cgroup_subsys_state *css,
|
|
struct cftype *cftype, u64 rt_period_us)
|
|
{
|
|
return sched_group_set_rt_period(css_tg(css), rt_period_us);
|
|
}
|
|
|
|
static u64 cpu_rt_period_read_uint(struct cgroup_subsys_state *css,
|
|
struct cftype *cft)
|
|
{
|
|
return sched_group_rt_period(css_tg(css));
|
|
}
|
|
#endif /* CONFIG_RT_GROUP_SCHED */
|
|
|
|
static struct cftype cpu_legacy_files[] = {
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
{
|
|
.name = "shares",
|
|
.read_u64 = cpu_shares_read_u64,
|
|
.write_u64 = cpu_shares_write_u64,
|
|
},
|
|
#endif
|
|
#ifdef CONFIG_CFS_BANDWIDTH
|
|
{
|
|
.name = "cfs_quota_us",
|
|
.read_s64 = cpu_cfs_quota_read_s64,
|
|
.write_s64 = cpu_cfs_quota_write_s64,
|
|
},
|
|
{
|
|
.name = "cfs_period_us",
|
|
.read_u64 = cpu_cfs_period_read_u64,
|
|
.write_u64 = cpu_cfs_period_write_u64,
|
|
},
|
|
{
|
|
.name = "stat",
|
|
.seq_show = cpu_cfs_stat_show,
|
|
},
|
|
#endif
|
|
#ifdef CONFIG_RT_GROUP_SCHED
|
|
{
|
|
.name = "rt_runtime_us",
|
|
.read_s64 = cpu_rt_runtime_read,
|
|
.write_s64 = cpu_rt_runtime_write,
|
|
},
|
|
{
|
|
.name = "rt_period_us",
|
|
.read_u64 = cpu_rt_period_read_uint,
|
|
.write_u64 = cpu_rt_period_write_uint,
|
|
},
|
|
#endif
|
|
#ifdef CONFIG_UCLAMP_TASK_GROUP
|
|
{
|
|
.name = "uclamp.min",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.seq_show = cpu_uclamp_min_show,
|
|
.write = cpu_uclamp_min_write,
|
|
},
|
|
{
|
|
.name = "uclamp.max",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.seq_show = cpu_uclamp_max_show,
|
|
.write = cpu_uclamp_max_write,
|
|
},
|
|
{
|
|
.name = "uclamp.latency_sensitive",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.read_u64 = cpu_uclamp_ls_read_u64,
|
|
.write_u64 = cpu_uclamp_ls_write_u64,
|
|
},
|
|
#endif
|
|
{ } /* Terminate */
|
|
};
|
|
|
|
static int cpu_extra_stat_show(struct seq_file *sf,
|
|
struct cgroup_subsys_state *css)
|
|
{
|
|
#ifdef CONFIG_CFS_BANDWIDTH
|
|
{
|
|
struct task_group *tg = css_tg(css);
|
|
struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth;
|
|
u64 throttled_usec;
|
|
|
|
throttled_usec = cfs_b->throttled_time;
|
|
do_div(throttled_usec, NSEC_PER_USEC);
|
|
|
|
seq_printf(sf, "nr_periods %d\n"
|
|
"nr_throttled %d\n"
|
|
"throttled_usec %llu\n",
|
|
cfs_b->nr_periods, cfs_b->nr_throttled,
|
|
throttled_usec);
|
|
}
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
static u64 cpu_weight_read_u64(struct cgroup_subsys_state *css,
|
|
struct cftype *cft)
|
|
{
|
|
struct task_group *tg = css_tg(css);
|
|
u64 weight = scale_load_down(tg->shares);
|
|
|
|
return DIV_ROUND_CLOSEST_ULL(weight * CGROUP_WEIGHT_DFL, 1024);
|
|
}
|
|
|
|
static int cpu_weight_write_u64(struct cgroup_subsys_state *css,
|
|
struct cftype *cft, u64 weight)
|
|
{
|
|
/*
|
|
* cgroup weight knobs should use the common MIN, DFL and MAX
|
|
* values which are 1, 100 and 10000 respectively. While it loses
|
|
* a bit of range on both ends, it maps pretty well onto the shares
|
|
* value used by scheduler and the round-trip conversions preserve
|
|
* the original value over the entire range.
|
|
*/
|
|
if (weight < CGROUP_WEIGHT_MIN || weight > CGROUP_WEIGHT_MAX)
|
|
return -ERANGE;
|
|
|
|
weight = DIV_ROUND_CLOSEST_ULL(weight * 1024, CGROUP_WEIGHT_DFL);
|
|
|
|
return sched_group_set_shares(css_tg(css), scale_load(weight));
|
|
}
|
|
|
|
static s64 cpu_weight_nice_read_s64(struct cgroup_subsys_state *css,
|
|
struct cftype *cft)
|
|
{
|
|
unsigned long weight = scale_load_down(css_tg(css)->shares);
|
|
int last_delta = INT_MAX;
|
|
int prio, delta;
|
|
|
|
/* find the closest nice value to the current weight */
|
|
for (prio = 0; prio < ARRAY_SIZE(sched_prio_to_weight); prio++) {
|
|
delta = abs(sched_prio_to_weight[prio] - weight);
|
|
if (delta >= last_delta)
|
|
break;
|
|
last_delta = delta;
|
|
}
|
|
|
|
return PRIO_TO_NICE(prio - 1 + MAX_RT_PRIO);
|
|
}
|
|
|
|
static int cpu_weight_nice_write_s64(struct cgroup_subsys_state *css,
|
|
struct cftype *cft, s64 nice)
|
|
{
|
|
unsigned long weight;
|
|
int idx;
|
|
|
|
if (nice < MIN_NICE || nice > MAX_NICE)
|
|
return -ERANGE;
|
|
|
|
idx = NICE_TO_PRIO(nice) - MAX_RT_PRIO;
|
|
idx = array_index_nospec(idx, 40);
|
|
weight = sched_prio_to_weight[idx];
|
|
|
|
return sched_group_set_shares(css_tg(css), scale_load(weight));
|
|
}
|
|
#endif
|
|
|
|
static void __maybe_unused cpu_period_quota_print(struct seq_file *sf,
|
|
long period, long quota)
|
|
{
|
|
if (quota < 0)
|
|
seq_puts(sf, "max");
|
|
else
|
|
seq_printf(sf, "%ld", quota);
|
|
|
|
seq_printf(sf, " %ld\n", period);
|
|
}
|
|
|
|
/* caller should put the current value in *@periodp before calling */
|
|
static int __maybe_unused cpu_period_quota_parse(char *buf,
|
|
u64 *periodp, u64 *quotap)
|
|
{
|
|
char tok[21]; /* U64_MAX */
|
|
|
|
if (sscanf(buf, "%20s %llu", tok, periodp) < 1)
|
|
return -EINVAL;
|
|
|
|
*periodp *= NSEC_PER_USEC;
|
|
|
|
if (sscanf(tok, "%llu", quotap))
|
|
*quotap *= NSEC_PER_USEC;
|
|
else if (!strcmp(tok, "max"))
|
|
*quotap = RUNTIME_INF;
|
|
else
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_CFS_BANDWIDTH
|
|
static int cpu_max_show(struct seq_file *sf, void *v)
|
|
{
|
|
struct task_group *tg = css_tg(seq_css(sf));
|
|
|
|
cpu_period_quota_print(sf, tg_get_cfs_period(tg), tg_get_cfs_quota(tg));
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t cpu_max_write(struct kernfs_open_file *of,
|
|
char *buf, size_t nbytes, loff_t off)
|
|
{
|
|
struct task_group *tg = css_tg(of_css(of));
|
|
u64 period = tg_get_cfs_period(tg);
|
|
u64 quota;
|
|
int ret;
|
|
|
|
ret = cpu_period_quota_parse(buf, &period, "a);
|
|
if (!ret)
|
|
ret = tg_set_cfs_bandwidth(tg, period, quota);
|
|
return ret ?: nbytes;
|
|
}
|
|
#endif
|
|
|
|
static struct cftype cpu_files[] = {
|
|
#ifdef CONFIG_FAIR_GROUP_SCHED
|
|
{
|
|
.name = "weight",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.read_u64 = cpu_weight_read_u64,
|
|
.write_u64 = cpu_weight_write_u64,
|
|
},
|
|
{
|
|
.name = "weight.nice",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.read_s64 = cpu_weight_nice_read_s64,
|
|
.write_s64 = cpu_weight_nice_write_s64,
|
|
},
|
|
#endif
|
|
#ifdef CONFIG_CFS_BANDWIDTH
|
|
{
|
|
.name = "max",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.seq_show = cpu_max_show,
|
|
.write = cpu_max_write,
|
|
},
|
|
#endif
|
|
#ifdef CONFIG_UCLAMP_TASK_GROUP
|
|
{
|
|
.name = "uclamp.min",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.seq_show = cpu_uclamp_min_show,
|
|
.write = cpu_uclamp_min_write,
|
|
},
|
|
{
|
|
.name = "uclamp.max",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.seq_show = cpu_uclamp_max_show,
|
|
.write = cpu_uclamp_max_write,
|
|
},
|
|
{
|
|
.name = "uclamp.latency_sensitive",
|
|
.flags = CFTYPE_NOT_ON_ROOT,
|
|
.read_u64 = cpu_uclamp_ls_read_u64,
|
|
.write_u64 = cpu_uclamp_ls_write_u64,
|
|
},
|
|
#endif
|
|
{ } /* terminate */
|
|
};
|
|
|
|
struct cgroup_subsys cpu_cgrp_subsys = {
|
|
.css_alloc = cpu_cgroup_css_alloc,
|
|
.css_online = cpu_cgroup_css_online,
|
|
.css_released = cpu_cgroup_css_released,
|
|
.css_free = cpu_cgroup_css_free,
|
|
.css_extra_stat_show = cpu_extra_stat_show,
|
|
.fork = cpu_cgroup_fork,
|
|
.can_attach = cpu_cgroup_can_attach,
|
|
.attach = cpu_cgroup_attach,
|
|
.legacy_cftypes = cpu_legacy_files,
|
|
.dfl_cftypes = cpu_files,
|
|
.early_init = true,
|
|
.threaded = true,
|
|
};
|
|
|
|
#endif /* CONFIG_CGROUP_SCHED */
|
|
|
|
void dump_cpu_task(int cpu)
|
|
{
|
|
pr_info("Task dump for CPU %d:\n", cpu);
|
|
sched_show_task(cpu_curr(cpu));
|
|
}
|
|
|
|
/*
|
|
* Nice levels are multiplicative, with a gentle 10% change for every
|
|
* nice level changed. I.e. when a CPU-bound task goes from nice 0 to
|
|
* nice 1, it will get ~10% less CPU time than another CPU-bound task
|
|
* that remained on nice 0.
|
|
*
|
|
* The "10% effect" is relative and cumulative: from _any_ nice level,
|
|
* if you go up 1 level, it's -10% CPU usage, if you go down 1 level
|
|
* it's +10% CPU usage. (to achieve that we use a multiplier of 1.25.
|
|
* If a task goes up by ~10% and another task goes down by ~10% then
|
|
* the relative distance between them is ~25%.)
|
|
*/
|
|
const int sched_prio_to_weight[40] = {
|
|
/* -20 */ 88761, 71755, 56483, 46273, 36291,
|
|
/* -15 */ 29154, 23254, 18705, 14949, 11916,
|
|
/* -10 */ 9548, 7620, 6100, 4904, 3906,
|
|
/* -5 */ 3121, 2501, 1991, 1586, 1277,
|
|
/* 0 */ 1024, 820, 655, 526, 423,
|
|
/* 5 */ 335, 272, 215, 172, 137,
|
|
/* 10 */ 110, 87, 70, 56, 45,
|
|
/* 15 */ 36, 29, 23, 18, 15,
|
|
};
|
|
|
|
/*
|
|
* Inverse (2^32/x) values of the sched_prio_to_weight[] array, precalculated.
|
|
*
|
|
* In cases where the weight does not change often, we can use the
|
|
* precalculated inverse to speed up arithmetics by turning divisions
|
|
* into multiplications:
|
|
*/
|
|
const u32 sched_prio_to_wmult[40] = {
|
|
/* -20 */ 48388, 59856, 76040, 92818, 118348,
|
|
/* -15 */ 147320, 184698, 229616, 287308, 360437,
|
|
/* -10 */ 449829, 563644, 704093, 875809, 1099582,
|
|
/* -5 */ 1376151, 1717300, 2157191, 2708050, 3363326,
|
|
/* 0 */ 4194304, 5237765, 6557202, 8165337, 10153587,
|
|
/* 5 */ 12820798, 15790321, 19976592, 24970740, 31350126,
|
|
/* 10 */ 39045157, 49367440, 61356676, 76695844, 95443717,
|
|
/* 15 */ 119304647, 148102320, 186737708, 238609294, 286331153,
|
|
};
|
|
|
|
void call_trace_sched_update_nr_running(struct rq *rq, int count)
|
|
{
|
|
trace_sched_update_nr_running_tp(rq, count);
|
|
}
|