All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@addtoit.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org,
	user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] UML is leaking memory in arch_dup_mmap
Date: Fri, 18 Jan 2008 13:07:49 -0500	[thread overview]
Message-ID: <20080118180749.GA7688@c2.user-mode-linux.org> (raw)
In-Reply-To: <E1JFsQo-0000aG-BZ@pomaz-ex.szeredi.hu>

On Fri, Jan 18, 2008 at 03:42:54PM +0100, Miklos Szeredi wrote:
> uml:~#  grep arch_dup_mmap /proc/slab_allocators
> size-32: 10861 arch_dup_mmap+0x9f/0x130

Whoops - try the patch below.

				Jeff

-- 
Work email - jdike at linux dot intel dot com

Index: linux-2.6.22/arch/um/include/um_mmu.h
===================================================================
--- linux-2.6.22.orig/arch/um/include/um_mmu.h	2008-01-17 13:44:49.000000000 -0500
+++ linux-2.6.22/arch/um/include/um_mmu.h	2008-01-18 12:53:10.000000000 -0500
@@ -17,6 +17,7 @@ typedef struct mm_context {
 	unsigned long last_pmd;
 #endif
 	struct uml_ldt ldt;
+	struct page **stub_pages;
 } mm_context_t;
 
 extern void __switch_mm(struct mm_id * mm_idp);
Index: linux-2.6.22/arch/um/kernel/skas/mmu.c
===================================================================
--- linux-2.6.22.orig/arch/um/kernel/skas/mmu.c	2008-01-18 13:02:52.000000000 -0500
+++ linux-2.6.22/arch/um/kernel/skas/mmu.c	2008-01-18 13:04:42.000000000 -0500
@@ -91,6 +91,8 @@ int init_new_context(struct task_struct 
 		goto out_free;
 	}
 
+	to_mm->stub_pages = NULL;
+
 	return 0;
 
  out_free:
@@ -126,6 +128,7 @@ void arch_dup_mmap(struct mm_struct *old
 
 	pages[0] = virt_to_page(&__syscall_stub_start);
 	pages[1] = virt_to_page(mm->context.id.stack);
+	mm->context.stub_pages = pages;
 
 	/* dup_mmap already holds mmap_sem */
 	err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
@@ -147,6 +150,8 @@ void arch_exit_mmap(struct mm_struct *mm
 {
 	pte_t *pte;
 
+	if(mm->context.stub_pages != NULL)
+		kfree(mm->context.stub_pages);
 	pte = virt_to_pte(mm, STUB_CODE);
 	if (pte != NULL)
 		pte_clear(mm, STUB_CODE, pte);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jeff Dike <jdike@addtoit.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: user-mode-linux-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: UML is leaking memory in arch_dup_mmap
Date: Fri, 18 Jan 2008 13:07:49 -0500	[thread overview]
Message-ID: <20080118180749.GA7688@c2.user-mode-linux.org> (raw)
In-Reply-To: <E1JFsQo-0000aG-BZ@pomaz-ex.szeredi.hu>

On Fri, Jan 18, 2008 at 03:42:54PM +0100, Miklos Szeredi wrote:
> uml:~#  grep arch_dup_mmap /proc/slab_allocators
> size-32: 10861 arch_dup_mmap+0x9f/0x130

Whoops - try the patch below.

				Jeff

-- 
Work email - jdike at linux dot intel dot com

Index: linux-2.6.22/arch/um/include/um_mmu.h
===================================================================
--- linux-2.6.22.orig/arch/um/include/um_mmu.h	2008-01-17 13:44:49.000000000 -0500
+++ linux-2.6.22/arch/um/include/um_mmu.h	2008-01-18 12:53:10.000000000 -0500
@@ -17,6 +17,7 @@ typedef struct mm_context {
 	unsigned long last_pmd;
 #endif
 	struct uml_ldt ldt;
+	struct page **stub_pages;
 } mm_context_t;
 
 extern void __switch_mm(struct mm_id * mm_idp);
Index: linux-2.6.22/arch/um/kernel/skas/mmu.c
===================================================================
--- linux-2.6.22.orig/arch/um/kernel/skas/mmu.c	2008-01-18 13:02:52.000000000 -0500
+++ linux-2.6.22/arch/um/kernel/skas/mmu.c	2008-01-18 13:04:42.000000000 -0500
@@ -91,6 +91,8 @@ int init_new_context(struct task_struct 
 		goto out_free;
 	}
 
+	to_mm->stub_pages = NULL;
+
 	return 0;
 
  out_free:
@@ -126,6 +128,7 @@ void arch_dup_mmap(struct mm_struct *old
 
 	pages[0] = virt_to_page(&__syscall_stub_start);
 	pages[1] = virt_to_page(mm->context.id.stack);
+	mm->context.stub_pages = pages;
 
 	/* dup_mmap already holds mmap_sem */
 	err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
@@ -147,6 +150,8 @@ void arch_exit_mmap(struct mm_struct *mm
 {
 	pte_t *pte;
 
+	if(mm->context.stub_pages != NULL)
+		kfree(mm->context.stub_pages);
 	pte = virt_to_pte(mm, STUB_CODE);
 	if (pte != NULL)
 		pte_clear(mm, STUB_CODE, pte);

  reply	other threads:[~2008-01-18 18:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-18 14:42 [uml-devel] UML is leaking memory in arch_dup_mmap Miklos Szeredi
2008-01-18 14:42 ` Miklos Szeredi
2008-01-18 18:07 ` Jeff Dike [this message]
2008-01-18 18:07   ` Jeff Dike
2008-01-18 18:29   ` [uml-devel] " Miklos Szeredi
2008-01-18 18:29     ` Miklos Szeredi

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=20080118180749.GA7688@c2.user-mode-linux.org \
    --to=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.