From: Larry Woodman <woodman@missioncriticallinux.com>
To: Andrea Arcangeli <andrea@suse.de>, linux-kernel@vger.rutgers.edu
Subject: 2.3.29 patch for releasing swap cache pages on exit and fixing race in do_swap_page.Larry
Date: Tue, 07 Dec 1999 10:25:26 -0500 [thread overview]
Message-ID: <384D26E6.6E21C624@missioncriticallinux.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 367 bytes --]
We have run into two problems in 2.3 related to the swap cache: 1.) When
a process
exits, some of its private pages can remain in the swap cache and tie up
swap space
unless shrink_mmap runs. 2.) What looks like a race between
do_swap_page
and shrink_mmap.
Here is my attempt at a patch that fixes both problems.
Larry Woodman
http://www/missioncriticallinux.com
[-- Attachment #2: patch-2.3.29.race --]
[-- Type: text/plain, Size: 1372 bytes --]
--- mm/memory.c.sav Tue Dec 7 10:04:33 1999
+++ mm/memory.c Tue Dec 7 10:06:14 1999
@@ -1004,12 +1004,15 @@
pte = mk_pte(page, vma->vm_page_prot);
set_bit(PG_swap_entry, &page->flags);
+ lock_page(page);
if (write_access && !is_page_shared(page)) {
- delete_from_swap_cache(page);
+ delete_from_swap_cache_nolock(page);
+ UnlockPage(page);
page = replace_with_highmem(page);
pte = mk_pte(page, vma->vm_page_prot);
pte = pte_mkwrite(pte_mkdirty(pte));
- }
+ } else
+ UnlockPage(page);
set_pte(page_table, pte);
/* No need to invalidate - it was non-present before */
update_mmu_cache(vma, address, pte);
--- mm/swap_state.c.sav Wed Dec 1 18:20:23 1999
+++ mm/swap_state.c Tue Dec 7 10:07:17 1999
@@ -171,7 +171,7 @@
unlock_kernel();
}
-static void delete_from_swap_cache_nolock(struct page *page)
+void delete_from_swap_cache_nolock(struct page *page)
{
if (block_flushpage(NULL, page, 0))
lru_cache_del(page);
--- include/linux/swap.h.sav Wed Dec 1 12:28:42 1999
+++ include/linux/swap.h Tue Dec 7 10:01:16 1999
@@ -147,8 +147,9 @@
if (PageReserved(page))
return 1;
count = page_count(page);
- if (PageSwapCache(page))
- count += swap_count(page) - 2;
+ if (PageSwapCache(page))
+ /* page_count is 3 if shrink_mmap didnt free buffer yet */
+ count += swap_count(page) - 2 - !!page->buffers;
return count > 1;
}
reply other threads:[~1999-12-07 15:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=384D26E6.6E21C624@missioncriticallinux.com \
--to=woodman@missioncriticallinux.com \
--cc=andrea@suse.de \
--cc=linux-kernel@vger.rutgers.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).