From nobody Sat Sep 28 10:38:11 2024 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 4XG3hN092jz5X8V8; Sat, 28 Sep 2024 10:38:12 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XG3hM56mwz46nw; Sat, 28 Sep 2024 10:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727519891; 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=lgB+JCkDwmwMXRIzb1t6fLICgcQUSlKO/TEQiD1jycU=; b=JyUVDjXDKryd98QFUFCwgTfNDvZEYNcCD/Vopvy8kScugqkzRwXSTg0ZTF8oXmXyzD82pI vqYuTXPRamLSr5E4HdtdEbKXZal5tMSqKaVPIBuSN7KeYYXWwhZslOXZskMwhw9DBAImHG LSevK0/jriE6NIzwNsfIdtiHhvr8ES4kQLt2jHZrNkJlu6zrx5+VBBqhHiaKakKuODwZe4 Ll8qgvy7XsCzKIgC4oPgbgeQ8m/nxwG6z3TKHGZykRDXYCKHbMo/kZTR9VSsztKM1WcuHK KYZOZ2sy6uoLr5dzdDIT5p5tIS0hyS1nsvCySra8TEml947UDVcwQRJklgTJqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727519891; 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=lgB+JCkDwmwMXRIzb1t6fLICgcQUSlKO/TEQiD1jycU=; b=bG5ICZz+DWpwStDV3VimgF/94m+9i12p2il22DjTsbjH4KYNbjeqGj9KGGyU/8KoflmWFG roWltxUJEVoqkQn0501CPB0xsMmgf+JVb7VpJ69jKWTlPFeE941mm8nUCvR8/7TPk43kyz EHH9t2BpVNKf6/9pdvGn2BTliIor7hdVKnPY1gzPBKIv2nNRRfWdu4xXLzYCSqxjhhW+UI xT+JSrJUbpTT1i68yS/HJJCILjS/0rcgKRvpYJPv2JG++iE+QGMteI5eJ/KVeW5AmciD6f PZEibO3QZxk7K10euypyyddc3PqxkCLCj1/tjuiHPTEDjxbcihRGn4USmz+IoA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727519891; a=rsa-sha256; cv=none; b=wcb1UMSPzWkQOEiMxkfFq9jztnNaFHH0r0l9zlxopXHEmQpc+qQHr2TEObtO0TQHI7vuNE B12IuKXTLpfOeGxQduQ5oDUCDHLoZUaWTkX+WBoTxGhUmWTsEg3DNNWT+vhaaNAfsPaC7F n87gC4LPyEDN2p7PU7lJWnUnPaI3HNykpQ2pZzKAmWGbszB9+59fD+Jwty6IZmWPH9RUGP pOyWXMdA/sRz++GG578Gt0MWOHNZXqCrM40tCYHFSYRcZDJ+SyBczjsdXIhEfE52ku7X+3 smKATuS58IkVA1tGhcUEuYYcihXtItay2qjpvG79Dt8GzS45YXKg4wvsoyzfcQ== 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 4XG3hM4Jg2zLc2; Sat, 28 Sep 2024 10:38:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48SAcBQA097660; Sat, 28 Sep 2024 10:38:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48SAcBeR097657; Sat, 28 Sep 2024 10:38:11 GMT (envelope-from git) Date: Sat, 28 Sep 2024 10:38:11 GMT Message-Id: <202409281038.48SAcBeR097657@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: f9edc5b3f687 - stable/14 - LinuxKPI: move __kmalloc from slab.h to slab.c 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: f9edc5b3f687ad0cd01ee4cac664a95d21413f3c Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=f9edc5b3f687ad0cd01ee4cac664a95d21413f3c commit f9edc5b3f687ad0cd01ee4cac664a95d21413f3c Author: Bjoern A. Zeeb AuthorDate: 2024-06-30 20:37:07 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-09-28 10:35:12 +0000 LinuxKPI: move __kmalloc from slab.h to slab.c In order to allow the allocator to change in the future move it into the implementation file from being an inline function in the header. While here factor out the size calculation and add a comment as-to why this is done. We will need the size (_s) in the future to make a decision on how to allocate. Sponsored by: The FreeBSD Foundation Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D45815 (cherry picked from commit 1f7df757017404011732196e65981d9325f7a89f) --- sys/compat/linuxkpi/common/include/linux/slab.h | 9 ++------- sys/compat/linuxkpi/common/src/linux_slab.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index 3f2d1621e148..07c16884b00e 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -92,6 +92,8 @@ struct linux_kmem_cache; #define ZERO_OR_NULL_PTR(x) ((x) == NULL || (x) == ZERO_SIZE_PTR) extern void *lkpi_kmalloc(size_t size, gfp_t flags); +void *lkpi___kmalloc(size_t size, gfp_t flags); +#define __kmalloc(_s, _f) lkpi___kmalloc(_s, _f) static inline gfp_t linux_check_m_flags(gfp_t flags) @@ -108,13 +110,6 @@ linux_check_m_flags(gfp_t flags) return (flags & GFP_NATIVE_MASK); } -static inline void * -__kmalloc(size_t size, gfp_t flags) -{ - return (malloc(MAX(size, sizeof(struct llist_node)), M_KMALLOC, - linux_check_m_flags(flags))); -} - static inline void * kmalloc_node(size_t size, gfp_t flags, int node) { diff --git a/sys/compat/linuxkpi/common/src/linux_slab.c b/sys/compat/linuxkpi/common/src/linux_slab.c index 68117d1c9fa7..72b35fee9214 100644 --- a/sys/compat/linuxkpi/common/src/linux_slab.c +++ b/sys/compat/linuxkpi/common/src/linux_slab.c @@ -207,6 +207,17 @@ linux_kmem_cache_destroy(struct linux_kmem_cache *c) free(c, M_KMALLOC); } +void * +lkpi___kmalloc(size_t size, gfp_t flags) +{ + size_t _s; + + /* sizeof(struct llist_node) is used for kfree_async(). */ + _s = MAX(size, sizeof(struct llist_node)); + + return (malloc(_s, M_KMALLOC, linux_check_m_flags(flags))); +} + struct lkpi_kmalloc_ctx { size_t size; gfp_t flags;