From nobody Sun Jul 21 13:14:47 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 4WRkQw060jz5RVP0; Sun, 21 Jul 2024 13:14:48 +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 4WRkQv3Y5Jz4Rlw; Sun, 21 Jul 2024 13:14:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721567687; 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=IW7VPWtTdGhfR/YoZsHqJkIDA2MVAaFK5ZtoYBm2k0E=; b=DhGx/yznFu+5dbpGaQ3lWkCksmOc20iVsUe8pSWBHH2xyqC4kGlgtZAHFuWlulW2KEErWc NcQ+G+II4kIz4hs6aod85He1DyCzeIb0i5EPzRRh5umn/wClIFOgmlSe/B43oDEIeCtoYh 9fWyyvXmsvX/B7hgQSi7MQxliUGjUR1FhmdNPkQsPatG9DaK5Eafj79jkjXp2UukGSS9LR 9P3MfeHOwP79QpsLp89wnJawj7AbNHK9gu4O1jKFOBcA5/hlYg9otc8QWhdDqvRBdeKzYU FEefeEvaMj50nFi25MRagy9l+6Vz14VX6BB+vmlUWqt+M0XC8hoNiMfnkjeepQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721567687; a=rsa-sha256; cv=none; b=U4dJ45itl43k3wIouF+yE3kzOmv0eGuLEhj7dpNL3LHodhh65iQfTom3H4U/2jTywbUxax Ma+0XBB9jcDiJ42/y88mUiJHsZiBs0Bq8ozElYUhqNe5bHLWQrzBooYEh44YxVb2R2mKBj FfJ4PpWA/sihu6B21nNWWaFjCaQdcodHApGFX/NmoIKW9PTxKP2H/nOPOp/kH4niTPhimJ PvjDOOGQf0qxUWB0osLNYInJHMjGtGlStf79HSDO1LMJZyRV2C8mB/Q5WJA3bt8LvJPdIz N9mNO4P7VqL3kjVWtD6GLtcImYpwKVzcla+ikNOMPEKNz65GAzSNXhtPFIXXTw== 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=1721567687; 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=IW7VPWtTdGhfR/YoZsHqJkIDA2MVAaFK5ZtoYBm2k0E=; b=nn7Gf9soGBUDe6WeTNAT1mRecMZLvUs+U9gJJULyQdPI0wHTW5dvtzRSkIjVhmKfFWtYTQ IFoszfy2y3zJSGDvZcQlHOw04erSqj4l3it09g5gexVeYaltRRdUGdC36tnaRMdOnaIHcA rAVlILut6OSJBB/Za/mBqASt6sMJLp1H/tmofbGZdtJTQqHS+/XuE/lKbZIQFwiwIiuZVu ufgfbzVoBUg7vOnUaWMpxyfSSTAtIym+K1EFRKqISjKtmadRnyqiNB9kQB5cts6d1HQzko LehRSO9iWAGlcjXjy2EtQ7BP2dsnIrmqOie6nBksqpiauL+FUZ//uudNmV1Kcw== 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 4WRkQv1vCBz11Zf; Sun, 21 Jul 2024 13:14:47 +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 46LDElma022990; Sun, 21 Jul 2024 13:14:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46LDElb2022987; Sun, 21 Jul 2024 13:14:47 GMT (envelope-from git) Date: Sun, 21 Jul 2024 13:14:47 GMT Message-Id: <202407211314.46LDElb2022987@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: ab1a5d8e2ade - main - 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/main X-Git-Reftype: branch X-Git-Commit: ab1a5d8e2ade8c706ff8cd7aa3d5c88a95633228 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=ab1a5d8e2ade8c706ff8cd7aa3d5c88a95633228 commit ab1a5d8e2ade8c706ff8cd7aa3d5c88a95633228 Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:08:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-07-21 13:08:37 +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 --- 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);