Re: quicklists confuse meminfo

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ingo Molnar
Date: Wednesday, March 26, 2008 - 1:13 am

* Bart Van Assche <bart.vanassche@gmail.com> wrote:


thanks a lot Bart for the persistent testing - this was a nasty one to 
track down. Find the standalone fix below.

	Ingo

---------------->
commit 985a34bd75cc8c96e43f00dcdda7c3fdb51a3026
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Sun Mar 9 13:14:37 2008 +0100

    x86: remove quicklists
    
    quicklists cause a serious memory leak on 32-bit x86,
    as documented at:
    
      http://bugzilla.kernel.org/show_bug.cgi?id=9991
    
    the reason is that the quicklist pool is a special-purpose
    cache that grows out of proportion. It is not accounted for
    anywhere and users have no way to even realize that it's
    the quicklists that are causing RAM usage spikes. It was
    supposed to be a relatively small pool, but as demonstrated
    by KOSAKI Motohiro, they can grow as large as:
    
      Quicklists:    1194304 kB
    
    given how much trouble this code has caused historically,
    and given that Andrew objected to its introduction on x86
    (years ago), the best option at this point is to remove them.
    
    [ any performance benefits of caching constructed pgds should
      be implemented in a more generic way (possibly within the page
      allocator), while still allowing constructed pages to be
      allocated by other workloads. ]
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f41c953..237fc12 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -66,9 +66,6 @@ config MMU
 config ZONE_DMA
 	def_bool y
 
-config QUICKLIST
-	def_bool X86_32
-
 config SBUS
 	bool
 
diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
index 73aba71..2f9e9af 100644
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -342,12 +342,16 @@ static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
 
 pgd_t *pgd_alloc(struct mm_struct *mm)
 {
-	pgd_t *pgd = quicklist_alloc(0, GFP_KERNEL, pgd_ctor);
+	pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
 
-	mm->pgd = pgd;		/* so that alloc_pd can use it */
+	/* so that alloc_pd can use it */
+	mm->pgd = pgd;
+	if (pgd)
+		pgd_ctor(pgd);
 
 	if (pgd && !pgd_prepopulate_pmd(mm, pgd)) {
-		quicklist_free(0, pgd_dtor, pgd);
+		pgd_dtor(pgd);
+		free_page((unsigned long)pgd);
 		pgd = NULL;
 	}
 
@@ -357,12 +361,8 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 {
 	pgd_mop_up_pmds(mm, pgd);
-	quicklist_free(0, pgd_dtor, pgd);
-}
-
-void check_pgt_cache(void)
-{
-	quicklist_trim(0, pgd_dtor, 25, 16);
+	pgd_dtor(pgd);
+	free_page((unsigned long)pgd);
 }
 
 void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte)
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index a842c72..4e6a0fc 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -26,10 +26,9 @@ struct mm_struct;
 struct vm_area_struct;
 
 extern pgd_t swapper_pg_dir[1024];
-extern struct kmem_cache *pmd_cache;
-void check_pgt_cache(void);
 
