WSL2-Linux-Kernel/drivers
Michal Hocko a7c3e901a4 mm: introduce kv[mz]alloc helpers
Patch series "kvmalloc", v5.

There are many open coded kmalloc with vmalloc fallback instances in the
tree.  Most of them are not careful enough or simply do not care about
the underlying semantic of the kmalloc/page allocator which means that
a) some vmalloc fallbacks are basically unreachable because the kmalloc
part will keep retrying until it succeeds b) the page allocator can
invoke a really disruptive steps like the OOM killer to move forward
which doesn't sound appropriate when we consider that the vmalloc
fallback is available.

As it can be seen implementing kvmalloc requires quite an intimate
knowledge if the page allocator and the memory reclaim internals which
strongly suggests that a helper should be implemented in the memory
subsystem proper.

Most callers, I could find, have been converted to use the helper
instead.  This is patch 6.  There are some more relying on __GFP_REPEAT
in the networking stack which I have converted as well and Eric Dumazet
was not opposed [2] to convert them as well.

[1] http://lkml.kernel.org/r/20170130094940.13546-1-mhocko@kernel.org
[2] http://lkml.kernel.org/r/1485273626.16328.301.camel@edumazet-glaptop3.roam.corp.google.com

This patch (of 9):

Using kmalloc with the vmalloc fallback for larger allocations is a
common pattern in the kernel code.  Yet we do not have any common helper
for that and so users have invented their own helpers.  Some of them are
really creative when doing so.  Let's just add kv[mz]alloc and make sure
it is implemented properly.  This implementation makes sure to not make
a large memory pressure for > PAGE_SZE requests (__GFP_NORETRY) and also
to not warn about allocation failures.  This also rules out the OOM
killer as the vmalloc is a more approapriate fallback than a disruptive
user visible action.

This patch also changes some existing users and removes helpers which
are specific for them.  In some cases this is not possible (e.g.
ext4_kvmalloc, libcfs_kvzalloc) because those seems to be broken and
require GFP_NO{FS,IO} context which is not vmalloc compatible in general
(note that the page table allocation is GFP_KERNEL).  Those need to be
fixed separately.

While we are at it, document that __vmalloc{_node} about unsupported gfp
mask because there seems to be a lot of confusion out there.
kvmalloc_node will warn about GFP_KERNEL incompatible (which are not
superset) flags to catch new abusers.  Existing ones would have to die
slowly.

[sfr@canb.auug.org.au: f2fs fixup]
  Link: http://lkml.kernel.org/r/20170320163735.332e64b7@canb.auug.org.au
Link: http://lkml.kernel.org/r/20170306103032.2540-2-mhocko@kernel.org
Signed-off-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>	[ext4 part]
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-05-08 17:15:12 -07:00
..
accessibility
acpi libnvdimm for 4.12 2017-05-05 18:49:20 -07:00
amba
android
ata
atm
auxdisplay
base DeviceTree for 4.12: 2017-05-05 19:33:07 -07:00
bcma
block Merge branch 'for-linus' of git://git.kernel.dk/linux-block 2017-05-06 11:25:08 -07:00
bluetooth
bus
cdrom
char char/misc patches for 4.12-rc1 2017-05-04 19:15:35 -07:00
clk MMC core: 2017-05-02 17:34:32 -07:00
clocksource
connector
cpufreq
cpuidle
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2017-05-02 15:53:46 -07:00
dax libnvdimm for 4.12 2017-05-05 18:49:20 -07:00
dca
devfreq
dio
dma
dma-buf
edac
eisa
extcon
firewire
firmware arm64 updates for 4.12: 2017-05-05 12:11:37 -07:00
fmc
fpga
fsi
gpio char/misc patches for 4.12-rc1 2017-05-04 19:15:35 -07:00
gpu media updates for v4.12-rc1 2017-05-05 17:34:57 -07:00
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2017-05-02 19:09:35 -07:00
hsi
hv char/misc patches for 4.12-rc1 2017-05-04 19:15:35 -07:00
hwmon
hwspinlock
hwtracing char/misc patches for 4.12-rc1 2017-05-04 19:15:35 -07:00
i2c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2017-05-03 12:38:20 -07:00
ide
idle
iio Staging/IIO patches for 4.12-rc1 2017-05-05 18:16:23 -07:00
infiniband char/misc patches for 4.12-rc1 2017-05-04 19:15:35 -07:00
input char/misc patches for 4.12-rc1 2017-05-04 19:15:35 -07:00
iommu extra pull request because I missed tegra. 2017-05-05 17:18:44 -07:00
ipack
irqchip
isdn
leds
lguest
lightnvm lightnvm: fix bad back free on error path 2017-05-04 07:53:04 -06:00
macintosh DeviceTree for 4.12: 2017-05-05 19:33:07 -07:00
mailbox
mcb
md mm: introduce kv[mz]alloc helpers 2017-05-08 17:15:12 -07:00
media Staging/IIO patches for 4.12-rc1 2017-05-05 18:16:23 -07:00
memory - New Drivers 2017-05-03 12:16:25 -07:00
memstick
message
mfd
misc drivers/misc/c2port/c2port-duramar2150.c: checking for NULL instead of IS_ERR() 2017-05-08 17:15:10 -07:00
mmc MMC core: 2017-05-02 17:34:32 -07:00
mtd Merge branch 'for-linus' of git://git.kernel.dk/linux-block 2017-05-06 11:25:08 -07:00
net qede: Fix possible misconfiguration of advertised autoneg value. 2017-05-04 12:31:03 -04:00
nfc
ntb
nubus
nvdimm libnvdimm for 4.12 2017-05-05 18:49:20 -07:00
nvme lightnvm: create cmd before allocating request 2017-05-04 07:53:04 -06:00
nvmem
of DeviceTree for 4.12: 2017-05-05 19:33:07 -07:00
oprofile
parisc
parport
pci main drm pull request for 4.12 kernel 2017-05-03 11:44:24 -07:00
pcmcia
perf
phy
pinctrl Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2017-05-02 19:09:35 -07:00
platform char/misc patches for 4.12-rc1 2017-05-04 19:15:35 -07:00
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio char/misc patches for 4.12-rc1 2017-05-04 19:15:35 -07:00
ras
regulator
remoteproc
reset
rpmsg
rtc
s390 libnvdimm for 4.12 2017-05-05 18:49:20 -07:00
sbus
scsi Merge branch 'for-linus' of git://git.kernel.dk/linux-block 2017-05-06 11:25:08 -07:00
sfi
sh
sn
soc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2017-05-02 16:40:27 -07:00
spi
spmi
ssb
staging Staging/IIO patches for 4.12-rc1 2017-05-05 18:16:23 -07:00
target
tc
thermal - New Drivers 2017-05-03 12:16:25 -07:00
thunderbolt
tty DeviceTree for 4.12: 2017-05-05 19:33:07 -07:00
uio
usb DeviceTree for 4.12: 2017-05-05 19:33:07 -07:00
uwb
vfio powerpc updates for 4.12 part 1. 2017-05-05 11:36:44 -07:00
vhost
video - New Drivers 2017-05-03 12:11:44 -07:00
virt drivers/virt/fsl_hypervisor.c: use get_user_pages_unlocked() 2017-05-08 17:15:10 -07:00
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile libnvdimm for 4.12 2017-05-05 18:49:20 -07:00