[PATCH 0/6 v5] kvmalloc

From: Michal Hocko
Date: Mon Mar 06 2017 - 05:32:44 EST


Hi,
this has been previously posted here [1]. Based on the discussion I have
dropped "[PATCH 9/9] net, bpf: use kvzalloc helper" and added "[PATCH]
xattr: zero out memory copied to userspace in getxattr". I have rebased
the series on top of 4.11-rc1. I hope there are no further obstacles to
have this merged during this release cycle.

Original cover:

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@xxxxxxxxxx
[2] http://lkml.kernel.org/r/1485273626.16328.301.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Michal Hocko (9):
mm: introduce kv[mz]alloc helpers
mm: support __GFP_REPEAT in kvmalloc_node for >32kB
rhashtable: simplify a strange allocation pattern
ila: simplify a strange allocation pattern
xattr: zero out memory copied to userspace in getxattr
treewide: use kv[mz]alloc* rather than opencoded variants
net: use kvmalloc with __GFP_REPEAT rather than open coded variant
md: use kvmalloc rather than opencoded variant
bcache: use kvmalloc

Diffstat says:
arch/s390/kvm/kvm-s390.c | 10 +---
arch/x86/kvm/lapic.c | 4 +-
arch/x86/kvm/page_track.c | 4 +-
arch/x86/kvm/x86.c | 4 +-
crypto/lzo.c | 4 +-
drivers/acpi/apei/erst.c | 8 +--
drivers/char/agp/generic.c | 8 +--
drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +-
drivers/md/bcache/super.c | 8 +--
drivers/md/bcache/util.h | 12 +----
drivers/md/dm-ioctl.c | 13 ++---
drivers/md/dm-stats.c | 7 +--
drivers/net/ethernet/chelsio/cxgb3/cxgb3_defs.h | 3 --
drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c | 29 ++---------
drivers/net/ethernet/chelsio/cxgb3/l2t.c | 8 +--
drivers/net/ethernet/chelsio/cxgb3/l2t.h | 1 -
drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c | 12 ++---
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 3 --
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 10 ++--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 8 +--
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 31 ++----------
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | 14 +++---
drivers/net/ethernet/chelsio/cxgb4/l2t.c | 2 +-
drivers/net/ethernet/chelsio/cxgb4/sched.c | 12 ++---
drivers/net/ethernet/mellanox/mlx4/en_tx.c | 9 ++--
drivers/net/ethernet/mellanox/mlx4/mr.c | 9 ++--
drivers/nvdimm/dimm_devs.c | 5 +-
.../staging/lustre/lnet/libcfs/linux/linux-mem.c | 11 +----
drivers/vhost/net.c | 9 ++--
drivers/vhost/vhost.c | 15 ++----
drivers/vhost/vsock.c | 9 ++--
drivers/xen/evtchn.c | 14 +-----
fs/btrfs/ctree.c | 9 ++--
fs/btrfs/ioctl.c | 9 ++--
fs/btrfs/send.c | 27 ++++------
fs/ceph/file.c | 9 ++--
fs/ext4/mballoc.c | 2 +-
fs/ext4/super.c | 4 +-
fs/f2fs/f2fs.h | 20 --------
fs/f2fs/file.c | 4 +-
fs/f2fs/node.c | 4 +-
fs/f2fs/segment.c | 14 +++---
fs/select.c | 5 +-
fs/seq_file.c | 16 +-----
fs/xattr.c | 27 ++++------
include/linux/kvm_host.h | 2 -
include/linux/mlx5/driver.h | 7 +--
include/linux/mm.h | 22 +++++++++
include/linux/vmalloc.h | 1 +
ipc/util.c | 7 +--
lib/iov_iter.c | 5 +-
lib/rhashtable.c | 13 ++---
mm/frame_vector.c | 5 +-
mm/nommu.c | 5 ++
mm/util.c | 57 ++++++++++++++++++++++
mm/vmalloc.c | 9 +++-
net/core/dev.c | 24 ++++-----
net/ipv4/inet_hashtables.c | 6 +--
net/ipv4/tcp_metrics.c | 5 +-
net/ipv6/ila/ila_xlat.c | 8 +--
net/mpls/af_mpls.c | 5 +-
net/netfilter/x_tables.c | 21 ++------
net/netfilter/xt_recent.c | 5 +-
net/sched/sch_choke.c | 5 +-
net/sched/sch_fq.c | 12 +----
net/sched/sch_fq_codel.c | 26 +++-------
net/sched/sch_hhf.c | 33 ++++---------
net/sched/sch_netem.c | 6 +--
net/sched/sch_sfq.c | 6 +--
security/apparmor/apparmorfs.c | 2 +-
security/apparmor/include/lib.h | 11 -----
security/apparmor/lib.c | 30 ------------
security/apparmor/match.c | 2 +-
security/apparmor/policy_unpack.c | 2 +-
security/keys/keyctl.c | 22 +++------
virt/kvm/kvm_main.c | 18 ++-----
76 files changed, 271 insertions(+), 561 deletions(-)