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,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 04D68C43460 for ; Wed, 12 May 2021 03:20:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 714A5610A1 for ; Wed, 12 May 2021 03:20:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 714A5610A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 028956B0036; Tue, 11 May 2021 23:20:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F1BBC6B006E; Tue, 11 May 2021 23:20:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D95536B0070; Tue, 11 May 2021 23:20:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id BB27B6B0036 for ; Tue, 11 May 2021 23:20:50 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7E6298249980 for ; Wed, 12 May 2021 03:20:50 +0000 (UTC) X-FDA: 78131127060.15.9F14EEE Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf26.hostedemail.com (Postfix) with ESMTP id 17CE040002F4 for ; Wed, 12 May 2021 03:20:34 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id y32so17180633pga.11 for ; Tue, 11 May 2021 20:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=I0E05OrXdqW9H2ReWLoImyNAZwoWDkKkUkvJVilZtAk=; b=VVRagCeMJog1E+4Kn5glvSDrq5Z9pScXTmoEgqtFvqbpwAp4+ssECkxAhdk/vtqDwj BZnaZgrR1jyX5rdx19eD0hi94IshSlJqglbb1GslPPXUQqb2Syw/GmM9YEmqHMaaXp81 2r+T8R8DYzEQ/rQOrSEdkFWINQGvFlkm4RrBWbbVLwk/7ON2mUsH2/Y067k3NY2G8cf9 t0jPJMrIJlf+GJ4buPS1vDmV8FYuO1GYcVG3PSCngqUEabK5nX2r5r6XoHVfUb1QKW0b Iipc35TkH1zgpr3J+ToxNIgfRWUUh4qNi/VAYS9P7T6JuZ35/1Oyd+hx7rXkRQBQW9Fa l+/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=I0E05OrXdqW9H2ReWLoImyNAZwoWDkKkUkvJVilZtAk=; b=oP+31EtrzhGkKHUNoY1D6oi4AJpkD5JBR12nr6zZKqqCJqwFsIP/UZQiEZkdws/apc B3QCs8ItaMTApL1s69HNs+0Eyujc5I1JlNuBsyr0wpWGgBcH0gre3EwfQDMny6Oo/mjH PQiFUQyBk8vk/4blKbo8BbA2SDhkQEVUEMxWSQI31hQ4cDSeAOhDwAU6j7iDWFmmE+Cn qwA2Y/AHOYf2CqmwcKIRkup57yx0Y23A+zismGT+ekJ74mg7nNLrgroij4NfP1u40Ww+ x/BM++6ALk/nLRdx33+omDeQbPXw7PO5ks8l2zMgtXhFpO5wfxQpd6Tr3Lw/p3mZhNp7 8RGw== X-Gm-Message-State: AOAM5322cY4ZJlBUU/dP85Q39xsMHyD88svBvqME14+LzIsuVri2zV4m /TdlGLUew/pi9CrWldZi0OjJfy6r6mzCm4BC8m4mHw== X-Google-Smtp-Source: ABdhPJyGmBzA6PB1rG2IFhsITR6WU/fAlG0hy4zTLptVYrtYuchEfeOpjh01hqqw+BQwMmZ4kbr6JD15UVyidm9h3CA= X-Received: by 2002:a05:6a00:8c7:b029:20f:1cf4:d02 with SMTP id s7-20020a056a0008c7b029020f1cf40d02mr34091256pfu.49.1620789647824; Tue, 11 May 2021 20:20:47 -0700 (PDT) MIME-Version: 1.0 References: <20210511104647.604-1-songmuchun@bytedance.com> <20210511104647.604-11-songmuchun@bytedance.com> <20210511234041.GP1872259@dread.disaster.area> In-Reply-To: <20210511234041.GP1872259@dread.disaster.area> From: Muchun Song Date: Wed, 12 May 2021 11:20:10 +0800 Message-ID: Subject: Re: [External] Re: [PATCH 10/17] fs: introduce alloc_inode_sb() to allocate filesystems specific inode To: Dave Chinner Cc: Matthew Wilcox , Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov , Shakeel Butt , Roman Gushchin , Yang Shi , alexs@kernel.org, Wei Yang , trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, linux-fsdevel , LKML , Linux Memory Management List , linux-nfs@vger.kernel.org, zhengqi.arch@bytedance.com, Xiongchun duan , fam.zheng@bytedance.com Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 17CE040002F4 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=VVRagCeM; spf=pass (imf26.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam04 X-Stat-Signature: zfsqj36fs5w9qhpo73a5jjngwyjquq9r Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=mail-pg1-f171.google.com; client-ip=209.85.215.171 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620789634-162156 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 Wed, May 12, 2021 at 7:40 AM Dave Chinner wrote: > > 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. Make sense to me. I'll fix it in the next version. > > 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.... Will do. > > /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? Good point. IMHO, I think that the BUG_ON check may be useful. Actually, it can catch such bugs. Any suggestions from others? Thanks. > > Cheers, > > Dave. > -- > Dave Chinner > david@fromorbit.com