diff mbox series

[v2,13/15] file: port to struct kmem_cache_args

Message ID 20240903-work-kmem_cache_args-v2-13-76f97e9a4560@kernel.org (mailing list archive)
State New
Headers show
Series slab: add struct kmem_cache_args | expand

Commit Message

Christian Brauner Sept. 3, 2024, 2:20 p.m. UTC
Port filp_cache to struct kmem_cache_args.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/file_table.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Mike Rapoport Sept. 4, 2024, 5:15 a.m. UTC | #1
On Tue, Sep 03, 2024 at 04:20:54PM +0200, Christian Brauner wrote:
> Port filp_cache to struct kmem_cache_args.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  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);
>  }
>  
> 
> -- 
> 2.45.2
>
diff mbox series

Patch

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);
 }