linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh.dickins@tiscali.co.uk>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Izik Eidus <ieidus@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Chris Wright <chrisw@redhat.com>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 6/9] ksm: mem cgroup charge swapin copy
Date: Mon, 30 Nov 2009 11:40:48 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0911301119060.20054@sister.anvils> (raw)
In-Reply-To: <20091130091316.b804a75c.kamezawa.hiroyu@jp.fujitsu.com>

On Mon, 30 Nov 2009, KAMEZAWA Hiroyuki wrote:
> 
> Ok. Maybe commit_charge will work enough. (I hope so.)

                                             Me too.
> 
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> 
> BTW, I'm happy if you adds "How to test" documenation to
> Documentation/vm/ksm.txt or to share some test programs.
> 
> 1. Map anonymous pages + madvise(MADV_MERGEABLE)
> 2. "echo 1 > /sys/kernel/mm/ksm/run"

Those are the main points, yes.

Though in testing for races, I do think the default
/sys/kernel/mm/ksm/sleep_millisecs 20 is probably too relaxed
to find issues quickly enough, so I usually change that to 0,
and also raise pages_to_scan from its default of 100 (though
that should matter less).  In testing for races, something I've
not done but probably should, is raise the priority of ksmd: we
have it niced down, but that may leave some nasties unobserved.

As to adding Documentation on testing: whilst my primary reason
for not doing so is certainly laziness (or an interest in moving
on to somewhere else), a secondary reason is that I'd much rather
that if someone does have an interest in testing this, that they
follow their own ideas, rather than copying what's already done.

But here's something I'll share with you, please don't show it
to anyone else ;)  Writing test programs using MADV_MERGEABLE is
good for testing specific issues, but can't give much coverage,
so I tend to run with this hack below: boot option "allksm" makes
as much as it can MADV_MERGEABLE.  (If you wonder why I squashed it
up, it was to avoid changing the line numbering as much as possible.)

Hugh

--- mmotm/mm/mmap.c	2009-11-25 09:28:50.000000000 +0000
+++ allksm/mm/mmap.c	2009-11-25 11:19:13.000000000 +0000
@@ -902,9 +902,9 @@ void vm_stat_account(struct mm_struct *m
 #endif /* CONFIG_PROC_FS */
 
 /*
- * The caller must hold down_write(&current->mm->mmap_sem).
- */
-
+ * The caller must hold down_write(&current->mm->mmap_sem). */
+#include <linux/ksm.h>
+unsigned long vm_mergeable;
 unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
 			unsigned long len, unsigned long prot,
 			unsigned long flags, unsigned long pgoff)
