Changes in 5.15.47
pcmcia: db1xxx_ss: restrict to MIPS_DB1XXX boards
staging: greybus: codecs: fix type confusion of list iterator variable
iio: adc: ad7124: Remove shift from scan_type
lkdtm/bugs: Check for the NULL pointer after calling kmalloc
lkdtm/bugs: Don't expect thread termination without CONFIG_UBSAN_TRAP
tty: goldfish: Use tty_port_destroy() to destroy port
tty: serial: owl: Fix missing clk_disable_unprepare() in owl_uart_probe
tty: n_tty: Restore EOF push handling behavior
serial: 8250_aspeed_vuart: Fix potential NULL dereference in aspeed_vuart_probe
tty: serial: fsl_lpuart: fix potential bug when using both of_alias_get_id and ida_simple_get
remoteproc: imx_rproc: Ignore create mem entry for resource table
usb: usbip: fix a refcount leak in stub_probe()
usb: usbip: add missing device lock on tweak configuration cmd
USB: storage: karma: fix rio_karma_init return
usb: musb: Fix missing of_node_put() in omap2430_probe
staging: fieldbus: Fix the error handling path in anybuss_host_common_probe()
pwm: lp3943: Fix duty calculation in case period was clamped
pwm: raspberrypi-poe: Fix endianness in firmware struct
rpmsg: qcom_smd: Fix irq_of_parse_and_map() return value
usb: dwc3: gadget: Replace list_for_each_entry_safe() if using giveback
usb: dwc3: pci: Fix pm_runtime_get_sync() error checking
misc: fastrpc: fix an incorrect NULL check on list iterator
firmware: stratix10-svc: fix a missing check on list iterator
usb: typec: mux: Check dev_set_name() return value
rpmsg: virtio: Fix possible double free in rpmsg_probe()
rpmsg: virtio: Fix possible double free in rpmsg_virtio_add_ctrl_dev()
rpmsg: virtio: Fix the unregistration of the device rpmsg_ctrl
iio: adc: stmpe-adc: Fix wait_for_completion_timeout return value check
iio: proximity: vl53l0x: Fix return value check of wait_for_completion_timeout
iio: adc: sc27xx: fix read big scale voltage not right
iio: adc: sc27xx: Fine tune the scale calibration values
rpmsg: qcom_smd: Fix returning 0 if irq_of_parse_and_map() fails
pvpanic: Fix typos in the comments
misc/pvpanic: Convert regular spinlock into trylock on panic path
phy: qcom-qmp: fix pipe-clock imbalance on power-on failure
power: supply: axp288_fuel_gauge: Drop BIOS version check from "T3 MRD" DMI quirk
serial: sifive: Report actual baud base rather than fixed 115200
export: fix string handling of namespace in EXPORT_SYMBOL_NS
soundwire: intel: prevent pm_runtime resume prior to system suspend
coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier
ksmbd: fix reference count leak in smb_check_perm_dacl()
extcon: ptn5150: Add queue work sync before driver release
soc: rockchip: Fix refcount leak in rockchip_grf_init
clocksource/drivers/riscv: Events are stopped during CPU suspend
ARM: dts: aspeed: ast2600-evb: Enable RX delay for MAC0/MAC1
rtc: mt6397: check return value after calling platform_get_resource()
rtc: ftrtc010: Use platform_get_irq() to get the interrupt
rtc: ftrtc010: Fix error handling in ftrtc010_rtc_probe
staging: r8188eu: add check for kzalloc
tty: n_gsm: Don't ignore write return value in gsmld_output()
tty: n_gsm: Fix packet data hex dump output
serial: meson: acquire port->lock in startup()
serial: 8250_fintek: Check SER_RS485_RTS_* only with RS485
serial: cpm_uart: Fix build error without CONFIG_SERIAL_CPM_CONSOLE
serial: digicolor-usart: Don't allow CS5-6
serial: rda-uart: Don't allow CS5-6
serial: txx9: Don't allow CS5-6
serial: sh-sci: Don't allow CS5-6
serial: sifive: Sanitize CSIZE and c_iflag
serial: st-asc: Sanitize CSIZE and correct PARENB for CS7
serial: stm32-usart: Correct CSIZE, bits, and parity
firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle
bus: ti-sysc: Fix warnings for unbind for serial
driver: base: fix UAF when driver_attach failed
driver core: fix deadlock in __device_attach
watchdog: rti-wdt: Fix pm_runtime_get_sync() error checking
watchdog: ts4800_wdt: Fix refcount leak in ts4800_wdt_probe
blk-mq: don't touch ->tagset in blk_mq_get_sq_hctx
ASoC: fsl_sai: Fix FSL_SAI_xDR/xFR definition
clocksource/drivers/oxnas-rps: Fix irq_of_parse_and_map() return value
s390/crypto: fix scatterwalk_unmap() callers in AES-GCM
net: sched: fixed barrier to prevent skbuff sticking in qdisc backlog
net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_entry()
net: ethernet: ti: am65-cpsw-nuss: Fix some refcount leaks
net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register
modpost: fix removing numeric suffixes
jffs2: fix memory leak in jffs2_do_fill_super
ubi: fastmap: Fix high cpu usage of ubi_bgt by making sure wl_pool not empty
ubi: ubi_create_volume: Fix use-after-free when volume creation failed
selftests/bpf: fix selftest after random: Urandom_read tracepoint removal
selftests/bpf: fix stacktrace_build_id with missing kprobe/urandom_read
bpf: Fix probe read error in ___bpf_prog_run()
block: take destination bvec offsets into account in bio_copy_data_iter
riscv: read-only pages should not be writable
net/smc: fixes for converting from "struct smc_cdc_tx_pend **" to "struct smc_wr_tx_pend_priv *"
tcp: add accessors to read/set tp->snd_cwnd
nfp: only report pause frame configuration for physical device
sfc: fix considering that all channels have TX queues
sfc: fix wrong tx channel offset with efx_separate_tx_channels
block: make bioset_exit() fully resilient against being called twice
vdpa: Fix error logic in vdpa_nl_cmd_dev_get_doit
virtio: pci: Fix an error handling path in vp_modern_probe()
net/mlx5: Don't use already freed action pointer
net/mlx5e: TC NIC mode, fix tc chains miss table
net/mlx5: CT: Fix header-rewrite re-use for tupels
net/mlx5: correct ECE offset in query qp output
net/mlx5e: Update netdev features after changing XDP state
net: sched: add barrier to fix packet stuck problem for lockless qdisc
tcp: tcp_rtx_synack() can be called from process context
vdpa: ifcvf: set pci driver data in probe
octeontx2-af: fix error code in is_valid_offset()
s390/mcck: isolate SIE instruction when setting CIF_MCCK_GUEST flag
regulator: mt6315-regulator: fix invalid allowed mode
gpio: pca953x: use the correct register address to do regcache sync
afs: Fix infinite loop found by xfstest generic/676
scsi: sd: Fix potential NULL pointer dereference
tipc: check attribute length for bearer name
driver core: Fix wait_for_device_probe() & deferred_probe_timeout interaction
perf c2c: Fix sorting in percent_rmt_hitm_cmp()
dmaengine: idxd: set DMA_INTERRUPT cap bit
mips: cpc: Fix refcount leak in mips_cpc_default_phys_base
bootconfig: Make the bootconfig.o as a normal object file
tracing: Make tp_printk work on syscall tracepoints
tracing: Fix sleeping function called from invalid context on RT kernel
tracing: Avoid adding tracer option before update_tracer_options
iommu/arm-smmu: fix possible null-ptr-deref in arm_smmu_device_probe()
iommu/arm-smmu-v3: check return value after calling platform_get_resource()
f2fs: remove WARN_ON in f2fs_is_valid_blkaddr
i2c: cadence: Increase timeout per message if necessary
m68knommu: set ZERO_PAGE() to the allocated zeroed page
m68knommu: fix undefined reference to `_init_sp'
dmaengine: zynqmp_dma: In struct zynqmp_dma_chan fix desc_size data type
NFSv4: Don't hold the layoutget locks across multiple RPC calls
video: fbdev: hyperv_fb: Allow resolutions with size > 64 MB for Gen1
video: fbdev: pxa3xx-gcu: release the resources correctly in pxa3xx_gcu_probe/remove()
RISC-V: use memcpy for kexec_file mode
m68knommu: fix undefined reference to `mach_get_rtc_pll'
f2fs: fix to tag gcing flag on page during file defragment
xprtrdma: treat all calls not a bcall when bc_serv is NULL
drm/bridge: sn65dsi83: Fix an error handling path in sn65dsi83_probe()
drm/bridge: ti-sn65dsi83: Handle dsi_lanes == 0 as invalid
netfilter: nat: really support inet nat without l3 address
netfilter: nf_tables: use kfree_rcu(ptr, rcu) to release hooks in clean_net path
netfilter: nf_tables: delete flowtable hooks via transaction list
powerpc/kasan: Force thread size increase with KASAN
SUNRPC: Trap RDMA segment overflows
netfilter: nf_tables: always initialize flowtable hook list in transaction
ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe
netfilter: nf_tables: release new hooks on unsupported flowtable flags
netfilter: nf_tables: memleak flow rule from commit path
netfilter: nf_tables: bail out early if hardware offload is not supported
xen: unexport __init-annotated xen_xlate_map_ballooned_pages()
stmmac: intel: Fix an error handling path in intel_eth_pci_probe()
af_unix: Fix a data-race in unix_dgram_peer_wake_me().
bpf, arm64: Clear prog->jited_len along prog->jited
net: dsa: lantiq_gswip: Fix refcount leak in gswip_gphy_fw_list
net/mlx4_en: Fix wrong return value on ioctl EEPROM query failure
i40e: xsk: Move tmp desc array from driver to pool
xsk: Fix handling of invalid descriptors in XSK TX batching API
SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()
net: mdio: unexport __init-annotated mdio_bus_init()
net: xfrm: unexport __init-annotated xfrm4_protocol_init()
net: ipv6: unexport __init-annotated seg6_hmac_init()
net/mlx5: Lag, filter non compatible devices
net/mlx5: Fix mlx5_get_next_dev() peer device matching
net/mlx5: Rearm the FW tracer after each tracer event
net/mlx5: fs, fail conflicting actions
ip_gre: test csum_start instead of transport header
net: altera: Fix refcount leak in altera_tse_mdio_create
net: dsa: mv88e6xxx: use BMSR_ANEGCOMPLETE bit for filling an_complete
tcp: use alloc_large_system_hash() to allocate table_perturb
drm: imx: fix compiler warning with gcc-12
nfp: flower: restructure flow-key for gre+vlan combination
iov_iter: Fix iter_xarray_get_pages{,_alloc}()
iio: dummy: iio_simple_dummy: check the return value of kstrdup()
staging: rtl8712: fix a potential memory leak in r871xu_drv_init()
iio: st_sensors: Add a local lock for protecting odr
lkdtm/usercopy: Expand size of "out of frame" object
drivers: staging: rtl8723bs: Fix deadlock in rtw_surveydone_event_callback()
drivers: staging: rtl8192bs: Fix deadlock in rtw_joinbss_event_prehandle()
tty: synclink_gt: Fix null-pointer-dereference in slgt_clean()
tty: Fix a possible resource leak in icom_probe
thunderbolt: Use different lane for second DisplayPort tunnel
drivers: staging: rtl8192u: Fix deadlock in ieee80211_beacons_stop()
drivers: staging: rtl8192e: Fix deadlock in rtllib_beacons_stop()
USB: host: isp116x: check return value after calling platform_get_resource()
drivers: tty: serial: Fix deadlock in sa1100_set_termios()
drivers: usb: host: Fix deadlock in oxu_bus_suspend()
USB: hcd-pci: Fully suspend across freeze/thaw cycle
char: xillybus: fix a refcount leak in cleanup_dev()
sysrq: do not omit current cpu when showing backtrace of all active CPUs
usb: dwc2: gadget: don't reset gadget's driver->bus
soundwire: qcom: adjust autoenumeration timeout
misc: rtsx: set NULL intfdata when probe fails
extcon: Fix extcon_get_extcon_dev() error handling
extcon: Modify extcon device to be created after driver data is set
clocksource/drivers/sp804: Avoid error on multiple instances
staging: rtl8712: fix uninit-value in usb_read8() and friends
staging: rtl8712: fix uninit-value in r871xu_drv_init()
serial: msm_serial: disable interrupts in __msm_console_write()
kernfs: Separate kernfs_pr_cont_buf and rename_lock.
watchdog: wdat_wdt: Stop watchdog when rebooting the system
md: protect md_unregister_thread from reentrancy
scsi: myrb: Fix up null pointer access on myrb_cleanup()
Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process"
ceph: allow ceph.dir.rctime xattr to be updatable
ceph: flush the mdlog for filesystem sync
drm/amd/display: Check if modulo is 0 before dividing.
drm/radeon: fix a possible null pointer dereference
drm/amd/pm: Fix missing thermal throttler status
um: line: Use separate IRQs per line
modpost: fix undefined behavior of is_arm_mapping_symbol()
x86/cpu: Elide KCSAN for cpu_has() and friends
jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds
nbd: call genl_unregister_family() first in nbd_cleanup()
nbd: fix race between nbd_alloc_config() and module removal
nbd: fix io hung while disconnecting device
s390/gmap: voluntarily schedule during key setting
cifs: version operations for smb20 unneeded when legacy support disabled
drm/amd/pm: use bitmap_{from,to}_arr32 where appropriate
nodemask: Fix return values to be unsigned
vringh: Fix loop descriptors check in the indirect cases
scripts/gdb: change kernel config dumping method
ALSA: usb-audio: Skip generic sync EP parse for secondary EP
ALSA: usb-audio: Set up (implicit) sync for Saffire 6
ALSA: hda/conexant - Fix loopback issue with CX20632
ALSA: hda/realtek: Fix for quirk to enable speaker output on the Lenovo Yoga DuetITL 2021
ALSA: hda/realtek: Add quirk for HP Dev One
cifs: return errors during session setup during reconnects
cifs: fix reconnect on smb3 mount types
KEYS: trusted: tpm2: Fix migratable logic
ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
mmc: block: Fix CQE recovery reset success
net: phy: dp83867: retrigger SGMII AN when link change
net: openvswitch: fix misuse of the cached connection on tuple changes
writeback: Fix inode->i_io_list not be protected by inode->i_lock error
nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION
nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling
nfc: st21nfca: fix incorrect sizing calculations in EVT_TRANSACTION
ixgbe: fix bcast packets Rx on VF after promisc removal
ixgbe: fix unexpected VLAN Rx in promisc mode on VF
Input: bcm5974 - set missing URB_NO_TRANSFER_DMA_MAP urb flag
vduse: Fix NULL pointer dereference on sysfs access
powerpc: Don't select HAVE_IRQ_EXIT_ON_IRQ_STACK
drm/bridge: analogix_dp: Support PSR-exit to disable transition
drm/atomic: Force bridge self-refresh-exit on CRTC switch
drm/amdgpu: update VCN codec support for Yellow Carp
powerpc/32: Fix overread/overwrite of thread_struct via ptrace
powerpc/mm: Switch obsolete dssall to .long
drm/ast: Create threshold values for AST2600
random: avoid checking crng_ready() twice in random_init()
random: mark bootloader randomness code as __init
random: account for arch randomness in bits
md/raid0: Ignore RAID0 layout if the second zone has only one device
net/sched: act_police: more accurate MTU policing
PCI: qcom: Fix pipe clock imbalance
zonefs: fix handling of explicit_open option on mount
iov_iter: fix build issue due to possible type mis-match
dmaengine: idxd: add missing callback function to support DMA_INTERRUPT
tcp: fix tcp_mtup_probe_success vs wrong snd_cwnd
xsk: Fix possible crash when multiple sockets are created
Linux 5.15.47
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I40e7672edf2bd713fee775919d062e2934d9103d
544 lines
17 KiB
C
544 lines
17 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LINUX_NODEMASK_H
|
|
#define __LINUX_NODEMASK_H
|
|
|
|
/*
|
|
* Nodemasks provide a bitmap suitable for representing the
|
|
* set of Node's in a system, one bit position per Node number.
|
|
*
|
|
* See detailed comments in the file linux/bitmap.h describing the
|
|
* data type on which these nodemasks are based.
|
|
*
|
|
* For details of nodemask_parse_user(), see bitmap_parse_user() in
|
|
* lib/bitmap.c. For details of nodelist_parse(), see bitmap_parselist(),
|
|
* also in bitmap.c. For details of node_remap(), see bitmap_bitremap in
|
|
* lib/bitmap.c. For details of nodes_remap(), see bitmap_remap in
|
|
* lib/bitmap.c. For details of nodes_onto(), see bitmap_onto in
|
|
* lib/bitmap.c. For details of nodes_fold(), see bitmap_fold in
|
|
* lib/bitmap.c.
|
|
*
|
|
* The available nodemask operations are:
|
|
*
|
|
* void node_set(node, mask) turn on bit 'node' in mask
|
|
* void node_clear(node, mask) turn off bit 'node' in mask
|
|
* void nodes_setall(mask) set all bits
|
|
* void nodes_clear(mask) clear all bits
|
|
* int node_isset(node, mask) true iff bit 'node' set in mask
|
|
* int node_test_and_set(node, mask) test and set bit 'node' in mask
|
|
*
|
|
* void nodes_and(dst, src1, src2) dst = src1 & src2 [intersection]
|
|
* void nodes_or(dst, src1, src2) dst = src1 | src2 [union]
|
|
* void nodes_xor(dst, src1, src2) dst = src1 ^ src2
|
|
* void nodes_andnot(dst, src1, src2) dst = src1 & ~src2
|
|
* void nodes_complement(dst, src) dst = ~src
|
|
*
|
|
* int nodes_equal(mask1, mask2) Does mask1 == mask2?
|
|
* int nodes_intersects(mask1, mask2) Do mask1 and mask2 intersect?
|
|
* int nodes_subset(mask1, mask2) Is mask1 a subset of mask2?
|
|
* int nodes_empty(mask) Is mask empty (no bits sets)?
|
|
* int nodes_full(mask) Is mask full (all bits sets)?
|
|
* int nodes_weight(mask) Hamming weight - number of set bits
|
|
*
|
|
* void nodes_shift_right(dst, src, n) Shift right
|
|
* void nodes_shift_left(dst, src, n) Shift left
|
|
*
|
|
* unsigned int first_node(mask) Number lowest set bit, or MAX_NUMNODES
|
|
* unsigend int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
|
|
* unsigned int next_node_in(node, mask) Next node past 'node', or wrap to first,
|
|
* or MAX_NUMNODES
|
|
* unsigned int first_unset_node(mask) First node not set in mask, or
|
|
* MAX_NUMNODES
|
|
*
|
|
* nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set
|
|
* NODE_MASK_ALL Initializer - all bits set
|
|
* NODE_MASK_NONE Initializer - no bits set
|
|
* unsigned long *nodes_addr(mask) Array of unsigned long's in mask
|
|
*
|
|
* int nodemask_parse_user(ubuf, ulen, mask) Parse ascii string as nodemask
|
|
* int nodelist_parse(buf, map) Parse ascii string as nodelist
|
|
* int node_remap(oldbit, old, new) newbit = map(old, new)(oldbit)
|
|
* void nodes_remap(dst, src, old, new) *dst = map(old, new)(src)
|
|
* void nodes_onto(dst, orig, relmap) *dst = orig relative to relmap
|
|
* void nodes_fold(dst, orig, sz) dst bits = orig bits mod sz
|
|
*
|
|
* for_each_node_mask(node, mask) for-loop node over mask
|
|
*
|
|
* int num_online_nodes() Number of online Nodes
|
|
* int num_possible_nodes() Number of all possible Nodes
|
|
*
|
|
* int node_random(mask) Random node with set bit in mask
|
|
*
|
|
* int node_online(node) Is some node online?
|
|
* int node_possible(node) Is some node possible?
|
|
*
|
|
* node_set_online(node) set bit 'node' in node_online_map
|
|
* node_set_offline(node) clear bit 'node' in node_online_map
|
|
*
|
|
* for_each_node(node) for-loop node over node_possible_map
|
|
* for_each_online_node(node) for-loop node over node_online_map
|
|
*
|
|
* Subtlety:
|
|
* 1) The 'type-checked' form of node_isset() causes gcc (3.3.2, anyway)
|
|
* to generate slightly worse code. So use a simple one-line #define
|
|
* for node_isset(), instead of wrapping an inline inside a macro, the
|
|
* way we do the other calls.
|
|
*
|
|
* NODEMASK_SCRATCH
|
|
* When doing above logical AND, OR, XOR, Remap operations the callers tend to
|
|
* need temporary nodemask_t's on the stack. But if NODES_SHIFT is large,
|
|
* nodemask_t's consume too much stack space. NODEMASK_SCRATCH is a helper
|
|
* for such situations. See below and CPUMASK_ALLOC also.
|
|
*/
|
|
|
|
#include <linux/threads.h>
|
|
#include <linux/bitmap.h>
|
|
#include <linux/minmax.h>
|
|
#include <linux/numa.h>
|
|
|
|
typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
|
|
extern nodemask_t _unused_nodemask_arg_;
|
|
|
|
/**
|
|
* nodemask_pr_args - printf args to output a nodemask
|
|
* @maskp: nodemask to be printed
|
|
*
|
|
* Can be used to provide arguments for '%*pb[l]' when printing a nodemask.
|
|
*/
|
|
#define nodemask_pr_args(maskp) __nodemask_pr_numnodes(maskp), \
|
|
__nodemask_pr_bits(maskp)
|
|
static inline unsigned int __nodemask_pr_numnodes(const nodemask_t *m)
|
|
{
|
|
return m ? MAX_NUMNODES : 0;
|
|
}
|
|
static inline const unsigned long *__nodemask_pr_bits(const nodemask_t *m)
|
|
{
|
|
return m ? m->bits : NULL;
|
|
}
|
|
|
|
/*
|
|
* The inline keyword gives the compiler room to decide to inline, or
|
|
* not inline a function as it sees best. However, as these functions
|
|
* are called in both __init and non-__init functions, if they are not
|
|
* inlined we will end up with a section mismatch error (of the type of
|
|
* freeable items not being freed). So we must use __always_inline here
|
|
* to fix the problem. If other functions in the future also end up in
|
|
* this situation they will also need to be annotated as __always_inline
|
|
*/
|
|
#define node_set(node, dst) __node_set((node), &(dst))
|
|
static __always_inline void __node_set(int node, volatile nodemask_t *dstp)
|
|
{
|
|
set_bit(node, dstp->bits);
|
|
}
|
|
|
|
#define node_clear(node, dst) __node_clear((node), &(dst))
|
|
static inline void __node_clear(int node, volatile nodemask_t *dstp)
|
|
{
|
|
clear_bit(node, dstp->bits);
|
|
}
|
|
|
|
#define nodes_setall(dst) __nodes_setall(&(dst), MAX_NUMNODES)
|
|
static inline void __nodes_setall(nodemask_t *dstp, unsigned int nbits)
|
|
{
|
|
bitmap_fill(dstp->bits, nbits);
|
|
}
|
|
|
|
#define nodes_clear(dst) __nodes_clear(&(dst), MAX_NUMNODES)
|
|
static inline void __nodes_clear(nodemask_t *dstp, unsigned int nbits)
|
|
{
|
|
bitmap_zero(dstp->bits, nbits);
|
|
}
|
|
|
|
/* No static inline type checking - see Subtlety (1) above. */
|
|
#define node_isset(node, nodemask) test_bit((node), (nodemask).bits)
|
|
|
|
#define node_test_and_set(node, nodemask) \
|
|
__node_test_and_set((node), &(nodemask))
|
|
static inline bool __node_test_and_set(int node, nodemask_t *addr)
|
|
{
|
|
return test_and_set_bit(node, addr->bits);
|
|
}
|
|
|
|
#define nodes_and(dst, src1, src2) \
|
|
__nodes_and(&(dst), &(src1), &(src2), MAX_NUMNODES)
|
|
static inline void __nodes_and(nodemask_t *dstp, const nodemask_t *src1p,
|
|
const nodemask_t *src2p, unsigned int nbits)
|
|
{
|
|
bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
|
|
}
|
|
|
|
#define nodes_or(dst, src1, src2) \
|
|
__nodes_or(&(dst), &(src1), &(src2), MAX_NUMNODES)
|
|
static inline void __nodes_or(nodemask_t *dstp, const nodemask_t *src1p,
|
|
const nodemask_t *src2p, unsigned int nbits)
|
|
{
|
|
bitmap_or(dstp->bits, src1p->bits, src2p->bits, nbits);
|
|
}
|
|
|
|
#define nodes_xor(dst, src1, src2) \
|
|
__nodes_xor(&(dst), &(src1), &(src2), MAX_NUMNODES)
|
|
static inline void __nodes_xor(nodemask_t *dstp, const nodemask_t *src1p,
|
|
const nodemask_t *src2p, unsigned int nbits)
|
|
{
|
|
bitmap_xor(dstp->bits, src1p->bits, src2p->bits, nbits);
|
|
}
|
|
|
|
#define nodes_andnot(dst, src1, src2) \
|
|
__nodes_andnot(&(dst), &(src1), &(src2), MAX_NUMNODES)
|
|
static inline void __nodes_andnot(nodemask_t *dstp, const nodemask_t *src1p,
|
|
const nodemask_t *src2p, unsigned int nbits)
|
|
{
|
|
bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
|
|
}
|
|
|
|
#define nodes_complement(dst, src) \
|
|
__nodes_complement(&(dst), &(src), MAX_NUMNODES)
|
|
static inline void __nodes_complement(nodemask_t *dstp,
|
|
const nodemask_t *srcp, unsigned int nbits)
|
|
{
|
|
bitmap_complement(dstp->bits, srcp->bits, nbits);
|
|
}
|
|
|
|
#define nodes_equal(src1, src2) \
|
|
__nodes_equal(&(src1), &(src2), MAX_NUMNODES)
|
|
static inline bool __nodes_equal(const nodemask_t *src1p,
|
|
const nodemask_t *src2p, unsigned int nbits)
|
|
{
|
|
return bitmap_equal(src1p->bits, src2p->bits, nbits);
|
|
}
|
|
|
|
#define nodes_intersects(src1, src2) \
|
|
__nodes_intersects(&(src1), &(src2), MAX_NUMNODES)
|
|
static inline bool __nodes_intersects(const nodemask_t *src1p,
|
|
const nodemask_t *src2p, unsigned int nbits)
|
|
{
|
|
return bitmap_intersects(src1p->bits, src2p->bits, nbits);
|
|
}
|
|
|
|
#define nodes_subset(src1, src2) \
|
|
__nodes_subset(&(src1), &(src2), MAX_NUMNODES)
|
|
static inline bool __nodes_subset(const nodemask_t *src1p,
|
|
const nodemask_t *src2p, unsigned int nbits)
|
|
{
|
|
return bitmap_subset(src1p->bits, src2p->bits, nbits);
|
|
}
|
|
|
|
#define nodes_empty(src) __nodes_empty(&(src), MAX_NUMNODES)
|
|
static inline bool __nodes_empty(const nodemask_t *srcp, unsigned int nbits)
|
|
{
|
|
return bitmap_empty(srcp->bits, nbits);
|
|
}
|
|
|
|
#define nodes_full(nodemask) __nodes_full(&(nodemask), MAX_NUMNODES)
|
|
static inline bool __nodes_full(const nodemask_t *srcp, unsigned int nbits)
|
|
{
|
|
return bitmap_full(srcp->bits, nbits);
|
|
}
|
|
|
|
#define nodes_weight(nodemask) __nodes_weight(&(nodemask), MAX_NUMNODES)
|
|
static inline int __nodes_weight(const nodemask_t *srcp, unsigned int nbits)
|
|
{
|
|
return bitmap_weight(srcp->bits, nbits);
|
|
}
|
|
|
|
#define nodes_shift_right(dst, src, n) \
|
|
__nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES)
|
|
static inline void __nodes_shift_right(nodemask_t *dstp,
|
|
const nodemask_t *srcp, int n, int nbits)
|
|
{
|
|
bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
|
|
}
|
|
|
|
#define nodes_shift_left(dst, src, n) \
|
|
__nodes_shift_left(&(dst), &(src), (n), MAX_NUMNODES)
|
|
static inline void __nodes_shift_left(nodemask_t *dstp,
|
|
const nodemask_t *srcp, int n, int nbits)
|
|
{
|
|
bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
|
|
}
|
|
|
|
/* FIXME: better would be to fix all architectures to never return
|
|
> MAX_NUMNODES, then the silly min_ts could be dropped. */
|
|
|
|
#define first_node(src) __first_node(&(src))
|
|
static inline unsigned int __first_node(const nodemask_t *srcp)
|
|
{
|
|
return min_t(unsigned int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
|
|
}
|
|
|
|
#define next_node(n, src) __next_node((n), &(src))
|
|
static inline unsigned int __next_node(int n, const nodemask_t *srcp)
|
|
{
|
|
return min_t(unsigned int, MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
|
|
}
|
|
|
|
/*
|
|
* Find the next present node in src, starting after node n, wrapping around to
|
|
* the first node in src if needed. Returns MAX_NUMNODES if src is empty.
|
|
*/
|
|
#define next_node_in(n, src) __next_node_in((n), &(src))
|
|
unsigned int __next_node_in(int node, const nodemask_t *srcp);
|
|
|
|
static inline void init_nodemask_of_node(nodemask_t *mask, int node)
|
|
{
|
|
nodes_clear(*mask);
|
|
node_set(node, *mask);
|
|
}
|
|
|
|
#define nodemask_of_node(node) \
|
|
({ \
|
|
typeof(_unused_nodemask_arg_) m; \
|
|
if (sizeof(m) == sizeof(unsigned long)) { \
|
|
m.bits[0] = 1UL << (node); \
|
|
} else { \
|
|
init_nodemask_of_node(&m, (node)); \
|
|
} \
|
|
m; \
|
|
})
|
|
|
|
#define first_unset_node(mask) __first_unset_node(&(mask))
|
|
static inline unsigned int __first_unset_node(const nodemask_t *maskp)
|
|
{
|
|
return min_t(unsigned int, MAX_NUMNODES,
|
|
find_first_zero_bit(maskp->bits, MAX_NUMNODES));
|
|
}
|
|
|
|
#define NODE_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES)
|
|
|
|
#if MAX_NUMNODES <= BITS_PER_LONG
|
|
|
|
#define NODE_MASK_ALL \
|
|
((nodemask_t) { { \
|
|
[BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD \
|
|
} })
|
|
|
|
#else
|
|
|
|
#define NODE_MASK_ALL \
|
|
((nodemask_t) { { \
|
|
[0 ... BITS_TO_LONGS(MAX_NUMNODES)-2] = ~0UL, \
|
|
[BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD \
|
|
} })
|
|
|
|
#endif
|
|
|
|
#define NODE_MASK_NONE \
|
|
((nodemask_t) { { \
|
|
[0 ... BITS_TO_LONGS(MAX_NUMNODES)-1] = 0UL \
|
|
} })
|
|
|
|
#define nodes_addr(src) ((src).bits)
|
|
|
|
#define nodemask_parse_user(ubuf, ulen, dst) \
|
|
__nodemask_parse_user((ubuf), (ulen), &(dst), MAX_NUMNODES)
|
|
static inline int __nodemask_parse_user(const char __user *buf, int len,
|
|
nodemask_t *dstp, int nbits)
|
|
{
|
|
return bitmap_parse_user(buf, len, dstp->bits, nbits);
|
|
}
|
|
|
|
#define nodelist_parse(buf, dst) __nodelist_parse((buf), &(dst), MAX_NUMNODES)
|
|
static inline int __nodelist_parse(const char *buf, nodemask_t *dstp, int nbits)
|
|
{
|
|
return bitmap_parselist(buf, dstp->bits, nbits);
|
|
}
|
|
|
|
#define node_remap(oldbit, old, new) \
|
|
__node_remap((oldbit), &(old), &(new), MAX_NUMNODES)
|
|
static inline int __node_remap(int oldbit,
|
|
const nodemask_t *oldp, const nodemask_t *newp, int nbits)
|
|
{
|
|
return bitmap_bitremap(oldbit, oldp->bits, newp->bits, nbits);
|
|
}
|
|
|
|
#define nodes_remap(dst, src, old, new) \
|
|
__nodes_remap(&(dst), &(src), &(old), &(new), MAX_NUMNODES)
|
|
static inline void __nodes_remap(nodemask_t *dstp, const nodemask_t *srcp,
|
|
const nodemask_t *oldp, const nodemask_t *newp, int nbits)
|
|
{
|
|
bitmap_remap(dstp->bits, srcp->bits, oldp->bits, newp->bits, nbits);
|
|
}
|
|
|
|
#define nodes_onto(dst, orig, relmap) \
|
|
__nodes_onto(&(dst), &(orig), &(relmap), MAX_NUMNODES)
|
|
static inline void __nodes_onto(nodemask_t *dstp, const nodemask_t *origp,
|
|
const nodemask_t *relmapp, int nbits)
|
|
{
|
|
bitmap_onto(dstp->bits, origp->bits, relmapp->bits, nbits);
|
|
}
|
|
|
|
#define nodes_fold(dst, orig, sz) \
|
|
__nodes_fold(&(dst), &(orig), sz, MAX_NUMNODES)
|
|
static inline void __nodes_fold(nodemask_t *dstp, const nodemask_t *origp,
|
|
int sz, int nbits)
|
|
{
|
|
bitmap_fold(dstp->bits, origp->bits, sz, nbits);
|
|
}
|
|
|
|
#if MAX_NUMNODES > 1
|
|
#define for_each_node_mask(node, mask) \
|
|
for ((node) = first_node(mask); \
|
|
(node >= 0) && (node) < MAX_NUMNODES; \
|
|
(node) = next_node((node), (mask)))
|
|
#else /* MAX_NUMNODES == 1 */
|
|
#define for_each_node_mask(node, mask) \
|
|
for ((node) = 0; (node) < 1 && !nodes_empty(mask); (node)++)
|
|
#endif /* MAX_NUMNODES */
|
|
|
|
/*
|
|
* Bitmasks that are kept for all the nodes.
|
|
*/
|
|
enum node_states {
|
|
N_POSSIBLE, /* The node could become online at some point */
|
|
N_ONLINE, /* The node is online */
|
|
N_NORMAL_MEMORY, /* The node has regular memory */
|
|
#ifdef CONFIG_HIGHMEM
|
|
N_HIGH_MEMORY, /* The node has regular or high memory */
|
|
#else
|
|
N_HIGH_MEMORY = N_NORMAL_MEMORY,
|
|
#endif
|
|
N_MEMORY, /* The node has memory(regular, high, movable) */
|
|
N_CPU, /* The node has one or more cpus */
|
|
N_GENERIC_INITIATOR, /* The node has one or more Generic Initiators */
|
|
NR_NODE_STATES
|
|
};
|
|
|
|
/*
|
|
* The following particular system nodemasks and operations
|
|
* on them manage all possible and online nodes.
|
|
*/
|
|
|
|
extern nodemask_t node_states[NR_NODE_STATES];
|
|
|
|
#if MAX_NUMNODES > 1
|
|
static inline int node_state(int node, enum node_states state)
|
|
{
|
|
return node_isset(node, node_states[state]);
|
|
}
|
|
|
|
static inline void node_set_state(int node, enum node_states state)
|
|
{
|
|
__node_set(node, &node_states[state]);
|
|
}
|
|
|
|
static inline void node_clear_state(int node, enum node_states state)
|
|
{
|
|
__node_clear(node, &node_states[state]);
|
|
}
|
|
|
|
static inline int num_node_state(enum node_states state)
|
|
{
|
|
return nodes_weight(node_states[state]);
|
|
}
|
|
|
|
#define for_each_node_state(__node, __state) \
|
|
for_each_node_mask((__node), node_states[__state])
|
|
|
|
#define first_online_node first_node(node_states[N_ONLINE])
|
|
#define first_memory_node first_node(node_states[N_MEMORY])
|
|
static inline unsigned int next_online_node(int nid)
|
|
{
|
|
return next_node(nid, node_states[N_ONLINE]);
|
|
}
|
|
static inline unsigned int next_memory_node(int nid)
|
|
{
|
|
return next_node(nid, node_states[N_MEMORY]);
|
|
}
|
|
|
|
extern unsigned int nr_node_ids;
|
|
extern unsigned int nr_online_nodes;
|
|
|
|
static inline void node_set_online(int nid)
|
|
{
|
|
node_set_state(nid, N_ONLINE);
|
|
nr_online_nodes = num_node_state(N_ONLINE);
|
|
}
|
|
|
|
static inline void node_set_offline(int nid)
|
|
{
|
|
node_clear_state(nid, N_ONLINE);
|
|
nr_online_nodes = num_node_state(N_ONLINE);
|
|
}
|
|
|
|
#else
|
|
|
|
static inline int node_state(int node, enum node_states state)
|
|
{
|
|
return node == 0;
|
|
}
|
|
|
|
static inline void node_set_state(int node, enum node_states state)
|
|
{
|
|
}
|
|
|
|
static inline void node_clear_state(int node, enum node_states state)
|
|
{
|
|
}
|
|
|
|
static inline int num_node_state(enum node_states state)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
#define for_each_node_state(node, __state) \
|
|
for ( (node) = 0; (node) == 0; (node) = 1)
|
|
|
|
#define first_online_node 0
|
|
#define first_memory_node 0
|
|
#define next_online_node(nid) (MAX_NUMNODES)
|
|
#define next_memory_node(nid) (MAX_NUMNODES)
|
|
#define nr_node_ids 1U
|
|
#define nr_online_nodes 1U
|
|
|
|
#define node_set_online(node) node_set_state((node), N_ONLINE)
|
|
#define node_set_offline(node) node_clear_state((node), N_ONLINE)
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_NUMA) && (MAX_NUMNODES > 1)
|
|
extern int node_random(const nodemask_t *maskp);
|
|
#else
|
|
static inline int node_random(const nodemask_t *mask)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#define node_online_map node_states[N_ONLINE]
|
|
#define node_possible_map node_states[N_POSSIBLE]
|
|
|
|
#define num_online_nodes() num_node_state(N_ONLINE)
|
|
#define num_possible_nodes() num_node_state(N_POSSIBLE)
|
|
#define node_online(node) node_state((node), N_ONLINE)
|
|
#define node_possible(node) node_state((node), N_POSSIBLE)
|
|
|
|
#define for_each_node(node) for_each_node_state(node, N_POSSIBLE)
|
|
#define for_each_online_node(node) for_each_node_state(node, N_ONLINE)
|
|
|
|
/*
|
|
* For nodemask scratch area.
|
|
* NODEMASK_ALLOC(type, name) allocates an object with a specified type and
|
|
* name.
|
|
*/
|
|
#if NODES_SHIFT > 8 /* nodemask_t > 32 bytes */
|
|
#define NODEMASK_ALLOC(type, name, gfp_flags) \
|
|
type *name = kmalloc(sizeof(*name), gfp_flags)
|
|
#define NODEMASK_FREE(m) kfree(m)
|
|
#else
|
|
#define NODEMASK_ALLOC(type, name, gfp_flags) type _##name, *name = &_##name
|
|
#define NODEMASK_FREE(m) do {} while (0)
|
|
#endif
|
|
|
|
/* Example structure for using NODEMASK_ALLOC, used in mempolicy. */
|
|
struct nodemask_scratch {
|
|
nodemask_t mask1;
|
|
nodemask_t mask2;
|
|
};
|
|
|
|
#define NODEMASK_SCRATCH(x) \
|
|
NODEMASK_ALLOC(struct nodemask_scratch, x, \
|
|
GFP_KERNEL | __GFP_NORETRY)
|
|
#define NODEMASK_SCRATCH_FREE(x) NODEMASK_FREE(x)
|
|
|
|
|
|
#endif /* __LINUX_NODEMASK_H */
|