path: root/mm
diff options
authorHugh Dickins <>2010-03-05 13:42:25 -0800
committerLinus Torvalds <>2010-03-06 11:26:27 -0800
commit08259d58e4fa12ceaece82193c5816152f638cca (patch)
tree8c032914139c5aec362a73b8316cf81f020f9f8f /mm
parentc08c6e1f54c85fc299cf9f88cf330d6dd28a9a1d (diff)
mm: add comment on swap_duplicate's error code
swap_duplicate()'s loop appears to miss out on returning the error code from __swap_duplicate(), except when that's -ENOMEM. In fact this is intentional: prior to -ENOMEM for swap_count_continuation, swap_duplicate() was void (and the case only occurs when copy_one_pte() hits a corrupt pte). But that's surprising behaviour, which certainly deserves a comment. Signed-off-by: Hugh Dickins <> Reported-by: Huang Shijie <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm')
1 files changed, 5 insertions, 1 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 4a986127f15..84374d8cf81 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2161,7 +2161,11 @@ void swap_shmem_alloc(swp_entry_t entry)
- * increase reference count of swap entry by 1.
+ * Increase reference count of swap entry by 1.
+ * Returns 0 for success, or -ENOMEM if a swap_count_continuation is required
+ * but could not be atomically allocated. Returns 0, just as if it succeeded,
+ * if __swap_duplicate() fails for another reason (-EINVAL or -ENOENT), which
+ * might occur if a page table entry has got corrupted.
int swap_duplicate(swp_entry_t entry)