Re: [PATCH 5/9] treewide: use kv[mz]alloc* rather than opencoded variants

From: Vlastimil Babka
Date: Mon Jan 30 2017 - 11:34:50 EST


On 01/30/2017 10:49 AM, Michal Hocko wrote:
From: Michal Hocko <mhocko@xxxxxxxx>

There are many code paths opencoding kvmalloc. Let's use the helper
instead. The main difference to kvmalloc is that those users are usually
not considering all the aspects of the memory allocator. E.g. allocation
requests <= 32kB (with 4kB pages) are basically never failing and invoke
OOM killer to satisfy the allocation. This sounds too disruptive for
something that has a reasonable fallback - the vmalloc. On the other
hand those requests might fallback to vmalloc even when the memory
allocator would succeed after several more reclaim/compaction attempts
previously. There is no guarantee something like that happens though.

This patch converts many of those places to kv[mz]alloc* helpers because
they are more conservative.

Changes since v1
- add kvmalloc_array - this might silently fix some overflow issues
because most users simply didn't check the overflow for the vmalloc
fallback.

Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Cc: Anton Vorontsov <anton@xxxxxxxxxx>
Cc: Colin Cross <ccross@xxxxxxxxxxx>
Cc: Kees Cook <keescook@xxxxxxxxxxxx>
Cc: Tony Luck <tony.luck@xxxxxxxxx>
Cc: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>
Cc: Ben Skeggs <bskeggs@xxxxxxxxxx>
Cc: Kent Overstreet <kent.overstreet@xxxxxxxxx>
Cc: Santosh Raspatur <santosh@xxxxxxxxxxx>
Cc: Hariprasad S <hariprasad@xxxxxxxxxxx>
Cc: Yishai Hadas <yishaih@xxxxxxxxxxxx>
Cc: Oleg Drokin <oleg.drokin@xxxxxxxxx>
Cc: "Yan, Zheng" <zyan@xxxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Alexei Starovoitov <ast@xxxxxxxxxx>
Cc: Eric Dumazet <eric.dumazet@xxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Acked-by: Andreas Dilger <andreas.dilger@xxxxxxxxx> # Lustre
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> # Xen bits
Acked-by: Christian Borntraeger <borntraeger@xxxxxxxxxx> # KVM/s390
Acked-by: Dan Williams <dan.j.williams@xxxxxxxxx> # nvdim
Acked-by: David Sterba <dsterba@xxxxxxxx> # btrfs
Acked-by: Ilya Dryomov <idryomov@xxxxxxxxx> # Ceph
Acked-by: Tariq Toukan <tariqt@xxxxxxxxxxxx> # mlx4
Signed-off-by: Michal Hocko <mhocko@xxxxxxxx>

Acked-by: Vlastimil Babka <vbabka@xxxxxxx>