mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Hui Su <sh_def@163.com>,
	hughd@google.com, akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode()
Date: Fri, 27 Nov 2020 18:26:23 +0100	[thread overview]
Message-ID: <416a0cb6-fe34-a7ff-6021-92b8dff24f0b@suse.cz> (raw)
In-Reply-To: <20201115174026.GA365412@rlk>

On 11/15/20 6:40 PM, Hui Su wrote:
> 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>

Looks correct, but now we clear also the inode part which seems to be handled by 
alloc_inode() well enough. So, unsure. btrfs and ext4 variants don't use kzalloc 
neither. It's also more obvious with the current way that the info is cleared. Hmm?

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


      reply	other threads:[~2020-11-27 17:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15 17:40 Hui Su
2020-11-27 17:26 ` Vlastimil Babka [this message]

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=416a0cb6-fe34-a7ff-6021-92b8dff24f0b@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sh_def@163.com \
    /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

all inboxes | Powered by JetHome®