Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26e28d68 authored by Ayush Mittal's avatar Ayush Mittal Committed by Greg Kroah-Hartman
Browse files

kernfs: Allocating memory for kernfs_iattrs with kmem_cache.



Creating a new cache for kernfs_iattrs.
Currently, memory is allocated with kzalloc() which
always gives aligned memory. On ARM, this is 64 byte aligned.
To avoid the wastage of memory in aligning the size requested,
a new cache for kernfs_iattrs is created.

Size of struct kernfs_iattrs is 80 Bytes.
On ARM, it will come in kmalloc-128 slab.
and it will come in kmalloc-192 slab if debug info is enabled.
Extra bytes taken 48 bytes.

Total number of objects created : 4096
Total saving = 48*4096 = 192 KB

After creating new slab(When debug info is enabled) :
sh-3.2# cat /proc/slabinfo
...
kernfs_iattrs_cache   4069   4096    128   32    1 : tunables    0    0    0 : slabdata    128    128      0
...

All testing has been done on ARM target.

Signed-off-by: default avatarAyush Mittal <ayush.m@samsung.com>
Signed-off-by: default avatarVaneet Narang <v.narang@samsung.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5b2f2bd6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -536,8 +536,8 @@ void kernfs_put(struct kernfs_node *kn)
			security_release_secctx(kn->iattr->ia_secdata,
						kn->iattr->ia_secdata_len);
		simple_xattrs_free(&kn->iattr->xattrs);
		kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
	}
	kfree(kn->iattr);
	spin_lock(&kernfs_idr_lock);
	idr_remove(&root->ino_idr, kn->id.ino);
	spin_unlock(&kernfs_idr_lock);
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ static struct kernfs_iattrs *kernfs_iattrs(struct kernfs_node *kn)
	if (kn->iattr)
		goto out_unlock;

	kn->iattr = kzalloc(sizeof(struct kernfs_iattrs), GFP_KERNEL);
	kn->iattr = kmem_cache_zalloc(kernfs_iattrs_cache, GFP_KERNEL);
	if (!kn->iattr)
		goto out_unlock;
	iattrs = &kn->iattr->ia_iattr;
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ static inline struct kernfs_node *kernfs_dentry_node(struct dentry *dentry)
}

extern const struct super_operations kernfs_sops;
extern struct kmem_cache *kernfs_node_cache;
extern struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache;

/*
 * inode.c
+6 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@

#include "kernfs-internal.h"

struct kmem_cache *kernfs_node_cache;
struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache;

static int kernfs_sop_remount_fs(struct super_block *sb, int *flags, char *data)
{
@@ -417,4 +417,9 @@ void __init kernfs_init(void)
					      0,
					      SLAB_PANIC | SLAB_TYPESAFE_BY_RCU,
					      NULL);

	/* Creates slab cache for kernfs inode attributes */
	kernfs_iattrs_cache  = kmem_cache_create("kernfs_iattrs_cache",
					      sizeof(struct kernfs_iattrs),
					      0, SLAB_PANIC, NULL);
}