From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63C99C3E8C5 for ; Fri, 27 Nov 2020 17:26:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8732D20786 for ; Fri, 27 Nov 2020 17:26:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8732D20786 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A5CC76B005C; Fri, 27 Nov 2020 12:26:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E5396B0068; Fri, 27 Nov 2020 12:26:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B0466B006C; Fri, 27 Nov 2020 12:26:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id 6EB096B005C for ; Fri, 27 Nov 2020 12:26:26 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 26F551EFF for ; Fri, 27 Nov 2020 17:26:26 +0000 (UTC) X-FDA: 77530877172.01.brick45_3e078f027389 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id E068B10055A3F for ; Fri, 27 Nov 2020 17:26:25 +0000 (UTC) X-HE-Tag: brick45_3e078f027389 X-Filterd-Recvd-Size: 2717 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Nov 2020 17:26:25 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2665CAE95; Fri, 27 Nov 2020 17:26:24 +0000 (UTC) To: Hui Su , hughd@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20201115174026.GA365412@rlk> From: Vlastimil Babka Subject: Re: [PATCH] mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode() Message-ID: <416a0cb6-fe34-a7ff-6021-92b8dff24f0b@suse.cz> Date: Fri, 27 Nov 2020 18:26:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201115174026.GA365412@rlk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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(); >=20 > memset(info, 0, (char *)inode - (char *)info); >=20 > So use kmem_cache_zalloc() in shmem_alloc_inode(), > and remove the memset in shmem_get_inode(). >=20 > Signed-off-by: Hui Su Looks correct, but now we clear also the inode part which seems to be han= dled by=20 alloc_inode() well enough. So, unsure. btrfs and ext4 variants don't use = kzalloc=20 neither. It's also more obvious with the current way that the info is cle= ared. Hmm? > --- > mm/shmem.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) >=20 > 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 =3D inode->i_mtime =3D inode->i_ctime =3D current_ti= me(inode); > inode->i_generation =3D prandom_u32(); > info =3D SHMEM_I(inode); > - memset(info, 0, (char *)inode - (char *)info); > spin_lock_init(&info->lock); > atomic_set(&info->stop_eviction, 0); > info->seals =3D 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 =3D kmem_cache_alloc(shmem_inode_cachep, GFP_KERNEL); > + info =3D kmem_cache_zalloc(shmem_inode_cachep, GFP_KERNEL); > if (!info) > return NULL; > return &info->vfs_inode; >=20