diff mbox series

[2/2] fs: Do not update nr_thps for mappings which support THPs

Message ID 20200916032717.22917-2-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series [1/2] fs: Add a filesystem flag for THPs | expand

Commit Message

Matthew Wilcox (Oracle) Sept. 16, 2020, 3:27 a.m. UTC
The nr_thps counter is to support THPs in the page cache when the
filesystem doesn't understand THPs.  Eventually it will be removed, but
we should still support filesystems which do not understand THPs yet.
Move the nr_thp manipulation functions to filemap.h since they're
page-cache specific.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/fs.h      | 27 ---------------------------
 include/linux/pagemap.h | 29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 27 deletions(-)

Comments

Christoph Hellwig Sept. 16, 2020, 5:21 a.m. UTC | #1
On Wed, Sep 16, 2020 at 04:27:17AM +0100, Matthew Wilcox (Oracle) wrote:
> The nr_thps counter is to support THPs in the page cache when the
> filesystem doesn't understand THPs.  Eventually it will be removed, but
> we should still support filesystems which do not understand THPs yet.
> Move the nr_thp manipulation functions to filemap.h since they're
> page-cache specific.

Honestly I don't think we should support the read-only THP crap.  We
should in fact never have merged that bandaid to start with given that
you did good progress on the real thing.
Matthew Wilcox (Oracle) Sept. 16, 2020, 11:46 a.m. UTC | #2
On Wed, Sep 16, 2020 at 06:21:26AM +0100, Christoph Hellwig wrote:
> On Wed, Sep 16, 2020 at 04:27:17AM +0100, Matthew Wilcox (Oracle) wrote:
> > The nr_thps counter is to support THPs in the page cache when the
> > filesystem doesn't understand THPs.  Eventually it will be removed, but
> > we should still support filesystems which do not understand THPs yet.
> > Move the nr_thp manipulation functions to filemap.h since they're
> > page-cache specific.
> 
> Honestly I don't think we should support the read-only THP crap.  We
> should in fact never have merged that bandaid to start with given that
> you did good progress on the real thing.

I'd like to see the feature ripped out again, yes.  Once we have a few more
filesystems converted, I think that'll be a reasonable thing to do.

It was a good step along the way; Song fixed a number of problems,
and worked on other things that I never had to learn anything about
(like uprobes and khugepaged).  I wouldn't go so far as to say we should
never have merged it, but I think we can remove it in about six months.
diff mbox series

Patch

diff --git a/include/linux/fs.h b/include/linux/fs.h
index f10190b22d5a..83d8f3ba17a5 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2701,33 +2701,6 @@  static inline errseq_t file_sample_sb_err(struct file *file)
 	return errseq_sample(&file->f_path.dentry->d_sb->s_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 ecb03e1b3555..2b637960be3a 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -130,6 +130,35 @@  static inline bool mapping_thp_support(struct address_space *mapping)
 	return test_bit(AS_THP_SUPPORT, &mapping->flags);
 }
 
+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_thp_support(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_thp_support(mapping))
+		atomic_dec(&mapping->nr_thps);
+#else
+	WARN_ON_ONCE(1);
+#endif
+}
+
 void release_pages(struct page **pages, int nr);
 
 /*