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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 1C1D6C43460 for ; Tue, 11 May 2021 23:40:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A6A0617C9 for ; Tue, 11 May 2021 23:40:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A6A0617C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fromorbit.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DA4FC6B006E; Tue, 11 May 2021 19:40:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D535E6B0070; Tue, 11 May 2021 19:40:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C43156B0071; Tue, 11 May 2021 19:40:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id A8DB56B006E for ; Tue, 11 May 2021 19:40:49 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5ECA76D81 for ; Tue, 11 May 2021 23:40:49 +0000 (UTC) X-FDA: 78130572618.21.A1EC35A Received: from mail110.syd.optusnet.com.au (mail110.syd.optusnet.com.au [211.29.132.97]) by imf21.hostedemail.com (Postfix) with ESMTP id B99C5E000129 for ; Tue, 11 May 2021 23:40:43 +0000 (UTC) Received: from dread.disaster.area (pa49-179-143-157.pa.nsw.optusnet.com.au [49.179.143.157]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id ADB8A1082A9; Wed, 12 May 2021 09:40:43 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1lgbzV-00EYIv-Js; Wed, 12 May 2021 09:40:41 +1000 Date: Wed, 12 May 2021 09:40:41 +1000 From: Dave Chinner To: Muchun Song Cc: willy@infradead.org, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, shakeelb@google.com, guro@fb.com, shy828301@gmail.com, alexs@kernel.org, richard.weiyang@gmail.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, zhengqi.arch@bytedance.com, duanxiongchun@bytedance.com, fam.zheng@bytedance.com Subject: Re: [PATCH 10/17] fs: introduce alloc_inode_sb() to allocate filesystems specific inode Message-ID: <20210511234041.GP1872259@dread.disaster.area> References: <20210511104647.604-1-songmuchun@bytedance.com> <20210511104647.604-11-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210511104647.604-11-songmuchun@bytedance.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=Tu+Yewfh c=1 sm=1 tr=0 a=I9rzhn+0hBG9LkCzAun3+g==:117 a=I9rzhn+0hBG9LkCzAun3+g==:17 a=kj9zAlcOel0A:10 a=5FLXtPjwQuUA:10 a=7-415B0cAAAA:8 a=eDM3njHHF8h-SXrJDeMA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 X-Rspamd-Queue-Id: B99C5E000129 Authentication-Results: imf21.hostedemail.com; dkim=none; spf=none (imf21.hostedemail.com: domain of david@fromorbit.com has no SPF policy when checking 211.29.132.97) smtp.mailfrom=david@fromorbit.com; dmarc=none X-Rspamd-Server: rspam03 X-Stat-Signature: 4ynu4cmgrkdfqyizgm3misc9rq9tnp4h Received-SPF: none (fromorbit.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=mail110.syd.optusnet.com.au; client-ip=211.29.132.97 X-HE-DKIM-Result: none/none X-HE-Tag: 1620776443-499496 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 Tue, May 11, 2021 at 06:46:40PM +0800, Muchun Song wrote: > The allocated inode cache will be added into its memcg lru list later, > but we do not allocate list_lru in the later patch. So the caller should > call kmem_cache_alloc_lru() to allocate inode and related list_lru. > Introduce alloc_inode_sb() to do that and convert all inodes allocation > to it. FWIW, this probably needs a documentation update to mention that inodes should always be allocated through alloc_inode_sb() rather than kmem_cache_alloc(). It's a "** mandatory **" requirement as per Documentation/filesytems/porting.rst. Also, > diff --git a/include/linux/fs.h b/include/linux/fs.h > index c3c88fdb9b2a..d8d5d4eb68d6 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -41,6 +41,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -3200,6 +3201,12 @@ extern void free_inode_nonrcu(struct inode *inode); > extern int should_remove_suid(struct dentry *); > extern int file_remove_privs(struct file *); > > +static inline void * > +alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache, gfp_t gfp) > +{ > + return kmem_cache_alloc_lru(cache, &sb->s_inode_lru, gfp); > +} > + This really needs a kerneldoc comment explaining that it must be used for allocating inodes to set up the inode reclaim context correctly.... /me wonders if we should add a BUG_ON() check in inode_init_always() to capture filesystems that don't call through kmem_cache_alloc_lru() for inodes? Cheers, Dave. -- Dave Chinner david@fromorbit.com