[v2,1/4] mm/migrate.c: not necessary to check start and i
diff mbox series

Message ID 20200122011647.13636-2-richardw.yang@linux.intel.com
State New
Headers show
Series
  • cleanup on do_pages_move()
Related show

Commit Message

Wei Yang Jan. 22, 2020, 1:16 a.m. UTC
Till here, i must no less than start. And if i equals to start,
store_status() would always return 0.

Remove some unnecessary check to make it easy to read and prepare for
further cleanup.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
---
 mm/migrate.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

David Hildenbrand Jan. 28, 2020, 10:04 a.m. UTC | #1
On 22.01.20 02:16, Wei Yang wrote:
> Till here, i must no less than start. And if i equals to start,
> store_status() would always return 0.

I'd suggest

"
mm/migrate.c: no need to check for i > start in do_pages_move()

At this point, we always have i >= start. If i == start, store_status()
will return 0. So we can drop the check for i > start.
"

Reviewed-by: David Hildenbrand <david@redhat.com>

> 
> Remove some unnecessary check to make it easy to read and prepare for
> further cleanup.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> Acked-by: Michal Hocko <mhocko@suse.com>
> ---
>  mm/migrate.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 430fdccc733e..4c2a21856717 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1661,11 +1661,9 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,
>  		err = do_move_pages_to_node(mm, &pagelist, current_node);
>  		if (err)
>  			goto out;
> -		if (i > start) {
> -			err = store_status(status, start, current_node, i - start);
> -			if (err)
> -				goto out;
> -		}
> +		err = store_status(status, start, current_node, i - start);
> +		if (err)
> +			goto out;
>  		current_node = NUMA_NO_NODE;
>  	}
>  out_flush:
>
Wei Yang Jan. 29, 2020, 12:32 a.m. UTC | #2
On Tue, Jan 28, 2020 at 11:04:23AM +0100, David Hildenbrand wrote:
>On 22.01.20 02:16, Wei Yang wrote:
>> Till here, i must no less than start. And if i equals to start,
>> store_status() would always return 0.
>
>I'd suggest
>
>"
>mm/migrate.c: no need to check for i > start in do_pages_move()
>
>At this point, we always have i >= start. If i == start, store_status()
>will return 0. So we can drop the check for i > start.
>"
>
>Reviewed-by: David Hildenbrand <david@redhat.com>
>

Thanks, I took it.

Patch
diff mbox series

diff --git a/mm/migrate.c b/mm/migrate.c
index 430fdccc733e..4c2a21856717 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1661,11 +1661,9 @@  static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,
 		err = do_move_pages_to_node(mm, &pagelist, current_node);
 		if (err)
 			goto out;
-		if (i > start) {
-			err = store_status(status, start, current_node, i - start);
-			if (err)
-				goto out;
-		}
+		err = store_status(status, start, current_node, i - start);
+		if (err)
+			goto out;
 		current_node = NUMA_NO_NODE;
 	}
 out_flush: