linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Nick Piggin <nickpiggin@yahoo.com.au>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	"Martin J. Bligh" <mbligh@mbligh.org>,
	Rik van Riel <riel@redhat.com>
Subject: Re: [RFC] Remove unswappable anonymous pages off the LRU
Date: Thu, 15 Feb 2007 21:02:53 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0702152056470.2290@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0702151852140.1511@schroedinger.engr.sgi.com>

On Thu, 15 Feb 2007, Christoph Lameter wrote:

> On Thu, 15 Feb 2007, Andrew Morton wrote:
> 
> > It's nice and simple, but I think I'd prefer to wait for the existing mlock
> > changes to crash a bit less before we do this.
> 
> Sigh. My optimizations must have done me in. Drop the last two patches and 
> it will be fine. I am not sure what is going on there but things work 
> right without the optimizations.
> 
> avoid-putting-new-mlocked-anonymous-pages-on-lru.patch
> opportunistically-move-mlocked-pages-off-the-lru.patch
> 

Would you put those two patches back?


The problem is that in some circumstances a page may be freed that is 
mlocked (if one is marking a page as mlocked early). The page allocator 
will not touch the PG_mlocked bit and thus a newly allocated page may have 
PG_mlocked set. If we then try to put it on the lru then the VM_BUG_ONs 
are triggered.

The following patch detects these conditions in the page allocator and 
does the proper checks and cleanup.

Signed-off-by: Christoph Lameter <clameter@sgi.com>

Index: linux-2.6.20/include/linux/page-flags.h
===================================================================
--- linux-2.6.20.orig/include/linux/page-flags.h	2007-02-15 20:42:42.000000000 -0800
+++ linux-2.6.20/include/linux/page-flags.h	2007-02-15 20:43:33.000000000 -0800
@@ -261,6 +261,7 @@ static inline void SetPageUptodate(struc
 #define PageMlocked(page)	test_bit(PG_mlocked, &(page)->flags)
 #define SetPageMlocked(page)	set_bit(PG_mlocked, &(page)->flags)
 #define ClearPageMlocked(page)	clear_bit(PG_mlocked, &(page)->flags)
+#define __ClearPageMlocked(page) __clear_bit(PG_mlocked, &(page)->flags)
 
 struct page;	/* forward declaration */
 
Index: linux-2.6.20/mm/page_alloc.c
===================================================================
--- linux-2.6.20.orig/mm/page_alloc.c	2007-02-15 20:42:42.000000000 -0800
+++ linux-2.6.20/mm/page_alloc.c	2007-02-15 20:55:23.000000000 -0800
@@ -203,6 +203,7 @@ static void bad_page(struct page *page)
 			1 << PG_slab    |
 			1 << PG_swapcache |
 			1 << PG_writeback |
+			1 << PG_mlocked |
 			1 << PG_buddy );
 	set_page_count(page, 0);
 	reset_page_mapcount(page);
@@ -442,6 +443,11 @@ static inline int free_pages_check(struc
 		bad_page(page);
 	if (PageDirty(page))
 		__ClearPageDirty(page);
+	if (PageMlocked(page)) {
+		/* Page is unused so no need to take the lru lock */
+		__ClearPageMlocked(page);
+		dec_zone_page_state(page, NR_MLOCK);
+	}
 	/*
 	 * For now, we report if PG_reserved was found set, but do not
 	 * clear it, and do not free the page.  But we shall soon need
@@ -588,6 +594,7 @@ static int prep_new_page(struct page *pa
 			1 << PG_swapcache |
 			1 << PG_writeback |
 			1 << PG_reserved |
+			1 << PG_mlocked |
 			1 << PG_buddy ))))
 		bad_page(page);
 

--
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-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2007-02-16  5:02 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-15 21:05 [RFC] Remove unswappable anonymous pages off the LRU Christoph Lameter
2007-02-15 22:31 ` Rik van Riel
2007-02-15 22:41   ` Christoph Lameter
2007-02-15 22:50     ` Rik van Riel
2007-02-15 22:53       ` Christoph Lameter
2007-02-15 23:19       ` Andrew Morton
2007-02-15 23:20       ` Lee Schermerhorn
2007-02-16  0:15         ` Andrew Morton
2007-02-16  1:13 ` Andrew Morton
2007-02-16  1:24   ` KAMEZAWA Hiroyuki
2007-02-16  1:40   ` Martin Bligh
2007-02-16  1:49     ` Andrew Morton
2007-02-16  2:21       ` Martin Bligh
2007-02-16  2:34       ` Christoph Lameter
2007-02-16  2:48         ` Andrew Morton
2007-02-16  2:50           ` Christoph Lameter
2007-02-16  3:18             ` Andrew Morton
2007-02-16  3:36               ` Christoph Lameter
2007-02-16  3:42                 ` Andrew Morton
2007-02-16  3:50                   ` Christoph Lameter
2007-02-16  4:02                     ` Andrew Morton
2007-02-16  4:07                       ` Christoph Lameter
2007-02-16  4:03                     ` Andrew Morton
2007-02-16  4:14                     ` Rik van Riel
2007-02-16  4:15                       ` Christoph Lameter
2007-02-16  4:57                         ` KAMEZAWA Hiroyuki
2007-02-16  5:16                           ` Andrew Morton
2007-02-16  5:25                             ` Christoph Lameter
2007-02-16  5:41                               ` Andrew Morton
2007-02-16  5:19                           ` Christoph Lameter
2007-02-16  4:24                       ` Andrew Morton
2007-02-16  8:15           ` Peter Zijlstra
2007-02-16  9:11             ` Rafael J. Wysocki
2007-02-16  9:19               ` Peter Zijlstra
2007-02-16 10:10             ` Christoph Lameter
2007-02-16 10:17               ` Peter Zijlstra
2007-02-16 11:04                 ` Rafael J. Wysocki
2007-02-16  2:16     ` Christoph Lameter
2007-02-16  3:17       ` Martin Bligh
2007-02-16  3:29         ` Christoph Lameter
2007-02-16  8:10     ` Peter Zijlstra
2007-02-16  2:15   ` Christoph Lameter
2007-02-16  2:55   ` Christoph Lameter
2007-02-16  5:02     ` Christoph Lameter [this message]

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.64.0702152056470.2290@schroedinger.engr.sgi.com \
    --to=clameter@sgi.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=mbligh@mbligh.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=riel@redhat.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;
as well as URLs for NNTP newsgroup(s).