linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mm: vmalloc: introduce array allocation functions
@ 2022-03-08 10:59 Paolo Bonzini
  2022-03-08 10:59 ` [PATCH 1/3] " Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Paolo Bonzini @ 2022-03-08 10:59 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: Michael Ellerman, Andrew Morton, Dennis Zhou, Tejun Heo,
	Christoph Lameter, Johannes Weiner, Michal Hocko,
	Vladimir Davydov, linux-mm, cgroups

The first patch in this series introduces four array allocation
functions to replace vmalloc(array_size()) and vzalloc(array_size()),
of which Linux has dozens of occurrences.  The Functions take care of
the multiplication and overflow check, result in simpler code and make
it easier for developers to avoid overflow bugs.

The other two patches start to apply the functions in the mm/ and KVM
areas.  In the case of KVM, it is also important to switch from kvcalloc
to __vcalloc; the allocation size is driven by userspace and can be larger
than 4GiB, which has been forbidden by the kv*alloc functions since 5.15.

Paolo

Paolo Bonzini (3):
  mm: vmalloc: introduce array allocation functions
  mm: use vmalloc_array and vcalloc for array allocations
  KVM: use __vcalloc for very large allocations

 arch/powerpc/kvm/book3s_hv_uvmem.c |  2 +-
 arch/x86/kvm/mmu/page_track.c      |  7 +++--
 arch/x86/kvm/x86.c                 |  4 +--
 include/linux/vmalloc.h            |  5 +++
 mm/percpu-stats.c                  |  2 +-
 mm/swap_cgroup.c                   |  4 +--
 mm/util.c                          | 50 ++++++++++++++++++++++++++++++
 virt/kvm/kvm_main.c                |  4 +--
 9 files changed, 66 insertions(+), 12 deletions(-)

-- 
2.31.1



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-03-10  4:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 10:59 [PATCH 0/3] mm: vmalloc: introduce array allocation functions Paolo Bonzini
2022-03-08 10:59 ` [PATCH 1/3] " Paolo Bonzini
2022-03-08 13:47   ` Michal Hocko
2022-03-08 13:55     ` Paolo Bonzini
2022-03-08 15:26       ` Michal Hocko
2022-03-08 14:26   ` David Hildenbrand
2022-03-08 10:59 ` [PATCH 2/3] mm: use vmalloc_array and vcalloc for array allocations Paolo Bonzini
2022-03-08 13:49   ` Michal Hocko
2022-03-08 14:27   ` David Hildenbrand
2022-03-08 16:13   ` Dennis Zhou
2022-03-08 10:59 ` [PATCH 3/3] KVM: use vcalloc/__vcalloc for very large allocations Paolo Bonzini
2022-03-08 14:25   ` David Hildenbrand
2022-03-10  4:18   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).