From nobody Fri Jul 26 11:51:41 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 4WVmLj3b81z5S0J6; Fri, 26 Jul 2024 11:51:41 +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 4WVmLj2y99z4cCV; Fri, 26 Jul 2024 11:51:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721994701; 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=FSJ1JBS8EvT18kijgdMBVp5Hv+22r1C1st6syRUTVyk=; b=JjK+1If17RFhk4qTXPmGHggAzgbGXc2OhOWdrb9Kf3nFyygc7//FAwg2ytgv8eyowZmBpp XrFKswHQ1d2EARTQxraB8xxSxVfRObKglgGkPsqvw4+rCc8lyqqEjZqX2K8qYuJIX9Ygp7 A5o6dqeFhjSLF0nNtIqmjXYiTATVAs820BGLcgApsDqwawLZdV5MSU8hP30Xp42MPLhqk3 gq95bBvN240bd28RIfxhtT18XAx+eWjsrEl6GSagov434EQeXGdDDfJZ4ARbG+NfGXDjF/ Doqb9zCoNXp+mqYQa9ZUniN/P1RwG8jbbP/vHPCtfqlWMA5CNsoP/LwPsAiQZw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721994701; a=rsa-sha256; cv=none; b=AVjB2xUzG2K8qmWLMoyafh6vHipqw8FTFePizBVJx/Q6IjtGRHOLdwvlBxhl+2mDue4WC1 8CfwK7hX17lbbIkFjDoU4UkIQdx1mhUm1jihCat9wXtwHljP/S5C0henUzhihpxyNXKPIh 8WJKAChvVSnJnyE0wciK+SjN96s/2XBr0lw9ZWJpxbmtZaubF+CTWR3kC2h1DNxU1RAOwN r/0b4gUBYC8qFb09y8IAUomUciOPQv897vYs5YYd7cKg9DBH+PeCdlXscq18fTnh/nGFqU QGcDY6uPQ93CGOWkpAmgPV1SskGMmywX8+gSYhPyqHDNxqPkGzyCEDY/DzH00A== 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=1721994701; 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=FSJ1JBS8EvT18kijgdMBVp5Hv+22r1C1st6syRUTVyk=; b=COTjNbSwk4sIkvvE6qcHdk4uCmf2Ak5RGLWElV5nLK0vwgRAUtiTa4Y5TQsD3e7R3SvmpI My068H9lFKJv74HS7v2adCQJipyNhz2K58cTv80UFjH7bWKRXJvaMVYI0uRQxMO5WkBDPN /l4FANBTp8uSilPdYMwv61ZK7S/AWIAU9jmxsqHG4YCzeElG1miCTCVpQGx6f7SQi88S7b JmdGrCBLN/qZTAPgYdFUoRAcWHbqD50UsWtoH25y2BP6F4fIlm9HKrfY5LKHgKuHYbkqw2 jrbHQpTLVxrdOXckpRe1wi4uG3pD0LeqH/Kzj511RM2oKiEpSFof08zMeia3Bg== 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 4WVmLj2YTSzMX9; Fri, 26 Jul 2024 11:51:41 +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 46QBpfGB000936; Fri, 26 Jul 2024 11:51:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46QBpfBo000933; Fri, 26 Jul 2024 11:51:41 GMT (envelope-from git) Date: Fri, 26 Jul 2024 11:51:41 GMT Message-Id: <202407261151.46QBpfBo000933@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 1f7df7570174 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 1f7df757017404011732196e65981d9325f7a89f Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=1f7df757017404011732196e65981d9325f7a89f commit 1f7df757017404011732196e65981d9325f7a89f Author: Bjoern A. Zeeb AuthorDate: 2024-06-30 20:37:07 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-07-26 11:51:04 +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 MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D45815 --- 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;