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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 95583C2D0E3 for ; Wed, 16 Sep 2020 03:27:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0652821D80 for ; Wed, 16 Sep 2020 03:27:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="lGnL9G0g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0652821D80 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8084D6B0055; Tue, 15 Sep 2020 23:27:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 790FD6B005A; Tue, 15 Sep 2020 23:27:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 680C86B005D; Tue, 15 Sep 2020 23:27:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 4706C6B0055 for ; Tue, 15 Sep 2020 23:27:29 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 124D7181AC9BF for ; Wed, 16 Sep 2020 03:27:29 +0000 (UTC) X-FDA: 77267489418.14.chain06_160fad527116 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id D9A7F18229818 for ; Wed, 16 Sep 2020 03:27:28 +0000 (UTC) X-HE-Tag: chain06_160fad527116 X-Filterd-Recvd-Size: 4606 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Sep 2020 03:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=9Wcd6pyA0kW5OVn3Wwf7BVBeUFWEe52ze3rkd5TtWfQ=; b=lGnL9G0gw7JtgaO0aLEb/oKGIc UceWafAvIPyodM0XxP/qa42sSvmF0IwVeClsm+GJIZylgsR4QPf3nrZngzq5oFuS0eOIPpPvH6ozQ zvsQgdH1zWph1n1xtvHaYvunv72kxK+xDLaV/6DVd9cp7Q1MvaBlHQ//FsHaS3b5wsu0cpLulSwMU P2d658G5Nw0d7GSat1+EtgI8DI2kvp2EwzP2zFSU8GpVcxn8pGzJz36nrrQc14TcylZH90maJqXLJ 9YK7LkxR3UuxCVVOY9Q/2qgqPo2sJnffhm21FUkvoDPfsmTESH11J7jjVZzmPK4wY59u/xLOCNsJM ooG6wzYQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIO6I-0005yL-W7; Wed, 16 Sep 2020 03:27:19 +0000 From: "Matthew Wilcox (Oracle)" To: Alexander Viro Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, Hugh Dickins , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Song Liu , Rik van Riel , "Kirill A . Shutemov" , Johannes Weiner , Dave Chinner Subject: [PATCH 1/2] fs: Add a filesystem flag for THPs Date: Wed, 16 Sep 2020 04:27:16 +0100 Message-Id: <20200916032717.22917-1-willy@infradead.org> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 X-Rspamd-Queue-Id: D9A7F18229818 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: The page cache needs to know whether the filesystem supports THPs so that it doesn't send THPs to filesystems which can't handle them. Dave Chinne= r points out that getting from the page mapping to the filesystem type is too many steps (mapping->host->i_sb->s_type->fs_flags) so cache that information in the address space flags. Signed-off-by: Matthew Wilcox (Oracle) --- fs/inode.c | 2 ++ include/linux/fs.h | 1 + include/linux/pagemap.h | 6 ++++++ mm/shmem.c | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 13d8c0a44e23..4531358ae97b 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -181,6 +181,8 @@ int inode_init_always(struct super_block *sb, struct = inode *inode) mapping->a_ops =3D &empty_aops; mapping->host =3D inode; mapping->flags =3D 0; + if (sb->s_type->fs_flags & FS_THP_SUPPORT) + __set_bit(AS_THP_SUPPORT, &mapping->flags); mapping->wb_err =3D 0; atomic_set(&mapping->i_mmap_writable, 0); #ifdef CONFIG_READ_ONLY_THP_FOR_FS diff --git a/include/linux/fs.h b/include/linux/fs.h index f8d75e4ad9d7..f10190b22d5a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2217,6 +2217,7 @@ struct file_system_type { #define FS_HAS_SUBTYPE 4 #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ #define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permission events= */ +#define FS_THP_SUPPORT 8192 /* Remove once all fs converted */ #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during re= name() internally. */ int (*init_fs_context)(struct fs_context *); const struct fs_parameter_spec *parameters; diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 09738075e478..ecb03e1b3555 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -34,6 +34,7 @@ enum mapping_flags { AS_EXITING =3D 4, /* final truncate in progress */ /* writeback related tags are not used */ AS_NO_WRITEBACK_TAGS =3D 5, + AS_THP_SUPPORT =3D 6, /* THPs supported */ }; =20 /** @@ -124,6 +125,11 @@ static inline void mapping_set_gfp_mask(struct addre= ss_space *m, gfp_t mask) m->gfp_mask =3D mask; } =20 +static inline bool mapping_thp_support(struct address_space *mapping) +{ + return test_bit(AS_THP_SUPPORT, &mapping->flags); +} + void release_pages(struct page **pages, int nr); =20 /* diff --git a/mm/shmem.c b/mm/shmem.c index bb0ebb52fcbe..c763a340ea86 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3844,7 +3844,7 @@ static struct file_system_type shmem_fs_type =3D { .parameters =3D shmem_fs_parameters, #endif .kill_sb =3D kill_litter_super, - .fs_flags =3D FS_USERNS_MOUNT, + .fs_flags =3D FS_USERNS_MOUNT | FS_THP_SUPPORT, }; =20 int __init shmem_init(void) --=20 2.28.0