From patchwork Fri May 15 13:16:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 11551523 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 951AD1391 for ; Fri, 15 May 2020 13:17:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DE59207C3 for ; Fri, 15 May 2020 13:17:05 +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="nqanRsm8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgEONRE (ORCPT ); Fri, 15 May 2020 09:17:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726242AbgEONRB (ORCPT ); Fri, 15 May 2020 09:17:01 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C5FEC05BD0D; Fri, 15 May 2020 06:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=FkHxGbykMgCdP+hiVpFj6lwTAQyIJGGRkvdY09TfM9I=; b=nqanRsm8CbBELPCnlwiLCacS9O WlkB/ez4UH2qiVdY+HY/5eHi8hgD0buGdG6FN+0HGwkTzH+L3L4jVlUyOcdRWAbX/aPoaDyW87mMb Qiu4N5CgmlTLWxr9ho1n3jW8OhJ2uxlSURzLqYEkdowQoigJAHgc4EhBbBX0ki0LWRvpFh8NczHeE Jf70UnBjk+D1F1NFAaki8tk4IjkMF8OywF70RvX8iLU8bjg6tIZGMVMFtq++db7O1nc0xdO23bIgO sOEsn1A2GP7cYwh4zs3QHOkjAwn2Cx3lY79IRX8WQDitMgukAOa7LOGqfyNChQh5IMDbcnbh7AjTi caBlNSJA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jZaCy-0005YF-Rp; Fri, 15 May 2020 13:17:00 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 08/36] fs: Do not update nr_thps for large page mappings Date: Fri, 15 May 2020 06:16:28 -0700 Message-Id: <20200515131656.12890-9-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200515131656.12890-1-willy@infradead.org> References: <20200515131656.12890-1-willy@infradead.org> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: "Matthew Wilcox (Oracle)" The nr_thps counter is to support large pages in the page cache when the filesystem does not support writing large pages. Eventually it will be removed, but we should still support filesystems which do not understand large pages yet. Move the nr_thp manipulation functions to filemap.h since they're page-cache specific. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/fs.h | 27 --------------------------- include/linux/pagemap.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 777783c8760b..1ab65898bd96 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2830,33 +2830,6 @@ static inline errseq_t filemap_sample_wb_err(struct address_space *mapping) return errseq_sample(&mapping->wb_err); } -static inline int filemap_nr_thps(struct address_space *mapping) -{ -#ifdef CONFIG_READ_ONLY_THP_FOR_FS - return atomic_read(&mapping->nr_thps); -#else - return 0; -#endif -} - -static inline void filemap_nr_thps_inc(struct address_space *mapping) -{ -#ifdef CONFIG_READ_ONLY_THP_FOR_FS - atomic_inc(&mapping->nr_thps); -#else - WARN_ON_ONCE(1); -#endif -} - -static inline void filemap_nr_thps_dec(struct address_space *mapping) -{ -#ifdef CONFIG_READ_ONLY_THP_FOR_FS - atomic_dec(&mapping->nr_thps); -#else - WARN_ON_ONCE(1); -#endif -} - extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync); extern int vfs_fsync(struct file *file, int datasync); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index c6db74b5e62f..cacd5a30cb9d 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -121,6 +121,35 @@ static inline bool mapping_large_pages(struct address_space *mapping) return mapping->host->i_sb->s_type->fs_flags & FS_LARGE_PAGES; } +static inline int filemap_nr_thps(struct address_space *mapping) +{ +#ifdef CONFIG_READ_ONLY_THP_FOR_FS + return atomic_read(&mapping->nr_thps); +#else + return 0; +#endif +} + +static inline void filemap_nr_thps_inc(struct address_space *mapping) +{ +#ifdef CONFIG_READ_ONLY_THP_FOR_FS + if (!mapping_large_pages(mapping)) + atomic_inc(&mapping->nr_thps); +#else + WARN_ON_ONCE(1); +#endif +} + +static inline void filemap_nr_thps_dec(struct address_space *mapping) +{ +#ifdef CONFIG_READ_ONLY_THP_FOR_FS + if (!mapping_large_pages(mapping)) + atomic_dec(&mapping->nr_thps); +#else + WARN_ON_ONCE(1); +#endif +} + void release_pages(struct page **pages, int nr); /*