From: Paolo Bonzini <pbonzini@redhat.com> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Michael Ellerman <mpe@ellerman.id.au>, Andrew Morton <akpm@linux-foundation.org>, Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@linux.com>, Johannes Weiner <hannes@cmpxchg.org>, Michal Hocko <mhocko@kernel.org>, Vladimir Davydov <vdavydov.dev@gmail.com>, linux-mm@kvack.org, cgroups@vger.kernel.org Subject: [PATCH 0/3] mm: vmalloc: introduce array allocation functions Date: Tue, 8 Mar 2022 05:59:15 -0500 [thread overview] Message-ID: <20220308105918.615575-1-pbonzini@redhat.com> (raw) 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
WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>, Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>, Dennis Zhou <dennis-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>, Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>, Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>, Vladimir Davydov <vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: [PATCH 0/3] mm: vmalloc: introduce array allocation functions Date: Tue, 8 Mar 2022 05:59:15 -0500 [thread overview] Message-ID: <20220308105918.615575-1-pbonzini@redhat.com> (raw) 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
next reply other threads:[~2022-03-08 10:59 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-08 10:59 Paolo Bonzini [this message] 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 15:26 ` Michal Hocko 2022-03-08 14:26 ` David Hildenbrand 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 13:49 ` Michal Hocko 2022-03-08 14:27 ` David Hildenbrand 2022-03-08 14:27 ` David Hildenbrand 2022-03-08 16:13 ` Dennis Zhou 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 10:59 ` Paolo Bonzini 2022-03-08 14:25 ` David Hildenbrand 2022-03-10 4:18 ` Andrew Morton
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220308105918.615575-1-pbonzini@redhat.com \ --to=pbonzini@redhat.com \ --cc=akpm@linux-foundation.org \ --cc=cgroups@vger.kernel.org \ --cc=cl@linux.com \ --cc=dennis@kernel.org \ --cc=hannes@cmpxchg.org \ --cc=kvm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mhocko@kernel.org \ --cc=mpe@ellerman.id.au \ --cc=tj@kernel.org \ --cc=vdavydov.dev@gmail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.