From: Richard Jerrell <jerrell@missioncriticallinux.com>
To: linux-mm@kvack.org
Subject: Re: [PATCH] Reclaim orphaned swap pages
Date: Mon, 2 Apr 2001 11:17:26 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.21.0104021102290.12558-200000@jerrell.lowell.mclinux.com> (raw)
[-- Attachment #1: Type: TEXT/PLAIN, Size: 561 bytes --]
>From what I can see of the patch vm_enough_memory will still fail causing
premature oom merely because those pages haven't been accounted for as
free. The checking should probably be done in page_launder, too, to
prevent the write at that level. Also, the page count might be two,
depending on if you have buffers. The attached patch should work just
fine and remove these pages as quickly as possible. I sent it out to the
kernel list on the 27th in response to Stephen Tweedie's point that exit
path deletion was slow, but I guess it belongs here.
Rich
[-- Attachment #2: Type: TEXT/PLAIN, Size: 3485 bytes --]
diff -rNu linux-2.4.1/include/linux/swap.h linux-2.4.1-paging-fix/include/linux/swap.h
--- linux-2.4.1/include/linux/swap.h Tue Jan 30 02:24:56 2001
+++ linux-2.4.1-paging-fix/include/linux/swap.h Tue Mar 27 14:00:17 2001
@@ -69,6 +69,7 @@
FASTCALL(unsigned int nr_free_buffer_pages(void));
extern int nr_active_pages;
extern int nr_inactive_dirty_pages;
+extern int nr_swap_cache_pages;
extern atomic_t nr_async_pages;
extern struct address_space swapper_space;
extern atomic_t page_cache_size;
diff -rNu linux-2.4.1/mm/mmap.c linux-2.4.1-paging-fix/mm/mmap.c
--- linux-2.4.1/mm/mmap.c Mon Jan 29 11:10:41 2001
+++ linux-2.4.1-paging-fix/mm/mmap.c Tue Mar 27 10:38:17 2001
@@ -63,6 +63,7 @@
free += atomic_read(&page_cache_size);
free += nr_free_pages();
free += nr_swap_pages;
+ free += nr_swap_cache_pages;
return free > pages;
}
diff -rNu linux-2.4.1/mm/swap_state.c linux-2.4.1-paging-fix/mm/swap_state.c
--- linux-2.4.1/mm/swap_state.c Fri Dec 29 18:04:27 2000
+++ linux-2.4.1-paging-fix/mm/swap_state.c Tue Mar 27 10:41:04 2001
@@ -17,6 +17,8 @@
#include <asm/pgtable.h>
+int nr_swap_cache_pages = 0;
+
static int swap_writepage(struct page *page)
{
rw_swap_page(WRITE, page, 0);
@@ -58,6 +60,7 @@
#ifdef SWAP_CACHE_INFO
swap_cache_add_total++;
#endif
+ nr_swap_cache_pages++;
if (!PageLocked(page))
BUG();
if (PageTestandSetSwapCache(page))
@@ -96,6 +99,7 @@
#ifdef SWAP_CACHE_INFO
swap_cache_del_total++;
#endif
+ nr_swap_cache_pages--;
remove_from_swap_cache(page);
swap_free(entry);
}
diff -rNu linux-2.4.1/mm/vmscan.c linux-2.4.1-paging-fix/mm/vmscan.c
--- linux-2.4.1/mm/vmscan.c Mon Jan 15 15:36:49 2001
+++ linux-2.4.1-paging-fix/mm/vmscan.c Tue Mar 27 14:37:18 2001
@@ -394,6 +394,21 @@
return page;
}
+/**
+ * Short-circuits the dead swap cache page to prevent
+ * unnecessary disk IO
+ */
+static inline void delete_dead_swap_cache_page(struct page *page) {
+ if (block_flushpage(page, 0))
+ lru_cache_del(page);
+
+ ClearPageDirty(page);
+ spin_unlock(&pagemap_lru_lock);
+ __delete_from_swap_cache(page);
+ spin_lock(&pagemap_lru_lock);
+ page_cache_release(page);
+}
+
/**
* page_launder - clean dirty inactive pages, move to inactive_clean list
* @gfp_mask: what operations we are allowed to do
@@ -467,6 +482,24 @@
}
/*
+ * Prevent a dead process's pages from being
+ * written to swap when no one else needs
+ * them. Lazy form of removing these pages
+ * at exit time.
+ */
+ if (PageSwapCache(page)) {
+ page_cache_get(page);
+ if(!is_page_shared(page)) {
+ delete_dead_swap_cache_page(page);
+
+ UnlockPage(page);
+ page_cache_release(page);
+ continue;
+ }
+ page_cache_release(page);
+ }
+
+ /*
* Dirty swap-cache page? Write it out if
* last copy..
*/
@@ -650,6 +683,24 @@
list_del(page_lru);
nr_active_pages--;
continue;
+ }
+
+ /*
+ * Prevent a dead process's pages from being
+ * written to swap when no one else needs
+ * them. Lazy form of removing these pages
+ * at exit time.
+ */
+ if (PageSwapCache(page)) {
+ page_cache_get(page);
+ if(!is_page_shared(page) && !TryLockPage(page)) {
+ delete_dead_swap_cache_page(page);
+
+ UnlockPage(page);
+ page_cache_release(page);
+ continue;
+ }
+ page_cache_release(page);
}
/* Do aging on the pages. */
next reply other threads:[~2001-04-02 15:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-02 15:17 Richard Jerrell [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-04-02 18:17 Szabolcs Szakacsits
2001-04-02 18:40 ` Richard Jerrell
2001-04-02 18:40 ` Szabolcs Szakacsits
2001-04-03 0:19 ` Marcelo Tosatti
2001-04-03 13:27 ` Richard Jerrell
2001-04-03 22:11 ` Marcelo Tosatti
2001-04-04 14:29 ` Richard Jerrell
2001-03-31 22:46 Bulent Abali
2001-03-28 22:59 Stephen Tweedie
2001-03-30 19:59 ` Patrick O'Rourke
2001-03-30 22:16 ` Rik van Riel
2001-04-04 21:59 ` Stephen Tweedie
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=Pine.LNX.4.21.0104021102290.12558-200000@jerrell.lowell.mclinux.com \
--to=jerrell@missioncriticallinux.com \
--cc=linux-mm@kvack.org \
/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