linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Christian Brauner <brauner@kernel.org>,
	Jens Axboe <axboe@kernel.dk>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Jann Horn <jannh@google.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Mike Rapoport <rppt@kernel.org>,
	linux-mm@kvack.org
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] fs: use kmem_cache_create_rcu()
Date: Wed, 28 Aug 2024 17:17:42 +0200	[thread overview]
Message-ID: <59a935ee-7507-4b94-aefb-f0e5a740e935@suse.cz> (raw)
In-Reply-To: <20240828-work-kmem_cache-rcu-v3-3-5460bc1f09f6@kernel.org>

On 8/28/24 12:56, Christian Brauner wrote:
> Switch to the new kmem_cache_create_rcu() helper which allows us to use
> a custom free pointer offset avoiding the need to have an external free
> pointer which would grow struct file behind our backs.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Reviewed-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  fs/file_table.c    | 6 +++---
>  include/linux/fs.h | 2 ++
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/file_table.c b/fs/file_table.c
> index 694199a1a966..83d5ac1fadc0 100644
> --- a/fs/file_table.c
> +++ b/fs/file_table.c
> @@ -514,9 +514,9 @@ EXPORT_SYMBOL(__fput_sync);
>  
>  void __init files_init(void)
>  {
> -	filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
> -				SLAB_TYPESAFE_BY_RCU | SLAB_HWCACHE_ALIGN |
> -				SLAB_PANIC | SLAB_ACCOUNT, NULL);
> +	filp_cachep = kmem_cache_create_rcu("filp", sizeof(struct file),
> +				offsetof(struct file, f_freeptr),
> +				SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT);
>  	percpu_counter_init(&nr_files, 0, GFP_KERNEL);
>  }
>  
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 61097a9cf317..5ca83e87adef 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1026,6 +1026,7 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
>   * @f_task_work: task work entry point
>   * @f_llist: work queue entrypoint
>   * @f_ra: file's readahead state
> + * @f_freeptr: Pointer used by SLAB_TYPESAFE_BY_RCU file cache (don't touch.)
>   */
>  struct file {
>  	atomic_long_t			f_count;
> @@ -1057,6 +1058,7 @@ struct file {
>  		struct callback_head	f_task_work;
>  		struct llist_node	f_llist;
>  		struct file_ra_state	f_ra;
> +		freeptr_t		f_freeptr;
>  	};
>  	/* --- cacheline 3 boundary (192 bytes) --- */
>  } __randomize_layout
> 



  reply	other threads:[~2024-08-28 15:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28 10:56 [PATCH v3 0/3] fs,mm: add kmem_cache_create_rcu() Christian Brauner
2024-08-28 10:56 ` [PATCH v3 1/3] mm: remove unused root_cache argument Christian Brauner
2024-08-28 15:05   ` Vlastimil Babka
2024-08-29  8:38     ` Christian Brauner
2024-08-28 10:56 ` [PATCH v3 2/3] mm: add kmem_cache_create_rcu() Christian Brauner
2024-08-28 15:16   ` Vlastimil Babka
2024-08-28 16:36   ` Mike Rapoport
2024-08-28 10:56 ` [PATCH v3 3/3] fs: use kmem_cache_create_rcu() Christian Brauner
2024-08-28 15:17   ` Vlastimil Babka [this message]
2024-08-29 15:58 ` [PATCH v3 0/3] fs,mm: add kmem_cache_create_rcu() Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59a935ee-7507-4b94-aefb-f0e5a740e935@suse.cz \
    --to=vbabka@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paulmck@kernel.org \
    --cc=roman.gushchin@linux.dev \
    --cc=rppt@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox