From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 346C9CD5BB6 for ; Thu, 5 Sep 2024 12:00:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFD506B048E; Thu, 5 Sep 2024 08:00:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A85C58D000A; Thu, 5 Sep 2024 08:00:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B02B6B0490; Thu, 5 Sep 2024 08:00:29 -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 67D636B048E for ; Thu, 5 Sep 2024 08:00:29 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D0679161517 for ; Thu, 5 Sep 2024 12:00:28 +0000 (UTC) X-FDA: 82530542136.06.AC55B9C Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf28.hostedemail.com (Postfix) with ESMTP id 6A26EC0003 for ; Thu, 5 Sep 2024 12:00:25 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=St9itUJG; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="M1VjWN8/"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=St9itUJG; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="M1VjWN8/"; dmarc=none; spf=pass (imf28.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725537554; a=rsa-sha256; cv=none; b=Uw8VF0wNrwdk0f1jHyEuCIdZxZZwnIJdtFT5/g617UEkp0Ff50C4WB2ezXsOSMyg+ewCpC +8TCWQXU97tATn+3AfQb+m7XW4D2vvJk+l3I1CJiasKKhzbaXZH/lDaLWI1OChX2oX3epO QyJfv0QBSURRk0azrnxbiKJynxK2/+w= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=St9itUJG; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="M1VjWN8/"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=St9itUJG; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="M1VjWN8/"; dmarc=none; spf=pass (imf28.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725537554; 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=Spn7CLo0CT0E6HWBORZo4RLPTll0vYYiUag7Fb/6L2s=; b=5NSEYlvnf6vm0MU6fQo7Ct0EniOqpJoiGjoWcIzkolySchMzCSubkHImniWYMS1f0Vksm6 Jz7I5gCwiFoM/YOx0W6nZx1TFDV27F6yMsOJ+1f8oly8LabsAUmqzxMWCjLV8hgnqUvYoX Wm1YXk1lG/3zcNT7mQI4i0lSIrWgyKU= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C25A321A80; Thu, 5 Sep 2024 12:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1725537623; h=from:from:reply-to: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; bh=Spn7CLo0CT0E6HWBORZo4RLPTll0vYYiUag7Fb/6L2s=; b=St9itUJGilB52a1VXfc4jVZi7e1h1RtgEnRbJEfZue2WMERqa7JgbonkulPbteHT0PzNLK mspZx/gEr1SSycu2oZaFwc7G//3AMqHIeAbElDS8ML6gAWB6QJjJmasrTGt8CvcCKo7m52 D9I+aCcSYFWrHVqQcOdeS8PJa+cxAGM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1725537623; h=from:from:reply-to: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; bh=Spn7CLo0CT0E6HWBORZo4RLPTll0vYYiUag7Fb/6L2s=; b=M1VjWN8/faTtL+YPVIXLQD9T123Fim9zwAcECtcwpSD62Q7u1ywiPSObNAM4UWMI/0zZH2 880m01+rdq2xIdCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1725537623; h=from:from:reply-to: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; bh=Spn7CLo0CT0E6HWBORZo4RLPTll0vYYiUag7Fb/6L2s=; b=St9itUJGilB52a1VXfc4jVZi7e1h1RtgEnRbJEfZue2WMERqa7JgbonkulPbteHT0PzNLK mspZx/gEr1SSycu2oZaFwc7G//3AMqHIeAbElDS8ML6gAWB6QJjJmasrTGt8CvcCKo7m52 D9I+aCcSYFWrHVqQcOdeS8PJa+cxAGM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1725537623; h=from:from:reply-to: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; bh=Spn7CLo0CT0E6HWBORZo4RLPTll0vYYiUag7Fb/6L2s=; b=M1VjWN8/faTtL+YPVIXLQD9T123Fim9zwAcECtcwpSD62Q7u1ywiPSObNAM4UWMI/0zZH2 880m01+rdq2xIdCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A9F0713419; Thu, 5 Sep 2024 12:00:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lx4zKVed2WZBaQAAD6G6ig (envelope-from ); Thu, 05 Sep 2024 12:00:23 +0000 Message-ID: <696de186-ecf1-49b5-bb27-b3290a705e82@suse.cz> Date: Thu, 5 Sep 2024 14:02:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 00/17] slab: add struct kmem_cache_args To: Christian Brauner , 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 References: <20240905-work-kmem_cache_args-v4-0-ed45d5380679@kernel.org> From: Vlastimil Babka Content-Language: en-US In-Reply-To: <20240905-work-kmem_cache_args-v4-0-ed45d5380679@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 6A26EC0003 X-Rspam-User: X-Rspamd-Server: rsp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+UYCnQgYvrXmpqsIxBBlGCx97Iajohf2zEtbfNQPU6AqBvhdZ2z8zY8awKz5AivS9LiYILyDqV/gOHQpeAqVvS6fsKBcXkaqI5MqihrQ0/BmXMhmnIe/QmLxtF71IYErk+2IgF9Okv77XrERo9rZ5/EBbupk8iHmOPMBLwiP/fAfADsFxh3SXPqfqrqXf1f+Lrmaih3bEp63Q5a8RZLbBExY44fCazMy7jN1w5U2gocnMJVrxUfZCK3x31XtgoPuqZDH8TnqUBoodNWuICyf3RlhtilQbY/tZya6p82k3EQIg/TI7PviVHACIrFyIELfanSxIyy3p37y8ps3oyuRFqRyDHNxBExgPj1lnoKuuoA9DqdwqQBwPm+jz/Dbnj/nmjPzQ0n6a57jesKjB2muR21GZGHxjNbMfAoVaLykbw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 9/5/24 9:56 AM, Christian Brauner wrote: > Hey, > > This is v4 which allows NULL to be passed in the struct kmem_cache_args > argument of kmem_cache_create() and substitutes default parameters in > this case. Thanks, I've followed your earlier suggestion and put this series to a branch that merges the vfs.file first: https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git/log/?h=slab/for-6.12/kmem_cache_args and I'm including it to slab/for-next Meanwhile I think we should look at the kerneldocs for the new kmem_cache_create() (hopefully kerneldoc can be persuaded to document it without throwing errors) and the kmem_cache_args, because patches 16 and 14 just removed what we had before, including the details about freeptr_offset in patch 14. > 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 said 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. > > In the first version I pointed out that 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. > > However, I came up with an alternative using _Generic() to create a > compatibility layer that will call the correct variant of > kmem_cache_create() depending on whether struct kmem_cache_args is > passed or not. That compatibility layer can stay in place until we > updated all calls to be based on struct kmem_cache_args. > > 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. > > Signed-off-by: Christian Brauner > --- > Changes in v4: > - Allow NULL to be passed in the struct kmem_cache_args argument of > kmem_cache_create() and use default parameters in this case. > - Link to v3: https://lore.kernel.org/r/20240904-work-kmem_cache_args-v3-0-05db2179a8c2@kernel.org > > Changes in v3: > - Reworded some commit messages. > - Picked up various RvBs. > - Added two patches to make two functions static inline. > - Link to v2: https://lore.kernel.org/r/20240903-work-kmem_cache_args-v2-0-76f97e9a4560@kernel.org > > Changes in v2: > - Remove kmem_cache_setup() and add a compatibility layer built around > _Generic() so that we can keep the kmem_cache_create() name and type > switch on the third argument to either call __kmem_cache_create() or > __kmem_cache_create_args(). > - Link to v1: https://lore.kernel.org/r/20240902-work-kmem_cache_args-v1-0-27d05bc05128@kernel.org > > --- > Christian Brauner (17): > slab: s/__kmem_cache_create/do_kmem_cache_create/g > slab: add struct kmem_cache_args > slab: port kmem_cache_create() to struct kmem_cache_args > slab: port kmem_cache_create_rcu() to struct kmem_cache_args > slab: port kmem_cache_create_usercopy() to struct kmem_cache_args > slab: pass struct kmem_cache_args to create_cache() > slab: pull kmem_cache_open() into do_kmem_cache_create() > slab: pass struct kmem_cache_args to do_kmem_cache_create() > slab: remove rcu_freeptr_offset from struct kmem_cache > slab: port KMEM_CACHE() to struct kmem_cache_args > slab: port KMEM_CACHE_USERCOPY() to struct kmem_cache_args > slab: create kmem_cache_create() compatibility layer > file: port to struct kmem_cache_args > slab: remove kmem_cache_create_rcu() > slab: make kmem_cache_create_usercopy() static inline > slab: make __kmem_cache_create() static inline > io_uring: port to struct kmem_cache_args > > fs/file_table.c | 11 ++- > include/linux/slab.h | 130 +++++++++++++++++++++++++++------ > io_uring/io_uring.c | 14 ++-- > mm/slab.h | 6 +- > mm/slab_common.c | 197 +++++++++++---------------------------------------- > mm/slub.c | 162 +++++++++++++++++++++--------------------- > 6 files changed, 250 insertions(+), 270 deletions(-) > --- > base-commit: 6e016babce7c845ed015da25c7a097fa3482d95a > change-id: 20240902-work-kmem_cache_args-e9760972c7d4 >