linux-stable/include
Aaron Lu 4fb12a087a mm/swap: use nr_node_ids for avail_lists in swap_info_struct
[ Upstream commit 66f71da9dd ]

Since a2468cc9bf ("swap: choose swap device according to numa node"),
avail_lists field of swap_info_struct is changed to an array with
MAX_NUMNODES elements.  This made swap_info_struct size increased to 40KiB
and needs an order-4 page to hold it.

This is not optimal in that:
1 Most systems have way less than MAX_NUMNODES(1024) nodes so it
  is a waste of memory;
2 It could cause swapon failure if the swap device is swapped on
  after system has been running for a while, due to no order-4
  page is available as pointed out by Vasily Averin.

Solve the above two issues by using nr_node_ids(which is the actual
possible node number the running system has) for avail_lists instead of
MAX_NUMNODES.

nr_node_ids is unknown at compile time so can't be directly used when
declaring this array.  What I did here is to declare avail_lists as zero
element array and allocate space for it when allocating space for
swap_info_struct.  The reason why keep using array but not pointer is
plist_for_each_entry needs the field to be part of the struct, so pointer
will not work.

This patch is on top of Vasily Averin's fix commit.  I think the use of
kvzalloc for swap_info_struct is still needed in case nr_node_ids is
really big on some systems.

Link: http://lkml.kernel.org/r/20181115083847.GA11129@intel.com
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Vasily Averin <vvs@virtuozzo.com>
Cc: Huang Ying <ying.huang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-01-26 09:37:06 +01:00
..
acpi
asm-generic locking/qspinlock: Fix build for anonymous union in older GCC compilers 2018-12-21 14:13:11 +01:00
clocksource
crypto crypto: vmac - separate tfm and request context 2018-08-17 21:01:10 +02:00
drm drm/edid: VSDB yCBCr420 Deep Color mode bit definitions 2018-11-10 07:48:35 -08:00
dt-bindings dt-bindings: clock: mediatek: add binding for fixed-factor clock axisel_d4 2018-04-24 09:36:34 +02:00
keys
kvm arm/arm64: KVM: Add PSCI version selection API 2018-05-01 12:58:27 -07:00
linux mm/swap: use nr_node_ids for avail_lists in swap_info_struct 2019-01-26 09:37:06 +01:00
math-emu
media media: v4l: event: Prevent freeing event subscriptions while accessed 2018-10-03 17:01:00 -07:00
memory
misc
net netfilter: nf_conncount: Fix garbage collection with zones 2019-01-09 17:14:51 +01:00
pcmcia
ras
rdma IB/hfi1: Optimize kthread pointer locking when queuing CQ entries 2018-07-03 11:24:54 +02:00
scsi scsi: core: introduce force_blk_mq 2018-08-15 18:12:47 +02:00
soc memory: tegra: Apply interrupts mask per SoC 2018-08-03 07:50:38 +02:00
sound ALSA: pcm: Fix interval evaluation with openmin/max 2018-12-13 09:18:51 +01:00
target
trace ext4: force inode writes when nfsd calls commit_metadata() 2019-01-09 17:14:49 +01:00
uapi Input: restore EV_ABS ABS_RESERVED 2019-01-13 10:00:56 +01:00
video udlfb: set optimal write delay 2018-09-09 19:56:01 +02:00
xen Revert "xen/balloon: Mark unallocated host memory as UNUSABLE" 2018-12-17 09:28:53 +01:00