From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0064C433EF for ; Tue, 8 Mar 2022 10:59:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 654818D0002; Tue, 8 Mar 2022 05:59:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 604588D0001; Tue, 8 Mar 2022 05:59:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F2B88D0002; Tue, 8 Mar 2022 05:59:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 3D1528D0001 for ; Tue, 8 Mar 2022 05:59:30 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 05B991214C3 for ; Tue, 8 Mar 2022 10:59:30 +0000 (UTC) X-FDA: 79220922900.14.6BEFA0C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 6635B180009 for ; Tue, 8 Mar 2022 10:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646737168; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3yqdS8zAEjaJjs00ZY9U4Ql4/aCVM8MsMEwUnD+zf4Q=; b=B002bamYRcZeIAm47hWVgZ5vi/nC5DLsDFZhFVn9wtAeiRSq3nywjgQs1bWABHE0Nc2Ank qm1d7B/5k7yvIjyVffpplJiWg6asQwsUD87PxCJS13LIH74eqHknEONPf/KMP4m3bW0Ztt QhENSncApFbirFRrv5X0avolDcZYn+E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-345-D7y9jPIWOpia1cea1Qxr2w-1; Tue, 08 Mar 2022 05:59:23 -0500 X-MC-Unique: D7y9jPIWOpia1cea1Qxr2w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D828801AEB; Tue, 8 Mar 2022 10:59:21 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9CB46FB03; Tue, 8 Mar 2022 10:59:19 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Michael Ellerman , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Johannes Weiner , Michal Hocko , Vladimir Davydov , 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 Message-Id: <20220308105918.615575-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6635B180009 X-Stat-Signature: p77q48i79mdh6rj7z4rwsmq69uf1gp75 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B002bamY; spf=none (imf24.hostedemail.com: domain of pbonzini@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=pbonzini@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-HE-Tag: 1646737169-809277 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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