@@ -1050,7 +1050,7 @@ unsigned long do_mmap_pgoff(struct file
 			/*
 			 * Set pgoff according to addr for anon_vma.
 			 */
-			pgoff = addr >> PAGE_SHIFT;
+			vm_flags |= vm_mergeable; pgoff = addr >> PAGE_SHIFT;
 			break;
 		default:
 			return -EINVAL;
@@ -1201,10 +1201,10 @@ munmap_back:
 		vma->vm_file = file;
 		get_file(file);
 		error = file->f_op->mmap(file, vma);
-		if (error)
-			goto unmap_and_free_vma;
-		if (vm_flags & VM_EXECUTABLE)
-			added_exe_file_vma(mm);
+		if (error) goto unmap_and_free_vma;
+		if (vm_flags & VM_EXECUTABLE) added_exe_file_vma(mm);
+		if (vm_mergeable)
+			ksm_madvise(vma, 0, 0, MADV_MERGEABLE,&vma->vm_flags);
 
 		/* Can addr have changed??
 		 *
@@ -2030,7 +2030,7 @@ unsigned long do_brk(unsigned long addr,
 		return error;
 
 	flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
-
+	flags |= vm_mergeable;
 	error = arch_mmap_check(addr, len, flags);
 	if (error)
 		return error;
@@ -2179,7 +2179,7 @@ int insert_vm_struct(struct mm_struct *
 	if (!vma->vm_file) {
 		BUG_ON(vma->anon_vma);
 		vma->vm_pgoff = vma->vm_start >> PAGE_SHIFT;
-	}
+		vma->vm_flags |= vm_mergeable;	}
 	__vma = find_vma_prepare(mm,vma->vm_start,&prev,&rb_link,&rb_parent);
 	if (__vma && __vma->vm_start < vma->vm_end)
 		return -ENOMEM;
@@ -2518,3 +2518,10 @@ void __init mmap_init(void)
 	ret = percpu_counter_init(&vm_committed_as, 0);
 	VM_BUG_ON(ret);
 }
+static int __init allksm(char *s)
+{
+	randomize_va_space = 0;
+	vm_mergeable = VM_MERGEABLE;
+	return 1;
+}
+__setup("allksm", allksm);

--
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:[~2009-11-30 11:40 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-24 16:37 [PATCH 0/9] ksm: swapping Hugh Dickins
2009-11-24 16:40 ` [PATCH 1/9] ksm: fix mlockfreed to munlocked Hugh Dickins
2009-11-24 23:53   ` Rik van Riel
2009-11-26 16:20   ` Mel Gorman
2009-11-27 12:45     ` Hugh Dickins
2009-11-30  6:01       ` KOSAKI Motohiro
2009-11-30 12:26         ` Hugh Dickins
2009-11-30 21:27           ` Lee Schermerhorn
2009-12-01 11:14       ` Mel Gorman
2009-11-24 16:42 ` [PATCH 2/9] ksm: let shared pages be swappable Hugh Dickins
2009-11-30  0:46   ` KAMEZAWA Hiroyuki
2009-11-30  9:15     ` KOSAKI Motohiro
2009-11-30 12:38       ` Hugh Dickins
2009-12-01  4:14         ` KOSAKI Motohiro
2009-11-30 11:55     ` Hugh Dickins
2009-11-30 12:07     ` Andrea Arcangeli
2009-12-01  0:39       ` KAMEZAWA Hiroyuki
2009-12-01  6:32         ` Chris Wright
2009-12-01  9:11         ` Andrea Arcangeli
2009-12-01  9:28           ` KOSAKI Motohiro
2009-12-01  9:37             ` Andrea Arcangeli
2009-12-01  9:46               ` KOSAKI Motohiro
2009-12-01  9:59                 ` Andrea Arcangeli
2009-12-02  5:08                   ` Rik van Riel
2009-12-02 12:55                     ` Andrea Arcangeli
2009-12-03  5:15                       ` KOSAKI Motohiro
2009-12-04  5:06                         ` KOSAKI Motohiro
2009-12-04  5:16                           ` KAMEZAWA Hiroyuki
2009-12-04 14:49                             ` Andrea Arcangeli
2009-12-04 17:16                             ` Chris Wright
2009-12-04 18:53                               ` Andrea Arcangeli
2009-12-04 19:03                                 ` Chris Wright
2009-12-09  0:43                               ` KAMEZAWA Hiroyuki
2009-12-09  1:04                                 ` Chris Wright
2009-12-09 16:12                                 ` Andrea Arcangeli
2009-12-09 23:54                                   ` KAMEZAWA Hiroyuki
2009-12-04 14:45                           ` Andrea Arcangeli
2009-12-04 16:21                             ` Rik van Riel
2009-11-24 16:43 ` [PATCH 3/9] ksm: hold anon_vma in rmap_item Hugh Dickins
2009-11-24 16:45 ` [PATCH 4/9] ksm: take keyhole reference to page Hugh Dickins
2009-11-24 16:48 ` [PATCH 5/9] ksm: share anon page without allocating Hugh Dickins
2009-11-30  0:04   ` KAMEZAWA Hiroyuki
2009-11-30 11:18     ` Hugh Dickins
2009-12-01  0:02       ` KAMEZAWA Hiroyuki
2009-11-24 16:51 ` [PATCH 6/9] ksm: mem cgroup charge swapin copy Hugh Dickins
2009-11-25 14:23   ` Balbir Singh
2009-11-25 17:12     ` Hugh Dickins
2009-11-25 17:36       ` Balbir Singh
2009-11-30  0:13   ` KAMEZAWA Hiroyuki
2009-11-30 11:40     ` Hugh Dickins [this message]
2009-11-24 16:54 ` [PATCH 7/9] ksm: rmap_walk to remove_migation_ptes Hugh Dickins
2009-11-24 16:56 ` [PATCH 8/9] ksm: memory hotremove migration only Hugh Dickins
2009-11-24 16:57 ` [PATCH 9/9] ksm: remove unswappable max_kernel_pages Hugh Dickins

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.0911301119060.20054@sister.anvils \
    --to=hugh.dickins@tiscali.co.uk \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=chrisw@redhat.com \
    --cc=ieidus@redhat.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /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