linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Lameter <cl@linux-foundation.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "hugh.dickins@tiscali.co.uk" <hugh.dickins@tiscali.co.uk>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, Tejun Heo <tj@kernel.org>
Subject: Re: [MM] Remove rss batching from copy_page_range()
Date: Wed, 4 Nov 2009 14:17:24 -0500 (EST)	[thread overview]
Message-ID: <alpine.DEB.1.10.0911041415480.7409@V090114053VZO-1> (raw)
In-Reply-To: <alpine.DEB.1.10.0911041409020.7409@V090114053VZO-1>

From: Christoph Lameter <cl@linux-foundation.org>
Subject: Remove rss batching from copy_page_range()

With per cpu counters in mm there is no need for batching
mm counter updates anymore. Update counters directly while
copying pages.

Signed-off-by: Christoph Lameter <cl@linux-foundation.org>

---
 mm/memory.c |   27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

Index: linux-2.6/mm/memory.c
===================================================================
--- linux-2.6.orig/mm/memory.c	2009-11-04 12:15:03.000000000 -0600
+++ linux-2.6/mm/memory.c	2009-11-04 13:03:45.000000000 -0600
@@ -376,14 +376,6 @@ int __pte_alloc_kernel(pmd_t *pmd, unsig
 	return 0;
 }

-static inline void add_mm_rss(struct mm_struct *mm, int file_rss, int anon_rss)
-{
-	if (file_rss)
-		__this_cpu_add(mm->rss->file, file_rss);
-	if (anon_rss)
-		__this_cpu_add(mm->rss->anon, anon_rss);
-}
-
 /*
  * This function is called to print an error when a bad pte
  * is found. For example, we might have a PFN-mapped pte in
@@ -575,7 +567,7 @@ out:
 static inline void
 copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 		pte_t *dst_pte, pte_t *src_pte, struct vm_area_struct *vma,
-		unsigned long addr, int *rss)
+		unsigned long addr)
 {
 	unsigned long vm_flags = vma->vm_flags;
 	pte_t pte = *src_pte;
@@ -630,7 +622,10 @@ copy_one_pte(struct mm_struct *dst_mm, s
 	if (page) {
 		get_page(page);
 		page_dup_rmap(page);
-		rss[PageAnon(page)]++;
+		if (PageAnon(page))
+			__this_cpu_inc(dst_mm->rss->anon);
+		else
+			__this_cpu_inc(dst_mm->rss->file);
 	}

 out_set_pte:
@@ -645,10 +640,8 @@ static int copy_pte_range(struct mm_stru
 	pte_t *src_pte, *dst_pte;
 	spinlock_t *src_ptl, *dst_ptl;
 	int progress = 0;
-	int rss[2];

 again:
-	rss[1] = rss[0] = 0;
 	dst_pte = pte_alloc_map_lock(dst_mm, dst_pmd, addr, &dst_ptl);
 	if (!dst_pte)
 		return -ENOMEM;
@@ -674,14 +667,13 @@ again:
 			progress++;
 			continue;
 		}
-		copy_one_pte(dst_mm, src_mm, dst_pte, src_pte, vma, addr, rss);
+		copy_one_pte(dst_mm, src_mm, dst_pte, src_pte, vma, addr);
 		progress += 8;
 	} while (dst_pte++, src_pte++, addr += PAGE_SIZE, addr != end);

 	arch_leave_lazy_mmu_mode();
 	spin_unlock(src_ptl);
 	pte_unmap_nested(orig_src_pte);
-	add_mm_rss(dst_mm, rss[0], rss[1]);
 	pte_unmap_unlock(orig_dst_pte, dst_ptl);
 	cond_resched();
 	if (addr != end)
@@ -803,8 +795,6 @@ static unsigned long zap_pte_range(struc
 	struct mm_struct *mm = tlb->mm;
 	pte_t *pte;
 	spinlock_t *ptl;
-	int file_rss = 0;
-	int anon_rss = 0;

 	pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
 	arch_enter_lazy_mmu_mode();
@@ -850,14 +840,14 @@ static unsigned long zap_pte_range(struc
 				set_pte_at(mm, addr, pte,
 					   pgoff_to_pte(page->index));
 			if (PageAnon(page))
-				anon_rss--;
+				__this_cpu_dec(mm->rss->anon);
 			else {
 				if (pte_dirty(ptent))
 					set_page_dirty(page);
 				if (pte_young(ptent) &&
 				    likely(!VM_SequentialReadHint(vma)))
 					mark_page_accessed(page);
-				file_rss--;
+				__this_cpu_dec(mm->rss->file);
 			}
 			page_remove_rmap(page);
 			if (unlikely(page_mapcount(page) < 0))
@@ -880,7 +870,6 @@ static unsigned long zap_pte_range(struc
 		pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
 	} while (pte++, addr += PAGE_SIZE, (addr != end && *zap_work > 0));

-	add_mm_rss(mm, file_rss, anon_rss);
 	arch_leave_lazy_mmu_mode();
 	pte_unmap_unlock(pte - 1, ptl);

--
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-04 19:18 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-04 19:14 [MM] Make mm counters per cpu instead of atomic Christoph Lameter
2009-11-04 19:17 ` Christoph Lameter [this message]
2009-11-04 21:02   ` [MM] Remove rss batching from copy_page_range() Andi Kleen
2009-11-04 22:02     ` Christoph Lameter
2009-11-05  8:27       ` Andi Kleen
2009-11-04 21:01 ` [MM] Make mm counters per cpu instead of atomic Andi Kleen
2009-11-04 23:49 ` Dave Jones
2009-11-05 15:04   ` Christoph Lameter
2009-11-05 15:36     ` [MM] Make mm counters per cpu instead of atomic V2 Christoph Lameter
2009-11-06  1:11       ` KAMEZAWA Hiroyuki
2009-11-06  3:23         ` KAMEZAWA Hiroyuki
2009-11-06 17:32           ` Christoph Lameter
2009-11-06 19:03             ` KAMEZAWA Hiroyuki
2009-11-06 19:13               ` Christoph Lameter
2009-11-06 19:20                 ` KAMEZAWA Hiroyuki
2009-11-06 19:47                   ` Christoph Lameter
2009-11-10 22:44         ` Andrew Morton
2009-11-10 23:20           ` Christoph Lameter
2009-11-06  4:08       ` KAMEZAWA Hiroyuki
2009-11-06  4:15       ` KAMEZAWA Hiroyuki
2009-11-05  1:16 ` [MM] Make mm counters per cpu instead of atomic KAMEZAWA Hiroyuki
2009-11-05 15:10   ` Christoph Lameter
2009-11-05 23:42     ` KAMEZAWA Hiroyuki
2009-11-17  6:48 ` Zhang, Yanmin
2009-11-17  7:31   ` Zhang, Yanmin
2009-11-17  9:34     ` Zhang, Yanmin
2009-11-17 17:25       ` Christoph Lameter
2009-11-19  0:48         ` Zhang, Yanmin
2009-11-23  8:51         ` Zhang, Yanmin
2009-11-23 14:31           ` Christoph Lameter
2009-11-24  8:02             ` Zhang, Yanmin
2009-11-24 15:17               ` Christoph Lameter
2009-11-25  1:23                 ` Zhang, Yanmin

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=alpine.DEB.1.10.0911041415480.7409@V090114053VZO-1 \
    --to=cl@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tj@kernel.org \
    /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