-static inline void pgtable_cache_init(void) {}
+static inline void pgtable_cache_init(void) { }
+static inline void check_pgt_cache(void) { }
 void paging_init(void);
 
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
quicklists confuse meminfo, Thomas Gleixner, (Sun Mar 9, 3:19 am)
Re: quicklists confuse meminfo, Bart Van Assche, (Sun Mar 9, 3:26 am)
Re: quicklists confuse meminfo, Andi Kleen, (Sun Mar 9, 3:29 am)
Re: quicklists confuse meminfo, KOSAKI Motohiro, (Sun Mar 9, 3:42 am)
Re: quicklists confuse meminfo, Ingo Molnar, (Sun Mar 9, 4:14 am)
Re: quicklists confuse meminfo, Thomas Gleixner, (Sun Mar 9, 4:56 am)
Re: quicklists confuse meminfo, Thomas Gleixner, (Sun Mar 9, 5:00 am)
Re: quicklists confuse meminfo, Ingo Molnar, (Sun Mar 9, 5:01 am)
Re: quicklists confuse meminfo, Johannes Weiner, (Sun Mar 9, 5:03 am)
Re: quicklists confuse meminfo, KOSAKI Motohiro, (Sun Mar 9, 5:03 am)
Re: quicklists confuse meminfo, Ingo Molnar, (Sun Mar 9, 5:09 am)
Re: quicklists confuse meminfo, Ingo Molnar, (Sun Mar 9, 5:34 am)
Re: quicklists confuse meminfo, KOSAKI Motohiro, (Sun Mar 9, 5:47 am)
Re: quicklists confuse meminfo, Andi Kleen, (Sun Mar 9, 5:49 am)
Re: quicklists confuse meminfo, KOSAKI Motohiro, (Sun Mar 9, 5:51 am)
Re: quicklists confuse meminfo, Thomas Gleixner, (Sun Mar 9, 6:20 am)
Re: quicklists confuse meminfo, Andrew Morton, (Sun Mar 9, 11:46 am)
Re: quicklists confuse meminfo, Arjan van de Ven, (Sun Mar 9, 12:11 pm)
Re: quicklists confuse meminfo, Ingo Molnar, (Sun Mar 9, 12:25 pm)
Re: quicklists confuse meminfo, Ingo Molnar, (Sun Mar 9, 12:27 pm)
Re: quicklists confuse meminfo, Ingo Molnar, (Sun Mar 9, 12:31 pm)
Re: quicklists confuse meminfo, Andi Kleen, (Sun Mar 9, 1:21 pm)
Re: quicklists confuse meminfo, Christoph Lameter, (Mon Mar 10, 8:51 am)
Re: quicklists confuse meminfo, Christoph Lameter, (Mon Mar 10, 8:54 am)
Re: quicklists confuse meminfo, Christoph Lameter, (Mon Mar 10, 8:55 am)
Re: quicklists confuse meminfo, Christoph Lameter, (Mon Mar 10, 8:57 am)
Re: quicklists confuse meminfo, Andi Kleen, (Mon Mar 10, 9:43 am)
Re: quicklists confuse meminfo, Hugh Dickins, (Mon Mar 10, 10:19 am)
Re: quicklists confuse meminfo, Andi Kleen, (Mon Mar 10, 10:25 am)
Re: quicklists confuse meminfo, Jeremy Fitzhardinge, (Mon Mar 10, 10:31 am)
Re: quicklists confuse meminfo, Andi Kleen, (Mon Mar 10, 10:53 am)
Re: quicklists confuse meminfo, Jeremy Fitzhardinge, (Mon Mar 10, 11:35 am)
Re: quicklists confuse meminfo, Andi Kleen, (Mon Mar 10, 12:06 pm)
Re: quicklists confuse meminfo, H. Peter Anvin, (Mon Mar 10, 1:54 pm)
Re: quicklists confuse meminfo, Jeremy Fitzhardinge, (Mon Mar 10, 2:26 pm)
Re: quicklists confuse meminfo, Nick Piggin, (Mon Mar 10, 9:07 pm)
Re: quicklists confuse meminfo, Bart Van Assche, (Fri Mar 21, 5:52 am)
Re: quicklists confuse meminfo, Ingo Molnar, (Fri Mar 21, 7:45 am)
Re: quicklists confuse meminfo, Bart Van Assche, (Wed Mar 26, 12:45 am)
Re: quicklists confuse meminfo, Andrew Morton, (Wed Mar 26, 12:53 am)
Re: quicklists confuse meminfo, Ingo Molnar, (Wed Mar 26, 1:13 am)
Re: quicklists confuse meminfo, Bart Van Assche, (Wed Mar 26, 3:37 am)
Re: quicklists confuse meminfo, Christoph Lameter, (Wed Mar 26, 9:34 am)
Re: quicklists confuse meminfo, Bart Van Assche, (Thu Mar 27, 2:48 am)