mm/mlock: not handle NULL vma specially
Subsystems (2)
PATCH 1/2 mm/mlock: not handle NULL vma specially
If we can't find a proper vma, the loop would terminate as expected.
It's not necessary to handle it specially.
--- mm/mlock.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
mm/mlock.c +1 -5
@@ -504,11 +504,7 @@ static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,if (mm ==NULL ) mm = current->mm; - vma =find_vma (mm, start); -if (vma ==NULL ) -return 0 ; - -for (; vma ; vma = vma->vm_next) { +for (vma =find_vma (mm, start); vma ; vma = vma->vm_next) {if (start >= vma->vm_end)continue ;if (start + len <= vma->vm_start)
Signature · 1 line
2.33.1
PATCH 2/2 mm/mlock: start is always smaller then vm_end
We would meet this situation in the loop since:
* find_vma() would return a vma meets vm_end > start.
* the following vma->vm_end is growing
So this situation never happens.
--- mm/mlock.c | 2 -- 1 file changed, 2 deletions(-)
mm/mlock.c +0 -2
@@ -505,8 +505,6 @@ static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, mm = current->mm;for (vma =find_vma (mm, start); vma ; vma = vma->vm_next) { -if (start >= vma->vm_end) -continue ;if (start + len <= vma->vm_start)break ;if (vma->vm_flags &VM_LOCKED ) {
Signature · 1 line
2.33.1
Andrew Morton
maintainerQuoted 11 lines · On Wed, 4 May 2022 00:39:57 +0000 Wei Yang <[email protected]> wrote:
If we can't find a proper vma, the loop would terminate as expected.
It's not necessary to handle it specially.
...
mm/mlock.c +0
-0@@ -504,11 +504,7 @@ static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,if (mm ==NULL ) mm = current->mm;
mm/mlock.c static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, · line 510
Quoted 10 lines
mm/mlock.c +1
-5- vma =find_vma (mm, start); -if (vma ==NULL ) -return 0 ; - -for (; vma ; vma = vma->vm_next) { +for (vma =find_vma (mm, start); vma ; vma = vma->vm_next) {if (start >= vma->vm_end)continue ;if (start + len <= vma->vm_start)
The mapletree patches mangle this code a lot.
Please take a look at linux-next or the mm-unstabe branch atgit://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm early to mid next week, see if you see anything which should be addressed.
Quoted 27 lines · Andrew Morton
Quoted 11 lines · On Wed, 4 May 2022 00:39:57 +0000 Wei Yang <[email protected]> wrote:
If we can't find a proper vma, the loop would terminate as expected.
It's not necessary to handle it specially.
...
mm/mlock.c +0
-0@@ -504,11 +504,7 @@ static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,if (mm ==NULL ) mm = current->mm;mm/mlock.c static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, · line 510
Quoted 10 lines
mm/mlock.c +1
-5- vma =find_vma (mm, start); -if (vma ==NULL ) -return 0 ; - -for (; vma ; vma = vma->vm_next) { +for (vma =find_vma (mm, start); vma ; vma = vma->vm_next) {if (start >= vma->vm_end)continue ;if (start + len <= vma->vm_start)The mapletree patches mangle this code a lot.
Quoted 4 lines
Please take a look at linux-next or the mm-unstabe branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mmearly to mid next week, see if you see anything which should be addressed.
I took a look at mm-unstabe branch with last commit
2b58b3f33ba2 mm/shmem: convert shmem_swapin_page() to shmem_swapin_folio()
Function count_mm_mlocked_page_nr() looks not changed.
Do I need to rebase on top of it?
Andrew Morton
maintainerQuoted 12 lines · On Sun, 8 May 2022 05:56:15 +0800 Wei Yang <[email protected]> wrote:
Quoted 12 lines
mm/mlock.c static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm, · line 510
Quoted 9 lines
mm/mlock.c +1
-5- vma =find_vma (mm, start); -if (vma ==NULL ) -return 0 ; - -for (; vma ; vma = vma->vm_next) { +for (vma =find_vma (mm, start); vma ; vma = vma->vm_next) {if (start >= vma->vm_end)continue ;if (start + len <= vma->vm_start)The mapletree patches mangle this code a lot.
Quoted 9 lines
Quoted 4 lines
Please take a look at linux-next or the mm-unstabe branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mmearly to mid next week, see if you see anything which should be addressed.I took a look at mm-unstabe branch with last commit
2b58b3f33ba2mm/shmem: convertshmem_swapin_page()toshmem_swapin_folio()
It isn't early to mid next week yet ;)
Quoted 3 lines
Function
count_mm_mlocked_page_nr()looks not changed.Do I need to rebase on top of it?
static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,
unsigned long start, size_t len)
{
struct vm_area_struct *vma;
unsigned long count = 0;
unsigned long end;
VMA_ITERATOR(vmi, mm, start);
if (mm == NULL)
mm = current->mm;
/* Don't overflow past ULONG_MAX */
if (unlikely(ULONG_MAX - len < start))
end = ULONG_MAX;
else
end = start + len;
for_each_vma_range(vmi, vma, end) {
if (vma->vm_flags & VM_LOCKED) {
if (start > vma->vm_start)
count -= (start - vma->vm_start);
if (end < vma->vm_end) {
count += end - vma->vm_start;
break;
}
count += vma->vm_end - vma->vm_start;
}
}
return count >> PAGE_SHIFT;
}