Re: [PATCH v11 1/7] mm: adjust address_space_operations.migratepage() return code

2012-11-07 Thread Rafael Aquini
On Wed, Nov 07, 2012 at 11:56:10AM -0800, Andrew Morton wrote:
> On Wed,  7 Nov 2012 01:05:48 -0200
> Rafael Aquini  wrote:
> 
> > This patch introduces MIGRATEPAGE_SUCCESS as the default return code
> > for address_space_operations.migratepage() method and documents the
> > expected return code for the same method in failure cases.
> 
> I hit a large number of rejects applying this against linux-next.  Due
> to the increasingly irritating sched/numa code in there.
> 
> I attempted to fix it up and also converted some (but not all) of the
> implicit tests of `rc' against zero.
> 
> Please check the result very carefully - more changes will be needed.
> 
> All those
> 
> - if (rc)
> + if (rc != MIGRATEPAGE_SUCCESS)
> 
> changes are a pain.  Perhaps we shouldn't bother.

Thanks for doing that.

This hunk at migrate_pages(), however, is not necessary:

@@ -1001,7 +1001,7 @@ out:
if (!swapwrite)
current->flags &= ~PF_SWAPWRITE;

-   if (rc)
+   if (rc != MIGRATEPAGE_SUCCESS)
return rc;

Here, migrate_pages() is not testing rc for the migration success, but it's 
just trying to
devise the flow if it has to return -ENOMEM, actually.

I guess, a change to make that snippet more clear could be:

diff --git a/mm/migrate.c b/mm/migrate.c
index 77ed2d7..6562aee 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -987,7 +987,7 @@ int migrate_pages(struct list_head *from,
case -EAGAIN:
retry++;
break;
-   case 0:
+   case MIGRATEPAGE_SUCCESS:
break;
default:
/* Permanent failure */
@@ -996,15 +996,12 @@ int migrate_pages(struct list_head *from,
}
}
}
-   rc = 0;
+   rc = nr_failed + retry;
 out:
if (!swapwrite)
current->flags &= ~PF_SWAPWRITE;
 
-   if (rc)
-   return rc;
-
-   return nr_failed + retry;
+   return rc;
 }


I can rebase this patch and resubmit if you prefer
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH v11 1/7] mm: adjust address_space_operations.migratepage() return code

2012-11-07 Thread Andrew Morton
On Wed,  7 Nov 2012 01:05:48 -0200
Rafael Aquini  wrote:

> This patch introduces MIGRATEPAGE_SUCCESS as the default return code
> for address_space_operations.migratepage() method and documents the
> expected return code for the same method in failure cases.

I hit a large number of rejects applying this against linux-next.  Due
to the increasingly irritating sched/numa code in there.

I attempted to fix it up and also converted some (but not all) of the
implicit tests of `rc' against zero.

Please check the result very carefully - more changes will be needed.

All those

-   if (rc)
+   if (rc != MIGRATEPAGE_SUCCESS)

changes are a pain.  Perhaps we shouldn't bother.
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v11 1/7] mm: adjust address_space_operations.migratepage() return code

2012-11-06 Thread Rafael Aquini
This patch introduces MIGRATEPAGE_SUCCESS as the default return code
for address_space_operations.migratepage() method and documents the
expected return code for the same method in failure cases.

Signed-off-by: Rafael Aquini 
---
 fs/hugetlbfs/inode.c|  4 ++--
 include/linux/migrate.h |  7 +++
 mm/migrate.c| 22 +++---
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index c5bc355..bdeda2c 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -608,11 +608,11 @@ static int hugetlbfs_migrate_page(struct address_space 
*mapping,
int rc;
 
rc = migrate_huge_page_move_mapping(mapping, newpage, page);
-   if (rc)
+   if (rc != MIGRATEPAGE_SUCCESS)
return rc;
migrate_page_copy(newpage, page);
 
-   return 0;
+   return MIGRATEPAGE_SUCCESS;
 }
 
 static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index ce7e667..a4e886d 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -7,6 +7,13 @@
 
 typedef struct page *new_page_t(struct page *, unsigned long private, int **);
 
+/*
+ * Return values from addresss_space_operations.migratepage():
+ * - negative errno on page migration failure;
+ * - zero on page migration success;
+ */
+#define MIGRATEPAGE_SUCCESS0
+
 #ifdef CONFIG_MIGRATION
 
 extern void putback_lru_pages(struct list_head *l);
diff --git a/mm/migrate.c b/mm/migrate.c
index 77ed2d7..98c7a89 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -286,7 +286,7 @@ static int migrate_page_move_mapping(struct address_space 
*mapping,
/* Anonymous page without mapping */
if (page_count(page) != 1)
return -EAGAIN;
-   return 0;
+   return MIGRATEPAGE_SUCCESS;
}
 
spin_lock_irq(&mapping->tree_lock);
@@ -356,7 +356,7 @@ static int migrate_page_move_mapping(struct address_space 
*mapping,
}
spin_unlock_irq(&mapping->tree_lock);
 
-   return 0;
+   return MIGRATEPAGE_SUCCESS;
 }
 
 /*
@@ -372,7 +372,7 @@ int migrate_huge_page_move_mapping(struct address_space 
*mapping,
if (!mapping) {
if (page_count(page) != 1)
return -EAGAIN;
-   return 0;
+   return MIGRATEPAGE_SUCCESS;
}
 
spin_lock_irq(&mapping->tree_lock);
@@ -399,7 +399,7 @@ int migrate_huge_page_move_mapping(struct address_space 
*mapping,
page_unfreeze_refs(page, expected_count - 1);
 
spin_unlock_irq(&mapping->tree_lock);
-   return 0;
+   return MIGRATEPAGE_SUCCESS;
 }
 
 /*
@@ -486,11 +486,11 @@ int migrate_page(struct address_space *mapping,
 
rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode);
 
-   if (rc)
+   if (rc != MIGRATEPAGE_SUCCESS)
return rc;
 
migrate_page_copy(newpage, page);
-   return 0;
+   return MIGRATEPAGE_SUCCESS;
 }
 EXPORT_SYMBOL(migrate_page);
 
@@ -513,7 +513,7 @@ int buffer_migrate_page(struct address_space *mapping,
 
rc = migrate_page_move_mapping(mapping, newpage, page, head, mode);
 
-   if (rc)
+   if (rc != MIGRATEPAGE_SUCCESS)
return rc;
 
/*
@@ -549,7 +549,7 @@ int buffer_migrate_page(struct address_space *mapping,
 
} while (bh != head);
 
-   return 0;
+   return MIGRATEPAGE_SUCCESS;
 }
 EXPORT_SYMBOL(buffer_migrate_page);
 #endif
@@ -814,7 +814,7 @@ skip_unmap:
put_anon_vma(anon_vma);
 
 uncharge:
-   mem_cgroup_end_migration(mem, page, newpage, rc == 0);
+   mem_cgroup_end_migration(mem, page, newpage, rc == MIGRATEPAGE_SUCCESS);
 unlock:
unlock_page(page);
 out:
@@ -987,7 +987,7 @@ int migrate_pages(struct list_head *from,
case -EAGAIN:
retry++;
break;
-   case 0:
+   case MIGRATEPAGE_SUCCESS:
break;
default:
/* Permanent failure */
@@ -1024,7 +1024,7 @@ int migrate_huge_page(struct page *hpage, new_page_t 
get_new_page,
/* try again */
cond_resched();
break;
-   case 0:
+   case MIGRATEPAGE_SUCCESS:
goto out;
default:
rc = -EIO;
-- 
1.7.11.7

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization