mm: mempolicy: Check return code of check_range
Subsystems (3)
PATCH 13/14 mm: mempolicy: Check return code of check_range
From: Vasiliy Kulikov <[email protected]>
Function check_range may return ERR_PTR(...). Check for it.
---
Compile tested.
mm/mempolicy.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
mm/mempolicy.c +4 -1
@@ -924,12 +924,15 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest,nodemask_t nmask;LIST_HEAD (pagelist);int err =0 ; +struct vm_area_struct *vma;nodes_clear (nmask);node_set (source, nmask); -check_range (mm, mm->mmap->vm_start, mm->task_size, &nmask, + vma =check_range (mm, mm->mmap->vm_start, mm->task_size, &nmask, flags |MPOL_MF_DISCONTIG_OK , &pagelist); +if (IS_ERR (vma)) +return PTR_ERR (vma);if (!list_empty (&pagelist)) err =migrate_pages (&pagelist, new_node_page, dest,0 );
Signature · 1 line
1.7.0.4
Quoted 5 lines · Kulikov Vasiliy
From: Vasiliy Kulikov <[email protected]>
Function
check_rangemay returnERR_PTR(...). Check for it.Signed-off-by Vasiliy Kulikov <[email protected]>
Quoted 3 lines
From: Vasiliy Kulikov <[email protected]>
Function
check_rangemay returnERR_PTR(...). Check for it.
When happen this issue?
afaik, check_range return error when following condition.
1) mm->mmap->vm_start argument is incorrect
2) don't have neigher MPOL_MF_STATS, MPOL_MF_MOVE and MPOL_MF_MOVE_ALL
I think both case is not happen in real. Am I overlooking anything?
Quoted 32 lines
Signed-off-by Vasiliy Kulikov <[email protected]>---
Compile tested.mm/mempolicy.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)mm/mempolicy.c +4
-1@@ -924,12 +924,15 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest,nodemask_t nmask;LIST_HEAD (pagelist);int err =0 ; +struct vm_area_struct *vma;nodes_clear (nmask);node_set (source, nmask); -check_range (mm, mm->mmap->vm_start, mm->task_size, &nmask, + vma =check_range (mm, mm->mmap->vm_start, mm->task_size, &nmask, flags |MPOL_MF_DISCONTIG_OK , &pagelist); +if (IS_ERR (vma)) +return PTR_ERR (vma);if (!list_empty (&pagelist)) err =migrate_pages (&pagelist, new_node_page, dest,0 );Signature · 1 line
1.7.0.4
Quoted 4 lines · KOSAKI Motohiro
Quoted 3 lines
From: Vasiliy Kulikov <[email protected]>
Function
check_rangemay returnERR_PTR(...). Check for it.
Quoted 8 lines
When happen this issue?
afaik,
check_rangereturn error when following condition.
1)mm->mmap->vm_startargument is incorrect
2) don't have neigherMPOL_MF_STATS,MPOL_MF_MOVEandMPOL_MF_MOVE_ALLI think both case is not happen in real. Am I overlooking anything?
There's no reason not to check the return value of a function when the implementation of either could change at any time. migrate_to_node() is certainly not in any fastpath where we can't sacrifice a branch for more robust code.
Quoted 12 lines · David Rientjes
Quoted 10 lines · KOSAKI Motohiro
Quoted 3 lines
From: Vasiliy Kulikov <[email protected]>
Function
check_rangemay returnERR_PTR(...). Check for it.When happen this issue?
afaik,
check_rangereturn error when following condition.
1)mm->mmap->vm_startargument is incorrect
2) don't have neigherMPOL_MF_STATS,MPOL_MF_MOVEandMPOL_MF_MOVE_ALL
Quoted 7 lines
Quoted 2 lines
I think both case is not happen in real. Am I overlooking anything?
There's no reason not to check the return value of a function when the implementation of either could change at any time.
migrate_to_node()is certainly not in any fastpath where we can't sacrifice a branch for more robust code.
Agreed, if you know that the caller must check input data and must not check return code, it's better to make this function return void.
Signature · 1 line
Vasiliy
Quoted 12 lines · KOSAKI Motohiro
Quoted 11 lines
Quoted 4 lines
From: Vasiliy Kulikov <[email protected]>
Function
check_rangemay returnERR_PTR(...). Check for it.When happen this issue?
afaik,
check_rangereturn error when following condition.
1)mm->mmap->vm_startargument is incorrect
2) don't have neigherMPOL_MF_STATS,MPOL_MF_MOVEandMPOL_MF_MOVE_ALL
Quoted 7 lines
Quoted 2 lines
I think both case is not happen in real. Am I overlooking anything?
There's no reason not to check the return value of a function when the implementation of either could change at any time.
migrate_to_node()is certainly not in any fastpath where we can't sacrifice a branch for more robust code.
I was not against this change. I was asking patch effectness.
Quoted 1 line · KOSAKI Motohiro
I think both case is not happen in real. Am I overlooking anything?
Its good to check the return code regardless. There is a lot of tinkering going on with that code.
KOSAKI Motohiro
Reviewed-byQuoted 6 lines · KOSAKI Motohiro
Quoted 2 lines
I think both case is not happen in real. Am I overlooking anything?
Its good to check the return code regardless. There is a lot of tinkering going on with that code.
OK. so, I'm convinced this is not -stable material.