Commit bf3d12b9 authored by Miaohe Lin's avatar Miaohe Lin Committed by Linus Torvalds

mm/hugeltb: simplify the return code of __vma_reservation_common()

It's guaranteed that the vma is associated with a resv_map, i.e.  either
VM_MAYSHARE or HPAGE_RESV_OWNER, when the code reaches here or we would
have returned via !resv check above.  So it's unneeded to check whether
HPAGE_RESV_OWNER is set here.  Simplify the return code to make it more
clear.

Link: https://lkml.kernel.org/r/20210410072348.20437-3-linmiaohe@huawei.comSigned-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Cc: Feilong Lin <linfeilong@huawei.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f84df0b7
...@@ -2174,27 +2174,26 @@ static long __vma_reservation_common(struct hstate *h, ...@@ -2174,27 +2174,26 @@ static long __vma_reservation_common(struct hstate *h,
if (vma->vm_flags & VM_MAYSHARE) if (vma->vm_flags & VM_MAYSHARE)
return ret; return ret;
else if (is_vma_resv_set(vma, HPAGE_RESV_OWNER) && ret >= 0) { /*
/* * We know private mapping must have HPAGE_RESV_OWNER set.
* In most cases, reserves always exist for private mappings. *
* However, a file associated with mapping could have been * In most cases, reserves always exist for private mappings.
* hole punched or truncated after reserves were consumed. * However, a file associated with mapping could have been
* As subsequent fault on such a range will not use reserves. * hole punched or truncated after reserves were consumed.
* Subtle - The reserve map for private mappings has the * As subsequent fault on such a range will not use reserves.
* opposite meaning than that of shared mappings. If NO * Subtle - The reserve map for private mappings has the
* entry is in the reserve map, it means a reservation exists. * opposite meaning than that of shared mappings. If NO
* If an entry exists in the reserve map, it means the * entry is in the reserve map, it means a reservation exists.
* reservation has already been consumed. As a result, the * If an entry exists in the reserve map, it means the
* return value of this routine is the opposite of the * reservation has already been consumed. As a result, the
* value returned from reserve map manipulation routines above. * return value of this routine is the opposite of the
*/ * value returned from reserve map manipulation routines above.
if (ret) */
return 0; if (ret > 0)
else return 0;
return 1; if (ret == 0)
} return 1;
else return ret;
return ret < 0 ? ret : 0;
} }
static long vma_needs_reservation(struct hstate *h, static long vma_needs_reservation(struct hstate *h,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment