From nobody Thu Aug 01 22:27:58 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 4WZkB71vLLz5RZfW; Thu, 01 Aug 2024 22:27:59 +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 4WZkB63Yydz4ZXN; Thu, 1 Aug 2024 22:27:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551278; 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=f5NEbLS+yeeo5GOzx3gcyWh5mOvRVsp3ilsOEkkOec0=; b=KJhtC2gWRIYwCR9H+7DpIR0w49IDoRpyp1hIo2inVKN5LAe3buxRbY+qwh+dKg1uVQpJHJ dYMcvaL8ESmyxzYIzAXlcBeyxX7M00Xp6b1Y1aDdoWxwLI9+EKd77pWZfGZ46GUvDz6SLt kfcXAeGBFksmS2ZtGv8jn3GSANwyehOBndcfCBBb1jeeoRLNdKMw3PqkAUVL/BQYSBS9bA SnmktH215hX+Sbbtqj16g3gJ8/XMbu9i0QX9Cp1K3/1meIixFaFheQkkckgFix7c5OOaop UXC2SiVvymuSeiHRP0UXj+dvkRDdzvXoAyIECtnUiN9H9E5WQikb48KLikkvlg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722551278; a=rsa-sha256; cv=none; b=icZGUaeg4axMbR4XqHWrWJKuAOY+rtGdFbOY9bFh3uJPWazBYai8nz9Yrym17DpuZ9/0FU w8ZR2tZaO/791wI7if9EMkPTHJdfgGCZap9oN52No58eXTzEJ5qVTaKx3TjpYOTBXFYCpX dxz30+5ViTBzM/jXvK4itxDfu42lbh2iuETR38qgI/3JY7IGSBiGaSmRy2jJWaO5mj2zIb c1BhvSSSDLDvYT51q7zzDUFY/vl+kTAIcBrBIy1pYxunU2ziUt2hm+0UZyFJ+YFFIxMhYM RqZD+eYjZyI48+fh/A5hPRZHpdGl16IAu/SAGXwpU+JNdzzubtnjtFiFSJIIJg== 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=1722551278; 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=f5NEbLS+yeeo5GOzx3gcyWh5mOvRVsp3ilsOEkkOec0=; b=USxQzK/RHxF/xwN/kjc0sDSiB7f85jYxcN7GxnBhhIgmNSchgxlX+d+ks+AkhZJDhj+0gI 6onegGNieANZF64NyzMO95ulfe7r3z2xaJFugZRFG+IAA7zHIBygawtvURfVBX27D+nQqO ZlcaYwfJO4VUX8ss0caj9yanmtEcb0ON0/63xFiAqNGkZ3eHjLwkfXSwJJQy8zkHYRnSHh C9pTIWNSD76z95nLru3/Vc4cfV0/uj16qY1rQNTKqMIAHjTMKtWAEfsd91rUn/VOnOH4u+ wYb/XK6xlbPVoXow3aCN1k2RDXWdrqT7A5wzid8KwXKGIaFPw9KcIVRBttoGzA== 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 4WZkB62mBTz12ns; Thu, 1 Aug 2024 22:27:58 +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 471MRwsF028422; Thu, 1 Aug 2024 22:27:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471MRwg5028419; Thu, 1 Aug 2024 22:27:58 GMT (envelope-from git) Date: Thu, 1 Aug 2024 22:27:58 GMT Message-Id: <202408012227.471MRwg5028419@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: b5d03f42e9bd - stable/14 - LinuxKPI: Add kmalloc_size_roundup function 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: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b5d03f42e9bdfa31a4d3db06640f25f091a1fc5f Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=b5d03f42e9bdfa31a4d3db06640f25f091a1fc5f commit b5d03f42e9bdfa31a4d3db06640f25f091a1fc5f Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:08:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-08-01 21:15:04 +0000 LinuxKPI: Add kmalloc_size_roundup function kmalloc_size_roundup reports allocation bucket size for the given size. Sponsored by: Serenity CyberSecurity, LLC MFC after: 1 week Reviewed by: manu, emaste Differential Revision: https://reviews.freebsd.org/D45841 (cherry picked from commit ab1a5d8e2ade8c706ff8cd7aa3d5c88a95633228) --- sys/compat/linuxkpi/common/include/linux/slab.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index e2d17e0558c2..3f2d1621e148 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -237,6 +237,14 @@ ksize(const void *ptr) return (malloc_usable_size(ptr)); } +static inline size_t +kmalloc_size_roundup(size_t size) +{ + if (unlikely(size == 0 || size == SIZE_MAX)) + return (size); + return (malloc_size(size)); +} + extern struct linux_kmem_cache *linux_kmem_cache_create(const char *name, size_t size, size_t align, unsigned flags, linux_kmem_ctor_t *ctor); extern void *lkpi_kmem_cache_alloc(struct linux_kmem_cache *, gfp_t);