From owner-dev-commits-src-main@freebsd.org Tue Jul 13 22:17:26 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 919F1666885; Tue, 13 Jul 2021 22:17:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GPZkY6p4Cz3sPn; Tue, 13 Jul 2021 22:17:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8B90126B5; Tue, 13 Jul 2021 22:17:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16DMHPhh060833; Tue, 13 Jul 2021 22:17:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16DMHP6d060832; Tue, 13 Jul 2021 22:17:25 GMT (envelope-from git) Date: Tue, 13 Jul 2021 22:17:25 GMT Message-Id: <202107132217.16DMHP6d060832@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 45e2357113e6 - main - malloc: Pass the allocation size to malloc_large() by value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 45e2357113e65537feabb7c872053b5ea5f7a0f1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2021 22:17:26 -0000 The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=45e2357113e65537feabb7c872053b5ea5f7a0f1 commit 45e2357113e65537feabb7c872053b5ea5f7a0f1 Author: Mark Johnston AuthorDate: 2021-07-13 21:47:02 +0000 Commit: Mark Johnston CommitDate: 2021-07-13 21:47:02 +0000 malloc: Pass the allocation size to malloc_large() by value Its callers do not make use the modified size that malloc_large() was returning, so there's no need to pass a pointer. No functional change intended. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- sys/kern/kern_malloc.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 75cbc2a0fd04..bd0f46ea5220 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -584,23 +584,21 @@ malloc_large_size(uma_slab_t slab) } static caddr_t __noinline -malloc_large(size_t *size, struct malloc_type *mtp, struct domainset *policy, +malloc_large(size_t size, struct malloc_type *mtp, struct domainset *policy, int flags DEBUG_REDZONE_ARG_DEF) { vm_offset_t kva; caddr_t va; - size_t sz; - sz = roundup(*size, PAGE_SIZE); - kva = kmem_malloc_domainset(policy, sz, flags); + size = roundup(size, PAGE_SIZE); + kva = kmem_malloc_domainset(policy, size, flags); if (kva != 0) { /* The low bit is unused for slab pointers. */ - vsetzoneslab(kva, NULL, (void *)((sz << 1) | 1)); - uma_total_inc(sz); - *size = sz; + vsetzoneslab(kva, NULL, (void *)((size << 1) | 1)); + uma_total_inc(size); } va = (caddr_t)kva; - malloc_type_allocated(mtp, va == NULL ? 0 : sz); + malloc_type_allocated(mtp, va == NULL ? 0 : size); if (__predict_false(va == NULL)) { KASSERT((flags & M_WAITOK) == 0, ("malloc(M_WAITOK) returned NULL")); @@ -608,7 +606,7 @@ malloc_large(size_t *size, struct malloc_type *mtp, struct domainset *policy, #ifdef DEBUG_REDZONE va = redzone_setup(va, osize); #endif - kasan_mark((void *)va, osize, sz, KASAN_MALLOC_REDZONE); + kasan_mark((void *)va, osize, size, KASAN_MALLOC_REDZONE); } return (va); } @@ -648,7 +646,7 @@ void * #endif if (__predict_false(size > kmem_zmax)) - return (malloc_large(&size, mtp, DOMAINSET_RR(), flags + return (malloc_large(size, mtp, DOMAINSET_RR(), flags DEBUG_REDZONE_ARG)); if (size & KMEM_ZMASK) @@ -718,7 +716,7 @@ malloc_domainset(size_t size, struct malloc_type *mtp, struct domainset *ds, #endif if (__predict_false(size > kmem_zmax)) - return (malloc_large(&size, mtp, DOMAINSET_RR(), flags + return (malloc_large(size, mtp, DOMAINSET_RR(), flags DEBUG_REDZONE_ARG)); vm_domainset_iter_policy_init(&di, ds, &domain, &flags); @@ -770,7 +768,7 @@ malloc_domainset_exec(size_t size, struct malloc_type *mtp, struct domainset *ds return (va); #endif - return (malloc_large(&size, mtp, ds, flags DEBUG_REDZONE_ARG)); + return (malloc_large(size, mtp, ds, flags DEBUG_REDZONE_ARG)); } void *