From patchwork Mon Sep 2 15:31: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: 13787429 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 CD91ECA0ED3 for ; Mon, 2 Sep 2024 15:31:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69F618D00EB; Mon, 2 Sep 2024 11:31:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 675D86B0298; Mon, 2 Sep 2024 11:31:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5647C8D00EB; Mon, 2 Sep 2024 11:31:26 -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 383D16B0297 for ; Mon, 2 Sep 2024 11:31:26 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BA53F1201C7 for ; Mon, 2 Sep 2024 15:31:25 +0000 (UTC) X-FDA: 82520187330.28.8E39145 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id E6A9D18000C for ; Mon, 2 Sep 2024 15:31:23 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OZsFR5wd; spf=pass (imf16.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=1725290959; 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: references:dkim-signature; bh=F2HmCDjSH35HlgIH1Rw4risXz80fu3E144ZfDUIF/wg=; b=ADC+TXJwEcaiWycURwsKy81To7Fe+LYpLu9v7ekslqVaj3ngPEgn+OlS9QLbh1QaTKI3fE K34PvtzFK1LKFwzLEsCZDADo8pOGzxQB1fMNg9Pr34q30qdbRUxwOQGK1xubJ2M54rapha F/yw2GirJHJEHks3iYNchAlW03lpzuk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OZsFR5wd; spf=pass (imf16.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=1725290959; a=rsa-sha256; cv=none; b=tb4JgRpHl36uEIENIBVa7OwPq9HqqCSdjhUEBs89GIc3viRo3zPpxm/n3xEHlTCaQHXAbp 7kQtZdZkgxg1nnL6aXGXOIDi3xj8xYbLtDT9/G05NUp1ufqA7TnaBQdHQxtYHUdY/m3nCJ UEL+tUparkXcOSIaHF9pT9tClGbVwQQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 54F315C0FE6; Mon, 2 Sep 2024 15:31:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1180EC4CEC4; Mon, 2 Sep 2024 15:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725291082; bh=kfGP3GZP9sJz13joLnhrlbPbNWKEC8o6u426ARljaws=; h=From:Subject:Date:To:Cc:From; b=OZsFR5wd/crGNW6ViwPhgNNipOf+V3vvdbW4mmNDoaWFf/KJfM2zGSOXJNsxmPyIT vF1Q8w3uPK96RNP/6ECCMn02r/cGyNU3ehdPxJlxrT2PSmJpvIIlKdWE6kcXTbAg+T ddsAsBdB3FbckbK72usF0LagwznFuJyr5pz2XS0cvjiZXXose2XVL8pM90RS5aoyv3 X+AMbL21m0/WAJq8GLPC9GqMAt6y68GfOqVYlK1/iHz0z5pxPKIpkBUWZBSkyaGqGB NdFBGJbbIfHKSRDJXj1OrNJEFfNHztKViaUBS1LCUEi9Mf3iCFp3rY94DiPp/kfx9e q79z7olMes4sw== From: Christian Brauner Subject: [PATCH RFC 0/6] slab: add kmem_cache_setup() Date: Mon, 02 Sep 2024 17:31:10 +0200 Message-Id: <20240902-work-kmem_cache_args-v1-0-27d05bc05128@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAD7a1WYC/x2MQQqDMBAAvyJ7bkoapCG9FvoAr0Ukxo1ZrLHsg hbEvzftcQZmdhBkQoFbtQPjSkJLLnA5VRCSzyMqGgqD0abWThu1LTypaca5Cz4k7DyPotDZq3b WBDvUUNI3Y6TPf/uE5nGHtsjeC6qefQ7pd1yjnCO9EI7jC5fPRXGGAAAA To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds Cc: linux-mm@kvack.org, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2660; i=brauner@kernel.org; h=from:subject:message-id; bh=kfGP3GZP9sJz13joLnhrlbPbNWKEC8o6u426ARljaws=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdveVuGiocecR+neCix5ZzG+ce1Xymdk/LQ85k6fvEM zEcHmWaHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABNhEmFkuJTazqWma3K21MDk 0/YUCW92zS06D/MMVCwKsri/G5+8xsjwRLT8k3leRIB89Ek33x+J7blGCRonPSv7g9rP8vUKW7E DAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E6A9D18000C X-Stat-Signature: 5t35pbgga4csfi6sreu3ux83mdzangx9 X-Rspam-User: X-HE-Tag: 1725291083-119704 X-HE-Meta: U2FsdGVkX1/fOtFSgVqfcfqvpI0rTzp9+S6hC9s6RRivBGEXlG2goLaAK6LJMuj0zU8MnUgqwKfYYCJaQkgHGpA07t5q1CpP4u6QYMa13cMpNvB0cMVd6/jkZ0GxuukvZY+VaVKS9hYStinE6UrwbfnyFFABsGwNtJIwK3xTo68RJ0K1AJZPDQwNFtBda9P/bVzdXeApMrIniexCuzobOMs670IvprJ8LMyhLduKj35QqR8o7ncXig24ecsg6MuNbbK1p8/dgQcUJPyTFxhpyqfedKnKpnfHUZrmlBMo37mJfGSrVdz7D9P50B0qr68gQ8/tpZUq41bOPaqLagztWKiG7byFUek74L8jWP214MRcoaHSAPCnsuscmcgJ0ywhdaRRKVoW+hQu2mIfQJm+5X2Q6iBmfWTT7IHGEpy2z8Dv0gK4XNszh/9NDgn/FGgz/X91w6xSLwZF/GP+qIpUwJZi/eeFCTJDeNMX2JJC8jFcjtOf6GHTp/kn+p96ZbpxwvEBCRxdtJDFsnK2QdNlGaiarg8tZDqB/ZMPy6YujPXAI1eDrvcAUm5LF/ZVmh+gpaKg/lmPhj3cNk86yi+neFJRZgYFZMDbD9cKKcgc4uni0HxpT+Aw8TpdUrzqDOoaMeB2rqD+B5aLpp/v1PgxTyZcQ3e8+tX+qNhfmdtmYXPjllGsgmI6WkMYIWnILdoEajb/iGdNcku3XCdw7KAB+1S5Fn8snIkBq78p8BhhKkOlhuZ+Y1/1tHeqWGl3eN/+YmVWnBUxUdFlMxytnMBA2SjRboOH6nQNSTHr5/VudYzn1VxPwHmlJP1RWImtQyCpsx6Y0koY+4nJmO5VyugXGiWeOrXloYchsafPEo6fbdtD8BnjeOQOqw+ojt3OVlqqnnQeXE2GXajFjCPHXEFOSIpcoaAGsWoxQYpOQn3k9afkKUq42dcv3wCwGI8Q4+h+ylowTCIL5XUB4eX3DJX jL/X6uaU Ot47AGR5j8I0Wo3/sqwhoNBP98Aup0lxFk258tiyd5Ld9ZDVTlaIqi0+L/7WyOG4m+CUeW7niB44JXNxRG9Kn4r7pR4ClPQVBjEb6khv5p27wyz01hBUHK3PBq6VP2KwC2Oz8jbVS+CBoCLjR2WZSPlg8QhcoBa1wEbbVk3CQWg0/FCsuvARHcKqaW24msSVFgHXShoLOWVHtrJvoQaRzMlCF8xs3VfRJz5DfuyO6bkHBcmAYAWvE8jX0yrbBillscWJFfXVhlWlsfw0uYeGA2mn7/Io6xbVKwEse X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hey, As discussed last week the various kmem_cache_*() functions should be replaced by a unified function that is based around a struct, with only the basic parameters passed separately. Vlastimil already hinted that he would like to keep core parameters out of the struct: name, object size, and flags. I personally don't care much and would not object to moving everything into the struct but that's a matter of taste and I yield that decision power to the maintainer. Here's an RFC built for a kmem_cache_setup() based on struct kmem_cache_args. The choice of name is somewhat forced as kmem_cache_create() is taken and the only way to reuse it would be to replace all users in one go. Or to do a global sed/kmem_cache_create()/kmem_cache_create2()/g. And then introduce kmem_cache_setup(). That doesn't strike me as a viable option. If we really cared about the *_create() suffix then an alternative might be to do a sed/kmem_cache_setup()/kmem_cache_create()/g after every user in the kernel is ported. I honestly don't think that's worth it but I wanted to at least mention it to highlight the fact that this might lead to a naming compromise. From a cursory grep (and not excluding Documentation mentions) we will have to replace 44 kmem_cache_create_usercopy() calls and about 463 kmem_cache_create() calls which makes for a bit above 500 calls to port to kmem_cache_setup(). That'll probably be good work for people getting into kernel development. Anyway, I wanted to get an RFC out to get some rough agreement on what the struct should look like, get some bikeshedding on the name done, and what else needs to be massaged as part of this. I think that cache_create() is the deepest we should stuff struct kmem_cache_args into the bowels of slab. Signed-off-by: Christian Brauner --- Christian Brauner (6): slab: introduce kmem_cache_setup() slab: port KMEM_CACHE() to kmem_cache_setup() slab: port KMEM_CACHE_USERCOPY() to kmem_cache_setup() file: port to kmem_cache_setup() slab: remove kmem_cache_create_rcu() io_uring: port to kmem_cache_setup() Documentation/core-api/memory-allocation.rst | 10 +- fs/file_table.c | 12 ++- include/linux/slab.h | 51 ++++++++--- io_uring/io_uring.c | 15 +-- mm/slab_common.c | 132 ++++++++++++--------------- 5 files changed, 121 insertions(+), 99 deletions(-) --- base-commit: 6e016babce7c845ed015da25c7a097fa3482d95a change-id: 20240902-work-kmem_cache_args-e9760972c7d4