linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Huang Shijie <shijie8@gmail.com>
To: akpm@linux-foundation.org
Cc: hugh.dickins@tiscali.co.uk, linux-mm@kvack.org,
	Huang Shijie <shijie8@gmail.com>
Subject: [PATCH] swapfile : export more return values for swap_duplicate()
Date: Thu,  4 Mar 2010 15:14:30 +0800	[thread overview]
Message-ID: <1267686870-2303-1-git-send-email-shijie8@gmail.com> (raw)
In-Reply-To: <1267501102-24190-1-git-send-email-shijie8@gmail.com>

Exporting more return values for swap_duplicate() is useful for
try_to_unmap(). It could check the swap entry more carefully which
is helpful for the system stability.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
---
 mm/memory.c   |    3 ++-
 mm/swapfile.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 72fb5f3..72d1d1c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -586,7 +586,8 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 		if (!pte_file(pte)) {
 			swp_entry_t entry = pte_to_swp_entry(pte);
 
-			if (swap_duplicate(entry) < 0)
+			/* add_swap_count_continuation() failed ? */
+			if (swap_duplicate(entry) == -ENOMEM)
 				return entry.val;
 
 			/* make sure dst_mm is on swapoff's mmlist. */
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 6c0585b..a2720d0 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2161,7 +2161,7 @@ int swap_duplicate(swp_entry_t entry)
 {
 	int err = 0;
 
-	while (!err && __swap_duplicate(entry, 1) == -ENOMEM)
+	while (!err && (err =  __swap_duplicate(entry, 1)) == -ENOMEM)
 		err = add_swap_count_continuation(entry, GFP_ATOMIC);
 	return err;
 }
-- 
1.6.6

--
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>

      parent reply	other threads:[~2010-03-04  7:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02  3:38 [PATCH] swapfile : fix the wrong return value Huang Shijie
2010-03-04  0:37 ` Hugh Dickins
2010-03-04  7:00   ` Huang Shijie
2010-03-04  7:28     ` Hugh Dickins
2010-03-04  7:48       ` Huang Shijie
2010-03-04  7:14 ` Huang Shijie [this message]

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=1267686870-2303-1-git-send-email-shijie8@gmail.com \
    --to=shijie8@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hugh.dickins@tiscali.co.uk \
    --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;
as well as URLs for NNTP newsgroup(s).