On 08/22/2018 02:05 PM, Kirill A. Shutemov wrote:
On Tue, Aug 21, 2018 at 06:10:42PM -0700, Mike Kravetz wrote:
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 3103099f64fd..f085019a4724 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4555,6 +4555,9 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) /* * check on proper vm_flags and page table alignment
*
* Note that this is the same check used in huge_pmd_sharing_possible.
* If you change one, consider changing both.
Should we have helper to isolate the check in one place?
Yes, I will create one. Most likely just a #define.
*/
if (vma->vm_flags & VM_MAYSHARE && vma->vm_start <= base && end <= vma->vm_end) @@ -4562,6 +4565,43 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) return false; } +/*
- Determine if start,end range within vma could be mapped by shared pmd.
- If yes, adjust start and end to cover range associated with possible
- shared pmd mappings.
- */
+bool huge_pmd_sharing_possible(struct vm_area_struct *vma,
unsigned long *start, unsigned long *end)
+{
- unsigned long check_addr = *start;
- bool ret = false;
- if (!(vma->vm_flags & VM_MAYSHARE))
return ret;
Do we ever use return value? I don't see it.
And in this case function name is not really work...
You are correct. None of the code uses the return value. I initially thought some caller would use it. But every caller wants/needs to adjust the range if sharing is possible. This is a really long name but how about:
void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, unsigned long *start, unsigned long *end)
I'm open to other names and will update patch with suggestions.