* common/android-4.9-q:
Linux 4.9.321
swiotlb: skip swiotlb_bounce when orig_addr is zero
kexec_file: drop weak attribute from arch_kexec_apply_relocations[_add]
fdt: Update CRC check for rng-seed
xen: unexport __init-annotated xen_xlate_map_ballooned_pages()
drm: remove drm_fb_helper_modinit
powerpc/pseries: wire up rng during setup_arch()
modpost: fix section mismatch check for exported init/exit sections
ARM: cns3xxx: Fix refcount leak in cns3xxx_init
ARM: Fix refcount leak in axxia_boot_secondary
ARM: exynos: Fix refcount leak in exynos_map_pmu
ARM: dts: imx6qdl: correct PU regulator ramp delay
powerpc: Enable execve syscall exit tracepoint
xtensa: Fix refcount leak bug in time.c
xtensa: xtfpga: Fix refcount leak bug in setup
iio: trigger: sysfs: fix use-after-free on remove
iio: accel: mma8452: ignore the return value of reset operation
iio:accel:bma180: rearrange iio trigger get and register
usb: chipidea: udc: check request status before setting device address
iio: adc: vf610: fix conversion mode sysfs node name
igb: Make DMA faster when CPU is active on the PCIe link
MIPS: Remove repetitive increase irq_err_count
x86/xen: Remove undefined behavior in setup_features()
bonding: ARP monitor spams NETDEV_NOTIFY_PEERS notifiers
USB: serial: option: add Telit LE910Cx 0x1250 composition
random: quiet urandom warning ratelimit suppression message
dm era: commit metadata in postsuspend after worker stops
ata: libata: add qc->flags in ata_qc_complete_template tracepoint
random: schedule mix_interrupt_randomness() less often
vt: drop old FONT ioctls
BACKPORT: l2tp: fix race in pppol2tp_release with session object destroy
BACKPORT: l2tp: don't use inet_shutdown on ppp session destroy
Linux 4.9.320
tcp: drop the hash_32() part from the index calculation
tcp: increase source port perturb table to 2^16
tcp: dynamically allocate the perturb table used by source ports
tcp: add small random increments to the source port
tcp: use different parts of the port_offset for index and offset
secure_seq: use the 64 bits of the siphash for port offset calculation
tcp: add some entropy in __inet_hash_connect()
tcp: change source port randomizarion at connect() time
fuse: fix pipe buffer lifetime for direct_io
Reinstate some of "swiotlb: rework "fix info leak with DMA_FROM_DEVICE""
swiotlb: fix info leak with DMA_FROM_DEVICE
xprtrdma: fix incorrect header size calculations
s390/mm: use non-quiescing sske for KVM switch to keyed guest
l2tp: fix race in pppol2tp_release with session object destroy
l2tp: don't use inet_shutdown on ppp session destroy
ext4: add reserved GDT blocks check
ext4: make variable "count" signed
ext4: fix bug_on ext4_mb_use_inode_pa
serial: 8250: Store to lsr_save_flags after lsr read
usb: gadget: lpc32xx_udc: Fix refcount leak in lpc32xx_udc_probe
USB: serial: io_ti: add Agilent E5805A support
USB: serial: option: add support for Cinterion MV31 with new baseline
comedi: vmk80xx: fix expression for tx buffer size
irqchip/gic-v3: Iterate over possible CPUs by for_each_possible_cpu()
irqchip/gic/realview: Fix refcount leak in realview_gic_of_init
misc: atmel-ssc: Fix IRQ check in ssc_probe
pNFS: Don't keep retrying if the server replied NFS4ERR_LAYOUTUNAVAILABLE
random: credit cpu and bootloader seeds by default
net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface netdev[napi]_alloc_frag
ipv6: Fix signed integer overflow in l2tp_ip6_sendmsg
nfc: nfcmrvl: Fix memory leak in nfcmrvl_play_deferred
virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed
scsi: lpfc: Fix port stuck in bypassed state after LIP in PT2PT topology
scsi: vmw_pvscsi: Expand vcpuHint to 16 bits
ASoC: wm8962: Fix suspend while playing music
ata: libata-core: fix NULL pointer deref in ata_host_alloc_pinfo()
ASoC: cs42l56: Correct typo in minimum level for SX volume controls
ASoC: cs42l52: Correct TLV for Bypass Volume
ASoC: cs53l30: Correct number of volume levels on SX controls
ASoC: cs42l52: Fix TLV scales for mixer controls
random: account for arch randomness in bits
random: mark bootloader randomness code as __init
random: avoid checking crng_ready() twice in random_init()
crypto: drbg - make reseeding from get_random_bytes() synchronous
crypto: drbg - always try to free Jitter RNG instance
crypto: drbg - move dynamic ->reseed_threshold adjustments to __drbg_seed()
crypto: drbg - track whether DRBG was seeded with !rng_is_initialized()
crypto: drbg - prepare for more fine-grained tracking of seeding state
crypto: drbg - always seeded with SP800-90B compliant noise source
crypto: drbg - add FIPS 140-2 CTRNG for noise source
Revert "random: use static branch for crng_ready()"
random: check for signals after page of pool writes
random: wire up fops->splice_{read,write}_iter()
random: convert to using fops->write_iter()
random: move randomize_page() into mm where it belongs
random: move initialization functions out of hot pages
random: use proper return types on get_random_{int,long}_wait()
random: remove extern from functions in header
random: use static branch for crng_ready()
random: credit architectural init the exact amount
random: handle latent entropy and command line from random_init()
random: use proper jiffies comparison macro
random: remove ratelimiting for in-kernel unseeded randomness
random: avoid initializing twice in credit race
random: use symbolic constants for crng_init states
siphash: use one source of truth for siphash permutations
random: help compiler out with fast_mix() by using simpler arguments
random: do not use input pool from hard IRQs
random: order timer entropy functions below interrupt functions
random: do not pretend to handle premature next security model
random: do not use batches when !crng_ready()
random: insist on random_get_entropy() existing in order to simplify
uapi: rename ext2_swab() to swab() and share globally in swab.h
xtensa: use fallback for random_get_entropy() instead of zero
sparc: use fallback for random_get_entropy() instead of zero
um: use fallback for random_get_entropy() instead of zero
x86/tsc: Use fallback for random_get_entropy() instead of zero
nios2: use fallback for random_get_entropy() instead of zero
arm: use fallback for random_get_entropy() instead of zero
mips: use fallback for random_get_entropy() instead of just c0 random
m68k: use fallback for random_get_entropy() instead of zero
timekeeping: Add raw clock fallback for random_get_entropy()
powerpc: define get_cycles macro for arch-override
alpha: define get_cycles macro for arch-override
parisc: define get_cycles macro for arch-override
s390: define get_cycles macro for arch-override
ia64: define get_cycles macro for arch-override
init: call time_init() before rand_initialize()
random: fix sysctl documentation nits
random: document crng_fast_key_erasure() destination possibility
random: make random_get_entropy() return an unsigned long
random: check for signals every PAGE_SIZE chunk of /dev/[u]random
random: check for signal_pending() outside of need_resched() check
random: do not allow user to keep crng key around on stack
random: do not split fast init input in add_hwgenerator_randomness()
random: mix build-time latent entropy into pool at init
random: re-add removed comment about get_random_{u32,u64} reseeding
random: treat bootloader trust toggle the same way as cpu trust toggle
random: skip fast_init if hwrng provides large chunk of entropy
random: check for signal and try earlier when generating entropy
random: reseed more often immediately after booting
random: make consistent usage of crng_ready()
random: use SipHash as interrupt entropy accumulator
random: replace custom notifier chain with standard one
random: don't let 644 read-only sysctls be written to
random: give sysctl_random_min_urandom_seed a more sensible value
random: do crng pre-init loading in worker rather than irq
random: unify cycles_t and jiffies usage and types
random: cleanup UUID handling
random: only wake up writers after zap if threshold was passed
random: round-robin registers as ulong, not u32
random: clear fast pool, crng, and batches in cpuhp bring up
random: pull add_hwgenerator_randomness() declaration into random.h
hwrng: remember rng chosen by user
hwrng: use rng source with best quality
hwrng: core - remove unused PFX macro
hwrng: core - Move hwrng miscdev minor number to include/linux/miscdevice.h
hwrng: core - Rewrite the header
hwrng: core - rewrite better comparison to NULL
hwrng: core - do not use multiple blank lines
random: check for crng_init == 0 in add_device_randomness()
random: unify early init crng load accounting
random: do not take pool spinlock at boot
random: defer fast pool mixing to worker
workqueue: make workqueue available early during boot
random: rewrite header introductory comment
random: group sysctl functions
random: group userspace read/write functions
random: group entropy collection functions
random: group entropy extraction functions
random: group initialization wait functions
random: remove whitespace and reorder includes
random: remove useless header comment
random: introduce drain_entropy() helper to declutter crng_reseed()
random: deobfuscate irq u32/u64 contributions
random: add proper SPDX header
random: remove unused tracepoints
random: remove ifdef'd out interrupt bench
random: tie batched entropy generation to base_crng generation
random: zero buffer after reading entropy from userspace
random: remove outdated INT_MAX >> 6 check in urandom_read()
random: use hash function for crng_slow_load()
random: absorb fast pool into input pool after fast load
random: do not xor RDRAND when writing into /dev/random
random: ensure early RDSEED goes through mixer on init
random: inline leaves of rand_initialize()
random: use RDSEED instead of RDRAND in entropy extraction
random: fix locking in crng_fast_load()
random: remove batched entropy locking
random: remove use_input_pool parameter from crng_reseed()
random: make credit_entropy_bits() always safe
random: always wake up entropy writers after extraction
random: use linear min-entropy accumulation crediting
random: simplify entropy debiting
random: use computational hash for entropy extraction
random: only call crng_finalize_init() for primary_crng
random: access primary_pool directly rather than through pointer
random: continually use hwgenerator randomness
random: simplify arithmetic function flow in account()
random: access input_pool_data directly rather than through pointer
random: cleanup fractional entropy shift constants
random: prepend remaining pool constants with POOL_
random: de-duplicate INPUT_POOL constants
random: remove unused OUTPUT_POOL constants
random: rather than entropy_store abstraction, use global
random: try to actively add entropy rather than passively wait for it
random: remove unused extract_entropy() reserved argument
random: remove incomplete last_data logic
random: cleanup integer types
crypto: chacha20 - Fix chacha20_block() keystream alignment (again)
random: cleanup poolinfo abstraction
random: fix typo in comments
random: don't reset crng_init_cnt on urandom_read()
random: avoid superfluous call to RDRAND in CRNG extraction
random: early initialization of ChaCha constants
random: initialize ChaCha20 constants with correct endianness
random: use IS_ENABLED(CONFIG_NUMA) instead of ifdefs
random: harmonize "crng init done" messages
random: mix bootloader randomness into pool
random: do not re-init if crng_reseed completes before primary init
random: do not sign extend bytes for rotation when mixing
random: use BLAKE2s instead of SHA1 in extraction
random: remove unused irq_flags argument from add_interrupt_randomness()
random: document add_hwgenerator_randomness() with other input functions
crypto: blake2s - adjust include guard naming
crypto: blake2s - include <linux/bug.h> instead of <asm/bug.h>
MAINTAINERS: co-maintain random.c
random: remove dead code left over from blocking pool
random: avoid arch_get_random_seed_long() when collecting IRQ randomness
random: add arch_get_random_*long_early()
powerpc: Use bool in archrandom.h
linux/random.h: Mark CONFIG_ARCH_RANDOM functions __must_check
linux/random.h: Use false with bool
linux/random.h: Remove arch_has_random, arch_has_random_seed
powerpc: Remove arch_has_random, arch_has_random_seed
x86: Remove arch_has_random, arch_has_random_seed
random: avoid warnings for !CONFIG_NUMA builds
random: split primary/secondary crng init paths
random: remove some dead code of poolinfo
random: fix typo in add_timer_randomness()
random: Add and use pr_fmt()
random: convert to ENTROPY_BITS for better code readability
random: remove unnecessary unlikely()
random: remove kernel.random.read_wakeup_threshold
random: delete code to pull data into pools
random: remove the blocking pool
random: fix crash on multiple early calls to add_bootloader_randomness()
random: make /dev/random be almost like /dev/urandom
random: ignore GRND_RANDOM in getentropy(2)
random: add GRND_INSECURE to return best-effort non-cryptographic bytes
random: Add a urandom_read_nowait() for random APIs that don't warn
random: Don't wake crng_init_wait when crng_init == 1
lib/crypto: sha1: re-roll loops to reduce code size
lib/crypto: blake2s: move hmac construction into wireguard
crypto: blake2s - generic C library implementation and selftest
crypto: Deduplicate le32_to_cpu_array() and cpu_to_le32_array()
Revert "hwrng: core - Freeze khwrng thread during suspend"
char/random: Add a newline at the end of the file
random: Use wait_event_freezable() in add_hwgenerator_randomness()
fdt: add support for rng-seed
random: Support freezable kthreads in add_hwgenerator_randomness()
random: fix soft lockup when trying to read from an uninitialized blocking pool
latent_entropy: avoid build error when plugin cflags are not set
random: document get_random_int() family
random: move rand_initialize() earlier
random: only read from /dev/random after its pool has received 128 bits
drivers/char/random.c: make primary_crng static
drivers/char/random.c: remove unused stuct poolinfo::poolbits
drivers/char/random.c: constify poolinfo_table
random: make CPU trust a boot parameter
random: Make crng state queryable
random: remove preempt disabled region
random: add a config option to trust the CPU's hwrng
random: Return nbytes filled from hw RNG
random: Fix whitespace pre random-bytes work
drivers/char/random.c: remove unused dont_count_entropy
random: optimize add_interrupt_randomness
random: always fill buffer in get_random_bytes_wait
crypto: chacha20 - Fix keystream alignment for chacha20_block()
random: fix data race on crng_node_pool
random: always use batched entropy for get_random_u{32,64}
Revert "char/random: silence a lockdep splat with printk()"
char/random: silence a lockdep splat with printk()
random: add a spinlock_t to struct batched_entropy
random: rate limit unseeded randomness warnings
random: fix possible sleeping allocation from irq context
random: set up the NUMA crng instances after the CRNG is fully initialized
random: use a different mixing algorithm for add_device_randomness()
random: fix warning message on ia64 and parisc
random: reorder READ_ONCE() in get_random_uXX
random: suppress spammy warnings about unseeded randomness
random: do not ignore early device randomness
random: warn when kernel uses unseeded randomness
random: add get_random_{bytes,u32,u64,int,long,once}_wait family
random: add wait_for_random_bytes() API
random: silence compiler warnings and fix race
random: invalidate batched entropy after crng init
random: move random_min_urandom_seed into CONFIG_SYSCTL ifdef block
random: convert get_random_int/long into get_random_u32/u64
random: fix comment for unused random_min_urandom_seed
random: remove variable limit
random: remove stale urandom_init_wait
random: remove stale maybe_reseed_primary_crng
9p: missing chunk of "fs/9p: Don't update file type when updating file attributes"
Linux 4.9.319
x86/speculation/mmio: Print SMT warning
KVM: x86/speculation: Disable Fill buffer clear within guests
x86/speculation/mmio: Reuse SRBDS mitigation for SBDS
x86/speculation/srbds: Update SRBDS mitigation selection
x86/speculation/mmio: Add sysfs reporting for Processor MMIO Stale Data
x86/speculation/mmio: Enable CPU Fill buffer clearing on idle
x86/bugs: Group MDS, TAA & Processor MMIO Stale Data mitigations
x86/speculation/mmio: Add mitigation for Processor MMIO Stale Data
x86/speculation: Add a common function for MD_CLEAR mitigation update
x86/speculation/mmio: Enumerate Processor MMIO Stale Data bug
Documentation: Add documentation for Processor MMIO Stale Data
x86/cpu: Add another Alder Lake CPU to the Intel family
x86/cpu: Add Lakefield, Alder Lake and Rocket Lake models to the to Intel CPU family
x86/cpu: Add Comet Lake to the Intel CPU models header
x86/CPU: Add more Icelake model numbers
x86/CPU: Add Icelake model number
x86/cpu: Add Cannonlake to Intel family
x86/cpu: Add Jasper Lake to Intel family
cpu/speculation: Add prototype for cpu_show_srbds()
x86/cpu: Add Elkhart Lake to Intel family
ANDROID: arch: fix backported syscall numbers
Linux 4.9.318
tcp: fix tcp_mtup_probe_success vs wrong snd_cwnd
PCI: qcom: Fix unbalanced PHY init on probe errors
mtd: cfi_cmdset_0002: Use chip_ready() for write on S29GL064N
mtd: cfi_cmdset_0002: Move and rename chip_check/chip_ready/chip_good_for_write
powerpc/32: Fix overread/overwrite of thread_struct via ptrace
Input: bcm5974 - set missing URB_NO_TRANSFER_DMA_MAP urb flag
nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling
nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION
ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
cifs: return errors during session setup during reconnects
ALSA: hda/conexant - Fix loopback issue with CX20632
vringh: Fix loop descriptors check in the indirect cases
nodemask: Fix return values to be unsigned
modpost: fix undefined behavior of is_arm_mapping_symbol()
drm/radeon: fix a possible null pointer dereference
Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process"
md: protect md_unregister_thread from reentrancy
serial: msm_serial: disable interrupts in __msm_console_write()
staging: rtl8712: fix uninit-value in r871xu_drv_init()
clocksource/drivers/sp804: Avoid error on multiple instances
misc: rtsx: set NULL intfdata when probe fails
usb: dwc2: gadget: don't reset gadget's driver->bus
USB: hcd-pci: Fully suspend across freeze/thaw cycle
drivers: usb: host: Fix deadlock in oxu_bus_suspend()
drivers: tty: serial: Fix deadlock in sa1100_set_termios()
USB: host: isp116x: check return value after calling platform_get_resource()
drivers: staging: rtl8192e: Fix deadlock in rtllib_beacons_stop()
tty: Fix a possible resource leak in icom_probe
tty: synclink_gt: Fix null-pointer-dereference in slgt_clean()
lkdtm/usercopy: Expand size of "out of frame" object
iio: dummy: iio_simple_dummy: check the return value of kstrdup()
net: altera: Fix refcount leak in altera_tse_mdio_create
net: xfrm: unexport __init-annotated xfrm4_protocol_init()
SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()
net/mlx4_en: Fix wrong return value on ioctl EEPROM query failure
ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe
net: fix nla_strcmp to handle more then one trailing null character
video: fbdev: pxa3xx-gcu: release the resources correctly in pxa3xx_gcu_probe/remove()
m68knommu: fix undefined reference to `_init_sp'
m68knommu: set ZERO_PAGE() to the allocated zeroed page
i2c: cadence: Increase timeout per message if necessary
tracing: Avoid adding tracer option before update_tracer_options
tcp: tcp_rtx_synack() can be called from process context
jffs2: fix memory leak in jffs2_do_fill_super
modpost: fix removing numeric suffixes
net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_entry()
clocksource/drivers/oxnas-rps: Fix irq_of_parse_and_map() return value
firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle
serial: st-asc: Sanitize CSIZE and correct PARENB for CS7
serial: sh-sci: Don't allow CS5-6
serial: txx9: Don't allow CS5-6
serial: digicolor-usart: Don't allow CS5-6
serial: meson: acquire port->lock in startup()
rtc: mt6397: check return value after calling platform_get_resource()
rpmsg: qcom_smd: Fix irq_of_parse_and_map() return value
pwm: lp3943: Fix duty calculation in case period was clamped
USB: storage: karma: fix rio_karma_init return
usb: usbip: add missing device lock on tweak configuration cmd
usb: usbip: fix a refcount leak in stub_probe()
staging: greybus: codecs: fix type confusion of list iterator variable
pcmcia: db1xxx_ss: restrict to MIPS_DB1XXX boards
netfilter: nf_tables: disallow non-stateful expression in sets earlier
MIPS: IP27: Remove incorrect `cpu_has_fpu' override
RDMA/rxe: Generate a completion for unsupported/invalid opcode
dt-bindings: gpio: altera: correct interrupt-cells
docs/conf.py: Cope with removal of language=None in Sphinx 5.0.0
gma500: fix an incorrect NULL check on list iterator
carl9170: tx: fix an incorrect use of list iterator
ASoC: rt5514: Fix event generation for "DSP Voice Wake Up" control
rtl818x: Prevent using not initialized queues
hugetlb: fix huge_pmd_unshare address update
nodemask.h: fix compilation error with GCC12
iommu/msm: Fix an incorrect NULL check on list iterator
um: Fix out-of-bounds read in LDT setup
um: chan_user: Fix winch_tramp() return value
mac80211: upgrade passive scan to active scan on DFS channels after beacon rx
irqchip: irq-xtensa-mx: fix initial IRQ affinity
irqchip/armada-370-xp: Do not touch Performance Counter Overflow on A375, A38x, A39x
RDMA/hfi1: Fix potential integer multiplication overflow errors
md: fix an incorrect NULL check in md_reload_sb
md: fix an incorrect NULL check in does_sb_need_changing
drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
drm/amdgpu/cs: make commands with 0 chunks illegal behaviour.
scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabled
scsi: dc395x: Fix a missing check on list iterator
ocfs2: dlmfs: fix error handling of user_dlm_destroy_lock
dlm: fix missing lkb refcount handling
dlm: fix plock invalid read
ext4: verify dir block before splitting it
ext4: fix bug_on in ext4_writepages
ext4: fix use-after-free in ext4_rename_dir_prepare
fs-writeback: writeback_sb_inodes:Recalculate 'wrote' according skipped pages
iwlwifi: mvm: fix assert 1F04 upon reconfig
wifi: mac80211: fix use-after-free in chanctx code
iommu/amd: Increase timeout waiting for GA log enablement
video: fbdev: clcdfb: Fix refcount leak in clcdfb_of_vram_setup
Input: sparcspkr - fix refcount leak in bbc_beep_probe
tty: fix deadlock caused by calling printk() under tty_port->lock
powerpc/4xx/cpm: Fix return value of __setup() handler
powerpc/idle: Fix return value of __setup() handler
powerpc/8xx: export 'cpm_setbrg' for modules
drivers/base/node.c: fix compaction sysfs file leak
scsi: fcoe: Fix Wstringop-overflow warnings in fcoe_wwn_from_mac()
mfd: ipaq-micro: Fix error check return value of platform_get_irq()
soc: qcom: smsm: Fix missing of_node_put() in smsm_parse_ipc
soc: qcom: smp2p: Fix missing of_node_put() in smp2p_parse_ipc
rxrpc: Don't try to resend the request if we're receiving the reply
rxrpc: Fix listen() setting the bar too high for the prealloc rings
ASoC: wm2000: fix missing clk_disable_unprepare() on error in wm2000_anc_transition()
sctp: read sk->sk_bound_dev_if once in sctp_rcv()
m68k: math-emu: Fix dependencies of math emulation support
Bluetooth: fix dangling sco_conn and use-after-free in sco_sock_timeout
media: pvrusb2: fix array-index-out-of-bounds in pvr2_i2c_core_init
media: exynos4-is: Change clk_disable to clk_disable_unprepare
regulator: pfuze100: Fix refcount leak in pfuze_parse_regulators_dt
ASoC: mxs-saif: Fix refcount leak in mxs_saif_probe
media: uvcvideo: Fix missing check to determine if element is found in list
drm/msm: return an error pointer in msm_gem_prime_get_sg_table()
x86/mm: Cleanup the control_va_addr_alignment() __setup handler
drm/rockchip: vop: fix possible null-ptr-deref in vop_bind()
drm/msm/hdmi: check return value after calling platform_get_resource_byname()
drm/msm/dsi: fix error checks and return values for DSI xmit functions
x86/pm: Fix false positive kmemleak report in msr_build_context()
inotify: show inotify mask flags in proc fdinfo
ath9k_htc: fix potential out of bounds access with invalid rxstatus->rs_keyix
spi: img-spfi: Fix pm_runtime_get_sync() error checking
HID: hid-led: fix maximum brightness for Dream Cheeky
NFC: NULL out the dev->rfkill to prevent UAF
spi: spi-ti-qspi: Fix return value handling of wait_for_completion_timeout
drm/mediatek: Fix mtk_cec_mask()
x86/delay: Fix the wrong asm constraint in delay_loop()
ASoC: mediatek: Fix error handling in mt8173_max98090_dev_probe
drm: fix EDID struct for old ARM OABI format
macintosh/via-pmu: Fix build failure when CONFIG_INPUT is disabled
powerpc/xics: fix refcount leak in icp_opal_init()
PCI: Avoid pci_dev_lock() AB/BA deadlock with sriov_numvfs_store()
ARM: hisi: Add missing of_node_put after of_find_compatible_node
ARM: dts: exynos: add atmel,24c128 fallback to Samsung EEPROM
ARM: versatile: Add missing of_node_put in dcscb_init
fat: add ratelimit to fat*_ent_bread()
ARM: OMAP1: clock: Fix UART rate reporting algorithm
fs: jfs: fix possible NULL pointer dereference in dbFree()
eth: tg3: silence the GCC 12 array-bounds warning
rxrpc: Return an error to sendmsg if call failed
media: exynos4-is: Fix compile warning
ASoC: rt5645: Fix errorenous cleanup order
nvme-pci: fix a NULL pointer dereference in nvme_alloc_admin_tags
openrisc: start CPU timer early in boot
ipmi:ssif: Check for NULL msg when handling events and messages
dma-debug: change allocation mode from GFP_NOWAIT to GFP_ATIOMIC
ASoC: dapm: Don't fold register value changes into notifications
ipv6: Don't send rs packets to the interface of ARPHRD_TUNNEL
drm/amd/pm: fix the compile warning
scsi: megaraid: Fix error check return value of register_chrdev()
media: cx25821: Fix the warning when removing the module
ath9k: fix QCA9561 PA bias level
drm/amd/pm: fix double free in si_parse_power_table()
ALSA: jack: Access input_dev under mutex
ACPICA: Avoid cache flush inside virtual machines
ipw2x00: Fix potential NULL dereference in libipw_xmit()
b43: Fix assigning negative value to unsigned variable
b43legacy: Fix assigning negative value to unsigned variable
mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue
drm/virtio: fix NULL pointer dereference in virtio_gpu_conn_get_modes
btrfs: add "0x" prefix for unsupported optional features
ptrace: Reimplement PTRACE_KILL by always sending SIGKILL
ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP
USB: new quirk for Dell Gen 2 devices
BACKPORT: psi: Fix uaf issue when psi trigger is destroyed while being polled
Conflicts:
drivers/char/Kconfig
drivers/char/random.c
fs/fat/fatent.c
include/linux/random.h
init/main.c
kernel/cpu.c
lib/Makefile
Change-Id: I06579fa22a0347a0d8d2fa32bd6b7b6b54db626f
720 lines
19 KiB
C
720 lines
19 KiB
C
/*
|
|
* Basic Node interface support
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/memory.h>
|
|
#include <linux/vmstat.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/node.h>
|
|
#include <linux/hugetlb.h>
|
|
#include <linux/compaction.h>
|
|
#include <linux/cpumask.h>
|
|
#include <linux/topology.h>
|
|
#include <linux/nodemask.h>
|
|
#include <linux/cpu.h>
|
|
#include <linux/device.h>
|
|
#include <linux/swap.h>
|
|
#include <linux/slab.h>
|
|
|
|
static struct bus_type node_subsys = {
|
|
.name = "node",
|
|
.dev_name = "node",
|
|
};
|
|
|
|
|
|
static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf)
|
|
{
|
|
struct node *node_dev = to_node(dev);
|
|
const struct cpumask *mask = cpumask_of_node(node_dev->dev.id);
|
|
|
|
/* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */
|
|
BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1));
|
|
|
|
return cpumap_print_to_pagebuf(list, buf, mask);
|
|
}
|
|
|
|
static inline ssize_t node_read_cpumask(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
return node_read_cpumap(dev, false, buf);
|
|
}
|
|
static inline ssize_t node_read_cpulist(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
return node_read_cpumap(dev, true, buf);
|
|
}
|
|
|
|
static DEVICE_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL);
|
|
static DEVICE_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
|
|
|
|
#define K(x) ((x) << (PAGE_SHIFT - 10))
|
|
static ssize_t node_read_meminfo(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
int n;
|
|
int nid = dev->id;
|
|
struct pglist_data *pgdat = NODE_DATA(nid);
|
|
struct sysinfo i;
|
|
|
|
si_meminfo_node(&i, nid);
|
|
n = sprintf(buf,
|
|
"Node %d MemTotal: %8lu kB\n"
|
|
"Node %d MemFree: %8lu kB\n"
|
|
"Node %d MemUsed: %8lu kB\n"
|
|
"Node %d Active: %8lu kB\n"
|
|
"Node %d Inactive: %8lu kB\n"
|
|
"Node %d Active(anon): %8lu kB\n"
|
|
"Node %d Inactive(anon): %8lu kB\n"
|
|
"Node %d Active(file): %8lu kB\n"
|
|
"Node %d Inactive(file): %8lu kB\n"
|
|
"Node %d Unevictable: %8lu kB\n"
|
|
"Node %d Mlocked: %8lu kB\n",
|
|
nid, K(i.totalram),
|
|
nid, K(i.freeram),
|
|
nid, K(i.totalram - i.freeram),
|
|
nid, K(node_page_state(pgdat, NR_ACTIVE_ANON) +
|
|
node_page_state(pgdat, NR_ACTIVE_FILE)),
|
|
nid, K(node_page_state(pgdat, NR_INACTIVE_ANON) +
|
|
node_page_state(pgdat, NR_INACTIVE_FILE)),
|
|
nid, K(node_page_state(pgdat, NR_ACTIVE_ANON)),
|
|
nid, K(node_page_state(pgdat, NR_INACTIVE_ANON)),
|
|
nid, K(node_page_state(pgdat, NR_ACTIVE_FILE)),
|
|
nid, K(node_page_state(pgdat, NR_INACTIVE_FILE)),
|
|
nid, K(node_page_state(pgdat, NR_UNEVICTABLE)),
|
|
nid, K(sum_zone_node_page_state(nid, NR_MLOCK)));
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
n += sprintf(buf + n,
|
|
"Node %d HighTotal: %8lu kB\n"
|
|
"Node %d HighFree: %8lu kB\n"
|
|
"Node %d LowTotal: %8lu kB\n"
|
|
"Node %d LowFree: %8lu kB\n",
|
|
nid, K(i.totalhigh),
|
|
nid, K(i.freehigh),
|
|
nid, K(i.totalram - i.totalhigh),
|
|
nid, K(i.freeram - i.freehigh));
|
|
#endif
|
|
n += sprintf(buf + n,
|
|
"Node %d Dirty: %8lu kB\n"
|
|
"Node %d Writeback: %8lu kB\n"
|
|
"Node %d FilePages: %8lu kB\n"
|
|
"Node %d Mapped: %8lu kB\n"
|
|
"Node %d AnonPages: %8lu kB\n"
|
|
"Node %d Shmem: %8lu kB\n"
|
|
"Node %d KernelStack: %8lu kB\n"
|
|
#ifdef CONFIG_SHADOW_CALL_STACK
|
|
"Node %d ShadowCallStack:%8lu kB\n"
|
|
#endif
|
|
"Node %d PageTables: %8lu kB\n"
|
|
"Node %d NFS_Unstable: %8lu kB\n"
|
|
"Node %d Bounce: %8lu kB\n"
|
|
"Node %d WritebackTmp: %8lu kB\n"
|
|
"Node %d Slab: %8lu kB\n"
|
|
"Node %d SReclaimable: %8lu kB\n"
|
|
"Node %d SUnreclaim: %8lu kB\n"
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
"Node %d AnonHugePages: %8lu kB\n"
|
|
"Node %d ShmemHugePages: %8lu kB\n"
|
|
"Node %d ShmemPmdMapped: %8lu kB\n"
|
|
#endif
|
|
,
|
|
nid, K(node_page_state(pgdat, NR_FILE_DIRTY)),
|
|
nid, K(node_page_state(pgdat, NR_WRITEBACK)),
|
|
nid, K(node_page_state(pgdat, NR_FILE_PAGES)),
|
|
nid, K(node_page_state(pgdat, NR_FILE_MAPPED)),
|
|
nid, K(node_page_state(pgdat, NR_ANON_MAPPED)),
|
|
nid, K(i.sharedram),
|
|
nid, sum_zone_node_page_state(nid, NR_KERNEL_STACK_KB),
|
|
#ifdef CONFIG_SHADOW_CALL_STACK
|
|
nid, sum_zone_node_page_state(nid, NR_KERNEL_SCS_BYTES) / 1024,
|
|
#endif
|
|
nid, K(sum_zone_node_page_state(nid, NR_PAGETABLE)),
|
|
nid, K(node_page_state(pgdat, NR_UNSTABLE_NFS)),
|
|
nid, K(sum_zone_node_page_state(nid, NR_BOUNCE)),
|
|
nid, K(node_page_state(pgdat, NR_WRITEBACK_TEMP)),
|
|
nid, K(sum_zone_node_page_state(nid, NR_SLAB_RECLAIMABLE) +
|
|
sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)),
|
|
nid, K(sum_zone_node_page_state(nid, NR_SLAB_RECLAIMABLE)),
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
nid, K(sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)),
|
|
nid, K(node_page_state(pgdat, NR_ANON_THPS) *
|
|
HPAGE_PMD_NR),
|
|
nid, K(node_page_state(pgdat, NR_SHMEM_THPS) *
|
|
HPAGE_PMD_NR),
|
|
nid, K(node_page_state(pgdat, NR_SHMEM_PMDMAPPED) *
|
|
HPAGE_PMD_NR));
|
|
#else
|
|
nid, K(sum_zone_node_page_state(nid, NR_SLAB_UNRECLAIMABLE)));
|
|
#endif
|
|
n += hugetlb_report_node_meminfo(nid, buf + n);
|
|
return n;
|
|
}
|
|
|
|
#undef K
|
|
static DEVICE_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);
|
|
|
|
static ssize_t node_read_numastat(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
return sprintf(buf,
|
|
"numa_hit %lu\n"
|
|
"numa_miss %lu\n"
|
|
"numa_foreign %lu\n"
|
|
"interleave_hit %lu\n"
|
|
"local_node %lu\n"
|
|
"other_node %lu\n",
|
|
sum_zone_node_page_state(dev->id, NUMA_HIT),
|
|
sum_zone_node_page_state(dev->id, NUMA_MISS),
|
|
sum_zone_node_page_state(dev->id, NUMA_FOREIGN),
|
|
sum_zone_node_page_state(dev->id, NUMA_INTERLEAVE_HIT),
|
|
sum_zone_node_page_state(dev->id, NUMA_LOCAL),
|
|
sum_zone_node_page_state(dev->id, NUMA_OTHER));
|
|
}
|
|
static DEVICE_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
|
|
|
|
static ssize_t node_read_vmstat(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
int nid = dev->id;
|
|
struct pglist_data *pgdat = NODE_DATA(nid);
|
|
int i;
|
|
int n = 0;
|
|
|
|
for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
|
|
n += sprintf(buf+n, "%s %lu\n", vmstat_text[i],
|
|
sum_zone_node_page_state(nid, i));
|
|
|
|
for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++)
|
|
n += sprintf(buf+n, "%s %lu\n",
|
|
vmstat_text[i + NR_VM_ZONE_STAT_ITEMS],
|
|
node_page_state(pgdat, i));
|
|
|
|
return n;
|
|
}
|
|
static DEVICE_ATTR(vmstat, S_IRUGO, node_read_vmstat, NULL);
|
|
|
|
static ssize_t node_read_distance(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
int nid = dev->id;
|
|
int len = 0;
|
|
int i;
|
|
|
|
/*
|
|
* buf is currently PAGE_SIZE in length and each node needs 4 chars
|
|
* at the most (distance + space or newline).
|
|
*/
|
|
BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE);
|
|
|
|
for_each_online_node(i)
|
|
len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));
|
|
|
|
len += sprintf(buf + len, "\n");
|
|
return len;
|
|
}
|
|
static DEVICE_ATTR(distance, S_IRUGO, node_read_distance, NULL);
|
|
|
|
static struct attribute *node_dev_attrs[] = {
|
|
&dev_attr_cpumap.attr,
|
|
&dev_attr_cpulist.attr,
|
|
&dev_attr_meminfo.attr,
|
|
&dev_attr_numastat.attr,
|
|
&dev_attr_distance.attr,
|
|
&dev_attr_vmstat.attr,
|
|
NULL
|
|
};
|
|
ATTRIBUTE_GROUPS(node_dev);
|
|
|
|
#ifdef CONFIG_HUGETLBFS
|
|
/*
|
|
* hugetlbfs per node attributes registration interface:
|
|
* When/if hugetlb[fs] subsystem initializes [sometime after this module],
|
|
* it will register its per node attributes for all online nodes with
|
|
* memory. It will also call register_hugetlbfs_with_node(), below, to
|
|
* register its attribute registration functions with this node driver.
|
|
* Once these hooks have been initialized, the node driver will call into
|
|
* the hugetlb module to [un]register attributes for hot-plugged nodes.
|
|
*/
|
|
static node_registration_func_t __hugetlb_register_node;
|
|
static node_registration_func_t __hugetlb_unregister_node;
|
|
|
|
static inline bool hugetlb_register_node(struct node *node)
|
|
{
|
|
if (__hugetlb_register_node &&
|
|
node_state(node->dev.id, N_MEMORY)) {
|
|
__hugetlb_register_node(node);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
static inline void hugetlb_unregister_node(struct node *node)
|
|
{
|
|
if (__hugetlb_unregister_node)
|
|
__hugetlb_unregister_node(node);
|
|
}
|
|
|
|
void register_hugetlbfs_with_node(node_registration_func_t doregister,
|
|
node_registration_func_t unregister)
|
|
{
|
|
__hugetlb_register_node = doregister;
|
|
__hugetlb_unregister_node = unregister;
|
|
}
|
|
#else
|
|
static inline void hugetlb_register_node(struct node *node) {}
|
|
|
|
static inline void hugetlb_unregister_node(struct node *node) {}
|
|
#endif
|
|
|
|
static void node_device_release(struct device *dev)
|
|
{
|
|
struct node *node = to_node(dev);
|
|
|
|
#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
|
|
/*
|
|
* We schedule the work only when a memory section is
|
|
* onlined/offlined on this node. When we come here,
|
|
* all the memory on this node has been offlined,
|
|
* so we won't enqueue new work to this work.
|
|
*
|
|
* The work is using node->node_work, so we should
|
|
* flush work before freeing the memory.
|
|
*/
|
|
flush_work(&node->node_work);
|
|
#endif
|
|
kfree(node);
|
|
}
|
|
|
|
/*
|
|
* register_node - Setup a sysfs device for a node.
|
|
* @num - Node number to use when creating the device.
|
|
*
|
|
* Initialize and register the node device.
|
|
*/
|
|
static int register_node(struct node *node, int num, struct node *parent)
|
|
{
|
|
int error;
|
|
|
|
node->dev.id = num;
|
|
node->dev.bus = &node_subsys;
|
|
node->dev.release = node_device_release;
|
|
node->dev.groups = node_dev_groups;
|
|
error = device_register(&node->dev);
|
|
|
|
if (!error){
|
|
hugetlb_register_node(node);
|
|
|
|
compaction_register_node(node);
|
|
}
|
|
return error;
|
|
}
|
|
|
|
/**
|
|
* unregister_node - unregister a node device
|
|
* @node: node going away
|
|
*
|
|
* Unregisters a node device @node. All the devices on the node must be
|
|
* unregistered before calling this function.
|
|
*/
|
|
void unregister_node(struct node *node)
|
|
{
|
|
compaction_unregister_node(node);
|
|
hugetlb_unregister_node(node); /* no-op, if memoryless node */
|
|
|
|
device_unregister(&node->dev);
|
|
}
|
|
|
|
struct node *node_devices[MAX_NUMNODES];
|
|
|
|
/*
|
|
* register cpu under node
|
|
*/
|
|
int register_cpu_under_node(unsigned int cpu, unsigned int nid)
|
|
{
|
|
int ret;
|
|
struct device *obj;
|
|
|
|
if (!node_online(nid))
|
|
return 0;
|
|
|
|
obj = get_cpu_device(cpu);
|
|
if (!obj)
|
|
return 0;
|
|
|
|
ret = sysfs_create_link(&node_devices[nid]->dev.kobj,
|
|
&obj->kobj,
|
|
kobject_name(&obj->kobj));
|
|
if (ret)
|
|
return ret;
|
|
|
|
return sysfs_create_link(&obj->kobj,
|
|
&node_devices[nid]->dev.kobj,
|
|
kobject_name(&node_devices[nid]->dev.kobj));
|
|
}
|
|
|
|
int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
|
|
{
|
|
struct device *obj;
|
|
|
|
if (!node_online(nid))
|
|
return 0;
|
|
|
|
obj = get_cpu_device(cpu);
|
|
if (!obj)
|
|
return 0;
|
|
|
|
sysfs_remove_link(&node_devices[nid]->dev.kobj,
|
|
kobject_name(&obj->kobj));
|
|
sysfs_remove_link(&obj->kobj,
|
|
kobject_name(&node_devices[nid]->dev.kobj));
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
|
|
#define page_initialized(page) (page->lru.next)
|
|
|
|
static int __ref get_nid_for_pfn(unsigned long pfn)
|
|
{
|
|
struct page *page;
|
|
|
|
if (!pfn_valid_within(pfn))
|
|
return -1;
|
|
#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
|
|
if (system_state == SYSTEM_BOOTING)
|
|
return early_pfn_to_nid(pfn);
|
|
#endif
|
|
page = pfn_to_page(pfn);
|
|
if (!page_initialized(page))
|
|
return -1;
|
|
return pfn_to_nid(pfn);
|
|
}
|
|
|
|
/* register memory section under specified node if it spans that node */
|
|
int register_mem_sect_under_node(struct memory_block *mem_blk, int nid)
|
|
{
|
|
int ret;
|
|
unsigned long pfn, sect_start_pfn, sect_end_pfn;
|
|
|
|
if (!mem_blk)
|
|
return -EFAULT;
|
|
if (!node_online(nid))
|
|
return 0;
|
|
|
|
sect_start_pfn = section_nr_to_pfn(mem_blk->start_section_nr);
|
|
sect_end_pfn = section_nr_to_pfn(mem_blk->end_section_nr);
|
|
sect_end_pfn += PAGES_PER_SECTION - 1;
|
|
for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) {
|
|
int page_nid;
|
|
|
|
/*
|
|
* memory block could have several absent sections from start.
|
|
* skip pfn range from absent section
|
|
*/
|
|
if (!pfn_present(pfn)) {
|
|
pfn = round_down(pfn + PAGES_PER_SECTION,
|
|
PAGES_PER_SECTION) - 1;
|
|
continue;
|
|
}
|
|
|
|
page_nid = get_nid_for_pfn(pfn);
|
|
if (page_nid < 0)
|
|
continue;
|
|
if (page_nid != nid)
|
|
continue;
|
|
ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj,
|
|
&mem_blk->dev.kobj,
|
|
kobject_name(&mem_blk->dev.kobj));
|
|
if (ret)
|
|
return ret;
|
|
|
|
return sysfs_create_link_nowarn(&mem_blk->dev.kobj,
|
|
&node_devices[nid]->dev.kobj,
|
|
kobject_name(&node_devices[nid]->dev.kobj));
|
|
}
|
|
/* mem section does not span the specified node */
|
|
return 0;
|
|
}
|
|
|
|
/* unregister memory section under all nodes that it spans */
|
|
int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
|
|
unsigned long phys_index)
|
|
{
|
|
NODEMASK_ALLOC(nodemask_t, unlinked_nodes, GFP_KERNEL);
|
|
unsigned long pfn, sect_start_pfn, sect_end_pfn;
|
|
|
|
if (!mem_blk) {
|
|
NODEMASK_FREE(unlinked_nodes);
|
|
return -EFAULT;
|
|
}
|
|
if (!unlinked_nodes)
|
|
return -ENOMEM;
|
|
nodes_clear(*unlinked_nodes);
|
|
|
|
sect_start_pfn = section_nr_to_pfn(phys_index);
|
|
sect_end_pfn = sect_start_pfn + PAGES_PER_SECTION - 1;
|
|
for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) {
|
|
int nid;
|
|
|
|
nid = get_nid_for_pfn(pfn);
|
|
if (nid < 0)
|
|
continue;
|
|
if (!node_online(nid))
|
|
continue;
|
|
if (node_test_and_set(nid, *unlinked_nodes))
|
|
continue;
|
|
sysfs_remove_link(&node_devices[nid]->dev.kobj,
|
|
kobject_name(&mem_blk->dev.kobj));
|
|
sysfs_remove_link(&mem_blk->dev.kobj,
|
|
kobject_name(&node_devices[nid]->dev.kobj));
|
|
}
|
|
NODEMASK_FREE(unlinked_nodes);
|
|
return 0;
|
|
}
|
|
|
|
static int link_mem_sections(int nid)
|
|
{
|
|
unsigned long start_pfn = NODE_DATA(nid)->node_start_pfn;
|
|
unsigned long end_pfn = start_pfn + NODE_DATA(nid)->node_spanned_pages;
|
|
unsigned long pfn;
|
|
struct memory_block *mem_blk = NULL;
|
|
int err = 0;
|
|
|
|
for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
|
|
unsigned long section_nr = pfn_to_section_nr(pfn);
|
|
struct mem_section *mem_sect;
|
|
int ret;
|
|
|
|
if (!present_section_nr(section_nr))
|
|
continue;
|
|
mem_sect = __nr_to_section(section_nr);
|
|
|
|
/* same memblock ? */
|
|
if (mem_blk)
|
|
if ((section_nr >= mem_blk->start_section_nr) &&
|
|
(section_nr <= mem_blk->end_section_nr))
|
|
continue;
|
|
|
|
mem_blk = find_memory_block_hinted(mem_sect, mem_blk);
|
|
|
|
ret = register_mem_sect_under_node(mem_blk, nid);
|
|
if (!err)
|
|
err = ret;
|
|
|
|
/* discard ref obtained in find_memory_block() */
|
|
}
|
|
|
|
if (mem_blk)
|
|
kobject_put(&mem_blk->dev.kobj);
|
|
return err;
|
|
}
|
|
|
|
#ifdef CONFIG_HUGETLBFS
|
|
/*
|
|
* Handle per node hstate attribute [un]registration on transistions
|
|
* to/from memoryless state.
|
|
*/
|
|
static void node_hugetlb_work(struct work_struct *work)
|
|
{
|
|
struct node *node = container_of(work, struct node, node_work);
|
|
|
|
/*
|
|
* We only get here when a node transitions to/from memoryless state.
|
|
* We can detect which transition occurred by examining whether the
|
|
* node has memory now. hugetlb_register_node() already check this
|
|
* so we try to register the attributes. If that fails, then the
|
|
* node has transitioned to memoryless, try to unregister the
|
|
* attributes.
|
|
*/
|
|
if (!hugetlb_register_node(node))
|
|
hugetlb_unregister_node(node);
|
|
}
|
|
|
|
static void init_node_hugetlb_work(int nid)
|
|
{
|
|
INIT_WORK(&node_devices[nid]->node_work, node_hugetlb_work);
|
|
}
|
|
|
|
static int node_memory_callback(struct notifier_block *self,
|
|
unsigned long action, void *arg)
|
|
{
|
|
struct memory_notify *mnb = arg;
|
|
int nid = mnb->status_change_nid;
|
|
|
|
switch (action) {
|
|
case MEM_ONLINE:
|
|
case MEM_OFFLINE:
|
|
/*
|
|
* offload per node hstate [un]registration to a work thread
|
|
* when transitioning to/from memoryless state.
|
|
*/
|
|
if (nid != NUMA_NO_NODE)
|
|
schedule_work(&node_devices[nid]->node_work);
|
|
break;
|
|
|
|
case MEM_GOING_ONLINE:
|
|
case MEM_GOING_OFFLINE:
|
|
case MEM_CANCEL_ONLINE:
|
|
case MEM_CANCEL_OFFLINE:
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return NOTIFY_OK;
|
|
}
|
|
#endif /* CONFIG_HUGETLBFS */
|
|
#else /* !CONFIG_MEMORY_HOTPLUG_SPARSE */
|
|
|
|
static int link_mem_sections(int nid) { return 0; }
|
|
#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
|
|
|
|
#if !defined(CONFIG_MEMORY_HOTPLUG_SPARSE) || \
|
|
!defined(CONFIG_HUGETLBFS)
|
|
static inline int node_memory_callback(struct notifier_block *self,
|
|
unsigned long action, void *arg)
|
|
{
|
|
return NOTIFY_OK;
|
|
}
|
|
|
|
static void init_node_hugetlb_work(int nid) { }
|
|
|
|
#endif
|
|
|
|
int register_one_node(int nid)
|
|
{
|
|
int error = 0;
|
|
int cpu;
|
|
|
|
if (node_online(nid)) {
|
|
int p_node = parent_node(nid);
|
|
struct node *parent = NULL;
|
|
|
|
if (p_node != nid)
|
|
parent = node_devices[p_node];
|
|
|
|
node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL);
|
|
if (!node_devices[nid])
|
|
return -ENOMEM;
|
|
|
|
error = register_node(node_devices[nid], nid, parent);
|
|
|
|
/* link cpu under this node */
|
|
for_each_present_cpu(cpu) {
|
|
if (cpu_to_node(cpu) == nid)
|
|
register_cpu_under_node(cpu, nid);
|
|
}
|
|
|
|
/* link memory sections under this node */
|
|
error = link_mem_sections(nid);
|
|
|
|
/* initialize work queue for memory hot plug */
|
|
init_node_hugetlb_work(nid);
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
void unregister_one_node(int nid)
|
|
{
|
|
if (!node_devices[nid])
|
|
return;
|
|
|
|
unregister_node(node_devices[nid]);
|
|
node_devices[nid] = NULL;
|
|
}
|
|
|
|
/*
|
|
* node states attributes
|
|
*/
|
|
|
|
static ssize_t print_nodes_state(enum node_states state, char *buf)
|
|
{
|
|
int n;
|
|
|
|
n = scnprintf(buf, PAGE_SIZE - 1, "%*pbl",
|
|
nodemask_pr_args(&node_states[state]));
|
|
buf[n++] = '\n';
|
|
buf[n] = '\0';
|
|
return n;
|
|
}
|
|
|
|
struct node_attr {
|
|
struct device_attribute attr;
|
|
enum node_states state;
|
|
};
|
|
|
|
static ssize_t show_node_state(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
struct node_attr *na = container_of(attr, struct node_attr, attr);
|
|
return print_nodes_state(na->state, buf);
|
|
}
|
|
|
|
#define _NODE_ATTR(name, state) \
|
|
{ __ATTR(name, 0444, show_node_state, NULL), state }
|
|
|
|
static struct node_attr node_state_attr[] = {
|
|
[N_POSSIBLE] = _NODE_ATTR(possible, N_POSSIBLE),
|
|
[N_ONLINE] = _NODE_ATTR(online, N_ONLINE),
|
|
[N_NORMAL_MEMORY] = _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
|
|
#ifdef CONFIG_HIGHMEM
|
|
[N_HIGH_MEMORY] = _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
|
|
#endif
|
|
#ifdef CONFIG_MOVABLE_NODE
|
|
[N_MEMORY] = _NODE_ATTR(has_memory, N_MEMORY),
|
|
#endif
|
|
[N_CPU] = _NODE_ATTR(has_cpu, N_CPU),
|
|
};
|
|
|
|
static struct attribute *node_state_attrs[] = {
|
|
&node_state_attr[N_POSSIBLE].attr.attr,
|
|
&node_state_attr[N_ONLINE].attr.attr,
|
|
&node_state_attr[N_NORMAL_MEMORY].attr.attr,
|
|
#ifdef CONFIG_HIGHMEM
|
|
&node_state_attr[N_HIGH_MEMORY].attr.attr,
|
|
#endif
|
|
#ifdef CONFIG_MOVABLE_NODE
|
|
&node_state_attr[N_MEMORY].attr.attr,
|
|
#endif
|
|
&node_state_attr[N_CPU].attr.attr,
|
|
NULL
|
|
};
|
|
|
|
static struct attribute_group memory_root_attr_group = {
|
|
.attrs = node_state_attrs,
|
|
};
|
|
|
|
static const struct attribute_group *cpu_root_attr_groups[] = {
|
|
&memory_root_attr_group,
|
|
NULL,
|
|
};
|
|
|
|
#define NODE_CALLBACK_PRI 2 /* lower than SLAB */
|
|
static int __init register_node_type(void)
|
|
{
|
|
int ret;
|
|
|
|
BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES);
|
|
BUILD_BUG_ON(ARRAY_SIZE(node_state_attrs)-1 != NR_NODE_STATES);
|
|
|
|
ret = subsys_system_register(&node_subsys, cpu_root_attr_groups);
|
|
if (!ret) {
|
|
static struct notifier_block node_memory_callback_nb = {
|
|
.notifier_call = node_memory_callback,
|
|
.priority = NODE_CALLBACK_PRI,
|
|
};
|
|
register_hotmemory_notifier(&node_memory_callback_nb);
|
|
}
|
|
|
|
/*
|
|
* Note: we're not going to unregister the node class if we fail
|
|
* to register the node state class attribute files.
|
|
*/
|
|
return ret;
|
|
}
|
|
postcore_initcall(register_node_type);
|