From: Marcelo Tosatti <marcelo@conectiva.com.br>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: "Stephen C. Tweedie" <sct@redhat.com>,
"David S. Miller" <davem@redhat.com>,
Rik van Riel <riel@conectiva.com.br>,
linux-mm@kvack.org
Subject: Re: Subtle MM bug
Date: Tue, 9 Jan 2001 18:33:19 -0200 (BRST) [thread overview]
Message-ID: <Pine.LNX.4.21.0101091654040.7377-100000@freak.distro.conectiva> (raw)
In-Reply-To: <Pine.LNX.4.10.10101081903450.1371-100000@penguin.transmeta.com>
On Mon, 8 Jan 2001, Linus Torvalds wrote:
> Try out 2.4.1-pre1 in testing.
The "while (!inactive_shortage())" should be "while (inactive_shortage())"
as Benjamin noted on lk.
The second problem is that background scanning is being done
unconditionally, and it should not. You end up getting all pages with the
same age if the system is idle. Look at this example (2.4.1-pre1):
MemTotal: 900148 kB
MemFree: 145060 kB
Cached: 725624 kB
Active: 3972 kB
Inact_dirty: 722940 kB
Inact_clean: 0 kB
Inact_target: 188 kB
> That kmem_cache_reap() thing still looks completely bogus, but I didn't
> touch it. It looks _so_ bogus that there must be some reason for doing it
> that ass-backwards way. Why should anybody have does a kmem_cache_reap()
> when we're _not_ short of free pages? That code just makes me very
> confused, so I'm not touching it.
This patch removes kmem_cache_reap() from refill_inactive() and moves it
to inside the free_shortage() check in do_try_to_free_pages().
It also changes the "while (!inactive_shortage())" mistake.
Comments?
diff -Nur linux.orig/include/linux/fs.h linux/include/linux/fs.h
--- linux.orig/include/linux/fs.h Tue Jan 9 19:32:51 2001
+++ linux/include/linux/fs.h Tue Jan 9 20:07:32 2001
@@ -985,7 +985,7 @@
extern int fs_may_remount_ro(struct super_block *);
-extern int try_to_free_buffers(struct page *, int);
+extern void try_to_free_buffers(struct page *, int);
extern void refile_buffer(struct buffer_head * buf);
#define BUF_CLEAN 0
diff -Nur linux.orig/include/linux/swap.h linux/include/linux/swap.h
--- linux.orig/include/linux/swap.h Tue Jan 9 19:32:51 2001
+++ linux/include/linux/swap.h Tue Jan 9 20:07:38 2001
@@ -108,7 +108,7 @@
extern int free_shortage(void);
extern int inactive_shortage(void);
extern void wakeup_kswapd(int);
-extern int try_to_free_pages(unsigned int gfp_mask);
+extern void try_to_free_pages(unsigned int gfp_mask);
/* linux/mm/page_io.c */
extern void rw_swap_page(int, struct page *, int);
diff -Nur linux.orig/mm/vmscan.c linux/mm/vmscan.c
--- linux.orig/mm/vmscan.c Tue Jan 9 19:35:41 2001
+++ linux/mm/vmscan.c Tue Jan 9 20:06:01 2001
@@ -825,9 +825,6 @@
count = (1 << page_cluster);
start_count = count;
- /* Always trim SLAB caches when memory gets low. */
- kmem_cache_reap(gfp_mask);
-
priority = 6;
do {
if (current->need_resched) {
@@ -842,16 +839,14 @@
/* If refill_inactive_scan failed, try to page stuff out.. */
swap_out(priority, gfp_mask);
- } while (!inactive_shortage());
+ } while (inactive_shortage());
done:
return (count < start_count);
}
-static int do_try_to_free_pages(unsigned int gfp_mask, int user)
+static void do_try_to_free_pages(unsigned int gfp_mask, int user)
{
- int ret = 0;
-
/*
* If we're low on free pages, move pages from the
* inactive_dirty list to the inactive_clean list.
@@ -862,32 +857,24 @@
*/
if (free_shortage() || nr_inactive_dirty_pages > nr_free_pages() +
nr_inactive_clean_pages())
- ret += page_launder(gfp_mask, user);
+ page_launder(gfp_mask, user);
/*
* If needed, we move pages from the active list
* to the inactive list.
*/
if (inactive_shortage())
- ret += refill_inactive(gfp_mask, user);
+ refill_inactive(gfp_mask, user);
/*
- * Delete pages from the inode and dentry cache
- * if memory is low.
+ * Delete pages from the inode and dentry cache and
+ * reclaim unused slab cache if memory is low.
*/
if (free_shortage()) {
shrink_dcache_memory(6, gfp_mask);
shrink_icache_memory(6, gfp_mask);
- } else {
-
- /*
- * Reclaim unused slab cache memory.
- */
kmem_cache_reap(gfp_mask);
- ret = 1;
}
-
- return ret;
}
DECLARE_WAIT_QUEUE_HEAD(kswapd_wait);
@@ -1029,17 +1016,13 @@
* memory but are unable to sleep on kswapd because
* they might be holding some IO locks ...
*/
-int try_to_free_pages(unsigned int gfp_mask)
+void try_to_free_pages(unsigned int gfp_mask)
{
- int ret = 1;
-
if (gfp_mask & __GFP_WAIT) {
current->flags |= PF_MEMALLOC;
- ret = do_try_to_free_pages(gfp_mask, 1);
+ do_try_to_free_pages(gfp_mask, 1);
current->flags &= ~PF_MEMALLOC;
}
-
- return ret;
}
DECLARE_WAIT_QUEUE_HEAD(kreclaimd_wait);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
next prev parent reply other threads:[~2001-01-09 20:33 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200101080602.WAA02132@pizda.ninka.net>
2001-01-08 6:42 ` Linus Torvalds
2001-01-08 13:11 ` Marcelo Tosatti
2001-01-08 16:42 ` Rik van Riel
2001-01-08 17:43 ` Linus Torvalds
2001-01-08 13:57 ` Stephen C. Tweedie
2001-01-08 17:29 ` Linus Torvalds
2001-01-08 18:10 ` Stephen C. Tweedie
2001-01-08 21:52 ` Marcelo Tosatti
2001-01-09 0:28 ` Linus Torvalds
2001-01-08 23:49 ` Marcelo Tosatti
2001-01-09 3:12 ` Linus Torvalds
2001-01-09 20:33 ` Marcelo Tosatti [this message]
2001-01-09 22:44 ` Linus Torvalds
2001-01-09 21:33 ` Marcelo Tosatti
2001-01-09 22:11 ` Yet another bogus piece of do_try_to_free_pages() Marcelo Tosatti
2001-01-10 0:06 ` Linus Torvalds
2001-01-10 6:39 ` Marcelo Tosatti
2001-01-10 22:19 ` Roger Larsson
2001-01-11 0:11 ` Zlatko Calusic
2001-01-17 6:58 ` Rik van Riel
2001-01-17 6:07 ` Marcelo Tosatti
2001-01-17 19:04 ` Zlatko Calusic
2001-01-17 19:22 ` Ingo Molnar
2001-01-18 0:55 ` Rik van Riel
2001-01-17 6:52 ` Rik van Riel
2001-01-09 23:58 ` Subtle MM bug Linus Torvalds
2001-01-09 22:21 ` Marcelo Tosatti
2001-01-10 0:23 ` Linus Torvalds
2001-01-10 0:12 ` Marcelo Tosatti
2001-01-10 11:29 ` Stephen C. Tweedie
2001-01-11 3:30 ` Marcelo Tosatti
2001-01-11 9:42 ` Stephen C. Tweedie
2001-01-11 15:24 ` Marcelo Tosatti
2001-01-17 4:54 ` Rik van Riel
2001-01-08 16:45 ` Rik van Riel
2001-01-08 17:50 ` Linus Torvalds
2001-01-08 18:21 ` Rik van Riel
2001-01-08 18:38 ` Linus Torvalds
2001-01-07 20:59 Zlatko Calusic
2001-01-07 21:37 ` Rik van Riel
2001-01-07 22:33 ` Zlatko Calusic
2001-01-09 2:01 ` Zlatko Calusic
2001-01-17 4:48 ` Rik van Riel
2001-01-17 18:53 ` Zlatko Calusic
2001-01-18 1:32 ` Rik van Riel
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.0101091654040.7377-100000@freak.distro.conectiva \
--to=marcelo@conectiva.com.br \
--cc=davem@redhat.com \
--cc=linux-mm@kvack.org \
--cc=riel@conectiva.com.br \
--cc=sct@redhat.com \
--cc=torvalds@transmeta.com \
/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