lkml.org 
[lkml]   [2013]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCHv6 13/22] mm, vfs: introduce i_split_sem
Date
i_split_sem taken on read will protect hugepages in inode's pagecache
against splitting.

i_split_sem will be taken on write during splitting.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
fs/inode.c | 3 +++
include/linux/fs.h | 3 +++
include/linux/huge_mm.h | 10 ++++++++++
3 files changed, 16 insertions(+)

diff --git a/fs/inode.c b/fs/inode.c
index b33ba8e021..ea06e378c6 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -162,6 +162,9 @@ int inode_init_always(struct super_block *sb, struct inode *inode)

atomic_set(&inode->i_dio_count, 0);

+#ifdef CONFIG_TRANSPARENT_HUGEPAGE_PAGECACHE
+ init_rwsem(&inode->i_split_sem);
+#endif
mapping->a_ops = &empty_aops;
mapping->host = inode;
mapping->flags = 0;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 3f40547ba1..26801f0bb1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -610,6 +610,9 @@ struct inode {
atomic_t i_readcount; /* struct files open RO */
#endif
void *i_private; /* fs or device private pointer */
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE_PAGECACHE
+ struct rw_semaphore i_split_sem;
+#endif
};

static inline int inode_unhashed(struct inode *inode)
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 3700ada4d2..ce9fcae8ef 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -241,12 +241,22 @@ static inline int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_str
#define HPAGE_CACHE_NR (1L << HPAGE_CACHE_ORDER)
#define HPAGE_CACHE_INDEX_MASK (HPAGE_CACHE_NR - 1)

+#define i_split_down_read(inode) down_read(&inode->i_split_sem)
+#define i_split_up_read(inode) up_read(&inode->i_split_sem)
+
#else

#define HPAGE_CACHE_ORDER ({ BUILD_BUG(); 0; })
#define HPAGE_CACHE_NR ({ BUILD_BUG(); 0; })
#define HPAGE_CACHE_INDEX_MASK ({ BUILD_BUG(); 0; })

+static inline void i_split_down_read(struct inode *inode)
+{
+}
+
+static inline void i_split_up_read(struct inode *inode)
+{
+}
#endif

static inline bool transparent_hugepage_pagecache(void)
--
1.8.4.rc3


\
 
 \ /
  Last update: 2013-09-23 14:41    [W:0.201 / U:7.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site