From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3962CD4F5B for ; Thu, 5 Sep 2024 08:18:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43B4E6B040E; Thu, 5 Sep 2024 04:18:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C2806B0413; Thu, 5 Sep 2024 04:18:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23C586B040E; Thu, 5 Sep 2024 04:18:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F0B696B040B for ; Thu, 5 Sep 2024 04:18:31 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A24A4121A17 for ; Thu, 5 Sep 2024 08:18:31 +0000 (UTC) X-FDA: 82529982822.03.7DAA0E6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 01EE680005 for ; Thu, 5 Sep 2024 08:18:29 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q9eRubES; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725524202; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RxPTVqTsj+dB3d6PwaWnoJoVe4fFUveGlukeyS5pbJk=; b=TjeNUJRuQW8X5dg6przvtnIP7umW0phTliNmgFpkjhQI62hJ+APak9a/VvkO6lIuzrCuGV kMbeYMGYp7w0JqErSltlol0k+8LRa5r0gxB51aEW4LGhwAprGAKFoHxV0QIFFoXxKZtf3v ZmmjdmjT7ujcfEUibIzb/Gmaatu3zwM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725524202; a=rsa-sha256; cv=none; b=XYMQRgfin/NeRcG6N2rpb7O+U05N1bnsPlqctX2T+SMEnxRUWnTozoa4gp0LnXvHMrn0SD F9rvCAc9QDXJ4g4RAQi9n7oFYZrkFwQ72kC9v79BWSulvdCOZKcSGzJhwixOZ5oNtZiTv2 oLIj9KvGjA95pvnDRv8mlvz5DvYPwfs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q9eRubES; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B5D815C5609; Thu, 5 Sep 2024 08:18:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B4E1C4AF0B; Thu, 5 Sep 2024 08:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725524308; bh=gNHAlcjyUiQhdcMW88pODZCcV2NS47zUsaBbz3VhaOk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q9eRubESyP9v1sdwltjL1AjeucOgMuA8zDtmIj3k5nCdhUqG6gX4gqWU4BWByoOfL H/QBe22M52wvE7OBjrGsj78qOlHjXqj7c35g/OYONgQ7+JTGj5Q4rqUf6dM69dTglB BnzXmrOvHQB2VavS2cq31+50UCV/UADMlU9wvnp0aoXRTEZ3cfaIeKRIWPuwYB3zyd vOq48Wjg+jEqmmEXvFeRLp7B53YHvXrOLVLCjquOYCZ74/FcE0gID9UM+BCT33z5fM Y2LYLlzoZlFgBFBN2Vv6QgP2ZFw3I94/JYWWRilSBBGYQiMOaQPxXxPP3cGNW7+3un 3d8eYeV5FD+jw== Date: Thu, 5 Sep 2024 11:15:37 +0300 From: Mike Rapoport To: Christian Brauner Cc: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Kees Cook , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v4 15/17] slab: make kmem_cache_create_usercopy() static inline Message-ID: References: <20240905-work-kmem_cache_args-v4-0-ed45d5380679@kernel.org> <20240905-work-kmem_cache_args-v4-15-ed45d5380679@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240905-work-kmem_cache_args-v4-15-ed45d5380679@kernel.org> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 01EE680005 X-Stat-Signature: ixqqwwdmkad6c9ip4g51a7zahr7cu1zn X-Rspam-User: X-HE-Tag: 1725524309-504702 X-HE-Meta: U2FsdGVkX1/1zZ8k42OBdjoaTLtVJUNh+fqRZhl1tGnUoHqyA6A1hJgVlXj6Qz2yS9TVAb26TLQE/zGOq6LmrPUX09mswV9o1w/lZfFyCaUuB+5ROnM2G+K4t5RkCozSU35fozdK3nT2lhp2nsN/nMN5B2yz6KTK1Cw0V/25yvN1UJKdi08LwXf0J1RuPhXRoT99gmGyiKwvVDDMMuL96LzvpBFh3a4rB4dOH5+Db0NYvb7qS8GBaYnreVoYFZuQTriMnJHDEZnhP5Y6Ala1MqNjdvw5fKIlJtL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kLEs0mYe6Ou+fWyz4vjedBBVXoez8QWqusTJO+1OWQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Sep 05, 2024 at 09:56:58AM +0200, Christian Brauner wrote: > Make kmem_cache_create_usercopy() a static inline function. > > Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) > --- > include/linux/slab.h | 49 ++++++++++++++++++++++++++++++++++++++++++++----- > mm/slab_common.c | 45 --------------------------------------------- > 2 files changed, 44 insertions(+), 50 deletions(-) > > diff --git a/include/linux/slab.h b/include/linux/slab.h > index 8246f9b28f43..d744397aa46f 100644 > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -265,11 +265,50 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, > struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size, > unsigned int align, slab_flags_t flags, > void (*ctor)(void *)); > -struct kmem_cache *kmem_cache_create_usercopy(const char *name, > - unsigned int size, unsigned int align, > - slab_flags_t flags, > - unsigned int useroffset, unsigned int usersize, > - void (*ctor)(void *)); > + > +/** > + * kmem_cache_create_usercopy - Create a cache with a region suitable > + * for copying to userspace > + * @name: A string which is used in /proc/slabinfo to identify this cache. > + * @size: The size of objects to be created in this cache. > + * @align: The required alignment for the objects. > + * @flags: SLAB flags > + * @useroffset: Usercopy region offset > + * @usersize: Usercopy region size > + * @ctor: A constructor for the objects. > + * > + * Cannot be called within a interrupt, but can be interrupted. > + * The @ctor is run when new pages are allocated by the cache. > + * > + * The flags are > + * > + * %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5) > + * to catch references to uninitialised memory. > + * > + * %SLAB_RED_ZONE - Insert `Red` zones around the allocated memory to check > + * for buffer overruns. > + * > + * %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware > + * cacheline. This can be beneficial if you're counting cycles as closely > + * as davem. > + * > + * Return: a pointer to the cache on success, NULL on failure. > + */ > +static inline struct kmem_cache * > +kmem_cache_create_usercopy(const char *name, unsigned int size, > + unsigned int align, slab_flags_t flags, > + unsigned int useroffset, unsigned int usersize, > + void (*ctor)(void *)) > +{ > + struct kmem_cache_args kmem_args = { > + .align = align, > + .ctor = ctor, > + .useroffset = useroffset, > + .usersize = usersize, > + }; > + > + return __kmem_cache_create_args(name, size, &kmem_args, flags); > +} > > /* If NULL is passed for @args, use this variant with default arguments. */ > static inline struct kmem_cache * > diff --git a/mm/slab_common.c b/mm/slab_common.c > index 9133b9fafcb1..3477a3918afd 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -337,51 +337,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, > } > EXPORT_SYMBOL(__kmem_cache_create_args); > > -/** > - * kmem_cache_create_usercopy - Create a cache with a region suitable > - * for copying to userspace > - * @name: A string which is used in /proc/slabinfo to identify this cache. > - * @size: The size of objects to be created in this cache. > - * @align: The required alignment for the objects. > - * @flags: SLAB flags > - * @useroffset: Usercopy region offset > - * @usersize: Usercopy region size > - * @ctor: A constructor for the objects. > - * > - * Cannot be called within a interrupt, but can be interrupted. > - * The @ctor is run when new pages are allocated by the cache. > - * > - * The flags are > - * > - * %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5) > - * to catch references to uninitialised memory. > - * > - * %SLAB_RED_ZONE - Insert `Red` zones around the allocated memory to check > - * for buffer overruns. > - * > - * %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware > - * cacheline. This can be beneficial if you're counting cycles as closely > - * as davem. > - * > - * Return: a pointer to the cache on success, NULL on failure. > - */ > -struct kmem_cache * > -kmem_cache_create_usercopy(const char *name, unsigned int size, > - unsigned int align, slab_flags_t flags, > - unsigned int useroffset, unsigned int usersize, > - void (*ctor)(void *)) > -{ > - struct kmem_cache_args kmem_args = { > - .align = align, > - .ctor = ctor, > - .useroffset = useroffset, > - .usersize = usersize, > - }; > - > - return __kmem_cache_create_args(name, size, &kmem_args, flags); > -} > -EXPORT_SYMBOL(kmem_cache_create_usercopy); > - > /** > * __kmem_cache_create - Create a cache. > * @name: A string which is used in /proc/slabinfo to identify this cache. > > -- > 2.45.2 > -- Sincerely yours, Mike.