From patchwork Wed Sep 4 10:21:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790354 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 765E7CD3431 for ; Wed, 4 Sep 2024 10:21:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05D316B0303; Wed, 4 Sep 2024 06:21:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00B076B0304; Wed, 4 Sep 2024 06:21:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DABC46B0306; Wed, 4 Sep 2024 06:21:58 -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 B7CF46B0303 for ; Wed, 4 Sep 2024 06:21:58 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 32AD7A0F8F for ; Wed, 4 Sep 2024 10:21:58 +0000 (UTC) X-FDA: 82526665116.02.906AC57 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 65A891A0007 for ; Wed, 4 Sep 2024 10:21:56 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pVRvFeeI; spf=pass (imf19.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445268; a=rsa-sha256; cv=none; b=YQUNAGm8pPkLdSM2mx9zdwG/57OcOw1OAyzj+r9+MxtIlOYpSbuWD7yQxyaoBNirz/H8gX 04gvwM9Rktg7i2hsRvSwoceeCh5ctK7PgU/HXEaFShwPOLqrBfYf5/q8apewtkBUPwaU4e RFCmt977LNpq3ziNzJ6hNue6fkBSgLI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pVRvFeeI; spf=pass (imf19.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445268; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=G4ZElHDl2PeTAu9EplblbOqMGtct6qvWga7h7ea/v+0=; b=DBkf7EdcdDjh5TV0fMYIC21zMI17XJuyIT0/3fqdqRREHCCManiNuUPSWYCh96/0B9Bk56 P5LdUX/PEk9UP0g2iZoTa8A+ERPFiI/EMW8pTlX9qNgwsMiBJMbrisyT0OQk1Zu+xUadgG 1rBMnfKyG3XQhqCAbISu5wUcCSXIMb0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 299E05C5467; Wed, 4 Sep 2024 10:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0CC5C4CEC2; Wed, 4 Sep 2024 10:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445315; bh=aZEAASsBiFk/RgRLba541LPDxJ17oriKgsD3TIAIOy8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pVRvFeeIXH04mtBi0pL304wNLzScNm6KRBcMNa+Kk3rJjFcQUjqct+CJhwG66KIy5 MzkAx0bUoO3qqI85wSK+22x/YC0YPxsIIS4OrO7zFh5MgezfDiawCwkChw8Mn57Orf aOmdR4bdcn2J0YD/lY6MIbAP76giGif1VTmMlO65s77Z25UQ3eMrUb6jE8Z0SL1H1l Oc9LHKBhX5vamFvnc/buanj7jLBG4pMRdENbAkzyWqWkeYy7kLrjmiDvc90WqZpeGB a5XITsPViOqtbzhFKuIOgNpN7kfd1fvQhpIcYhQigq7u81tCFyq281BXUhqi8zMhoU MkMdBVI9gWAQg== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:06 +0200 Subject: [PATCH v3 01/17] slab: s/__kmem_cache_create/do_kmem_cache_create/g MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-1-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2022; i=brauner@kernel.org; h=from:subject:message-id; bh=aZEAASsBiFk/RgRLba541LPDxJ17oriKgsD3TIAIOy8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNm5xyytO7rTxql9L3d59dyG0jNp6epyKrNMn79vu jrrKGNWRykLgxgXg6yYIotDu0m43HKeis1GmRowc1iZQIYwcHEKwES6Whj+e89ZwziJweJX1ePQ /xlPfa8++PKG5Sfj1j8JW+PFfyYIrWNkuPyp5eJFc4m2ZcpXXhxkPDL3fYi/R09dzyxzxQZ+7eR gDgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: jcbkwrxbmn5tt6cswygige9px5dsefzs X-Rspamd-Queue-Id: 65A891A0007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725445316-802193 X-HE-Meta: U2FsdGVkX1/h5IDdF6DSFD4te9i0zniQQ+ovf2zZlhbAxMhBS562A4+et9LcjsN/JTBS0uFhVxgwiAH9BDdH0lpRPgFcbrhxxFnFZeBp9hGCPDudQ4bmPV1eWYXW4Hygmv0dPkLZu5dZ6X3Xv2iSlSQDjppuhK9EwDff0fx1KMsweRuQEIUSqkhocGO40oQ4jqUv9YtwXrbptmS5tQc9ZUATz7OYSGru4u10F3e1+N57+avAQoOrTre8sTUct7TmOMwmHpZ8B5EC4F8OwQTXpY/o41Ple5vfRNe7ThD3jTcJsh0AwHVSV4OPZ06MWsuvjZfwnoTcJ1BvQu53zySVt3XziH0GWNdZJqfFEdJqJ/CdsBYqqKaGFGyHXVlMmtN9AHBz7oD46vhruHawB6MNRSuu7eOgtBoK3SHz6JxxIHSl77/qZgTZuIsMY6w8lT8DsGH1NVGNZwl62b6xMJIqmQDzhLY9Gba3L5VvQ5WNrIuu727E5LsiXPu8dYyhdXP17Ff9sNq6aEd9Gy1d2XUdEeZdkUMwbC6K//B1eW023ppmYoWAVU4KoJkhvB/bKpG9vQVWX9+oirDDL6CPy17zDmFvWHL4gJwc2Gs8nsewpV0ExVCNvp/v53HCi5cg8IDw+SryO76AFdgBhDWRQu+RMKj7HiLHHejK0FS4dt8U3ZPyWBIUHcQuPdiy/xnaoQeBMybOt/7QkDR5+qxU0MBg50tJF7n9R/0ROWaEh+b0b+xwhG0kWhwRD/jdZPMcdcql8k72hizS/yDy1OvmyprBElEIXDv/xlIGmqcyZPvch0TXaW0D4aSwu8PoWpMkiz6HuIjyLvJplqbd0dk3nyhZwSkAsidx6ofdIG3XnwFQRofXjf1NwVz+wdBEge9PUpNrUyRDFXlmRTD+lA1ThWmkq9Fdk4iLBENm9KzFIqWchciu6cZ7fAUK270s4LqosXMpeaNudf/35WGZVKVV2yk wnocgmqG +Jodts57K2lGWNxKes0BvsBdb+1/bc3yVK8TEjfQU/nm8ERY7/8y4xHnflJPPyVLfH7oIqpiaKyPcnmMBdi4kTTPD9OfTDWHyf13p1rr08C7v/cc8DB+xq6DT9Ct/FxUcBeLT29vP//V2zuCLpewc6Iq0CxvmJFLCCXW9a5RLDSgyjIlS347gGRlPfKDQLYDLOynjsjZjtEFAhirDmMDQPEypUVt7i+3KB/EUeBNq5Fyq7eczDekyIwGktfQPaKOcHZpcfwd0q2X2QsJmFpdZHnhGWqP3A57JukarE3vKXZudfUN7Y3GLxFYW3JH5e7kHj1wL0Pb7gYqrG1St3rQtByLMyLLiEjxfoE/+5Bkr5PbU7JG8+/XmOfssLSyxO4IBhOaThrGbSce357xa1kExYxSXp32NeUhSlQiL 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: Free up reusing the double-underscore variant for follow-up patches. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- mm/slab.h | 2 +- mm/slab_common.c | 4 ++-- mm/slub.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index a6051385186e..684bb48c4f39 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -424,7 +424,7 @@ kmalloc_slab(size_t size, kmem_buckets *b, gfp_t flags, unsigned long caller) gfp_t kmalloc_fix_flags(gfp_t flags); /* Functions provided by the slab allocators */ -int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags); +int do_kmem_cache_create(struct kmem_cache *, slab_flags_t flags); void __init kmem_cache_init(void); extern void create_boot_cache(struct kmem_cache *, const char *name, diff --git a/mm/slab_common.c b/mm/slab_common.c index 95db3702f8d6..91e0e36e4379 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -234,7 +234,7 @@ static struct kmem_cache *create_cache(const char *name, s->useroffset = useroffset; s->usersize = usersize; #endif - err = __kmem_cache_create(s, flags); + err = do_kmem_cache_create(s, flags); if (err) goto out_free_cache; @@ -778,7 +778,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, s->usersize = usersize; #endif - err = __kmem_cache_create(s, flags); + err = do_kmem_cache_create(s, flags); if (err) panic("Creation of kmalloc slab %s size=%u failed. Reason %d\n", diff --git a/mm/slub.c b/mm/slub.c index 9aa5da1e8e27..23d9d783ff26 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5902,7 +5902,7 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, return s; } -int __kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) +int do_kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) { int err; From patchwork Wed Sep 4 10:21:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790355 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 6507BCA0ED3 for ; Wed, 4 Sep 2024 10:22:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB5E08D0243; Wed, 4 Sep 2024 06:22:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3CF38D0242; Wed, 4 Sep 2024 06:22:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB7938D0243; Wed, 4 Sep 2024 06:22:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A44EC8D0242 for ; Wed, 4 Sep 2024 06:22:02 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2657AA9E45 for ; Wed, 4 Sep 2024 10:22:02 +0000 (UTC) X-FDA: 82526665284.16.26AA3F5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 549EC40019 for ; Wed, 4 Sep 2024 10:22:00 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="R1y/uMG6"; spf=pass (imf17.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445224; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jxVftAYU0xDJ8Ce3plBhtpBX6qnB3UkHBV8DhWYp8Qo=; b=m+wkY7ksCDS1cxshcEUw45liTXkdGXjWa44+8IjMuhcjK7ACYClDwnc7dH/3duy+cNoJvd IZZ3VsY5+YBvXLEVUCVS3UQF34nNinoAIQ97MFpdndasGdTKw+DUR4D6KoIwjRZ1uf64p1 ZuRqLTzZLSR87PZEREHy3cEijIF1LXI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445224; a=rsa-sha256; cv=none; b=yZhExTFJ9xnLe6hTtG7cnLyNTMV7ur9u+pguq4L/M++XWKriBBp10QXwhCsD2bQl0A6CV7 GCB6f5MNOoPFKKiQtL39F9ExbcvA9tMhc8lDBWe6X4vPdtpeHyx2rw0FcWsLm94brOgWyU RnUrgIt4IDLKGKP3MZkjgJuRKttJzag= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="R1y/uMG6"; spf=pass (imf17.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0AA1B5C5706; Wed, 4 Sep 2024 10:21:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0DB0C4CEC6; Wed, 4 Sep 2024 10:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445319; bh=YrF0YLTWmhzO7ohK2/AAEF++N1Zrk2GGMPwzT5f/roQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=R1y/uMG6e0aaQJlJr5qnvCpHQ3FGR8xCSzgrJj43XHhClJcTH4aQgaRS0vIgoHBt1 jw1g4OsII1pDgv1IGB/YhIhdBx2fO2Ffq3uhe3aCPNGgyPcF/W3VCB+Q7u79OOzaUD cVhFkmhqSf5uA3i4oRlL38Oe6CMmbIMWymgqw+7gO/ElkY7Mp2Bac/wpTba6o4VAZ/ jEZvnnO9LHyDpghOuFNmjRsPUZl40k3dCPjCFn3294/WQRCsfb7Y6FnjVZQwM8XgOS y4FhlZBWVAFW601oThoHu20D5kW0/nsSXsajbVjzMdaPQqDh3LPyIF+xk17yYUY9Wj WbK8uxxKCt+AA== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:07 +0200 Subject: [PATCH v3 02/17] slab: add struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-2-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=5895; i=brauner@kernel.org; h=from:subject:message-id; bh=YrF0YLTWmhzO7ohK2/AAEF++N1Zrk2GGMPwzT5f/roQ=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNn5Zy1b43m913E1vBfFXhlN6hf4K6t8o4d1sZH0D NOX0RkaHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABOxncrw32W15y+9mCesh/rF jnjanXMQy1z6QeRw3pwetYV7bfi1LjMyfM0T6tlg35cW4vT058FtGzhnW3B/aNK0zY/a8sgoNP0 6MwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 549EC40019 X-Stat-Signature: y6mbywqxubhz74urjajcru778hkdzjok X-HE-Tag: 1725445320-133885 X-HE-Meta: U2FsdGVkX19X/0+7Il4bfzxRxTGycKDx4pHj6Y7RYloEjWN7FVha0SeYj82YXEGYYLJR1dyC+t5pCv2JT2hts5SKCZAtVnNY2A3KHsZOJNuf+/s6jjXYN8EEwSBg4zYEVhxsku/fWcoJOTybcCCxK7/BrVA67mqQMFLvHW09LGGUNOghA3zlA1hnCXK0GfZngOSCnM+JAhWnoC0JZYy+0vvTl9JKc2+8FkXl1m2Chv/dtCFSP7Jxvy7TEE6xd80en+lcjPpd7AE1pV8o/2cKUVe69VunjlXndhHJ6qjCYk/wN4pNR3r1Lpho/ucuoznUr+XWn2wrjWcSy4mr6N+UAPUiZ/RTQCeoh09472C1crjgXKJVNK6l34xx/zhPFzavxWnoDSKtSs64tuk2AZ1g5S9XkK/FHsubFND+EJYN1Jb7mnc1GErwRV5sCPeY7OCaCKPNMwtXMeasdBZn0Z7HB4qlBIXEdJNu2aXxwXnRKm422uDwJauGZwh+tRxE70lpC5XhTxoGDAL3NcWoM2LqjvTqo2M+zkFGiI3MR15a1ja79CJF9bxDIHPbwpTpPbICbUh6xd8lCOBu8KK3rNZP02I5esaL2afkjId+b71/FdIaHEmu1WaOcwlqDtmc7/Bx7iez2rfllmc9c73JJrtc204OBRqyEeMBJxFjtFT6JN2/ok1/ty9wpmP+2Y5rJO/LCg3s+mxBGCz9bQhjVrx+DY6SMn6uKnRunM25/M4bmcNaRCrBbE5lkGYpV9t+6nY6IlwwMXe5QI1BTsEDk+RU3p19hHgjSGphKKVtuZSictu96lzIj7wkucSeqb7cSGiG3Ubiu3MIZtISc25bmTasd91dF22WAMxsyZEK7Zt4Mc1G2ZxAlI2xDl7+B+m6Tjygu5HCy8bBa6HBc0fJ2FGUbNsvlXEBU/WWCdfk3dCJ9KLRWpbfAEq2LOLRWmwXaYQtdhsP15BbXxbQR9Xcaq/ KcK7ahtc rLQo/44gyRnyO7F/u/Q7FSWw/qOtD9PmkVDeKpUwZXTAkAvbCoUqCxp2wa3wWNhP5eoU+NkLigVTql7cZKLChoU2mT5LqWfhEV/rNy45cH7Ja26A5oCqJiNg3jTuUa9B8XtWJDJYVWMVbGq/mOJltS6s61ZjfekTXCV4RSG1wVJwUD78Si182LYfUbWqRy/xXI0ZI4wwMYyjUoBiD6sMGtT2hGtJaRJYG2BEVuOuTk7HoHoTDj6LZxoOgJ2ProYOI44/p11fpSMsCMQv62qYXuJWmH8uk+YBr94SZ5CGTtQko7+MO0XvkwJhTcXD4mP1lytTvk4Z6gK41W7iqiDrM3vJ5kr2JSSWGh/nNBxer82UjQf4= 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: Currently we have multiple kmem_cache_create*() variants that take up to seven separate parameters with one of the functions having to grow an eigth parameter in the future to handle both usercopy and a custom freelist pointer. Add a struct kmem_cache_args structure and move less common parameters into it. Core parameters such as name, object size, and flags continue to be passed separately. Add a new function __kmem_cache_create_args() that takes a struct kmem_cache_args pointer and port do_kmem_cache_create_usercopy() over to it. In follow-up patches we will port the other kmem_cache_create*() variants over to it as well. Reviewed-by: Kees Cook Reviewed-by: Jens Axboe Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- include/linux/slab.h | 21 ++++++++++++++++ mm/slab_common.c | 67 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 5b2da2cf31a8..79d8c8bca4a4 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -240,6 +240,27 @@ struct mem_cgroup; */ bool slab_is_available(void); +/** + * @align: The required alignment for the objects. + * @useroffset: Usercopy region offset + * @usersize: Usercopy region size + * @freeptr_offset: Custom offset for the free pointer in RCU caches + * @use_freeptr_offset: Whether a @freeptr_offset is used + * @ctor: A constructor for the objects. + */ +struct kmem_cache_args { + unsigned int align; + unsigned int useroffset; + unsigned int usersize; + unsigned int freeptr_offset; + bool use_freeptr_offset; + void (*ctor)(void *); +}; + +struct kmem_cache *__kmem_cache_create_args(const char *name, + unsigned int object_size, + struct kmem_cache_args *args, + slab_flags_t flags); struct kmem_cache *kmem_cache_create(const char *name, unsigned int size, unsigned int align, slab_flags_t flags, void (*ctor)(void *)); diff --git a/mm/slab_common.c b/mm/slab_common.c index 91e0e36e4379..0f13c045b8d1 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -248,14 +248,24 @@ static struct kmem_cache *create_cache(const char *name, return ERR_PTR(err); } -static struct kmem_cache * -do_kmem_cache_create_usercopy(const char *name, - unsigned int size, unsigned int freeptr_offset, - unsigned int align, slab_flags_t flags, - unsigned int useroffset, unsigned int usersize, - void (*ctor)(void *)) +/** + * __kmem_cache_create_args - Create a kmem cache + * @name: A string which is used in /proc/slabinfo to identify this cache. + * @object_size: The size of objects to be created in this cache. + * @args: Arguments for the cache creation (see struct kmem_cache_args). + * @flags: See %SLAB_* flags for an explanation of individual @flags. + * + * Cannot be called within a interrupt, but can be interrupted. + * + * Return: a pointer to the cache on success, NULL on failure. + */ +struct kmem_cache *__kmem_cache_create_args(const char *name, + unsigned int object_size, + struct kmem_cache_args *args, + slab_flags_t flags) { struct kmem_cache *s = NULL; + unsigned int freeptr_offset = UINT_MAX; const char *cache_name; int err; @@ -275,7 +285,7 @@ do_kmem_cache_create_usercopy(const char *name, mutex_lock(&slab_mutex); - err = kmem_cache_sanity_check(name, size); + err = kmem_cache_sanity_check(name, object_size); if (err) { goto out_unlock; } @@ -296,12 +306,14 @@ do_kmem_cache_create_usercopy(const char *name, /* Fail closed on bad usersize of useroffset values. */ if (!IS_ENABLED(CONFIG_HARDENED_USERCOPY) || - WARN_ON(!usersize && useroffset) || - WARN_ON(size < usersize || size - usersize < useroffset)) - usersize = useroffset = 0; - - if (!usersize) - s = __kmem_cache_alias(name, size, align, flags, ctor); + WARN_ON(!args->usersize && args->useroffset) || + WARN_ON(object_size < args->usersize || + object_size - args->usersize < args->useroffset)) + args->usersize = args->useroffset = 0; + + if (!args->usersize) + s = __kmem_cache_alias(name, object_size, args->align, flags, + args->ctor); if (s) goto out_unlock; @@ -311,9 +323,11 @@ do_kmem_cache_create_usercopy(const char *name, goto out_unlock; } - s = create_cache(cache_name, size, freeptr_offset, - calculate_alignment(flags, align, size), - flags, useroffset, usersize, ctor); + if (args->use_freeptr_offset) + freeptr_offset = args->freeptr_offset; + s = create_cache(cache_name, object_size, freeptr_offset, + calculate_alignment(flags, args->align, object_size), + flags, args->useroffset, args->usersize, args->ctor); if (IS_ERR(s)) { err = PTR_ERR(s); kfree_const(cache_name); @@ -335,6 +349,27 @@ do_kmem_cache_create_usercopy(const char *name, } return s; } +EXPORT_SYMBOL(__kmem_cache_create_args); + +static struct kmem_cache * +do_kmem_cache_create_usercopy(const char *name, + unsigned int size, unsigned int freeptr_offset, + unsigned int align, slab_flags_t flags, + unsigned int useroffset, unsigned int usersize, + void (*ctor)(void *)) +{ + struct kmem_cache_args kmem_args = { + .align = align, + .use_freeptr_offset = freeptr_offset != UINT_MAX, + .freeptr_offset = freeptr_offset, + .useroffset = useroffset, + .usersize = usersize, + .ctor = ctor, + }; + + return __kmem_cache_create_args(name, size, &kmem_args, flags); +} + /** * kmem_cache_create_usercopy - Create a cache with a region suitable From patchwork Wed Sep 4 10:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790356 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 5449ECA0ED3 for ; Wed, 4 Sep 2024 10:22:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BCE9D8D0244; Wed, 4 Sep 2024 06:22:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B7F6D8D0242; Wed, 4 Sep 2024 06:22:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1F7A8D0244; Wed, 4 Sep 2024 06:22:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 858878D0242 for ; Wed, 4 Sep 2024 06:22:06 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3762D80EFF for ; Wed, 4 Sep 2024 10:22:06 +0000 (UTC) X-FDA: 82526665452.01.8612AAE Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf26.hostedemail.com (Postfix) with ESMTP id 6953C14000F for ; Wed, 4 Sep 2024 10:22:04 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ATXYzaED; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445246; a=rsa-sha256; cv=none; b=4/HG7IFVM+7NMMhxvsZBzIqhiZCWw2xXNTPf0b+Q9Szkj2fMMWP2iUQGCCP2gYNSxly1xY 3xeQ+81GMrilmBv3Iw52X3XLF7wFeZ+m7Xr1IvI69m+1GWTYz4u2fQyRB7EnS+lIgKTu57 D8/0hXZCbFu/e0Pdln5ArkKHwy/rFiY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ATXYzaED; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445246; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fny6sgK5/VE8AxqTuJuSDYZWl91pcfBlM4GcgoxMsxY=; b=j8ixO9+2nCHdrc8Wrfp5UOLbshLn7UfDmahYIpn8JjVH1JuMAhQ/K6uGRW6iTgQsg2U83T GAHo8/amvzclMydJ1nF6ZS//9dk4vNUmcXbGyx3D5v1v5aoYPE5ZcX0R1EiTYRLaSWEQ1k eJ2oDWGocO5QRXFdApM1T3mR9O6g1ic= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 4D020A4327F; Wed, 4 Sep 2024 10:21:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBE8DC4CEC6; Wed, 4 Sep 2024 10:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445323; bh=0yvBsmIzvOyKMPTmQD/+Lg+Nh4nfzS75mqd2tBAiPek=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ATXYzaEDvpyqO1cHVGL9BkKUYRZSfC3s2XK116B4f+XLDx3OR0OqXp7vJQk46lpOB o0+rzieBKLa9Ck3jreS4t1TXQ2/X2f2ZJiWgyRJbWBepXzXY3p+72PP1P4A3enMKTp YJRpuc78eW/3QcKhW5wPqjj4YnoFgpSAk2Io02F/kROX5bxT+VVUVojSV6CVAKX4Pu vytuhD1n/pj06Tld94xW8mBjHjSWEJuQeg790cjshKRbKdFqcY2fp1zrjgPLDERZ+a JuJN7gsBnG4CbYClaIaCTeKJjJthJTBWZcboXJvlqzjvLiKUz4QcaE3SIbQ5x/xzlp WU6mG6l3Yp7Pg== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:08 +0200 Subject: [PATCH v3 03/17] slab: port kmem_cache_create() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-3-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=925; i=brauner@kernel.org; h=from:subject:message-id; bh=0yvBsmIzvOyKMPTmQD/+Lg+Nh4nfzS75mqd2tBAiPek=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNnJbu88Z6+bms7x+X9qq2pO9d8V69rFpSOosqRs4 dV4zTlNHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABN5HMfw38X95L1Xu9QYhQ+t eJ13zN/OOL72oUYV06oQzmyNjE57dkaGuc/0N6ZdNHR3KmN4suviqSP+rQ0ru98LPu7ZYKId783 KAwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6953C14000F X-Stat-Signature: spuwfuqut5gwewc9qzdb8qk3wuibicyi X-Rspam-User: X-HE-Tag: 1725445324-31246 X-HE-Meta: U2FsdGVkX19QnGX4dAOXteqiPD/rLyNXLBF4Ir2VzkKB75MXyDrm+WzIq+Z+xf2+Z9z6rmHy0K2FmyVM/6DZeoWIE/edDJyq3Z2U6oj2h58hbsPb0uVZZT0tdGlWuvcvSACWAy/qPrAPOVFABvpUDWUQrqF32qExmqPp4gF2FGUAaSxUVCN+BBwwX7Hvt2LVuX0v+frj1jP4hH4iMN/nUpxt+wEKwQfjLSNcy0pgYGOInK2cvrShs9K/BfVj/u9BNMBLoV6ZbhbnqF7YPh/Un41kfM/SNA1XlOfQ+PywNVhpnqphnacVWxWeLoFhMCZwR6ivQCgST9O0Hv04xMwKuKuxotNZMQK/8O3OVTlsgfVYvLGXRSdMBYxO3XRkpeabOJqLlgBJwQJuCj24bGi9JSyGw1DAu6CTAeEklK1pX8j1ViZ522p7yjo9O23d3K0rDoCruxwJZ1+YjgSqkLCNbTVIciUuLLTwNiFrZmNbBB7PXsFSV4GEN6L9DA8GxrWHNU4X5Alzn6h9YeHfRynACyVBXKH1ku28A6W76uY5IaoCsa9RlpSu/k2oatTmVBoe5RAyI2+SV8JVU1coR327jqD/bRC+hqATsvG0liY68WY2vsKF36IrS45YBAL0FYlCUrJ3ilLBXif+Kb/R7rDRU/xSi63z4yyLScYnwjRA4FrcZPsXmJqgddt12dNTvfOYQRcckipZYbLCQY35IqIdPY9tCETlAlZkrMCtdnDnFStGwLdHg50PJxGECvRjDU1G5KzB5Lj3HR5cfmODvSn8iHLsG/yaW1nhlgha1tRURnzvvVzNxh4gg9OXh2HQOobtr5GXa/+8bt4ziairLREluCV0iItRYpiYJBK0H0zLooXG043MxfocrdBJKXNXE2H6DANIA/26cN1SLhAV9Cm0kGfq4LORPJEDwHjR1EvqQjxyjnE4ZmeM+YNIygopYFQqAf1+dydolqLUdyJnPXc F7W/Isk8 GmQFDXjGf4yprF4XFzeeYswRARxQbhUWgd8Z3+RkasJuidGn4Yw/XsLFuFs22xPtWaf2oBsKxHXr1KsJtkxpY20JgNNV+C6/ncGxK0iLwAmTYgNK6b2WtvP+IR3zvye/bTXNnth1MWGs+wnaQlwhpPahoyDFcg9Ua2x+mwJnOUVelnfCQQSR0CM0mJ8Gq5JmruG5bMbUAKkG/H3lJFdjfn5B0bbzM1NkhizjY9gb49Bahk7diawWT1KcN7yVd9C0sbbLBIn8B4ftacbCtL2ywKlEWgVclHobnooASa9pGpUZ/aqYbWS41LxeahoFxHs5oPcYaQxxznF7uufBf7Bf7bDPPgGsWMv6ca84KgjXr3W1mJGs= 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: Port kmem_cache_create() to struct kmem_cache_args. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- mm/slab_common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 0f13c045b8d1..ac0832dac01e 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -439,8 +439,12 @@ struct kmem_cache * kmem_cache_create(const char *name, unsigned int size, unsigned int align, slab_flags_t flags, void (*ctor)(void *)) { - return do_kmem_cache_create_usercopy(name, size, UINT_MAX, align, flags, - 0, 0, ctor); + struct kmem_cache_args kmem_args = { + .align = align, + .ctor = ctor, + }; + + return __kmem_cache_create_args(name, size, &kmem_args, flags); } EXPORT_SYMBOL(kmem_cache_create); From patchwork Wed Sep 4 10:21:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790357 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 0A088CA0ED3 for ; Wed, 4 Sep 2024 10:22:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 936BE8D0245; Wed, 4 Sep 2024 06:22:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F29F8D0242; Wed, 4 Sep 2024 06:22:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 760DC8D0245; Wed, 4 Sep 2024 06:22:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 574378D0242 for ; Wed, 4 Sep 2024 06:22:10 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CC07216107E for ; Wed, 4 Sep 2024 10:22:09 +0000 (UTC) X-FDA: 82526665578.16.EAFF4C3 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf13.hostedemail.com (Postfix) with ESMTP id 1A3A520014 for ; Wed, 4 Sep 2024 10:22:07 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Fr54x1ND; spf=pass (imf13.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445280; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dmbb6gLW12yG1qxWdtUGDk/ThB2vBNcttkyZZ0/1B9Y=; b=aWc6UCOW7wVNh5gk6L+e9VeJ8FO74MwzFc+dMZK+qS/fJNacSwc2EETNtEj61O6BVcc+Um T9YfB/tIl9P7e86/C82lQhzkTbLd1ScpRQVtLox9pm+2689NMtHeo53urH4MnEE30/7zoF 7pK/SZiKaRZ5EtSWxuZrjWZ1AkMX5Ic= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Fr54x1ND; spf=pass (imf13.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445280; a=rsa-sha256; cv=none; b=BSe0YhwCyzAveq1gPwLknB40uP+zfLKSZ9Mng5Ad+Qbmy6t40Gl9GeNA743jFRM/J4Hxtk C9xAB303Wsb7iXxaHiNIpk5ARGcRLYP0FcGsqm/0wcMGxixDR3EKFWJ5OIgWvzPAOZbsNo T9nuYDJIlbW+DMlOhJaNmGj71OJKYro= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 4C1FBA40D7D; Wed, 4 Sep 2024 10:22:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3B2FC4CECA; Wed, 4 Sep 2024 10:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445327; bh=PzF+2+t3y9QvUaK7XGtoJxZCJ/C5QzrTNKeCBjRAdK8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Fr54x1ND6hGLkeb2A+9fO433Az2ZzEZSs5uo+FsIlP5Rw2c5k2FFT8CkidVw9waS0 w7VCYJqFVwFep3ul/BzzO5m1crxq1AiiijoEUK9ir5la6ndOW8jydEEDMNalFx4fbJ 5tm+i+5GCM2/3bMDIFNMRNQSQdRbw8OL5axjA3I2mXDhjNrNVQdUkCrOboSZx0Mg5I FokxkNFZmpuxIUo5vu27G5LISDln8afLXkDB809xn+aw5LfGyV6VVIRiml77B9FxWq T0gOE7uAzLjDGMpykeHfbEWYNRdoq7cO+fPIT4gfPh5JBnTMu6uNXWErgihqRQcbVE bxzsSnzCnTYfA== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:09 +0200 Subject: [PATCH v3 04/17] slab: port kmem_cache_create_rcu() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-4-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1036; i=brauner@kernel.org; h=from:subject:message-id; bh=PzF+2+t3y9QvUaK7XGtoJxZCJ/C5QzrTNKeCBjRAdK8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNm1Se/tBhcrk60f62veG7IUPfrovW+R6MMvMkZr7 xkn+f3+2lHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRresZGVZfuV3EN+lIY7Zv nejLMMEIbQedvUoXnpmtd1omvz0y/B0jw6e5HyJSY5waTD/eWWn7ce3MCg/f1Q6nuDpd735I06x +zQ0A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 1A3A520014 X-Stat-Signature: zqhhzr51r1zpzsmrrwpnbseyxjk5ipbo X-HE-Tag: 1725445327-647059 X-HE-Meta: U2FsdGVkX1+RrkXlTMLMXIcGLtKrjDhfYZVFFguv1ooQEbE6YINjwpVGphnKPdoUKbRbsrgYyHQ5hidWuW6NVzMnnRtKO3K1EoPuIP7xUW8TAhR6FZ2dWTKAWMyO0o7+WvEftV+XL8ERbxK3m2YipAQHWbyVHkxvk6EHd4a4gBwzbhJD1k7YNUM02jyARRlNEOAILDMr5Rd046dmFULpKq8hwVkZgceML5Fw7IsHfr56gyWVZQQsc44OKsHdV1INdWZLP1jiwDWQVKTbWob6S5zEtWCOgKS4kUUA2Ct5quK+n3DS9zt4QWBNWlFeiMJqHhJOHG4MYnZWmhJqE7d4ui0pFztpzuvgxEehKsYeSk+4lsqnCZ1yKgx3TjHTHfEMHNYjZzxh0GXrrKa0HrSTss9eAteZDlS4/aNAWq8lnVvTbbL4n0A3LmyilKY5n/MJOdyh0YTSlaPligIiLJLH3NxH1Z0a6WwPO61dPRj11ca0qtXvr/EaDkTpykzMevLb1Vm3ZOkN+lXOdphsjyCzkXEV+tyUu6a8hZuVEg0aNDV9vaiH+vGInIiZGvLpcx5zIrt9vtc4DtbOG4zEGfMqLq1W+NQ37haebnopx5wePDmrs8wns8Fx2EwnvcXBgJnwJOF+NYtshylfaSVcLXnymEaNEJafkPO1QVBfyqYkvSOROCe0jbaUt3ZBuOo9CHwgRNMI7HqvhUuSiPTqf+2ZQgasJCHLa3n0R4hnoMgVOudiCv+USBukeqSN0w7IHQG3iQzzeQHaBgzpqvZNfSxH+ehhecygXDKbhNStNwBHpLTEqvom1V49CU1mmjeBMYkMiNbiOKNbGWe0nU+4E2QUKxUhHriIWUKzR7XrcFHHA8A6+iGIG6/1sKsOb02TPz18nkB5i8lHAQMvb68cJyL96p+khHG2jcvOLLGid/rNbKW2AFC6UgfiHkq33hXo/xOii+g9/FhTeNstmjrLGdJ xu0fU0ya wGDq63/TM5VysSEIiNTJULuLMBrJRRaaEXXA4IK90AV6A50twqKLJBfWZbxQrsL5S93jEucZr1Eh1IZiC41BOyeRFetW4Thgo2siu1jk73aE4n63ajRTygEuVLkRyiO6U/UikU1lqD+02GYpB/4OsdAaSbjr9bPRjlBlsZSvJSGfVYnknjoVsXOYXSicL6G4Lgr7VZ0I9KGkvfu1xmSrlWwUvf2Ha1jlwEVP/xcSWyG2r4pEf3XR1WykJlRcjitEp1/hzxXMwx/LYY+U6OknrH9abjgIRkrvKo1/higAAs9rY2UISav+M4/ZtVCz6uoG3Ew9UioT0KNHKPBzGOjoN7Zt1lcuWm8Etv9H7JoFiRoCxZNI= 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: Port kmem_cache_create_rcu() to struct kmem_cache_args. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- mm/slab_common.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index ac0832dac01e..da62ed30f95d 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -481,9 +481,13 @@ struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size, unsigned int freeptr_offset, slab_flags_t flags) { - return do_kmem_cache_create_usercopy(name, size, freeptr_offset, 0, - flags | SLAB_TYPESAFE_BY_RCU, 0, 0, - NULL); + struct kmem_cache_args kmem_args = { + .freeptr_offset = freeptr_offset, + .use_freeptr_offset = true, + }; + + return __kmem_cache_create_args(name, size, &kmem_args, + flags | SLAB_TYPESAFE_BY_RCU); } EXPORT_SYMBOL(kmem_cache_create_rcu); From patchwork Wed Sep 4 10:21:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790358 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 C858DCD3431 for ; Wed, 4 Sep 2024 10:22:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 603518D0246; Wed, 4 Sep 2024 06:22:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B16D8D0242; Wed, 4 Sep 2024 06:22:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47A558D0246; Wed, 4 Sep 2024 06:22:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 221F78D0242 for ; Wed, 4 Sep 2024 06:22:14 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CDA131C53DD for ; Wed, 4 Sep 2024 10:22:13 +0000 (UTC) X-FDA: 82526665746.15.AA19164 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 0BB241A000C for ; Wed, 4 Sep 2024 10:22:11 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="B/f4yXXq"; spf=pass (imf19.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445236; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TxJF+O6Ny2o9AWqq7b2DEyhmZ+aOxh+wkvsuHBnSJ04=; b=D4kT+UYV6DRbdV6gAytGOvdekfR6fSj/IKvAeuAUTuuowYeKx8XRwyKYwaAEqN0sTeKdoh Qxb0/CTaN0vz+cpesqxNBPnm6pJdHc/F0ja3vntwl1ZIib88AqB78xHQVVEdG/4Nci/WXF ZbwRf33rw66g9BDAnShKOpYJWCYMIDo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445236; a=rsa-sha256; cv=none; b=8FUZ64+tG8RZIji+M0y6gTy4orCfsrvWVWogJHuLm1Zb1EoV2DHLm+jvfg4aVUgACPDAaT ZTdH0GhropThEhkijQEJadKGAf8ooTc6yg7ua1Ai1uSr8AVrjGWeHTLmkNLv3e2MQWSpCG Kkhzee946+Tk7YPDGiIE/5TNMHxzAd4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="B/f4yXXq"; spf=pass (imf19.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C95175C56EA; Wed, 4 Sep 2024 10:22:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5044C4CEC2; Wed, 4 Sep 2024 10:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445331; bh=t6CjazxfkyG3rY4OORK6/WvzeiMUzf2dJjeC2mkHY5Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=B/f4yXXqFQ5vSEkfdHwtQuqANWB/P0R8vg2RYv1QfjxFiwI6B4jTz9W2XYox8RnVm Z6ewd99jp6fgqA4fe65Io6FD7qgiSiDkoiTXmBf6KQAdODA+gNEda0V4kozGjVNG7j XrcNweG+qb00+grRhqri5Ak6yVTy0XlpAlwXoabLBVfBSMQHAppX4uZyDY5mTfdNFn aOQmTTDICjs94eG6xNLw+AOQMGtqXvxNW+oE2qg9v1HRbwngViSuLWVKB+Zr0I6gR4 nO0V1WPSENxkaRMm12hnLq0+uJCw9w2ian4gZdTotnfz2H2FKSVqYzFbGgp8mo2iAf 0mxWu5/Dzs2eg== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:10 +0200 Subject: [PATCH v3 05/17] slab: port kmem_cache_create_usercopy() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-5-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1992; i=brauner@kernel.org; h=from:subject:message-id; bh=t6CjazxfkyG3rY4OORK6/WvzeiMUzf2dJjeC2mkHY5Q=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNmV7rWmntNfIcDgadi0xuMKx5YKclqElxXs2/fBb sYCi6UHOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACbC8oOR4a3j0sVZ1x/0LDOz P6LpWNzw3OpOs+thuVsvmm91hH3ffZGRYYHB01rVNsnGvdNNOYtfLrpoyTK/SMLTavONcpd8T/8 X7AA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0BB241A000C X-Stat-Signature: d4uoeadpb5px8z6igdz7h4zbf6pb4k5k X-HE-Tag: 1725445331-619379 X-HE-Meta: U2FsdGVkX1+tIzLuPtsEDcaFBJPtOaGttiLB6Wn6hfo3MGjmmYsJVcuOOEgBmDIeX0oyHYO55qycszP9ZCeQsXGMsFEigmKI4HfhCtEraucMPVpOFOkHltXkiaYHUxalDIbpTpZBHFvb6OgkVbyI+pqiPhkGMaXgF8ocRUdcLBGU+/qryqdMeMrZcWY92waNINKTGGhgcJKDOkLPM7fhw1VGTOkEsjcnLKfTcLtvf/u/rjpugSRQXD5p5fKDZr2kIhRIIajDPAB/+92IvQjOrNQD3DqTqXsEcdjPuQgxhXsX8ZPealcHFTncS+mOhKEGXJ1+gN+pamB5Jgt2/FHJammRDJqKf0zxsw9+J/j/JmVzSOZRP4SarEsiPUvxkmiDD/gx1iOEQmjeWsoFGGpsGs7GiYmnMi1SfQiQELqEPFVkZDvQBvGxBr4NoBLtiD1ztNXaRlczV7h/rNeqPFD9FdLYtXvN6tuMF8vfwLica60DPz0Qtw6i57Y1Hkuz/18aih0wzeXhO6OBo+p7q5vgkq51I1qB/efrWfrgHjfHJFTmg4DUuYPYNFk2b9HpNUu7jf8H+mQvLuTn3JA0ctNcVsACdmLioJxoGg/qSkM7gqusmVpC5RTR/GlEOY1/84VJlQ++Po/nFUBvq9Kz1IE/qzGqLTowSn5cF0PQx8wd2E5+8FKtGoT9PmAOQAX8h/jHRETpYiQyOJ0GFoRmLovc0+gleNRh2pBcNshc1uk+6foeq8CsBP0KeRyko+1pPzlftTn2l0celn/RcmdjXXeZ1BpYaPZgQnUO5j6Bu8fsv76HvQlDcAJgrmPWkS5wyvzFn+Kza4L2f34fXGuaMM1t+yOKBpII8Aa63fBv/j5xNoGVKeHbXsWzhB9mRPFf0Bniz393IOgzHUdBYMpM32jgJlhIVys0xSWm1ZrO0/IkR3Tw1UXJNcU7EoLYiyBENpMye7Uhw3I+YEtsa0Ep7l1 PkdmUbfC Iv6sqYIK9em0oSXMaNUkw4Huof90diEPERkum5/YvPMS80l5cLJKiMV9992w1ybIt08i09BW2NKHsun0qgM52C7OqYU5tg27ON4gfgNCTLJMQ9KJdYvvSeRKWXm4m5h3oKptnLA/HmMQMt8g3mYo1CHzaJIYmr9Dkk9JZHbjB6PoMTsfBi41rX7xEe9+BRKVEAseUwOR1i83YDkckE6gihjBFxPWwEbNGddm4/Rp1Fh0cGMnlqLcK28ZIG838wd8wYso9+T7np38RxEiuRoupqBqjSnffPorNdaZn4Hq2FMHmgNn/gChGH+zo6sffeiVomWGjW9FdRtf1ETfPzwBpK0h/2gw9HH7Jd6dv/e0K/5wSxGY= 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: Port kmem_cache_create_usercopy() to struct kmem_cache_args and remove the now unused do_kmem_cache_create_usercopy() helper. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- mm/slab_common.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index da62ed30f95d..16c36a946135 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -351,26 +351,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, } EXPORT_SYMBOL(__kmem_cache_create_args); -static struct kmem_cache * -do_kmem_cache_create_usercopy(const char *name, - unsigned int size, unsigned int freeptr_offset, - unsigned int align, slab_flags_t flags, - unsigned int useroffset, unsigned int usersize, - void (*ctor)(void *)) -{ - struct kmem_cache_args kmem_args = { - .align = align, - .use_freeptr_offset = freeptr_offset != UINT_MAX, - .freeptr_offset = freeptr_offset, - .useroffset = useroffset, - .usersize = usersize, - .ctor = ctor, - }; - - return __kmem_cache_create_args(name, size, &kmem_args, flags); -} - - /** * kmem_cache_create_usercopy - Create a cache with a region suitable * for copying to userspace @@ -405,8 +385,14 @@ kmem_cache_create_usercopy(const char *name, unsigned int size, unsigned int useroffset, unsigned int usersize, void (*ctor)(void *)) { - return do_kmem_cache_create_usercopy(name, size, UINT_MAX, align, flags, - useroffset, usersize, ctor); + 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); From patchwork Wed Sep 4 10:21:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790359 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 DFEEFCD3431 for ; Wed, 4 Sep 2024 10:22:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73BD66B0317; Wed, 4 Sep 2024 06:22:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EA8A6B031A; Wed, 4 Sep 2024 06:22:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53DD96B031B; Wed, 4 Sep 2024 06:22:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 33DC36B0317 for ; Wed, 4 Sep 2024 06:22:18 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E95E7120F44 for ; Wed, 4 Sep 2024 10:22:17 +0000 (UTC) X-FDA: 82526665914.20.C836C6B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 225921C0012 for ; Wed, 4 Sep 2024 10:22:15 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RcQXs353; spf=pass (imf18.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445287; a=rsa-sha256; cv=none; b=CKup2zJJncF0f/godtEqqAdMlwiQuQLdGQxQiUeFvNa+CXc65WmKlunJ379Agbyh2thhPZ CUYiBHOnF259XuSAAFHo/A8elNzIlwGSKsiRTitOwwHR5YLNa7XMwAjfH7EzRcdJ5qu0WB DpKRtDoGBTJdfecFZL5TuLlfblH05Mw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RcQXs353; spf=pass (imf18.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445287; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=o27A/LKlbOJ7Sc9aB+05j+9dGVu2UPSc5F+bSicdO6M=; b=EGVoZ92baKY1KEL04rp8ztUVwQW0KBguKHogE7OfIi10XyQghlwBdK7G341VLbwA59ocx8 9h97R4K3dm7fXuKxF7x73pESfbUmDJ5NX+AEOpGCzZ6/ozjLtqxnetWbtrVuFTB+aJY2EI kif9wcMpJIkHRcDefISue3WdfCCUNHA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D22545C56FF; Wed, 4 Sep 2024 10:22:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84756C4CEC6; Wed, 4 Sep 2024 10:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445335; bh=wlErePvTE8gEuAQI7b5rPaz+icXnXkiXiNHwXkcPVSE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RcQXs353asnqMtizb8ucN9fB/kmrdEonJJa4WhFzECgl1zSEYCask+0iHaYbU7A0z +WT8J2sxrWx2DYfPN/Wp0oJO3cpPXzoGsp6g5FhdnDbxO7BgD15iCDZh8iC6F55AX6 tfdEmhho3yPQgkUQ8YDVdjVp/rtS5mItx6Tzp19daAiBkCSHovIv67mP8rvt+HVn6u iRosz7EPbnsH157G/WRr7qwowiavGfbdahCmEcloUYfOv6UIpynTERb7ORi/fbyqXc U9GjQr7pb/4Z0r01sVOv/ezRE6PGYyMPqa3bv3wOEPhXC91/lNC6Z+GVtwHG51Fwnc jofw4P+pfNMZw== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:11 +0200 Subject: [PATCH v3 06/17] slab: pass struct kmem_cache_args to create_cache() MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-6-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=3153; i=brauner@kernel.org; h=from:subject:message-id; bh=wlErePvTE8gEuAQI7b5rPaz+icXnXkiXiNHwXkcPVSE=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNl1R3mW7FIn46d5Uw7FCL8OX7j68p7IPTOUeZ6nW fQ4evzz6yhlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZhIkQrDPwMljWLOnBfnlr85 ev34+sX3utvinm91l5RrsfgnVFdw8S3DX5meJ8+41y4wiH14V6ymv6fdjn3j+rfRbbdULWL17pj WsgAA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: cgj9ej1rdnagazqebd8uf3pawdfp4er4 X-Rspamd-Queue-Id: 225921C0012 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725445335-449382 X-HE-Meta: U2FsdGVkX1/pbKpRv5apLRNT2/jjJwh4v3HV4EZwy3dVQj2HFFKNh52qr3mpI3VCDJbHa2pcW0qX3bJVuIQUo3NEIB6w6By/rX2sVFn2PzChWOV0fOxj0xHZ2LhVosASUlfr55ilBLXoQoWGJpVott6OdL5pXzk9ejLkqh85VuqU4ZVzAD+Nd9F8oBEJLf02GoG5FJDHMIhIit2hP/yfeBl/SJ8uXJaZ6BGqJfVaG37InBkEFLduIgrsMP3JG+QrH/cE7+JAHQePAymGntvga7arbUjry0ka/FGNRidfWC2s6ECTHc8mi9fAvUB9xhR1gHXe0HuzT383qZFn5B2uG7iN2oeDRU015uKWog9ZHFAqkRaBm53DEnGhCYwFESalNfDNFrQbEil2qpNO2Cg0Ge9KmK9x5NV7On797cVaX6ZcZc4fWn2Phl29dsIzlahioAMDcR1Nh899kI5TWt5rGcXxV9UxDsjKKMl0+e7LVwLXxHsf1I+DpVfgqTodXviEZjCsP1bgI/KCPLIdlLFwQPgKdVXY88vtRPrkkZBN9quBq5MbHlAdRKizDSDJWgrjJZ3JSAK6eJnRDliw1yO2SopoIa8WK3nZaH4xMOUyUi7EkO1EhjXivaEq9NTf8WkgbLeZzEPqmynKhF9H57AY6OitwAI1CKxn5HG0RPPGiZ0ocPyT4F75Cu75z02VLiVANgQyVMUzdRmxd63SNN7y4bN8C4WVUTPiYq9kABsqCcWp9GrzvJJHpLhy2MkGO1LkBfGq/rCFuRcVVAEsR8azp1njVI6cKQbJSdqSNK4Rdhe+AW/kcMpNE13du8sS/FnmIzkCMMtQ44OBJcd4sSFBxGOoYEaOg/rJSydV1G3TirWEX2NYCIA1mR/QB5SLqim4OAavbNrWjSMmRESjl07pg9CrdESuzaGa2Uc35xhj3cghmqC/Xy5gQzpLamE3jjYGEyDjz/SVQLj07cWh1I0 Z8mbpshV G9m7BcQg+rX22/JoJFuNbTWTQZw9LFHh5cQlfts8/vcH2zCXcoQRcQGLQYYhnrEeVDALjCifQK94EHpFdxoggO7bfHkK79/GjTpmEtb/D4rLX51LuJNhcpIK03rpWQZ9XwZ6lpGe1i2DEUiDCUIr32nTUoAUk09BehKK6smvqOb7wH3c//b8xWAGNrktWa/+H0oarXIzsmmmdoC4IV9gPZUfxcQBl8zk8QM/FEP/ooKSxKtxu/V+sWdCYEyceWvNiyOaLAaMMU/DdCjn+LBaJV25Fe6NHiZL13MP7bDatqArczjobGuFY4OEVUScyKPxhylAIJUmKTvfNWvsIGwFDrCXKPhLlaHGinytTzsJRV5SmStU= 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: Pass struct kmem_cache_args to create_cache() so that we can later simplify further helpers. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- mm/slab_common.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 16c36a946135..9baa61c9c670 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -202,22 +202,22 @@ struct kmem_cache *find_mergeable(unsigned int size, unsigned int align, } static struct kmem_cache *create_cache(const char *name, - unsigned int object_size, unsigned int freeptr_offset, - unsigned int align, slab_flags_t flags, - unsigned int useroffset, unsigned int usersize, - void (*ctor)(void *)) + unsigned int object_size, + struct kmem_cache_args *args, + slab_flags_t flags) { struct kmem_cache *s; int err; - if (WARN_ON(useroffset + usersize > object_size)) - useroffset = usersize = 0; + if (WARN_ON(args->useroffset + args->usersize > object_size)) + args->useroffset = args->usersize = 0; /* If a custom freelist pointer is requested make sure it's sane. */ err = -EINVAL; - if (freeptr_offset != UINT_MAX && - (freeptr_offset >= object_size || !(flags & SLAB_TYPESAFE_BY_RCU) || - !IS_ALIGNED(freeptr_offset, sizeof(freeptr_t)))) + if (args->use_freeptr_offset && + (args->freeptr_offset >= object_size || + !(flags & SLAB_TYPESAFE_BY_RCU) || + !IS_ALIGNED(args->freeptr_offset, sizeof(freeptr_t)))) goto out; err = -ENOMEM; @@ -227,12 +227,15 @@ static struct kmem_cache *create_cache(const char *name, s->name = name; s->size = s->object_size = object_size; - s->rcu_freeptr_offset = freeptr_offset; - s->align = align; - s->ctor = ctor; + if (args->use_freeptr_offset) + s->rcu_freeptr_offset = args->freeptr_offset; + else + s->rcu_freeptr_offset = UINT_MAX; + s->align = args->align; + s->ctor = args->ctor; #ifdef CONFIG_HARDENED_USERCOPY - s->useroffset = useroffset; - s->usersize = usersize; + s->useroffset = args->useroffset; + s->usersize = args->usersize; #endif err = do_kmem_cache_create(s, flags); if (err) @@ -265,7 +268,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, slab_flags_t flags) { struct kmem_cache *s = NULL; - unsigned int freeptr_offset = UINT_MAX; const char *cache_name; int err; @@ -323,11 +325,8 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, goto out_unlock; } - if (args->use_freeptr_offset) - freeptr_offset = args->freeptr_offset; - s = create_cache(cache_name, object_size, freeptr_offset, - calculate_alignment(flags, args->align, object_size), - flags, args->useroffset, args->usersize, args->ctor); + args->align = calculate_alignment(flags, args->align, object_size); + s = create_cache(cache_name, object_size, args, flags); if (IS_ERR(s)) { err = PTR_ERR(s); kfree_const(cache_name); From patchwork Wed Sep 4 10:21:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790360 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 D4EE3CD3431 for ; Wed, 4 Sep 2024 10:22:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 605136B00A7; Wed, 4 Sep 2024 06:22:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B4F76B00AC; Wed, 4 Sep 2024 06:22:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42DF86B00B2; Wed, 4 Sep 2024 06:22:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1FC3B6B00A7 for ; Wed, 4 Sep 2024 06:22:22 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C9264160FCC for ; Wed, 4 Sep 2024 10:22:21 +0000 (UTC) X-FDA: 82526666082.19.8604F20 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id E57D9140021 for ; Wed, 4 Sep 2024 10:22:19 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dHNDkNyo; spf=pass (imf26.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445243; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Vs7vbuUxiD8+4I1sHX2bOXordzhmmy8PlAhIo7UL34o=; b=U6fuAcLvumCm8iphgs18+ZORFnFAlKb8WlPOKjt1igVbves4Abmfj0fc1EgbIOJXWqWDFS cnZjAYziQfnIbBKlL7/F7ByQw525yPcUkfjqB8KlK48AFZ+zoZRUxuVwiBDw0Rltc138up aJzrl/vrYfJoXVNcg9NFWrXmn6wMLHo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445243; a=rsa-sha256; cv=none; b=WNWe7KflJdU3hs747xbPL6yxBryuLiEXqETMs1QKJCU31I6QFnCBQSHL3tpixiQ2NN36jH qbz33l5312U7MESI/HybxaxneB5kfawpOZM9dnH51AwNbmkK4CLFe6M1VY5JlyD6lrTpz0 at5h3+Guh3DjnhKrUcQLkKDnLDnqIw0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dHNDkNyo; spf=pass (imf26.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B024C5C56EA; Wed, 4 Sep 2024 10:22:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FCF6C4CEC8; Wed, 4 Sep 2024 10:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445338; bh=XvA3OjNvZTXuO+1s1Yt+F4vUj5bmDXzlHdYPfx3s9dQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dHNDkNyof6PXzmIXAY/8Nxv2qxyJEp6i9DMdtkFlhAvTa/5gvBP4elVrdQWCQbs/g UqHo6xYX/3ja7Mla50VPP7g0eWGgcGcFZPdp6Xe/K9ksOQzVGHjDcZ/x/lg9hZrpI4 w7jrv19fpk/YrutcUmR+3sVhnY1AW/KTGxJ3a8PzpMu42uUBzCanWtarU3eHK/6i3w GB39Wfo27w8EWKr07F9s5ue6ob2fFV97Z/9RKVmKTXiCez04wM5+4dsdQkfyKvkXPn mGrUwTUx6TgmWhjgdb/JXbR9H/VGapduDWqswy7FQXdvKM3csBKfacz50Nm1GSP3J2 tLntU20O+Ds8A== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:12 +0200 Subject: [PATCH v3 07/17] slab: pull kmem_cache_open() into do_kmem_cache_create() MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-7-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=4287; i=brauner@kernel.org; h=from:subject:message-id; bh=XvA3OjNvZTXuO+1s1Yt+F4vUj5bmDXzlHdYPfx3s9dQ=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNm19VTQ/A31/Pcu2kyd5/7N9tnrK+eEj5TmndY0t DG4qP9lXkcpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBEvK4wMrzY0Sn98yJDqfmu HNOPRaseRR7wXDt5jfvSf15amn62AQ8Z/oocyBH68vthrP6iL/4TN0+xFO8VmnIh98LPPQ5Lb9u 1HeYHAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: itzmd6pjf6bcpkhquu8wjk55kqrnsoe6 X-Rspamd-Queue-Id: E57D9140021 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725445339-887520 X-HE-Meta: U2FsdGVkX1+2ACO24Y0Kla9rtC3qOEOEbEo+RvwGUuitLbVlxtRi6yLPng/f63aqL76q34SwTNGuyso9N7gE1WFC75kOJuLs+Cb3cohdw2BsSwO3bDf4XgQ/dcIpRJmXKY9AOyLfuvH6mD1DlvIHgf7UniVDmgTfpeWEJHUy05o3x/HE9IQDNDkcZLTCHoAHbzxb4E1+DE5hMnQINX4BPmoxbWY0LD2Zs19fWSEkA6WvQ8emIJmOlQXCu6IcRHFOjxJn49v1JKBfZIyCH8rVe54QR2TZlSYiCMS5e2PHgZgT8Ve2SGg7+38+T+7H143g3TDEZxx9L0gt8AqMmFa33MqahK6f8gPpcJApQkCuz2meii0r+MASGwRvH5mTxi8Ql4OtgdkjuSU8obFG/eFAiJLAOJOmXJqwi3jVrNUrd8MA0wGEGa9NvVJjU/mmYoIpRnUy4YsNC5TY2aAIn8uSBk3ZJpxoF8rvsB/2EOaI6XZwtzosUeqUKSn7Vx9jw+UCpCxM+s9D89A5uTqVe9d7OZsT96G3CXthr5G1oGY7O/4H8poLpmXJjYC5QjWxp1aw+ZCJJrOqUWwMNjNMQ5ZTgfcJSM+UKEWEpkE5mJ0rAKF9QrM3DLt4xj0ppvgqD62i/6FcIzYA/8z/DGlIULqRxrZIPCeI7/8UF2zCbYn9Ps9GLM+pOAdGKnk3yGj2/ivl3yXy1qFElm3ma5CLr/zHRHVF4IcylaTuXLdP1ilkpsM/pluPY6OBd3UbhOsfVJiXJMDZIaSMP0iSDiUuAbAFABk5QvkzBmWmj/gkICRdz/QAvuRE+87T3rzqd8YAdNdPlvIaK/q0ILyukxTLq6KVBgX6A8rUsu25oHt8Tzg/uWQlmx8NbP9V0WRScsR0LW8rmHp58Qhr97yLAmGf2sg96I5Z+Ujg2uhVz9jiAGWcGgfPjGyQXpSKXQUHsu/c9OM6O0CxEKO2H6n/BuCFbtc lSzCkTcW 06ZGwnjcOm08MOeLKp8gQTovGfZ5ydAxQQb+h6kkXNEblUf3eLdVn5g3l072SsuYvnTrma1iNHzWSUrtRXFjoSQJKDCy6D9H7Z/N+OuHtt1mn9wQMHc94k9qMXoyvVYdASRSbYOrbu+G2L1lkULoK33ShCk6TU85UISeS54uWsSWNZeDyaVX9u8qDlKFsS9Me6XBXiz8IfndkmFCil2LA4B2gqcQ4SeVDzuyTI9yz+k6K1wqfUC/1y1NgeeN7Cu9TNyXRdalMv3zLFRRhneolMOgzOa4PkVCwbSm/Y1BZZsyUfu5y/3BOgWLqNNKQHIGH53xVyXrpHaNS8cIW2uvkUla62jHmXCcl2W+PLZ02SlmGDAg= 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: do_kmem_cache_create() is the only caller and we're going to pass down struct kmem_cache_args in a follow-up patch. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- mm/slub.c | 132 +++++++++++++++++++++++++++++--------------------------------- 1 file changed, 62 insertions(+), 70 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 23d9d783ff26..30f4ca6335c7 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5290,65 +5290,6 @@ static int calculate_sizes(struct kmem_cache *s) return !!oo_objects(s->oo); } -static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags) -{ - s->flags = kmem_cache_flags(flags, s->name); -#ifdef CONFIG_SLAB_FREELIST_HARDENED - s->random = get_random_long(); -#endif - - if (!calculate_sizes(s)) - goto error; - if (disable_higher_order_debug) { - /* - * Disable debugging flags that store metadata if the min slab - * order increased. - */ - if (get_order(s->size) > get_order(s->object_size)) { - s->flags &= ~DEBUG_METADATA_FLAGS; - s->offset = 0; - if (!calculate_sizes(s)) - goto error; - } - } - -#ifdef system_has_freelist_aba - if (system_has_freelist_aba() && !(s->flags & SLAB_NO_CMPXCHG)) { - /* Enable fast mode */ - s->flags |= __CMPXCHG_DOUBLE; - } -#endif - - /* - * The larger the object size is, the more slabs we want on the partial - * list to avoid pounding the page allocator excessively. - */ - s->min_partial = min_t(unsigned long, MAX_PARTIAL, ilog2(s->size) / 2); - s->min_partial = max_t(unsigned long, MIN_PARTIAL, s->min_partial); - - set_cpu_partial(s); - -#ifdef CONFIG_NUMA - s->remote_node_defrag_ratio = 1000; -#endif - - /* Initialize the pre-computed randomized freelist if slab is up */ - if (slab_state >= UP) { - if (init_cache_random_seq(s)) - goto error; - } - - if (!init_kmem_cache_nodes(s)) - goto error; - - if (alloc_kmem_cache_cpus(s)) - return 0; - -error: - __kmem_cache_release(s); - return -EINVAL; -} - static void list_slab_objects(struct kmem_cache *s, struct slab *slab, const char *text) { @@ -5904,26 +5845,77 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, int do_kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) { - int err; + int err = -EINVAL; - err = kmem_cache_open(s, flags); - if (err) - return err; + s->flags = kmem_cache_flags(flags, s->name); +#ifdef CONFIG_SLAB_FREELIST_HARDENED + s->random = get_random_long(); +#endif + + if (!calculate_sizes(s)) + goto out; + if (disable_higher_order_debug) { + /* + * Disable debugging flags that store metadata if the min slab + * order increased. + */ + if (get_order(s->size) > get_order(s->object_size)) { + s->flags &= ~DEBUG_METADATA_FLAGS; + s->offset = 0; + if (!calculate_sizes(s)) + goto out; + } + } + +#ifdef system_has_freelist_aba + if (system_has_freelist_aba() && !(s->flags & SLAB_NO_CMPXCHG)) { + /* Enable fast mode */ + s->flags |= __CMPXCHG_DOUBLE; + } +#endif + + /* + * The larger the object size is, the more slabs we want on the partial + * list to avoid pounding the page allocator excessively. + */ + s->min_partial = min_t(unsigned long, MAX_PARTIAL, ilog2(s->size) / 2); + s->min_partial = max_t(unsigned long, MIN_PARTIAL, s->min_partial); + + set_cpu_partial(s); + +#ifdef CONFIG_NUMA + s->remote_node_defrag_ratio = 1000; +#endif + + /* Initialize the pre-computed randomized freelist if slab is up */ + if (slab_state >= UP) { + if (init_cache_random_seq(s)) + goto out; + } + + if (!init_kmem_cache_nodes(s)) + goto out; + + if (!alloc_kmem_cache_cpus(s)) + goto out; /* Mutex is not taken during early boot */ - if (slab_state <= UP) - return 0; + if (slab_state <= UP) { + err = 0; + goto out; + } err = sysfs_slab_add(s); - if (err) { - __kmem_cache_release(s); - return err; - } + if (err) + goto out; if (s->flags & SLAB_STORE_USER) debugfs_slab_add(s); - return 0; +out: + if (err) + __kmem_cache_release(s); + return err; } #ifdef SLAB_SUPPORTS_SYSFS From patchwork Wed Sep 4 10:21:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790361 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 A0B35CA0ED3 for ; Wed, 4 Sep 2024 10:22:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CEDE8D0247; Wed, 4 Sep 2024 06:22:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27EFA8D0242; Wed, 4 Sep 2024 06:22:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F7DF8D0247; Wed, 4 Sep 2024 06:22:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E4B928D0242 for ; Wed, 4 Sep 2024 06:22:25 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9E2A0C0CCA for ; Wed, 4 Sep 2024 10:22:25 +0000 (UTC) X-FDA: 82526666250.22.E45683D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id CBB6F4002D for ; Wed, 4 Sep 2024 10:22:23 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=k2CX6esi; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445273; a=rsa-sha256; cv=none; b=UcnWYL0ZvbZPIIIlGFCCp1wXyxYvUvCxLPyFHlyGK8RS89G/NvdOLF/EGQmFe+JvtSdRH+ kmUX3tfiE3kAwDQPFVAIQ/srrQual20zfsA4UZI9+Jlo7Pru/phRSr2Ba0FLrDoPS+tmIY HKhLC/84gOl+fO1Le4v7Fn+w9p9IwlI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=k2CX6esi; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445273; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=v3c5ee4jtvAh4gUMzM9sCjbM+yCqLCRuUvmtHvAlvjc=; b=1pyPOONHeCVkxh37j0xLUN0sCB3Yq3ByMBwUFeXpFW76/dY/Mf7MNUXWsWmj6hMZfrTLMn fZGTBNygXq5UvGtcjig5DIJqEzEXkqqWl/Fn4M1/rHLHlprwTv8TM0GWQRg6Ok1Ap8lAlC 9ywOXLJlGXOtefpRRXYqPq3tJn2tlD4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 976085C56FC; Wed, 4 Sep 2024 10:22:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5504FC4CEC2; Wed, 4 Sep 2024 10:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445342; bh=Lf0x5OF2wU4gj/MS9gGKSdAWPtAXYg+UCtXI3xTY+oM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=k2CX6esieR2DSrAm/zlh8hGQRtYTUzTrBeRwPO4dtam+p9PJiYfG34rAxs0jMItFa cOl2HPnbM7Ctg0Hs636nvcXa0OH8jdpw76Pu6lDoc32JoJjX7kyHUu4wHEzLpsfyyW lYLPJETA7CzrJI3yMFTjxAGcUudA9zwJavBSnj39Nu7hjByuCpXZGz0fzWsyFJEgI0 pCXrMQuJqu2DWDPxk2rTXSaC2wvegM1eoS4ZR+atlIyIqKiEJtfQSOm0YkyEWBnmlq VX8QOQWnaX6kz6xvhOCUP5lXZP0Ol7wkQWdBTPg+Z51NwMZ6G5hf1J0Fck4Wg3SmoY Cau2hk1OwJSBg== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:13 +0200 Subject: [PATCH v3 08/17] slab: pass struct kmem_cache_args to do_kmem_cache_create() MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-8-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=3919; i=brauner@kernel.org; h=from:subject:message-id; bh=Lf0x5OF2wU4gj/MS9gGKSdAWPtAXYg+UCtXI3xTY+oM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNl1+96yN7XuIidXBs55eepY8tVfXOd+KTMHvNO3z D1WGHAut6OUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAisf4M/zSZEzhbP0dUxJov OM0mnnX6RPbX2bdmNPX+Dz/1tjzplirD/5QuHrUktw1HP5dd3Mr0Xr8gq9tjo7WD85GFlvdMNRl 4GQE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: CBB6F4002D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1x4obg5dixupsijhigbfrgms5pftyuwg X-HE-Tag: 1725445343-541863 X-HE-Meta: U2FsdGVkX1/1HS5nX2wPZxFEL8tBZHmfPOuXOdPGFti9Xg+1/Ihyh4wwd+HCeQHx3eCs1RU9OIqKQXgcFIDnuQHqt2IFYhoAZH5854KaLAoAqddFGua24c4+MneWybVt84J8SvzeywushQ0Oklvs308b0JQhYoNfHeSvF6A4+bDVBvt+OipecK96gvJXOLtsc9oWNo0+sbo9DeG1OTE9jJiTbZw93K1VND7vbq9oLyuNFRPoHDK/DacZoduIy7rDNmEzNeIBFlZONsD+grsNoe0/GNy1JB0cfTtp5RYeWQhTyG3+ru5HnCmP4f3A0ChwcINltGlKmf7xSUsy1IpP66dBhJmel7rGeuJ9DVT3FZMXbuYM06luPW9jn+RmCtVUFf/wOE86oqUgDYp8PymcerYjfqFrOps+P2Dtg2yQQHBNKX76gR2TC7Q3l9FoyuzlCI7X1KuXCAtixJE2ahM/uW5dsbsH4jUYjvTjRR8DUcjZoQCXn3E8H3LzGAA+1YLiB1hxwQpiHAhzSqX9vcp93n5/BituhTDqSA6PlpsORgVwKKZ/9AMQ9MBNmGAC1CvjszoZx1ysyrSwtHV0NKzokDJI/AFKSh+p1EHlwqRvhHGHr0HjamamjA4dpxn7HqsJA9zd8wJIkQgKieGBLG3GxUt45mxS0rlNxnLC/fag9oVHgoMDrh+yPMx8RIn9DFYcAMoYeULdqUOndYVhaar+AwQQHUTjiInIa7GUbpXd7em5ZY8ZUPeucrq8q60rOXDc+t+7M5nNte4YksyFKGbAlYGdi160VyzeQSj1HZ4zZvPCMUc3fgMhxMOxqFGXYlAsBYd65aNADZCtCggetAj9/HqA0KsOnxehpRVGs7H5OQWlT2XSMnLxQrKAdMODzzY5DIfpeNPszCKdnJTPrs7QaFgat7ZBDRC9MwdXY6KMrHWRfcyIyK4k3XGTbF843ujym1GjOPdZIyrI3En101q x5myByFJ QaEJnWuIoSJfigOKm9fMjEvGS3wvLcheR317bELuahiIe99PLTlPTwJwHgiNAfTw2MFMGj6SS8JrUjO+A+2i7C8UBJv7UTU9nz4f5eo0gGNbEy7LeqYf5VZYNdrzH80Y/KnJZ0RhW77Y5JydJM+7pV7Txhk785BE6MsapyRh87s0xTVhMLhJ3Ewens8jNu/amOnfL8Rjq735ibsK9Of0a08zxVzYjUcdowfplb/fd6nXjLpofV5ounRbx9Th8F+gdxTL7Z35dTDMue9cTnimDk1av8GtXqBicroKetJq99HB3zV7UT+Xlnbkyb0ISwQZUadWMl70P/7DZ/QLKdMsersicrvWEMz37Jt+JzWb7wuQKkWQ= 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: and initialize most things in do_kmem_cache_create(). In a follow-up patch we'll remove rcu_freeptr_offset from struct kmem_cache. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- mm/slab.h | 4 +++- mm/slab_common.c | 27 ++++++--------------------- mm/slub.c | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 684bb48c4f39..c7a4e0fc3cf1 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -424,7 +424,9 @@ kmalloc_slab(size_t size, kmem_buckets *b, gfp_t flags, unsigned long caller) gfp_t kmalloc_fix_flags(gfp_t flags); /* Functions provided by the slab allocators */ -int do_kmem_cache_create(struct kmem_cache *, slab_flags_t flags); +int do_kmem_cache_create(struct kmem_cache *s, const char *name, + unsigned int size, struct kmem_cache_args *args, + slab_flags_t flags); void __init kmem_cache_init(void); extern void create_boot_cache(struct kmem_cache *, const char *name, diff --git a/mm/slab_common.c b/mm/slab_common.c index 9baa61c9c670..19ae3dd6e36f 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -224,20 +224,7 @@ static struct kmem_cache *create_cache(const char *name, s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL); if (!s) goto out; - - s->name = name; - s->size = s->object_size = object_size; - if (args->use_freeptr_offset) - s->rcu_freeptr_offset = args->freeptr_offset; - else - s->rcu_freeptr_offset = UINT_MAX; - s->align = args->align; - s->ctor = args->ctor; -#ifdef CONFIG_HARDENED_USERCOPY - s->useroffset = args->useroffset; - s->usersize = args->usersize; -#endif - err = do_kmem_cache_create(s, flags); + err = do_kmem_cache_create(s, name, object_size, args, flags); if (err) goto out_free_cache; @@ -788,9 +775,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, { int err; unsigned int align = ARCH_KMALLOC_MINALIGN; - - s->name = name; - s->size = s->object_size = size; + struct kmem_cache_args kmem_args = {}; /* * kmalloc caches guarantee alignment of at least the largest @@ -799,14 +784,14 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, */ if (flags & SLAB_KMALLOC) align = max(align, 1U << (ffs(size) - 1)); - s->align = calculate_alignment(flags, align, size); + kmem_args.align = calculate_alignment(flags, align, size); #ifdef CONFIG_HARDENED_USERCOPY - s->useroffset = useroffset; - s->usersize = usersize; + kmem_args.useroffset = useroffset; + kmem_args.usersize = usersize; #endif - err = do_kmem_cache_create(s, flags); + err = do_kmem_cache_create(s, name, size, &kmem_args, flags); if (err) panic("Creation of kmalloc slab %s size=%u failed. Reason %d\n", diff --git a/mm/slub.c b/mm/slub.c index 30f4ca6335c7..4719b60215b8 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5843,14 +5843,29 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align, return s; } -int do_kmem_cache_create(struct kmem_cache *s, slab_flags_t flags) +int do_kmem_cache_create(struct kmem_cache *s, const char *name, + unsigned int size, struct kmem_cache_args *args, + slab_flags_t flags) { int err = -EINVAL; + s->name = name; + s->size = s->object_size = size; + s->flags = kmem_cache_flags(flags, s->name); #ifdef CONFIG_SLAB_FREELIST_HARDENED s->random = get_random_long(); #endif + if (args->use_freeptr_offset) + s->rcu_freeptr_offset = args->freeptr_offset; + else + s->rcu_freeptr_offset = UINT_MAX; + s->align = args->align; + s->ctor = args->ctor; +#ifdef CONFIG_HARDENED_USERCOPY + s->useroffset = args->useroffset; + s->usersize = args->usersize; +#endif if (!calculate_sizes(s)) goto out; From patchwork Wed Sep 4 10:21:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790362 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 C8E53CA0ED3 for ; Wed, 4 Sep 2024 10:22:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B6286B00BF; Wed, 4 Sep 2024 06:22:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 53D346B00CD; Wed, 4 Sep 2024 06:22:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 404BC6B00D0; Wed, 4 Sep 2024 06:22:30 -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 200516B00BF for ; Wed, 4 Sep 2024 06:22:30 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B6ADF80F93 for ; Wed, 4 Sep 2024 10:22:29 +0000 (UTC) X-FDA: 82526666418.18.3E8A89F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id D957CA0015 for ; Wed, 4 Sep 2024 10:22:27 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=us9HEmIz; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445324; a=rsa-sha256; cv=none; b=iEzXyDSRy9ldFz+3erw2Q1tidTPNiEYg9KeXX7xGwonwVqem39gv3nus8BQuz1bLrXWY4+ f/ztMzL55m3zDxpX+jy71udjs6PZkQB+ShTPIC8sSPCJTPkFOZEu2zz5b4i0q4+ABBNUx8 GAiEyeKYt7mHjJH0V2R/Tfyzm9VRZVQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=us9HEmIz; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445324; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=W0IBUcs4bR+e/ACSTkKoJTzE3j3GJoZfBKXsggNrr5w=; b=33Jp7+HSL3oWzIzBPPqNzEYYFoEfIVZa7j2/tVhvl14oznp05Zs9fuf9lH+iBq2zhB5bkN FZH7/tMGpn2d+dyaxuTYiCS2T0IxijDk8Cpdi6ZEK/OphlJeC/5dtXPKrjEhwEu/mmMEFb PajE6o9tWGS3mjUFcawLRCmHEsCCKEk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9052F5C56EA; Wed, 4 Sep 2024 10:22:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35D50C4CEC6; Wed, 4 Sep 2024 10:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445346; bh=8hORSdr9O/EqElT2ajhJQ8gEdIqY6bU8s9Nue9pitwk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=us9HEmIzCgJ1DP9lrROrQhAb2zX+L5BEnnhdKkWq6pq0V3MhZk2lZ4bevheiquKzS 60XaBJaYfYppDbcqI/WDixM0L7NIaJA4M8LKXgTWMK0fphczOVIiFOsf9Atupsb1bj UFfnioh3A2OD/lsX+87sFGf2cMJ/Xtal5GknHUeK0aBeZV2Hc3G2OFN09CIPtZSCNH Bf9Xglj3Y62QKfyzei6gxD5Ilr4phgEjtoQX5dDDD2zqvwnJ9Fxs8c2MqhIwTYArAf Q8EafrAHwYLvHu3mDnBU/gu2RKAk59ffY6BBz7AxxxC9klbM/s1gJ+x4RApnjLJkVA iLHmH+bMcC5Gw== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:14 +0200 Subject: [PATCH v3 09/17] slab: remove rcu_freeptr_offset from struct kmem_cache MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-9-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=3911; i=brauner@kernel.org; h=from:subject:message-id; bh=8hORSdr9O/EqElT2ajhJQ8gEdIqY6bU8s9Nue9pitwk=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNk1Y2pnvP31qKVpOcJ5do+eigrNe3hBOWNSeo3uI obMvRKBHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABNRMWFkeMCSwrpzXcROLyPf JzwXoxOe3hR/ovf8iI7sgtCN83NWVjMytJ4XPf57hZ7huRP6s2Z5+YTtMrRZIt6vpv7B7bDZisW +fAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Rspamd-Queue-Id: D957CA0015 X-Rspamd-Server: rspam01 X-Stat-Signature: j5pq713iait3b9cro1he3ushbme5i1zh X-HE-Tag: 1725445347-908484 X-HE-Meta: U2FsdGVkX1/2R1v9r5s5TdPsuubq3dCa0SWQQGDdcxLHyixccJOAy3Eln8v2U/2dSnrnGV3m5778uDVBO+H9W8Z12G9ErvccMk1QvtQDbDqBunOw+Qvn8/jtLHcQNFqHpoQqO4YmiUsyGVIFwPFFMILvYO9e0PBNx9c9Y64W82i2wP7e368GN9g9ilG6H7pSWkY+GoU8bsIfJkTrbyfJW5ChHRWeXJB8c5XsuNDzRh3cf7VTzICCaf+Fg8Nngqh12tJpHvywNd9lBM+fm+4kuwojyu/tA1+y05NsV0x98XFwAliKj05Hjxk7d3otwRVPfvro1turB3+ZUE7AspULweySOwS6N9rvoEY0K9SQAhyRtkVNy1roSJE7QbhZmxCedQ4qhswJYwbZUb0dBCfgRHfYh8UaXa+uC53c7C1KG2wFDDkXwgj9YLeIbGvf43XWBIpYjsJWXE0FPVIgKq4p1Lq+qukfGl8bBeaUCRX10oeEv8/CftwLMJxMsWNIE9YHc05nQSZUM+w1avGHmoXngo/qMGhOsNJA5qdJuMp8SE4hE6itb7E7Ncm96usuWUvxn7hnFMLeLXzHj5vYcg4TD7oygYEw6UWpHAuQ0v3cU4LYP8Z+l2bbZD9aRT2DMz9NQyiNknppdVociZjWejXBLWpZRY2bv6l5sjqHP9fsxNgeiSJ9Ir2Zxt2tYNfrZfLhDt7rQAfjhxI4JrmXWw7VuhGkxn5uo5FVLA6yXXyG4bZHmZD1ucMQRE0RSCZzKd47AdZZUE+Ji4XKeclTYTo2A9b+3wssmNo8mYerMzuTw+N54H2wKf/xeCsHE7uYDQNziqwAb+Lq4wXfyxYupE7ZFwrIgmDcwxOrq/huV5fzkEPXkn1D1jErAre+KWtyXU9kpwWNvZuLH8mg0mT+H2onvzA3dmz1PptQXAhJwFn8Tjq9bzjzjs1AE+54rHWYw5ebDSn8qxfQYLwkjtmkwQn UMx7x7Da fvvfSPqBfFPGq5ig/AuW+sHR9mpeK4tr2RAsHI9dDCr6mi51fFklcc/dVQkyjOaF/80+KHepo9GH3pg4P3FyRj5C+hSQ2KDUbk5yyGy3dJhSqbIumNfVCPVpDR6gExmq47QqEH3eHG6NJjmTVZNYS148ONXiGn7xuGeD4kN5eBavS9OwKex0u83E8NS5gmkS9jnppNd5E+UaCpl91IidEDY2aJ8e9zXQ/KK07mfTMv2sbsso9U1rhYyfgndI/omTz32zwExtWN/2DYXFSlzt61a7F8kKTu7GgTmdsoKWHcOEsgjvk4b8hWeQXFS3P2k9N2Vt1fzR902LnH7ZFGoqLiC7AXnD2KWJFsRpJM+zsBYn387fGPZVoB5DdGzwHB0URJpK6mgIyWyjikcseeLOMROVWWg== 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: Pass down struct kmem_cache_args to calculate_sizes() so we can use args->{use}_freeptr_offset directly. This allows us to remove ->rcu_freeptr_offset from struct kmem_cache. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- mm/slab.h | 2 -- mm/slub.c | 25 +++++++------------------ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index c7a4e0fc3cf1..36ac38e21fcb 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -261,8 +261,6 @@ struct kmem_cache { unsigned int object_size; /* Object size without metadata */ struct reciprocal_value reciprocal_size; unsigned int offset; /* Free pointer offset */ - /* Specific free pointer requested (if not UINT_MAX) */ - unsigned int rcu_freeptr_offset; #ifdef CONFIG_SLUB_CPU_PARTIAL /* Number of per cpu partial objects to keep around */ unsigned int cpu_partial; diff --git a/mm/slub.c b/mm/slub.c index 4719b60215b8..a23c7036cd61 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3916,8 +3916,7 @@ static void *__slab_alloc_node(struct kmem_cache *s, * If the object has been wiped upon free, make sure it's fully initialized by * zeroing out freelist pointer. * - * Note that we also wipe custom freelist pointers specified via - * s->rcu_freeptr_offset. + * Note that we also wipe custom freelist pointers. */ static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s, void *obj) @@ -5141,17 +5140,11 @@ static void set_cpu_partial(struct kmem_cache *s) #endif } -/* Was a valid freeptr offset requested? */ -static inline bool has_freeptr_offset(const struct kmem_cache *s) -{ - return s->rcu_freeptr_offset != UINT_MAX; -} - /* * calculate_sizes() determines the order and the distribution of data within * a slab object. */ -static int calculate_sizes(struct kmem_cache *s) +static int calculate_sizes(struct kmem_cache_args *args, struct kmem_cache *s) { slab_flags_t flags = s->flags; unsigned int size = s->object_size; @@ -5192,7 +5185,7 @@ static int calculate_sizes(struct kmem_cache *s) */ s->inuse = size; - if (((flags & SLAB_TYPESAFE_BY_RCU) && !has_freeptr_offset(s)) || + if (((flags & SLAB_TYPESAFE_BY_RCU) && !args->use_freeptr_offset) || (flags & SLAB_POISON) || s->ctor || ((flags & SLAB_RED_ZONE) && (s->object_size < sizeof(void *) || slub_debug_orig_size(s)))) { @@ -5214,8 +5207,8 @@ static int calculate_sizes(struct kmem_cache *s) */ s->offset = size; size += sizeof(void *); - } else if ((flags & SLAB_TYPESAFE_BY_RCU) && has_freeptr_offset(s)) { - s->offset = s->rcu_freeptr_offset; + } else if ((flags & SLAB_TYPESAFE_BY_RCU) && args->use_freeptr_offset) { + s->offset = args->freeptr_offset; } else { /* * Store freelist pointer near middle of object to keep @@ -5856,10 +5849,6 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, #ifdef CONFIG_SLAB_FREELIST_HARDENED s->random = get_random_long(); #endif - if (args->use_freeptr_offset) - s->rcu_freeptr_offset = args->freeptr_offset; - else - s->rcu_freeptr_offset = UINT_MAX; s->align = args->align; s->ctor = args->ctor; #ifdef CONFIG_HARDENED_USERCOPY @@ -5867,7 +5856,7 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, s->usersize = args->usersize; #endif - if (!calculate_sizes(s)) + if (!calculate_sizes(args, s)) goto out; if (disable_higher_order_debug) { /* @@ -5877,7 +5866,7 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, if (get_order(s->size) > get_order(s->object_size)) { s->flags &= ~DEBUG_METADATA_FLAGS; s->offset = 0; - if (!calculate_sizes(s)) + if (!calculate_sizes(args, s)) goto out; } } From patchwork Wed Sep 4 10:21:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790363 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 47B71CD3431 for ; Wed, 4 Sep 2024 10:22:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBA748D0248; Wed, 4 Sep 2024 06:22:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C69158D0242; Wed, 4 Sep 2024 06:22:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0C7E8D0248; Wed, 4 Sep 2024 06:22:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 91B678D0242 for ; Wed, 4 Sep 2024 06:22:33 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 49F46A9F1C for ; Wed, 4 Sep 2024 10:22:33 +0000 (UTC) X-FDA: 82526666586.29.935BE0F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 7F2F820011 for ; Wed, 4 Sep 2024 10:22:31 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ng4+fX0s; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445273; a=rsa-sha256; cv=none; b=RU2s5cByYla1zB+u8rh8QozTRI+U2Eaqkqd99lj/X07ZxuQ5FKlQ4kPuRMcUlbRc2Se1XL 6mI03+l4BK1mynDhY3iUQ4FVIqSuMEzUDN3O7CIPcZWb6Up5WzmVg5FkChfbkVpD2pVbwq Viit+avwoXd2tWdwMPlhYIoVfQFzx6E= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ng4+fX0s; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445273; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4vks5PaaGEf3b57hflqOzeumZWaV2BauV/HHHP12jDA=; b=7Hze9gGay6JiftDPOcvUVJhbJHpNgR/PXD/3eYxixRG2U0GfE6ve/frW33zBlmxPCjlPlU RIfGb5XwZdWHdjrgq3Q7aEhFjKBlQr6UW1es513Il75gz8lShMsxn8ipTgL0HFNC9z3oXL s0xFooQo8X/Sj0U4cQ6vU46m1j4yjDU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 55CD25C5706; Wed, 4 Sep 2024 10:22:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F8C5C4CECA; Wed, 4 Sep 2024 10:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445350; bh=/U/EdH2xjh8wlswrDAib0TyvkUltBmXomIATwtZQzXM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ng4+fX0s+8DqSHCR5z9UFG82jzXO8WDWHFkEdHUi9jQ+e6ydvcsUhDcnPzOss7yio dLO4oWouJTmhgVH/3C4C6a9ju/RIGsmQiuDTcIqUwxTrzQqI/+RQ/777jJQpjGiLSB A+/xoiff9qLDxM/465PUiXMat7Lr3YyFKz8b0fmKKk4fs39EMdvIj7ewjAbOl3w/x5 0Z0kfj9Ohvs2pLp/lty6ljCM24y3jD1VnWrq7IjWzVavn53N15ekpNeJIst9gJ62Jo xR03wiqIsnNZsFzHH10rsWoMeZs7UJCsvQJ6xyckYgxCOKnTlfYjYFUa0f3lOK+gnM 17/RgHPMb0kEQ== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:15 +0200 Subject: [PATCH v3 10/17] slab: port KMEM_CACHE() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-10-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1217; i=brauner@kernel.org; h=from:subject:message-id; bh=/U/EdH2xjh8wlswrDAib0TyvkUltBmXomIATwtZQzXM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNl1oG5JPOf83ttis7ZNrFp7sPrsoz65lH2ntZ427 Zh+zOjevI5SFgYxLgZZMUUWh3aTcLnlPBWbjTI1YOawMoEMYeDiFICJeBUxMvx76K26/FDZJaco 2x96nI93rMk6O7OU9/2r7Sv46r59qw9nZNi5vaQsb84tv0tfMpQaD03zbGLs1VmtW9a8+9ut8H1 MUxgB X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7F2F820011 X-Stat-Signature: bc3hf1jwzptpcp3opo4s7e6ipu9awywp X-Rspam-User: X-HE-Tag: 1725445351-269972 X-HE-Meta: U2FsdGVkX19lBKA0g3OABEbfvJfE4nToGtimsl8FYG2l/hc/znA8Y+I4n28SsZtkyfPKIjtb2OtsQQk40lGr1Wo8ngBt2GIFMZNcfz/1M8GU7/1GvrAU7rsMEiavpcSI700kZ1sPlDPbpDID/hFs2Sybb8EpfQBqxb+gYsdp4Hvyf6kg4vjW0TjpWHKdRtjy7x5EdHZPpO/GyI1e4F6VI8lK3SniV54NAk1TajWmhBBaOHWNbF2mHgwmSZnqi1aMzOf5jrkkZR1W4jQ8mHUAY3Y3oX+IRPknFM8/8q0t1HFa1W7zTk76FzufZSi+r01hd8sOPPI1j4zQ1G8E55xCamS8+38Bbs5KmOrMo5+yRrQQaY91Fxi0kdC/0idUZzZWkApUj04AQyPGQhgY2J+qlrUZxtqIn95RQ6yvU/8Y4Eq4mx4g1/BTQg5Md5N5pXW4+84mPEm3bRJ4SeOaa0MmUyPPsgelVw0aWnJgC8kyy1hGzEgsMDsgnO8C65VPkJ1SmphnwEvzTRRoKL2YqG2WZ0xcZ1wX6aBRNDP/uKscKSP3mNdnj+ynuZDZ0rXUt0bh31/X0YNYSNZt2+NTRx3Nf8hG7ts9QsqDxfnIMECClf29OUOSaHmnDHuC2+rU1rn2uKf2OZfeh1TyFNZRd9/BEg7oC3qDCYOQHrM7LsQfhhAKZ4nDhLK8DMA6sF3jmHBF18ViTqeoh5m+nUl1C0ggG/AY6NtJa/ntKBx+Vi63nQ6dgrivJt/3ctpAoEs0sdnxdVsScawFjdyd/Q+sR2YDwAyeWjhjJDnU38ZbgqJ9/ILTsrl4W+L17nFwE+tBrgQTJaf60sDevUxYkKs6S2DipTXGx8mcs3lOx9Mn+LuydTAK9M9JvxhI+B9jm1lzm6yIAUz41SOEcleAVXIMv6JA1u8yH8zvF/JcNG6/oIOkXeKAR/4ev4o09lD4GD1uq91G/uFzZmWvOu7swfNFiIH Riw2UwMA pbMF5Ce+wqZBVTFLHLsJdOC1+zVdOWhaSnobqW6XOvsjsngE2tcqGoJSG5IMmMKWFKvzR2dT0X0mfNfyiw1Dbxu+SGulwwrtryjyevW/RfZMBnZq2/p/aSX2B0qVcl9v7BmbXYJ9DJOceNpApzMoYWpWYcPRUcg34SPbdstZJge0VlsTffdtA3Sc0ATq5fBG3b9t4Wu/P8QukUUcqr4I+OsEV3Y+Heu5P23to1jy/Bc7F7T/OCFvgjlkCsTMfbnbtNwfkzpi9OBV6k8io01mAlGao1gNyz7H1Tunzttl717Oz0BD4Ba1+TiXvjeA6aH4g1Ilwb+BhvW8eraP3NX2rpIYSuMg78oaE6ORoboT3PUJrSixyrionMya2KQ== 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: Make KMEM_CACHE() use struct kmem_cache_args. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- include/linux/slab.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 79d8c8bca4a4..d9c2ed5bc02f 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -283,9 +283,12 @@ int kmem_cache_shrink(struct kmem_cache *s); * f.e. add ____cacheline_aligned_in_smp to the struct declaration * then the objects will be properly aligned in SMP configurations. */ -#define KMEM_CACHE(__struct, __flags) \ - kmem_cache_create(#__struct, sizeof(struct __struct), \ - __alignof__(struct __struct), (__flags), NULL) +#define KMEM_CACHE(__struct, __flags) \ + __kmem_cache_create_args(#__struct, sizeof(struct __struct), \ + &(struct kmem_cache_args) { \ + .align = __alignof__(struct __struct), \ + .ctor = NULL, \ + }, (__flags)) /* * To whitelist a single field for copying to/from usercopy, use this From patchwork Wed Sep 4 10:21:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790364 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 34C3DCD3431 for ; Wed, 4 Sep 2024 10:22:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A979E8D0249; Wed, 4 Sep 2024 06:22:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A489F8D0242; Wed, 4 Sep 2024 06:22:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E7E38D0249; Wed, 4 Sep 2024 06:22:37 -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 6742F8D0242 for ; Wed, 4 Sep 2024 06:22:37 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 23506A0F96 for ; Wed, 4 Sep 2024 10:22:37 +0000 (UTC) X-FDA: 82526666754.16.C614FC5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 71FA0C0012 for ; Wed, 4 Sep 2024 10:22:35 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="VftW6h/4"; spf=pass (imf22.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445259; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cr+zJef9rFi1LPaZQhRMtjM8emHx5yay7S/2k3Dhjp0=; b=IIO9QqmQTq0UX/p3gKy4QgT1fDHV9PsFIJIZORkpAnsGZhOsq2Qrb5Du3X9AGs+jMM02cF u1EnPG/WKxvm/wXugU6VRJ/bNIktBQ7Vt6BoUfiNzSniOlxpbetWjvf2jShhRUKn/yQ/19 0ikZmMQfx+qy8zPQI4Df4UZfL+orOg0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445259; a=rsa-sha256; cv=none; b=tnPYHa7u7Fe1VwUE/Mi5bH5RGx8ZGvqDMG/E/NcqOucfzfzZ0FgiHjIjIRggoBhkn6gNaS zcWSjeyqUaDrflNN2EhzUOpErnCM7Pa/zhEtA3/xTNagEVKUJAqnXGkqJkYl0mJvq4yFpF OScrSN0djhIOmDyqbE0r7zJWqZpi2Zw= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="VftW6h/4"; spf=pass (imf22.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4B9355C56EA; Wed, 4 Sep 2024 10:22:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6A98C4CEC8; Wed, 4 Sep 2024 10:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445354; bh=82J8Bf3LCC365/T9k9A+CuN1jBmnIwSLQl/UyUW6uSk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VftW6h/4nP22SErP4ZUBode4BsdoX/rn/Oe2nrMJfHyJqoUNq9k9mqtieylVbFrTu /Rb5LHSBVEgxWAM9gIifQg79JG+qOOzP/g8cwhWLXPwoc2WzvHbr5OZHPRpVixzW2l AKWOunLfQ9TRuoKUIG3mnHOxjlmDxnng0QCl05BKY5qCy8L+XRktHVZKA3DXb3867Y HA8zx3rGwx39UgKzj3y6Fg+yIsXcKDa9dbmI2AxaEY1xfFE/EvGXLNN+qYq/I6Hf11 PRy9tXEt6NHf3W0hoe9oDsg4S12TYYAPavNlvJK0s6nenxgW6T+/4NtAYHxdE4LVYl 9ZURfLw0qrAuQ== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:16 +0200 Subject: [PATCH v3 11/17] slab: port KMEM_CACHE_USERCOPY() to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-11-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1417; i=brauner@kernel.org; h=from:subject:message-id; bh=82J8Bf3LCC365/T9k9A+CuN1jBmnIwSLQl/UyUW6uSk=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNllvcm9/S2D0dtHnVb2ptY3cvLiTpxk4XvUvaP8Z 0LVsbwTHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABM5e5uRYUHpdQ8euaUhvDaS vbvYfR1nHDyetjnWZVWPwKNH2bXGwgz/w2R25VxKdOL6q/okJ5z7zd4zAb46QseLvVh5ah5X/Jn JCAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 71FA0C0012 X-Stat-Signature: za3fawej7te6zdkprs9h9x6p9yypqgzp X-HE-Tag: 1725445355-884450 X-HE-Meta: U2FsdGVkX19ddY5eX6A8nfyd5J2M0XukFROl6seGQN7WANZQgDA6RDUJphVmVH17LfwmBxnIcuN4kQSzUNaRQ/ytmrViKguqKwecuBQ1pKS0u35T+lgHTMRDxtTTBNj+SDn5eks5mAeDK4plAfDfCIDqykz9XnlLOqCKpWS3+OaM6zsGTWg8hqtaNhodBpSQluWtTc5zBgtubuQCScZ9avFCVcXX2jvNFlDP21wUu98QPSBHe2fzrWHYL5bLEeuiiYhzp7uLLGSe5ooAL2GgRbheIINykF4MyScuMKW9DlMYJNffNUvvXMCpv1/SWWHGBN6p3avtWJu23jreYHzHtZ0W4FGzQkuxdli8sQj3/6gS1SqybzsGCbVAhOjq4qqgsU8xONKShDC/HV5FlSQn/P0v1x71L/k5v3ESp9GpHBD0Ixstj3mFSdCVakk69nh4rnnm1yv6fRBewzEY24VbKDGxthqmfspRESSZRtWZgVUwaR5oxW4pDbrhY1K+xK/L3NDBIO6xJmkMF9Gu9BZ610wYhcl6Lh0E7C7OnnSA9ee8befaeBXlZ+8YPcT1Q1kc+AbIQ1Mp9HrLfEIrJqRogtKZYf0hB/OMdoazQhBSbqgqy1WddV0viiwBkCMoLSJr/15zPocG41egjiPF8XcTYhIIykCpKp/0Vn9pPAdbujBta1pkadJzIz2m66bQrLDMbR/Y/XCz9tUYrFHWBzmub37O3SrlcMB4h8R1KKCDbG+pnZa1UMJ8R/7Q1EV04/2OqVhyQK8q2PxXl3mdnfIuyINGr+CGXKc3KjHgo3CSrXgH0YqRecIhnhIN7hhj/VXYICyGiLxhZRCEAwBw/Diop9dQYAT/Qqr7DRvEDv2mn1rs5Su40TCJrKRXhi/Zm34QW/8JRXJEX9bSitObX9JCaHD0O6hQ1TVrJKgS34TM/4fwGUiJYvBj2P6Gf177JLpVpCqvsh064hbTn797jd7 5qS1b4kn 6otHOCbmmVIb+X59wd9YiaC6C87lxJR5TdT2to8G4osZi+uhFqlsVkg638g6W2N+U6rE+jgpByTOf6nW64TsQv3CmFsUj4qiRiz9EPXj3TFRkBnjjl6T1tfZOAUwSDgqR65NYXzxrdqliMlTqzS/G6kDHJ3YCc41Pz1XMYyPPCl2ygEnyGzhjPqKCgExwCBEMtLgTF5vuSqPt5b7QbeY96mvhyE9goJeAPZCggf6N4VFILGoFzfvwTKNou9iXMJu9TV+w0aTHx97A20kO1haKx2tg95oSKTZthj02CDNWRH6RhbosRYFA0IChmxsUdAnB7VwBHn5cbf0qgh54dzQOl5NK3WniTcCjh1gEj+9Lw66guQaHhF86dlerQg== 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: Make KMEM_CACHE_USERCOPY() use struct kmem_cache_args. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- include/linux/slab.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index d9c2ed5bc02f..aced16a08700 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -294,12 +294,14 @@ int kmem_cache_shrink(struct kmem_cache *s); * To whitelist a single field for copying to/from usercopy, use this * macro instead for KMEM_CACHE() above. */ -#define KMEM_CACHE_USERCOPY(__struct, __flags, __field) \ - kmem_cache_create_usercopy(#__struct, \ - sizeof(struct __struct), \ - __alignof__(struct __struct), (__flags), \ - offsetof(struct __struct, __field), \ - sizeof_field(struct __struct, __field), NULL) +#define KMEM_CACHE_USERCOPY(__struct, __flags, __field) \ + __kmem_cache_create_args(#__struct, sizeof(struct __struct), \ + &(struct kmem_cache_args) { \ + .align = __alignof__(struct __struct), \ + .useroffset = offsetof(struct __struct, __field), \ + .usersize = sizeof_field(struct __struct, __field), \ + .ctor = NULL, \ + }, (__flags)) /* * Common kmalloc functions provided by all allocators From patchwork Wed Sep 4 10:21:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790365 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 3E17ACD3431 for ; Wed, 4 Sep 2024 10:22:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C45628D024A; Wed, 4 Sep 2024 06:22:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA5FB8D0242; Wed, 4 Sep 2024 06:22:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1FC58D024A; Wed, 4 Sep 2024 06:22:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 832A58D0242 for ; Wed, 4 Sep 2024 06:22:41 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 26F7B120F5E for ; Wed, 4 Sep 2024 10:22:41 +0000 (UTC) X-FDA: 82526666922.02.1367C57 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf15.hostedemail.com (Postfix) with ESMTP id 6C2C8A0012 for ; Wed, 4 Sep 2024 10:22:39 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HhZh9DXp; spf=pass (imf15.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445283; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=F0D9YABQJXkuctn4M92D5YWV5HVwbeySEi/bw/8C2FU=; b=YfRUTgEUCUuUUAXXTtFXJZNTnqwjLlrOS7N5zJgWjN3dt6Rq5HEJlIqzhZJzmsDJIzHOJl q4vT86DLiYSWMnEY+YWhEwMAGA0ARU9o/qYC+vgWqloW54yZsFrslvcYMijdB5QaNoqst9 gMI+ympCv2fWzgi4wX5zRsi+8ifFVlg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HhZh9DXp; spf=pass (imf15.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445283; a=rsa-sha256; cv=none; b=qspTKOB+WnUPAAQ8xL5Opml/2MZtaRLKJUaF4XS04L9PJgu3iK6+1zj6VBB6ihr8pB790I RVsCZ+t1LLdEWAUta8VMNrqR8U+rKIk66HBrV7fWUVJJOaAPu9V1XpfeIlNlst4+SL74yH rBuPWklB4DRJQGEuyMe8e7VupIHU2sM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id A24F1A4327F; Wed, 4 Sep 2024 10:22:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F26DAC4CEC6; Wed, 4 Sep 2024 10:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445358; bh=dnwP/c5HlqpuuYs6TocRpCymaBfpftG+kdwK6XKc1E0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HhZh9DXpXCPba9MpQZVKOy0Ru27OS0HEskSXwAoDug2DUBzvgpz64S98j7Hw1t/bC BVj+HYC6e8qqlAqINxPAkWw3OhJM3Ou2+TOjNYfe+EPeKyLXxkaN31I3Uo6sUMGr+9 MmCk+iSDrssxm7ruDUw4wx6fAOPkz/++IWZjV1gD66ymm4gV9WFq+aOJGQH309H/7M EFpGvoa7aVx0dDTnBfaX01Bd5+U3LjFbuYSjbLn/nqf9tHWtEepUycPqo+VXfDFM8L 9BehLMX+Y0F3ogbV8kHXUl0vnhsfc0ExXBSSmNz5GI5GDFX0yUHmZeScAnze6TYIEU NN53xl5rTni6w== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:17 +0200 Subject: [PATCH v3 12/17] slab: create kmem_cache_create() compatibility layer MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-12-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=3373; i=brauner@kernel.org; h=from:subject:message-id; bh=dnwP/c5HlqpuuYs6TocRpCymaBfpftG+kdwK6XKc1E0=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNl15rbBxssX1ASll7Ntr2iuelPPt6tHsviFY87f+ 97vVoi4dZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEzk7g2Gv/IhxWev+F9Q+PAl 1O+De+AROQ+p2wpTl6p7Js2erjNNvoLhf7Z27Q3zJWyBfJVrtRhcdZ/UPjV03BB5ksl+6sHqBXl 5bAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: podsfogszqgk7pnk5wrg5jrabb4unfpb X-Rspam-User: X-Rspamd-Queue-Id: 6C2C8A0012 X-Rspamd-Server: rspam02 X-HE-Tag: 1725445359-90973 X-HE-Meta: U2FsdGVkX18ZxXUxz7eNFQMcftDdNjLTFo7j4QTE9AA1xcBjeoL0XVzua6U7kl88iojLVBq6YBTndUiarL6TntqybQ7o//ivc4lC0vIgyCVFgSXSNOkX5kUja6jYh9QZKtxqM2FK7E+9GP1yerdAuWw9COAQivikg3JbzbLayZH8kLye6Kvr/pVLoEn1ZUepP34rGJ53TVw97tt4VXrb2vWKZ2lRVO6QXYE12e3kMyFp+gvCvH9WRFOJvQrroxsNLTpTCsKtctPgwwGNFMDqV2lSeiVM0FHNNVdc7SF2CortZV9AgDNxJ3SZ15hgxYClhFqkALNHUzKY+BxYDb/qa+bdBjV5uDPbR6FKSSVwKLCA6RBoxM14Nzl47R/7kUVY1tSeybvMCWeVeTtm/NYqAqP6mRGjLInFZ3Zu+ReVzuu0S6IwbWiHmpSRFQ8TPZTtEQ3O/o4dpdwxy3qp33zxcZ1SPcxIqrMgQQt+0DVZ1kBcpDiwXPEhvBzMRSG6PtofEIlBJj6f+z/S+mR5+xrMkDNwnca1oN90JW/s3PCRuysZmyBbcsIMnPvNaqHpihDMwulraLoRuaXapviCI1/8Tm+fxhnfPo1tyRKhv9wvfVVS/YK9EEVgLMb6qf6mk49OipCHqvqxpZdrt4mHx8LoPLeiAaM5Jlu5yY2D94VWmuSyH/2trjbAIgrYTn0hphSh4eAKkaEpG019r/vt8NXIzKwrvcTXyp287/tDr6YynXtklskoCdihCTcO4/kku/lZZIz1hn2VJ1wlqgPA0I5yuqMCObXw7rJy8owcOYlkjJ37MDl762tnVSjNk28RLdhNLP/ccTUZ27bZYxZ+bDWHoZ3OLTXDt7HNJUEfvy256tTjljiRiJatBSa8p1sNdA0/MmUo36gu0+zoZWUcFhEVABTSWmgYoz0mgPYdetyq4jtPxssS1RE/dgNUUsJVFHLlBXb0QdX6XGTsa8U/Pih 6dlJnTwa wjkKZciW1UzKDly2NUpsALwrnpjiCuIO7OBNm87AAEL4YJWuL2DL51UUR4O1tVV/Vwb6/FtpchNcr+dSOr1jwDRDk21WgDnBzWdKVWA+gIoHdS2sG4PaxOSvc8tRTexmWk/OC/cfGlVn5gIfP31BUPD2rYQRDOF+wyAuMivhNLm46t980PfSzyWyXNGtEGsZZSzkv1/Cwyqx2QcM5KiOuIYLhWyWaWc+HDLq4jqX0Twst4JTmdZgbfGQiEE47Yqq/9C4I+bSjcvoBpEGmtiWYgyUBuT3Z4lsF9JvJwBdkoz+Hiw6XeZCknvSuSdhMj2U13SsN/ZZr3altZLBRTkxiclQphpNuJVBQm+w6Hx3rMEeVzyA= 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: Use _Generic() to create a compatibility layer that type switches on the third argument to either call __kmem_cache_create() or __kmem_cache_create_args(). This can be kept in place until all callers have been ported to struct kmem_cache_args. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- include/linux/slab.h | 13 ++++++++++--- mm/slab_common.c | 10 +++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index aced16a08700..4292d67094c3 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -261,9 +261,10 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, unsigned int object_size, struct kmem_cache_args *args, slab_flags_t flags); -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(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, @@ -272,6 +273,12 @@ struct kmem_cache *kmem_cache_create_usercopy(const char *name, struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size, unsigned int freeptr_offset, slab_flags_t flags); + +#define kmem_cache_create(__name, __object_size, __args, ...) \ + _Generic((__args), \ + struct kmem_cache_args *: __kmem_cache_create_args, \ + default: __kmem_cache_create)(__name, __object_size, __args, __VA_ARGS__) + void kmem_cache_destroy(struct kmem_cache *s); int kmem_cache_shrink(struct kmem_cache *s); diff --git a/mm/slab_common.c b/mm/slab_common.c index 19ae3dd6e36f..418459927670 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -383,7 +383,7 @@ kmem_cache_create_usercopy(const char *name, unsigned int size, EXPORT_SYMBOL(kmem_cache_create_usercopy); /** - * kmem_cache_create - Create a cache. + * __kmem_cache_create - Create a cache. * @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. @@ -407,9 +407,9 @@ EXPORT_SYMBOL(kmem_cache_create_usercopy); * * Return: a pointer to the cache on success, NULL on failure. */ -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(const char *name, unsigned int size, + unsigned int align, slab_flags_t flags, + void (*ctor)(void *)) { struct kmem_cache_args kmem_args = { .align = align, @@ -418,7 +418,7 @@ kmem_cache_create(const char *name, unsigned int size, unsigned int align, return __kmem_cache_create_args(name, size, &kmem_args, flags); } -EXPORT_SYMBOL(kmem_cache_create); +EXPORT_SYMBOL(__kmem_cache_create); /** * kmem_cache_create_rcu - Create a SLAB_TYPESAFE_BY_RCU cache. From patchwork Wed Sep 4 10:21:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790366 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 6A98ECA0ED3 for ; Wed, 4 Sep 2024 10:22:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 010FC8D024B; Wed, 4 Sep 2024 06:22:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F02138D0242; Wed, 4 Sep 2024 06:22:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA45D8D024B; Wed, 4 Sep 2024 06:22:45 -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 7F58F8D0242 for ; Wed, 4 Sep 2024 06:22:45 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3F7A7A9E86 for ; Wed, 4 Sep 2024 10:22:45 +0000 (UTC) X-FDA: 82526667090.08.A00E5A1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 76AD620015 for ; Wed, 4 Sep 2024 10:22:43 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Y5mD2qJI; spf=pass (imf03.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445236; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+LMT9Pcej4RmatWfBTBFWa1qfI8iZx89qoTMiINgq9o=; b=B8w3Buhx8aLuKtza0C36IUAZelcdRDhBwybA6Cgm4gRuSoTiYEVUGBsDLcbD5YmWB9xOcQ M/eT77H6i2Mjf3bwEDKeEpm50KX7hcEXp72PmUhN1zrXkND89QrQAxzzYieY7rIMrBCXI2 2nGeGh95tdLg9/jUvBw3t2EGfQfsSrg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Y5mD2qJI; spf=pass (imf03.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445236; a=rsa-sha256; cv=none; b=dOLr+M7rcgq3COK2to+8lzvfHGeEANwryuopQzCPGtYc98hiuovbw5kcbF/jKoA9BrunNM hikgEU2aYUkG3mpn667FjD3Py2NiqhpaUrNJWDRLwYHXa+MaWrLvWhObALOSm/UF8SJ/d1 meANR1ntGmXHUk5t4Lw1glE/z06UIoI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4BD115C5706; Wed, 4 Sep 2024 10:22:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15AE3C4CEC6; Wed, 4 Sep 2024 10:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445362; bh=MhdNhrflcCHIlYw4WJW1aVuEAIulx0BazYlkdUtItAE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Y5mD2qJIqza8xUSaKCniqGT6GyvL5XOqqUqSen1zwDmgse53XxgDkB/IaZ6OsdYYY HYib9vb7fhSa0D2q4dqzyj/8xC1BxXzCl4IA1dLaiKDhsnZ+025pBjcaYYIt56ewzj ImyELYiUYXyDW0VEvr/BVWQpJGlLykJqI7wS3YOuAMzGJDRvoCGiHtUw2UzduwguzR 940m3KaGmUe9hQRpBz8qObWAKghEKOZLvzpTjFxNZAyCcxk3DlWHiHrlgM1BkhzusM Ae1/8K1zvEazD1LkNYQfJJ85PlwjmAy3UoiuSb8kDBKXmGvelED+4HYUZVLErZA8O1 nniIQcrF4IcHQ== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:18 +0200 Subject: [PATCH v3 13/17] file: port to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-13-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1043; i=brauner@kernel.org; h=from:subject:message-id; bh=MhdNhrflcCHIlYw4WJW1aVuEAIulx0BazYlkdUtItAE=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNn1OddWmEttJccRu4daT9PNdz/3OvbG1UZGZaKCS 9Ckp24WHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABMpcWD4n7e4eGv9V5XWu/md cffOJzq8mfAveRnXW84XuW2nErR+iDD8FV3y7dXBLL7PUvqJBmJsp52Yuva55RXdt1xyuPSwDXM hNwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 76AD620015 X-Stat-Signature: gutg55ui63ctfndahsex6x3ebxpyuzoe X-Rspam-User: X-HE-Tag: 1725445363-852560 X-HE-Meta: U2FsdGVkX1+UN1dEeGEljqmFU9QZSqXlShuvflSdPGlzd/E3bKRKR5IFE9lUrFLfdt4OOEzlrjrCFXfkF41TV29MylHqaXnRkubQcsbd4AXb/SwMC0+F7cKxtqxHL3tD/QHcFqKJZqDRhejUqQ2oW3bZjATrHxJKpIuByMDjxpUSlRBgPzxMoG/dn7+P79OLyoj2RGc5rPFv3z8EcPkBkGrMO8UZYcwBYOZhBhpw5rPtY6YJMyHWgeXmp4vIqH4pZK4sm0YcTg0kXCniQjPUm4UVsByKIbvvrvjGem3e0RHCFpTfC5xH3rCrA456lx0UKTc0HeoJTkyHgBbcc77ERj22OPkHGZnkkNHEWJtgw9VZMul9O6NLGS+swASSToWTqb8Tc+ydb4q72z0kD3zmSm0QVfkNZNl32j41unTJHp5DNZpFG6S+NwDo8VYPlKU/S1vRF0a5owErMJMkr8xrifDXEWgx6GByz3TvfURP5wADGsyCQb2qsfef1WdYugiRLm+/U1CCM7M5SC5guV8f7NfeGjiq63WTWkpbXjP/t18nNnro2HguN7n5TlEdlXdPyXJI2UOk70YEodWlNkkJJ3bqskkRCCOwOD9yaRv0HlvzGkkqVIkGZYkHBfFLirFBW+TN2ntT+dobVyTYak2D7okiXsdqefBxxXzDbPR47XEpYF8rDl0feLuyORB0QVb7eoTI0DWFbGQBNYB+/uLuu9iB9LPbXl425ofk7QHWGFoqmApbUNnhpb8+mOX4bTblaqq5hfZhAdIk1MLWTw2aRT4XDweQ2YUFchA/PhLuLgZn78Jejf/oBKF6lRmS3Jtqv8eMB/bo3mAqvnhH9FfZwsOAfboVdC1oomIzKWLLl3qN9jn5OfdU1DoMKSXQ/YVYykjeV9qwDLCXVcpVpUjL+ZJ/uXytSthLSewbA6/3ZTDjeqPzvlWYxnjRb7y0gTPCiByjKuA0JmxumIY7fSK Tt/T9sCY NGPhT0H1vh3bkq+BtT3MDJs+l8NIfvCUC3IcOO6Qb3/YQewd2Eeqw+8dAkOXwASQmL7tE8bYbjGrmkcM44xhrXsgnDSvZZbOhTDWCbW2N4AtZvroNueLuBtetgkTnqR279UBdVI35+7Uffv3OHqNQ0Ls9jgfV4vREdRfpIPrltB9fBeJfO8kv3qOg4NIEy2jAKBXZi1MtQDbJkqNBQh6auK+jN+MY9UtlUR1v5Aa4/VAcb232IP5OhpxeUE02zkVn1HSmInzBcNv4Ydv1nkA1pa0/Suxo7b/k4BNV4IXP2fJlq8cmZPUu4i4OG7J85AMEKsi1LUlBBeOb2DD/qil6le0BLpulBISPnErXPU1G1RKmeL8= 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: Port filp_cache to struct kmem_cache_args. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- fs/file_table.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/file_table.c b/fs/file_table.c index 3ef558f27a1c..861c03608e83 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -511,9 +511,14 @@ EXPORT_SYMBOL(__fput_sync); void __init files_init(void) { - filp_cachep = kmem_cache_create_rcu("filp", sizeof(struct file), - offsetof(struct file, f_freeptr), - SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); + struct kmem_cache_args args = { + .use_freeptr_offset = true, + .freeptr_offset = offsetof(struct file, f_freeptr), + }; + + filp_cachep = kmem_cache_create("filp", sizeof(struct file), &args, + SLAB_HWCACHE_ALIGN | SLAB_PANIC | + SLAB_ACCOUNT | SLAB_TYPESAFE_BY_RCU); percpu_counter_init(&nr_files, 0, GFP_KERNEL); } From patchwork Wed Sep 4 10:21:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790367 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 4BB3FCA0ED3 for ; Wed, 4 Sep 2024 10:22:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBA9F8D024C; Wed, 4 Sep 2024 06:22:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1B668D0242; Wed, 4 Sep 2024 06:22:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABC8F8D024C; Wed, 4 Sep 2024 06:22:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8C5408D0242 for ; Wed, 4 Sep 2024 06:22:49 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 494E9C0D6B for ; Wed, 4 Sep 2024 10:22:49 +0000 (UTC) X-FDA: 82526667258.10.6EF9AC0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 6BA8A40006 for ; Wed, 4 Sep 2024 10:22:47 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JRb8YchA; spf=pass (imf04.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445272; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iRXJ74JGXxhhieUoVKXM8YRkSn2Eta4kedrFgxgg5Y4=; b=IsIVDHqozageGHJKvt8SbQR8gDq62m/9MWjIIkGksWlGhwE79Ohjre0KXuK26Na0TetcEy inwmQ7LszsfwJHY4TtAw8V6lJ61FB5ZbRYITIHGCwAPn7/XR8bp9eI70AmWLaDWZ1Y90lC FSE7XKOzeT5SXN01oIj5C56kzvozxFg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445272; a=rsa-sha256; cv=none; b=a9rhr/Ib2LOgn0LdHdCTb3mweWiceXi9czHZ8+ChoL7Lc853SUE4fOrEf1Gv5E7NYZgt1X yXaeMOAXzAioL4C86ZuGANlXuvsUxLQCXkPDyo3OwnLwXRujhNxlSvHWpE7+KknxOvnTvt v66SDvwkaiAN3bq/ddWrBv0H72ty4G8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JRb8YchA; spf=pass (imf04.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2FC255C5720; Wed, 4 Sep 2024 10:22:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD028C4CEC2; Wed, 4 Sep 2024 10:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445366; bh=ob7tfSkKKaOFfsUNw54A8NnR55QWcUPRYRE0hGJ3b7c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JRb8YchA1ASqQ3gjaPNCb2ql7VsuECo83v0Lq+OcjYRob92h21b4kbDsuHmjJqRZW qoSlLkVDQOxp2eAaBmMBDJ19GHaa/AAaD1r4SxRhIz4RQm1a1ONGWK/lFYPQDNafQ3 j7LA0AAPa4Zan7gvOn0W+nVU8RSDISc4ZRmuAKoXHPNA2jDH+On/sNA6mDW1anw+KL 4W54tzz2lLjzH42yg2+1h2f2SD6WBOQRajfBNgC5Mb/51bSWfOYXipxW/tHfzOaDjG E3iiNtpx601BMCVUfuwfr5VoFgpooZwUU1wPcE8rttxqQ/My7vpCohzgD/t9OKIBvt SL8JA2SyIL6Wg== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:19 +0200 Subject: [PATCH v3 14/17] slab: remove kmem_cache_create_rcu() MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-14-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=3146; i=brauner@kernel.org; h=from:subject:message-id; bh=ob7tfSkKKaOFfsUNw54A8NnR55QWcUPRYRE0hGJ3b7c=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNl9h8VC/ZrFR6Mzc6ZER+rs5dr4x2dKw/Pwh95OW tcSTRtkOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACYSf57hn45wDQOP2darxaJt NXwPNXi71KIeTUt7Nksl5J+fyc9l5xj+u3W69D4PXbsz+/GX+XE+Zgv5VPV9b/zcezK0m+nk2g/ 8TAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 6BA8A40006 X-Stat-Signature: 1d8aj38sgxkwgum8gbfdwbomf7dfmpeg X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725445367-892578 X-HE-Meta: U2FsdGVkX181Utwti0Uq/XMB3y2DUCSUJevNDHOINgu0WfnDX8gDPVxuppTZhjId6odmOnoKHXKfUNJxrToxh8yEAzPbtmeH3BjOTG8FmYrjwi8oI+JdTv+M9IgRHAlPTKdDS43cUBH7Zi5pkkW1HIqo2DaOd16gX8xfSshq/axctu5zJ74Pfted1BF7pG4xfP618o6Az+6IfhpXWktx90UWNa3PadwAhRw4Yyh9N96k3E0DCu7x3+hqG7muTjTPGU+DcdLpXIu1E2AVl8bD5J/sC7seDyKB0zeJRfg7SDpSSSRL0p3Uhheg0J+YDK3H5Oei36WP8Lbq2pFk9ZCstxaPMaVCBwv5kZKaqrggAxtnoxjTOs/itVv+nXxZciNGDoYzxuUJpoK4N++VwTShf5HEP1yxpj8zBWHiKooOn3E0IB9uFiLrIP4Qu/yX/FVqCbmuvx388MsLxgxoAAnp+Rxqzi0D1c7X0uY+QYL2UPmvgsIGh5sNEeHcQ9JJxhgJxUxHNXUwViXL1zLbuW1t3lcpCLlGL9YW7Vnn3pn/ajB6tvINXUJwSryCju7vIil1SpTtTHD0dDFdxFm84SxpBGHuasxUCUngajIlEMadcIsphaMcrZ4l3yMVMbj++k/kcYR4MG4bsKmGgDGodJso8j//recEsbdncP3QA8KzAnUeMXWDpYaCg7qGH26G9F1ye4uKtXlKA3YZt6cvfTJ9YzeYJEyyzBFZ8hgGA6bSO21r7bIKsHXimZwVIQvzVXsGL5wxnu2VS/byG0ZE1/OrjYxQEwjrlbe+WbzXQAFvD4K6xHLYCZNmbikNY9ja+CXk43pFb+3sUMVD/MooSZp1lwEjHTCxXDMs9slE6MBpzoK7lrRMOsjIOAqpGjBgl5TCT14QuTuQjpKDRT5a/mzGGPLCHpphZq0jBYsY7fAEkB/A7pYVXK3spN1eETIw+8VAIrgrr1vHPdyI1BnE9LH awLQB0GS 55394BESGLzg64Ye0s35ePKcyguZ1dUoMVTRNb3spAZLyg/3GTfZUsvt7Zj4m97EtXaEU/0pNMYsY+Mdlma7AyysBfBIi+dYMkkevI54m+foVlPUu6RXSV602D9hPtohuHh4YiSbnhQVdNncHoDR6Skh6+xW0c8ltnUgxQVnJBrA4iiuGisojOf2lhYLojNpnPBEOV70SlScTa4QByXVZ4DY+ugiUHJesP9vfqqAaBIw/K1usk7hGMW40UCFzebnuyM00/TIyJt6rl622iQX3AWLIhg2UchiLoPzSbNBoJVXAUTvHEqZHQJO8/t9S8NUyd58Whg1cyeipJRqUtolK2X0c36S4RsHHsZxx1s8GWQ9+0ZY= 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: Now that we have ported all users of kmem_cache_create_rcu() to struct kmem_cache_args the function is unused and can be removed. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- include/linux/slab.h | 3 --- mm/slab_common.c | 43 ------------------------------------------- 2 files changed, 46 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 4292d67094c3..1176b30cd4b2 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -270,9 +270,6 @@ struct kmem_cache *kmem_cache_create_usercopy(const char *name, slab_flags_t flags, unsigned int useroffset, unsigned int usersize, void (*ctor)(void *)); -struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size, - unsigned int freeptr_offset, - slab_flags_t flags); #define kmem_cache_create(__name, __object_size, __args, ...) \ _Generic((__args), \ diff --git a/mm/slab_common.c b/mm/slab_common.c index 418459927670..9133b9fafcb1 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -420,49 +420,6 @@ struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size, } EXPORT_SYMBOL(__kmem_cache_create); -/** - * kmem_cache_create_rcu - Create a SLAB_TYPESAFE_BY_RCU cache. - * @name: A string which is used in /proc/slabinfo to identify this cache. - * @size: The size of objects to be created in this cache. - * @freeptr_offset: The offset into the memory to the free pointer - * @flags: SLAB flags - * - * Cannot be called within an interrupt, but can be interrupted. - * - * See kmem_cache_create() for an explanation of possible @flags. - * - * By default SLAB_TYPESAFE_BY_RCU caches place the free pointer outside - * of the object. This might cause the object to grow in size. Callers - * that have a reason to avoid this can specify a custom free pointer - * offset in their struct where the free pointer will be placed. - * - * Note that placing the free pointer inside the object requires the - * caller to ensure that no fields are invalidated that are required to - * guard against object recycling (See SLAB_TYPESAFE_BY_RCU for - * details.). - * - * Using zero as a value for @freeptr_offset is valid. To request no - * offset UINT_MAX must be specified. - * - * Note that @ctor isn't supported with custom free pointers as a @ctor - * requires an external free pointer. - * - * Return: a pointer to the cache on success, NULL on failure. - */ -struct kmem_cache *kmem_cache_create_rcu(const char *name, unsigned int size, - unsigned int freeptr_offset, - slab_flags_t flags) -{ - struct kmem_cache_args kmem_args = { - .freeptr_offset = freeptr_offset, - .use_freeptr_offset = true, - }; - - return __kmem_cache_create_args(name, size, &kmem_args, - flags | SLAB_TYPESAFE_BY_RCU); -} -EXPORT_SYMBOL(kmem_cache_create_rcu); - static struct kmem_cache *kmem_buckets_cache __ro_after_init; /** From patchwork Wed Sep 4 10:21:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790368 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 2FD6DCD4847 for ; Wed, 4 Sep 2024 10:22:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAD498D024D; Wed, 4 Sep 2024 06:22:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5B6A8D0242; Wed, 4 Sep 2024 06:22:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F9548D024D; Wed, 4 Sep 2024 06:22:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7F8C08D0242 for ; Wed, 4 Sep 2024 06:22:53 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2750380FE3 for ; Wed, 4 Sep 2024 10:22:53 +0000 (UTC) X-FDA: 82526667426.23.918FD96 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf11.hostedemail.com (Postfix) with ESMTP id 6182E40014 for ; Wed, 4 Sep 2024 10:22:51 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="bDGa/Ivc"; spf=pass (imf11.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445322; a=rsa-sha256; cv=none; b=yrzbt3T8ba5WZIkr63W4qymBVKrBEUQzkEaxc+l0MobrVBKb02/qQ3UUA8yrruHsXwrGrk 70ml9LnW0E3PuQpwCdefot1HGO58++r3nkZcrBxNpLchCzBapPwg7/c3jtC9rtcdHIBwDW Wc5eQqozAwPpA7+hWGMPhfoJDr/qGsw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="bDGa/Ivc"; spf=pass (imf11.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445322; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=L0N8A0tBKgQmVt0CVqwsaSQxPKg/rQFNBZMwUi59MNE=; b=1p3MdH4VwhRU7yQ8MF8ugWypVceUSuEpCRibFroxR/uVG2ubAQ+3hk6OEugVVqouhNFcru DSmfi8MF5khaUWL//pfEK8R9HhtOmzeSyF7DxQJ0WJryYRtg4U+6DRKZ/BhIy7foDCmVzI ndEbW05sT6baHdCzXxpN6W6AngTSzJ8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 80FACA41050; Wed, 4 Sep 2024 10:22:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F27C4CEC6; Wed, 4 Sep 2024 10:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445370; bh=otBPVDb5wSFqFX+emtlwUyqyvPQGIcX7yx9PMQsOqjw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bDGa/IvcMSu4GQ4Irqb6p7xSlqntR0jiy/9X9+lLUcAnsYW4ttuniVZERzqaXh1Ud L5gf8yBN5UrenlR2eXCqo6BbRFAIaCB3HS3bV6FfMmD5e7Hqls1vAKAXTJzFrET2yd FmjH6Vci+98N//pLFtJiUJbDjmPzo5QXksmnLpMHV54wVjSgAK49ZZ81Te553Me8IL 62zOQ5vI8sERsbwrxVrAcjY02sCf/wPLkcUo0KNao3wJxWXMxsgvvXxx4uSN+6XxeB f+bf1rb1OTj7j3A3Yy4zzHM7G2px1cBaa4TlMgvyO5h4+KNnEJ34t/hrIibFJufYrC GFx5Z2ilhYzFA== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:20 +0200 Subject: [PATCH v3 15/17] slab: make kmem_cache_create_usercopy() static inline MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-15-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=4638; i=brauner@kernel.org; h=from:subject:message-id; bh=otBPVDb5wSFqFX+emtlwUyqyvPQGIcX7yx9PMQsOqjw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNm97Phk78obioayNwPatj1TMDp+ZF9VYkVXH/O+B /Jt7LurOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACby05ORYcKJiwsts2xFFzUX ugcwrBC8HHNuub3Sn9Q1jwL0kzvnP2X4n9DQlrdkZt8qM0XHb44egXPmcayWS+TjN9y5yis1Zgc zFwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Stat-Signature: k83tm8kguas8wankd1j318u871d1rtxc X-Rspamd-Queue-Id: 6182E40014 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725445371-951829 X-HE-Meta: U2FsdGVkX1/uSKGRX6WCGpiN17gOv61QQ/c14Rq96EiSPgjpsQK4MKdbfsDXEVDfiTGIWl3udgMyPE3pQMoCr75xBcGpMRNxmw5F7gCaB53jsAlam4dAiuUNaunrhkJWd6Okh+viLMco9eEU07ma+pSdpCNJCZWsvgavvw9DlVZQKYdwOsm3jdkr6vf4plVFkHWoiuOg1xc56+RYsbsja9egHjn7fy2ODIpiE0AjCZ08pizjnljAF8PFw+pV6ucow4//Il6I32GED1p3FkZuIILEYiA/OFk7T598I3ibgscq8OfwiZNROn10Zl5wyyZlK0Sw39zq/tiMmFS0oOJahJ+GdH0pnyZELF8Isj+IlkiZ7ocvvw+61NNGVJLpEPoteVAqvBdavixbKSGGnSq8ah6vblezXqtbcBWxM3gYOa/D8M69Lv8m7wCOrkj2M58RGJdoFxiLHDZFUSf+r5BYioEgowjEAS8RIFJVpo7Qq4cBALg9TMSxl6Ob6jxWOTnm83yQozcG0CCJuSKKsDn2N03X8EQ2xOxSHgswTuLAMVDkrEJCZkNF6goo5s2gGmtUYsGAwET6rE11g83R8pTdG+EDpxUi03KnXtbWJfSYzwygNPdK0gyvdd4sqsz+k4uWHjG80CNK0BqJnCSac8kN03Tc/+6/ddSjo/WwKGsIoswqDfwYKdTsaRnvC7eBESzJrjX9dsE5wLG3yYp++t/SXnqVQ3bRfCEvgTfg6ePNxRsTCqDf0z4VvptHmIRn8AgUzpohoa4E+Ur7Sjc1DbUeT3XKSx+amsYuBSMOro03d2njvjIEYUa2aBK1pzc7m2KI9Cu+mFXYipFUAxrtDa8o/UaViDnxVGwEtWARnGjBLxNksqvS5624EON073/jgydOdPs6Q3Ey7LMyTDZqrvetdtqr8fbGGUU760HuXRJosWng444TXCn5ePLTmaq+tsdnqtN0egKPox4NpUrli+r hyOjZ++c ODARDHj3wIvR2L11u616cTo7ZGAMpiFkP3Y1udhsZiQ3tbSf2/GHZS+aoy+gs5ffiPJ9tlWYF30lSTHyt7l5Q3/rYu9I6VwhjanEXIiA0wOITC/0wGNlw0JaZwbJV250cjqqF3C4zzOlD4iWOADb77pmaA3mMlQI6kItr2eeIhIMVB9AJG8Uf+zpNSv81W/j5czZXruSWF/VmSv9letIUPVMOzAeKIqTNcvref/OOOcenCPn2oa3qsvY49WUpLbeNQG0s+WYEU3EFiPAL3c8fTa6y3INQ8IITn0KZtSw+9eRdwPCngBF9UOKg4ohCZ4eiOvXUAcXS4X6Zku+9Jk9QfLTdnK7RwOjnPetAcKqJJYW+59ZeEWvlU9gS/g== 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: Make kmem_cache_create_usercopy() a static inline function. Signed-off-by: Christian Brauner --- 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 1176b30cd4b2..e224a1a9bcbc 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); +} #define kmem_cache_create(__name, __object_size, __args, ...) \ _Generic((__args), \ 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. From patchwork Wed Sep 4 10:21:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790369 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 64B7ECD4847 for ; Wed, 4 Sep 2024 10:22:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E91CC8D024E; Wed, 4 Sep 2024 06:22:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E423C8D0242; Wed, 4 Sep 2024 06:22:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB8A76B00D2; Wed, 4 Sep 2024 06:22:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AA4FD6B00CF for ; Wed, 4 Sep 2024 06:22:57 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 65FACA0F94 for ; Wed, 4 Sep 2024 10:22:57 +0000 (UTC) X-FDA: 82526667594.09.0DC9B0A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 9349B1C0004 for ; Wed, 4 Sep 2024 10:22:55 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AEfBh4WZ; spf=pass (imf18.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445248; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4Z9Ht8DPFxehkbXR69ujslpphgMyAamSjvVjjtyCvnE=; b=IR77H4ZFM8XSiEkhFhx20rKFIoCkwuQ4VFz84H87cDrTU/+dm7b3aCBhJHQWC0TtE2m4gO GZbIx6m4E7Arp5964ywntS5op9FQ9NE8ItcMFWQP1oxAD5droCeaJUHdBGvD2+SWiO30D2 7fRpBBUpHRUrlG+toF8KLKzgVujmi/8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AEfBh4WZ; spf=pass (imf18.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445248; a=rsa-sha256; cv=none; b=y/Fi9H+m7TshNc3MYYjLMihsptysV0Axc4DzQWTZ05KiGAJSF6w5nDEEub4Sy/z4jmrjnx KjA+CuwCZTgqu71OCt/sBqcTdIcxS2Q1xBk00yv3BPvAuDMIVnU+NFTb9zTkc9Gtf9u9g9 jryOz20TdFgA1y1j+rnxpXKHHaW4jGY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4EF7C5C5706; Wed, 4 Sep 2024 10:22:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC9B5C4CECC; Wed, 4 Sep 2024 10:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445374; bh=YjxO66hJ+BVi0bwZydpu1jfLI/x58A7MkM0YNuLTP98=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AEfBh4WZJ7pNUvjtrYEMp5wXlLriDBDcZYoIuOd4xpupauIsqPzuDzphXZBV4kLV6 TcOZFri2K0HWuchx6mo47Vr+pxy16ovN7pPwNNUVXmGx0I8umtB4a6zQLkYasZBer6 EgvxZrHDnb2A9oa6qB+INgGpn+OS9/RinxZzTzVs8cq0WTzCD8+08jglfGHct+ZnCJ 4iQw5og6J5qluAYydkJv1Us4UU8C7+2Z6LC7mmnDe55ZZgS5PESq77XyMSI0d0jhf4 QX4v/aadFfTR4hnlXSjUP/2yB1sLSbB2OOapeSjVCTVtJ/5ispRbDWwt1+Kuy0mOVV XzTmmcjshI5EQ== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:21 +0200 Subject: [PATCH v3 16/17] slab: make __kmem_cache_create() static inline MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-16-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2885; i=brauner@kernel.org; h=from:subject:message-id; bh=YjxO66hJ+BVi0bwZydpu1jfLI/x58A7MkM0YNuLTP98=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNm9XjXnZfdPg79/rR6baEe3TpARutzz7eEu2WcW0 a/LpL4zdJSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAExkHw/D/xKxXKeZEyNXL72z d+5/TQFl7seBn70y714QVhcpi3M61s3w38H/W79TX2P+vgf8U5M2bJ+yfGGtosqbiz4uVt1Cu89 m8AMA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9349B1C0004 X-Stat-Signature: j37zpjjd54oucpsbaf6t8sqjtuyu4dsp X-Rspam-User: X-HE-Tag: 1725445375-986661 X-HE-Meta: U2FsdGVkX1+wEuYkHqNujq/5UedJ44ySMiqokFPx9IZLU54wLeN6PQ8EZvF967pJsiKLAgcUetSVGHzF8kVGftP9lOqwuV2ZpU2hnydNKPZvchJPnBKaQ2h6ImCvz08/HyNPiEA+p9SiaFrOwfXB8QsAuK9P0x9x/fPfnoLtyrQVrl7YcnbSDzsQ0qJOg+A7MBamIwW/DtffmGw1bHTsiCcTx2cR+rJz84JNdeyvJ6q0acQeFDk1HOj/YvlelWhB5GLXu9n9YMgLH84tGWbo6lVmV/6JlSgdDmRHO1Iz4DVlQLFYV5F2cEGtY2ASbOeBq/HnniFdCjxB7spfobCO9qNL0rgpcwIs2khlwmVrxsONlKVCN4wdCYm95sAw4NSX4EM+y7J6j3Sw4YM13cz2tottwLxfuq9C6/5K2Tz5jgfd3xd+4sxmcjq9/6rNgOhEoWeyDxdKlrCnupjospnXhr/eYDrwKQWoQovwjJHv05lJUn9ppUZZIcSA/ZexB+uzsNbhQ3fRpNndbM97hRXSG9EooGZEvYybYz8r8BUcXhkkTQfbfufhPTL+Fe0W42LFDxnj1vxQlxAzGkVdriyB53WT8+GhflLoEIie37vjk/c3XQjZNU1VKH99TcSwx70Jfa6mkbe0ijyRAAs/g6Zk8fNZUa6eW68/XNcr4MXFvZlGDnFvGjzpK03vuHp/kyjdhEtvlmTP6/jofVZZ0yXYyG52Ca1nCbSMl+cX2NcCDzqDy5UPy20XXJgD9tzpVm1ZP8+EevrYohdS7izD23nIYTL56g8oYSiJMLRtevP32FhAdbE4FINVRSz9QTMmi5ku3Ocnv930FACXeuAib7dvXP6dSV3NU95hOu2/pv52Td+M3U48qMivUObvi2C7XLlvFDCDRJxgRwx0aYtOp4zdYE7TsLM3gx+d8V1ZrnpT769WRhDwr+2aFCXBWnY3P51hOk7UPfLUG7ap4lk0zzQ hK1m9VC8 HPMu0hK3g0ilURqm4t5w+cBgBQ7GoHheoWa0s9dvPQiEVvIenpNFm5WbnrqoErmaV2evpQkKBi2kPSKT1wVE7jTMqYU0UnWi0a/CqpkMn/8skKxw99gxQb+iLHNTGJiB79ZiGhOclkfLuUfmn5Eqz7XH23FVyxC8nxsFdoqzbuORyPILCbz7b9kQrEkCrnKJzLuuTkeW7DwxXAJhOHQU3Jlx3YSCtlDjmiAiREu9hMv9bwr2o6kllFA/yPs8IAaTfW+tGg5Zn+6MTeoCcLN6/P9X6vUP7ugr8WsirnBHzIWunoDv1+0WIDLuq5zhhwUXkJHd36zFGsij0wAmaSMziJoyv74MJUmDmXbwDCoNAlJc31cs= 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: Make __kmem_cache_create() a static inline function. Signed-off-by: Christian Brauner --- include/linux/slab.h | 13 ++++++++++--- mm/slab_common.c | 38 -------------------------------------- 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index e224a1a9bcbc..70a0f530b89f 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -261,10 +261,17 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, unsigned int object_size, struct kmem_cache_args *args, slab_flags_t flags); +static inline 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_args kmem_args = { + .align = align, + .ctor = ctor, + }; -struct kmem_cache *__kmem_cache_create(const char *name, unsigned int size, - unsigned int align, slab_flags_t flags, - void (*ctor)(void *)); + return __kmem_cache_create_args(name, size, &kmem_args, flags); +} /** * kmem_cache_create_usercopy - Create a cache with a region suitable diff --git a/mm/slab_common.c b/mm/slab_common.c index 3477a3918afd..30000dcf0736 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -337,44 +337,6 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, } EXPORT_SYMBOL(__kmem_cache_create_args); -/** - * __kmem_cache_create - Create a cache. - * @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 - * @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(const char *name, unsigned int size, - unsigned int align, slab_flags_t flags, - void (*ctor)(void *)) -{ - struct kmem_cache_args kmem_args = { - .align = align, - .ctor = ctor, - }; - - return __kmem_cache_create_args(name, size, &kmem_args, flags); -} -EXPORT_SYMBOL(__kmem_cache_create); - static struct kmem_cache *kmem_buckets_cache __ro_after_init; /** From patchwork Wed Sep 4 10:21:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13790370 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 49939CD3431 for ; Wed, 4 Sep 2024 10:23:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDFFE8D024F; Wed, 4 Sep 2024 06:23:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C90628D0242; Wed, 4 Sep 2024 06:23:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B82BA8D024F; Wed, 4 Sep 2024 06:23:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9419C8D0242 for ; Wed, 4 Sep 2024 06:23:01 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4949AA0F51 for ; Wed, 4 Sep 2024 10:23:01 +0000 (UTC) X-FDA: 82526667762.25.4B0E85E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 6F19A140010 for ; Wed, 4 Sep 2024 10:22:59 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lrPSuG+i; spf=pass (imf23.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725445331; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wbNz6RNjV9KoW5aO6PbBG7Un9bjRmB++cl0YdehIvX4=; b=KUXwpQGAItNrSzZQgetDwgseL/NrI9HF+d0KWCtwLJvc+cjWI1e7D1zzUs9QpALtVkTAoh 0OfEQru/BLrmSmpsP/Tc2ym340PygLtOyh76Fp/aQFYuurh/0zcOdYHFyG0MnPRCnQaHjc 8mJ5ClW0ZDuV/1BE7jqo3a1OKVvFzXM= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lrPSuG+i; spf=pass (imf23.hostedemail.com: domain of brauner@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=brauner@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725445331; a=rsa-sha256; cv=none; b=FfPAsZwpxH6mXA8rsJT8TVcKJBPxoWhlVvOKEJ3tg9wQ06PbPGfoIHqz1Z3+LXexdNG1Yf qaeQmixVQ4a7SQhz5Ig7bm8nD4Vpxdl55wnMDj9dMNt9r3Zk3yyl4NUsZWSV/d0gluyC35 aTGkQ3o3IBpSyWAvWHh98YxyvxBexG8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 376245C5720; Wed, 4 Sep 2024 10:22:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA1E4C4CEC2; Wed, 4 Sep 2024 10:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725445378; bh=fyePhUeJgoPiuTJClIk+6OpwiFIuMNlpyvRSeOBVO/I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lrPSuG+iQHm9RvIy0WSzIC2PaCeqRuJifT/frNLorTp/Y+si8I22TATwm54EoN0D/ wF2P4/AMPbEdKK8eAUsdGJnFov14GBDKvKX233goB9TE5E+/nTOFTrtxZydchwpjK1 +0ROLJQWn2g/nElnAFEGmPaXKWER5LFg02TTLWE8FQYKvkqBiIj0JdJHaHPRCsfNeW z/GvHBdEK/9S6wPDwW2H85vXa1ChSZCNWtDyoMoRQhfHefYlRAxgclb4rvVPxQlxEL HaG1ACOdWYQDoDWn9c4EU632lFH62HODflmben8lJ2I1zQb7trHaHaGJlfVK93r/hW 5MIvW4MbSGP9w== From: Christian Brauner Date: Wed, 04 Sep 2024 12:21:22 +0200 Subject: [PATCH v3 17/17] io_uring: port to struct kmem_cache_args MIME-Version: 1.0 Message-Id: <20240904-work-kmem_cache_args-v3-17-05db2179a8c2@kernel.org> References: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> In-Reply-To: <20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: 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, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1645; i=brauner@kernel.org; h=from:subject:message-id; bh=fyePhUeJgoPiuTJClIk+6OpwiFIuMNlpyvRSeOBVO/I=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaTdMNm954/H99mFK48VyBu05f33uZhWXFSRZ9Oa3Nj54 xK3WOHZjlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgInU8jH8jxfh7RF5IrdmtcJi O4uEiafyNqqu2X9kyg62j7sr95lqdjH8D1pQYvVGdIZVkvf/uVXinWfkBDd91tHiPr1kRtkmwQZ rLgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 6F19A140010 X-Stat-Signature: zkpfe3h516ta8me4h7mr9t6faepmxfcw X-HE-Tag: 1725445379-253397 X-HE-Meta: U2FsdGVkX1968wQelY1eZHlK6pLNFUGkNRh6ys4G7h3jdKVvEPlPUCva5gKyKEW+KVD7hA7BdUOUa96VAf8qzMl0xjXXHbC/7ZZLVFNhpPT1gnKYmg5hZflJsD5GJv66PN4PtwRovmiEVfLrFi2CP8sN8EP/FUZddnZS5vV66eMGSmJ6dNb6JJPepoHK6vd8HOD49TfX8MSwZCJEXG6xrjCDcO67j86bQS41JmSOjBIs2DqsU2+fllSlHx8nH7AD1B1gImvfoTxY2cbBOOUAyPHm0Gz8vXVdMyUlSDZen59laaFTYAdL5N09RUUs2bIDHhJGVMeb/e3yN+eGAeXxfiAwf62ZKRMnEe6DLE5o3IgOLjYkTSZLd9oNG8fHuAruRNUT2OkkSpQzbeUmcFlLHWHZ1aPVyEh6knK/6Fe9MniqQx2GvLLGwkJiozlGaWQZFCDQxLtRgw9faAmSRsQGcsJqDyxm8E4itErJwZASVLW1fbawprN39lePljbyWuXBy7eR9kZrQh5w5z+cOAnakUlxGSw6W1tbEOv+umhZoPxqy0cxGpiAywOCKjQOH003cgn3t73qhEiwmC0T0gkyPGCQ5nQy95qH2uZIVEqyl/we9lyZmv2NzLDKF1WxQEaP+gy0tqHvFNahWtAahCnWdPUsLDVA16ZIwbvKQIQZXPKqDQ3DGelYHpnHAHi+3Fh8snEf3Zvx+ZXvn8SCOz0XVIRDppqgDzEFsKFB8EZocbWne7VfGOhNWP/54nRoxusiJbWf9UJod6P3IkrYfK3myJDjtKpc4ebWsR0JkYJc4Ov5APSR+yii+nUJVOC65uc2HWUExmTbpAvyii3xsCZH80nt9Pfc45O3FAgx7fVIu616UBcC96jtFU6VJIWEOXYPT0V02N0R1rx874Vit6YAJOdOxSmNLoIJVwL0LfTbErV2PpUR1xKUsKwqKrIagimiG0iFp+NyuSp1E4/w2WL RDFg3kDz eCWp634py8QduqdxDAvXLb2bS8WHu5onWyd9DlRnHe/2OyxOMOqGqMNpV4TVZtRZnlPJ9tax99TubDWoPBkRx9FfZSnssy1Zp4u70sEEWqSTZYmZmLKVlUq8GP3Z+NMT2fFRm9JmSNKK4YURD8XBrQWasrKPuF1b3RTjb9zagSt2ynumI0UgawSl1uX/PUynCgX5jxbqiVSjt3GADxe3+AaSfaDpKyCP3Gn9AS97TaYd44tw+pOg92NqHKQYsEROlY9JJNfaCk/f+TX9r8w/A9TXfS8VSmvV2Ptt3pM4VNDiZcUmPFBTzFooQxg1KeBGoeS39AgCPzH11PQA9IWMnlQhUGyPRwRGm/9+K1B7JArN92WM= 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: Port req_cachep to struct kmem_cache_args. Reviewed-by: Mike Rapoport (Microsoft) Reviewed-by: Vlastimil Babka Signed-off-by: Christian Brauner --- io_uring/io_uring.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 3942db160f18..d9d721d1424e 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3638,6 +3638,11 @@ SYSCALL_DEFINE2(io_uring_setup, u32, entries, static int __init io_uring_init(void) { + struct kmem_cache_args kmem_args = { + .useroffset = offsetof(struct io_kiocb, cmd.data), + .usersize = sizeof_field(struct io_kiocb, cmd.data), + }; + #define __BUILD_BUG_VERIFY_OFFSET_SIZE(stype, eoffset, esize, ename) do { \ BUILD_BUG_ON(offsetof(stype, ename) != eoffset); \ BUILD_BUG_ON(sizeof_field(stype, ename) != esize); \ @@ -3722,12 +3727,9 @@ static int __init io_uring_init(void) * range, and HARDENED_USERCOPY will complain if we haven't * correctly annotated this range. */ - req_cachep = kmem_cache_create_usercopy("io_kiocb", - sizeof(struct io_kiocb), 0, - SLAB_HWCACHE_ALIGN | SLAB_PANIC | - SLAB_ACCOUNT | SLAB_TYPESAFE_BY_RCU, - offsetof(struct io_kiocb, cmd.data), - sizeof_field(struct io_kiocb, cmd.data), NULL); + req_cachep = kmem_cache_create("io_kiocb", sizeof(struct io_kiocb), &kmem_args, + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT | + SLAB_TYPESAFE_BY_RCU); io_buf_cachep = KMEM_CACHE(io_buffer, SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT);