linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@engr.sgi.com>
To: Hugh Dickins <hugh@veritas.com>
Cc: linux-mm@kvack.org, akpm@osdl.org
Subject: unuse_pte: set pte dirty if the page is dirty
Date: Mon, 27 Feb 2006 17:33:59 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0602271731410.14242@schroedinger.engr.sgi.com> (raw)

When replacing a swap pte with a real pte in unuse_pte, we simply generate
a pte that has no dirty bit set regardless of what state the page is in.

If a process wants to write to a dirty page after replacement then a
page fault has to first  set the dirty bit in the pte.

This patch generates a pte with the dirty bit already set and so avoids
that fault.

Page migration moves a page from regular ptes to swap ptes and back
for anonymous page and so may generate lots of ptes that are not marked
dirty. This patch will increase the efficiency of page migration.

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

Index: linux-2.6.16-rc5/mm/swapfile.c
===================================================================
--- linux-2.6.16-rc5.orig/mm/swapfile.c	2006-02-26 21:09:35.000000000 -0800
+++ linux-2.6.16-rc5/mm/swapfile.c	2006-02-27 17:17:38.000000000 -0800
@@ -425,10 +425,14 @@ void free_swap_and_cache(swp_entry_t ent
 static void unuse_pte(struct vm_area_struct *vma, pte_t *pte,
 		unsigned long addr, swp_entry_t entry, struct page *page)
 {
+	pte_t new_pte = pte_mkold(mk_pte(page, vma->vm_page_prot));
+
 	inc_mm_counter(vma->vm_mm, anon_rss);
 	get_page(page);
+
 	set_pte_at(vma->vm_mm, addr, pte,
-		   pte_mkold(mk_pte(page, vma->vm_page_prot)));
+			PageDirty(page) ? pte_mkdirty(new_pte) : new_pte);
+
 	page_add_anon_rmap(page, vma, addr);
 	swap_free(entry);
 	/*

--
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:[~2006-02-28  1:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-28  1:33 Christoph Lameter [this message]
2006-02-28  1:53 ` Andrew Morton
2006-02-28  1:57   ` Christoph Lameter
2006-02-28  2:21     ` Andrew Morton
2006-02-28  4:20       ` Christoph Lameter
2006-02-28  4:39         ` Andrew Morton
2006-02-28  5:32           ` Christoph Lameter
2006-02-28 14:05             ` Hugh Dickins
2006-02-28 16:06               ` Christoph Lameter

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.0602271731410.14242@schroedinger.engr.sgi.com \
    --to=clameter@engr.sgi.com \
    --cc=akpm@osdl.org \
    --cc=hugh@veritas.com \
    --cc=linux-mm@kvack.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