[Devel] [PATCH RHEL7 COMMIT] ms/mm/rmap: share the i_mmap_rwsem
Vasily Averin
vvs at virtuozzo.com
Thu Dec 3 11:40:58 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1160.6.1.vz7.171.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.6.1.vz7.171.1
------>
commit c2f195c2a4c5845b80c2ae9c2dd1cafc2ee1a6b8
Author: Davidlohr Bueso <dave at stgolabs.net>
Date: Thu Dec 3 11:40:58 2020 +0300
ms/mm/rmap: share the i_mmap_rwsem
Similarly to the anon memory counterpart, we can share the mapping's lock
ownership as the interval tree is not modified when doing doing the walk,
only the file page.
Signed-off-by: Davidlohr Bueso <dbueso at suse.de>
Acked-by: Rik van Riel <riel at redhat.com>
Acked-by: "Kirill A. Shutemov" <kirill at shutemov.name>
Acked-by: Hugh Dickins <hughd at google.com>
Cc: Oleg Nesterov <oleg at redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz at infradead.org>
Cc: Srikar Dronamraju <srikar at linux.vnet.ibm.com>
Acked-by: Mel Gorman <mgorman at suse.de>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
https://jira.sw.ru/browse/PSBM-122663
(cherry picked from commit 3dec0ba0be6a532cac949e02b853021bf6d57dad)
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
VvS: merged [PATCH rh7 4.1/8] ms/mm/rmap: share the i_mmap_rwsem fix
"Use down_read_nested to avoid lockdep complain. (in rmap_walk_file())"
---
include/linux/fs.h | 10 ++++++++++
mm/rmap.c | 6 +++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1ea2a23..8398ec2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -709,6 +709,16 @@ static inline void i_mmap_unlock_write(struct address_space *mapping)
up_write(&mapping->i_mmap_rwsem);
}
+static inline void i_mmap_lock_read(struct address_space *mapping)
+{
+ down_read(&mapping->i_mmap_rwsem);
+}
+
+static inline void i_mmap_unlock_read(struct address_space *mapping)
+{
+ up_read(&mapping->i_mmap_rwsem);
+}
+
/*
* Might pages of this file be mapped into userspace?
*/
diff --git a/mm/rmap.c b/mm/rmap.c
index e72be32c..846d027 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1748,7 +1748,7 @@ static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
if (!mapping_mapped(peer))
continue;
- i_mmap_lock_write(peer);
+ i_mmap_lock_read(peer);
vma_interval_tree_foreach(vma, &peer->i_mmap, pgoff, pgoff) {
unsigned long address = vma_address(page, vma);
@@ -1764,7 +1764,7 @@ static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
cond_resched();
}
- i_mmap_unlock_write(peer);
+ i_mmap_unlock_read(peer);
if (ret != SWAP_AGAIN)
goto done;
@@ -1772,7 +1772,7 @@ static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc)
goto done;
}
done:
- i_mmap_unlock_write(mapping);
+ i_mmap_unlock_read(mapping);
return ret;
}
More information about the Devel
mailing list