Hi Peter,
I've updated the patch. Could you please review it?
I'm also thinking that it can be in the mainline because it makes
the lock period shorter, correct?
---
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
There is a deadlock scenario; remove_mapping() vs free_swap_and_cache().
remove_mapping() turns PG_nonewrefs bit on, then locks swap_lock.
free_swap_and_cache() locks swap_lock, then wait to turn PG_nonewrefs bit
off in find_get_page().
swap_lock can be unlocked before calling find_get_page().
In remove_exclusive_swap_page(), there is similar lock sequence;
swap_lock, then PG_nonewrefs bit. swap_lock can be unlocked before
turning PG_nonewrefs bit on.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
mm/swapfile.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 5036b70..6fbc77e 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -366,6 +366,7 @@ int remove_exclusive_swap_page(struct page *page)
/* Is the only swap cache user the cache itself? */
retval = 0;
if (p->swap_map[swp_offset(entry)] == 1) {
+ spin_unlock(&swap_lock);
/* Recheck the page count with the swapcache lock held.. */
lock_page_ref_irq(page);
if ((page_count(page) == 2) && !PageWriteback(page)) {
@@ -374,8 +375,8 @@ int remove_exclusive_swap_page(struct page *page)
retval = 1;
}
unlock_page_ref_irq(page);
- }
- spin_unlock(&swap_lock);
+ } else
+ spin_unlock(&swap_lock);
if (retval) {
swap_free(entry);
@@ -400,13 +401,14 @@ void free_swap_and_cache(swp_entry_t entry)
p = swap_info_get(entry);
if (p) {
if (swap_entry_free(p, swp_offset(entry)) == 1) {
+ spin_unlock(&swap_lock);
page = find_get_page(&swapper_space, entry.val);
if (page && unlikely(TestSetPageLocked(page))) {
page_cache_release(page);
page = NULL;
}
- }
- spin_unlock(&swap_lock);
+ } else
+ spin_unlock(&swap_lock);
}
if (page) {
int one_user;
--
1.5.4.1
--
| Artem Bityutskiy | [PATCH 10/44 take 2] [UBI] debug unit implementation |
| Jeremy Fitzhardinge | [PATCH 03 of 36] x86: add memory barriers to wrmsr |
| Zachary Amsden | Re: [patch 13/26] Xen-paravirt_ops: Consistently wrap paravirt ops callsites to ma... |
| Justin Mattock | macbook pro dvd playback after suspend Buffer I/O error |
git: | |
| David Kastrup | Empty directories... |
| Johannes Schindelin | Re: [PATCH 1/4] Move redo merge code in a function |
| Jeff King | Re: detecting rename->commit->modify->commit |
| Pierre Habouzit | Re: [RFC] git integrated bugtracking |
| David Higgs | Re: Using the C programming language |
| Chris Bullock | OpenBSD isakmpd and pf vs Cisco PIX or ASA |
| Richard Stallman | Real men don't attack straw men |
| Chris S | Re: No text cursor on OpenBSD/i386 4.1 |
| Jojie R. T. | Re: SLS |
| Peter MacDonald | demand paging: proposal |
| Theodore Ts'o | Re: Stabilizing Linux |
| Doug Evans | Re: Stabilizing Linux |
| Battery Maximizer Software | 8 hours ago | Linux kernel |
| windows folder creation surprise | 10 hours ago | Windows |
| Problem in scim in Fedora 9 | 11 hours ago | Linux general |
| Firewall | 1 day ago | OpenBSD |
| IP layer send packet | 1 day ago | Linux kernel |
| dtrace for linux available | 2 days ago | Linux kernel |
| Unable to mount ramdisk image using UBoot while upgrading to 2.6.15 kernel for a MPC8540 based target | 2 days ago | Linux kernel |
| RealTek RTL8169 - can't connect | 2 days ago | NetBSD |
| vsftpd Upload Problems | 2 days ago | Linux general |
| creating con folder in desktop | 3 days ago | Windows |
