All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode()
@ 2020-11-15 17:40 Hui Su
  2020-11-27 17:26 ` Vlastimil Babka
  0 siblings, 1 reply; 2+ messages in thread
From: Hui Su @ 2020-11-15 17:40 UTC (permalink / raw)
  To: hughd, akpm, linux-mm, linux-kernel; +Cc: sh_def

in shmem_get_inode():
new_inode();
  new_inode_pseudo();
    alloc_inode();
      ops->alloc_inode(); -> shmem_alloc_inode()
        kmem_cache_alloc();

memset(info, 0, (char *)inode - (char *)info);

So use kmem_cache_zalloc() in shmem_alloc_inode(),
and remove the memset in shmem_get_inode().

Signed-off-by: Hui Su <sh_def@163.com>
---
 mm/shmem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 537c137698f8..b84adda45461 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2308,7 +2308,6 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
 		inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
 		inode->i_generation = prandom_u32();
 		info = SHMEM_I(inode);
-		memset(info, 0, (char *)inode - (char *)info);
 		spin_lock_init(&info->lock);
 		atomic_set(&info->stop_eviction, 0);
 		info->seals = F_SEAL_SEAL;
@@ -3828,7 +3827,7 @@ static struct kmem_cache *shmem_inode_cachep;
 static struct inode *shmem_alloc_inode(struct super_block *sb)
 {
 	struct shmem_inode_info *info;
-	info = kmem_cache_alloc(shmem_inode_cachep, GFP_KERNEL);
+	info = kmem_cache_zalloc(shmem_inode_cachep, GFP_KERNEL);
 	if (!info)
 		return NULL;
 	return &info->vfs_inode;
-- 
2.29.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-27 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-15 17:40 [PATCH] mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode() Hui Su
2020-11-27 17:26 ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.