From nobody Thu Dec 21 13:43:52 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Sws8n3nPvz54pZk; Thu, 21 Dec 2023 13:43:53 +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 4Sws8n0T57z4P44; Thu, 21 Dec 2023 13:43:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703166233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AmTFiowc03Q8tJJk2QidWtshYZtP6b0WxCqho8gsrNs=; b=xxEXePt/ZZYpQ3C3BJGehSy3yXxhUMIsJ1pkcy6wqNe68SPzu53b4Mf63TeZKmc7Fjo3eU QMtBktWNR4TgG3XWtdvNZFuN1EGIzuYjnpCPM8LQ9FH7UOwQMF8eZEhtQayrnnG7FZ5Klm zO/y6pEY4CVFjusi/ASxPNLPh+NZL7wA4SY9JMZ4WLh9V7xUSNpcZHayiPZFBVhOLex3C5 8X3tddch7X1GJoMU78j6hJVlgW/FumuwdxnsqXtllH42Bo5IM8ShcwKgLp/EzljbB3FUZ9 KgTqGLyFYKmaQCCAm43OylclihLyF+j8W/ljv/GE1idEFg/uiiX6pUSW5yUBRg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703166233; a=rsa-sha256; cv=none; b=K/t9EoqqFzKKUmKRgKfAKBBt/6aorUBSjMbWzQKujL/PSlF5/8n9hhbQHmr+qDBt/hZez9 tYiUCGO7uAvY5+ickuyKaikMZnm4oGTnchdpJaU5tPXwTK6f4a4eeb5JPJPfBYyArkCm1t DBYWDt1hljtssgjL7TmUDTfIYgsqKiPYh20lG3XM+BQEF39BmoMF33qJiCNieLpeJwJScb WrPcxcZx9yrnZCHKEhho58gxGJSwfbSJcYH2uBjWcpHlFExQe/SDFeI5Y7DN5gqL/i3MGp HTKMHubVp0IejG2Xx3SRx5n9/V9q66MJoOVQBUiXiZyqsQ0UETqIM5hgZgKBUw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703166233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AmTFiowc03Q8tJJk2QidWtshYZtP6b0WxCqho8gsrNs=; b=W63muFoLNag6OjnKymuDVKDiowVsCBB8BfN7vo1PxG2vYblg0ALecm0pah11B69cP2LlGl a2h/KhEb7na5bplxyW+hvy/IRDjVKDfCsAROzfODd+ai6mX4wKoRwzzDFFAgUa7YmAH7gr VIS9irHNiFkhXTh4QyC2i4zaoyIF3zxHAfiAJGPl1cTvWcevjBnO78pkcJ64Zl+yphFHy7 4JVy3QKY2092lvz09Wk3MqctkfrTlhjInCfFjJ3y+9UwNOfG+JXHQ8aR4K1syqAEF6pzjs OH3BEqb+PY43T0+3I2FmWc6Vy9IrmV45zeGVQR2piWixY7/Qqsy/exsVftrqUg== 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 4Sws8m6hKNzZRX; Thu, 21 Dec 2023 13:43:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BLDhqUG079813; Thu, 21 Dec 2023 13:43:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BLDhqb6079810; Thu, 21 Dec 2023 13:43:52 GMT (envelope-from git) Date: Thu, 21 Dec 2023 13:43:52 GMT Message-Id: <202312211343.3BLDhqb6079810@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 56c53cc8fb3e - stable/13 - uma: Hide 'uma_align_cache'; Create/rename accessors List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 56c53cc8fb3edaed82678440da5cf8e0dc482d03 Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=56c53cc8fb3edaed82678440da5cf8e0dc482d03 commit 56c53cc8fb3edaed82678440da5cf8e0dc482d03 Author: Olivier Certner AuthorDate: 2023-10-13 09:52:28 +0000 Commit: Olivier Certner CommitDate: 2023-12-21 13:39:26 +0000 uma: Hide 'uma_align_cache'; Create/rename accessors Create the uma_get_cache_align_mask() accessor and put it in a separate private header so as to minimize namespace pollution in header/source files that need only this function and not the whole 'uma.h' header. Make sure the accessors have '_mask' as a suffix, so that callers are aware that the real alignment is the power of two that is the mask plus one. Rename the stem to something more explicit. Rename uma_set_cache_align_mask()'s single parameter to 'mask'. Hide 'uma_align_cache' to ensure that it cannot be set in any other way then by a call to uma_set_cache_align_mask(), which will perform sanity checks in a further commit. While here, rename it to 'uma_cache_align_mask'. This is also in preparation for some further changes, such as improving the sanity checks, eliminating internal resolving of UMA_ALIGN_CACHE and changing the type of the 'uma_cache_align_mask' variable. Reviewed by: markj, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42258 (cherry picked from commit dc8f7692fd1de628814f4eaf4a233dccf4c92199) Approved by: markj (mentor) --- sys/arm/arm/cpufunc.c | 2 +- .../linuxkpi/common/include/linux/dma-mapping.h | 4 +-- sys/vm/uma.h | 6 ++-- sys/vm/uma_align_mask.h | 36 ++++++++++++++++++++++ sys/vm/uma_core.c | 18 ++++++++--- 5 files changed, 56 insertions(+), 10 deletions(-) diff --git a/sys/arm/arm/cpufunc.c b/sys/arm/arm/cpufunc.c index 32b3d2f869c9..f2845eb80f3b 100644 --- a/sys/arm/arm/cpufunc.c +++ b/sys/arm/arm/cpufunc.c @@ -254,7 +254,7 @@ set_cpufuncs(void) panic("No support for this CPU type (%08x) in kernel", cputype); return(ARCHITECTURE_NOT_PRESENT); out: - uma_set_align(arm_dcache_align_mask); + uma_set_cache_align_mask(arm_dcache_align_mask); return (0); } diff --git a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h index 4a53b7675302..fb63a45ac307 100644 --- a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h +++ b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -350,8 +351,7 @@ dma_max_mapping_size(struct device *dev) #define dma_unmap_len(p, name) ((p)->name) #define dma_unmap_len_set(p, name, v) (((p)->name) = (v)) -extern int uma_align_cache; -#define dma_get_cache_alignment() uma_align_cache +#define dma_get_cache_alignment() uma_get_cache_align_mask() static inline int diff --git a/sys/vm/uma.h b/sys/vm/uma.h index 954d64c4d63b..4225bd83ba23 100644 --- a/sys/vm/uma.h +++ b/sys/vm/uma.h @@ -470,12 +470,14 @@ void uma_zone_reclaim_domain(uma_zone_t, int req, int domain); * alignment. Should be called by MD boot code prior to starting VM/UMA. * * Arguments: - * align The alignment mask + * mask The alignment mask * * Returns: * Nothing */ -void uma_set_align(int align); +void uma_set_cache_align_mask(int mask); + +#include /* * Set a reserved number of items to hold for M_USE_RESERVE allocations. All diff --git a/sys/vm/uma_align_mask.h b/sys/vm/uma_align_mask.h new file mode 100644 index 000000000000..666633350b9d --- /dev/null +++ b/sys/vm/uma_align_mask.h @@ -0,0 +1,36 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 The FreeBSD Foundation + * + * This software was developed by Olivier Certner + * at Kumacom SAS under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _VM_UMA_ALIGN_MASK_H_ +#define _VM_UMA_ALIGN_MASK_H_ + +int uma_get_cache_align_mask(void) __pure; + +#endif /* !_VM_UMA_ALIGN_MASK_H_ */ diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 679fd5ef1187..506bc63033ba 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -149,7 +149,7 @@ static uma_zone_t slabzones[2]; static uma_zone_t hashzone; /* The boot-time adjusted value for cache line alignment. */ -int uma_align_cache = 64 - 1; +static int uma_cache_align_mask = 64 - 1; static MALLOC_DEFINE(M_UMAHASH, "UMAHash", "UMA Hash Buckets"); static MALLOC_DEFINE(M_UMA, "UMA", "UMA Misc"); @@ -3182,7 +3182,7 @@ uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, uma_fini fini, args.size = size; args.uminit = uminit; args.fini = fini; - args.align = (align == UMA_ALIGN_CACHE) ? uma_align_cache : align; + args.align = (align == UMA_ALIGN_CACHE) ? uma_cache_align_mask : align; args.flags = flags; args.zone = zone; return (zone_alloc_item(kegs, &args, UMA_ANYDOMAIN, M_WAITOK)); @@ -3191,11 +3191,19 @@ uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, uma_fini fini, /* Public functions */ /* See uma.h */ void -uma_set_align(int align) +uma_set_cache_align_mask(int mask) { - if (align != UMA_ALIGN_CACHE) - uma_align_cache = align; + if (mask >= 0) + /* UMA_ALIGN_CACHE is also not permitted here. */ + uma_cache_align_mask = mask; +} + +/* Returns the alignment mask to use to request cache alignment. */ +int +uma_get_cache_align_mask(void) +{ + return (uma_cache_align_mask); } /* See uma.h */