Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1231509 > unrolled thread
| Started by | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| First post | 2015-09-23 17:40 +0200 |
| Last post | 2015-09-23 17:50 +0200 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Multiple potential races on vma->vm_flags Oleg Nesterov <oleg@redhat.com> - 2015-09-23 17:40 +0200
Re: Multiple potential races on vma->vm_flags Oleg Nesterov <oleg@redhat.com> - 2015-09-23 17:50 +0200
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Date | 2015-09-23 17:40 +0200 |
| Subject | Re: Multiple potential races on vma->vm_flags |
| Message-ID | <qbUjg-8im-19@gated-at.bofh.it> |
On 09/11, Kirill A. Shutemov wrote: > > This one is tricky. I *assume* the mm cannot be generally accessible after > mm_users drops to zero, but I'm not entirely sure about it. > procfs? ptrace? Well, all I can say is that proc/ptrace look fine afaics... This is off-topic, but how about the patch below? Different threads can expand different vma's at the same time under read_lock(mmap_sem), so vma_lock_anon_vma() can't help to serialize "locked_vm += grow". Oleg. --- x/mm/mmap.c +++ x/mm/mmap.c @@ -2146,9 +2146,6 @@ static int acct_stack_growth(struct vm_a if (security_vm_enough_memory_mm(mm, grow)) return -ENOMEM; - /* Ok, everything looks good - let it rip */ - if (vma->vm_flags & VM_LOCKED) - mm->locked_vm += grow; vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow); return 0; } @@ -2210,6 +2207,8 @@ int expand_upwards(struct vm_area_struct * against concurrent vma expansions. */ spin_lock(&vma->vm_mm->page_table_lock); + if (vma->vm_flags & VM_LOCKED) + mm->locked_vm += grow; anon_vma_interval_tree_pre_update_vma(vma); vma->vm_end = address; anon_vma_interval_tree_post_update_vma(vma); @@ -2281,6 +2280,8 @@ int expand_downwards(struct vm_area_stru * against concurrent vma expansions. */ spin_lock(&vma->vm_mm->page_table_lock); + if (vma->vm_flags & VM_LOCKED) + mm->locked_vm += grow; anon_vma_interval_tree_pre_update_vma(vma); vma->vm_start = address; vma->vm_pgoff -= grow; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Date | 2015-09-23 17:50 +0200 |
| Message-ID | <qbUsW-8tN-19@gated-at.bofh.it> |
| In reply to | #1231509 |
On 09/23, Oleg Nesterov wrote: > > On 09/11, Kirill A. Shutemov wrote: > > > > This one is tricky. I *assume* the mm cannot be generally accessible after > > mm_users drops to zero, but I'm not entirely sure about it. > > procfs? ptrace? > > Well, all I can say is that proc/ptrace look fine afaics... > > This is off-topic, but how about the patch below? Different threads can > expand different vma's at the same time under read_lock(mmap_sem), so > vma_lock_anon_vma() can't help to serialize "locked_vm += grow". perhaps vm_stat_account() should be moved too, but total_vm/etc is less important. Or I missed something? Oleg. > --- x/mm/mmap.c > +++ x/mm/mmap.c > @@ -2146,9 +2146,6 @@ static int acct_stack_growth(struct vm_a > if (security_vm_enough_memory_mm(mm, grow)) > return -ENOMEM; > > - /* Ok, everything looks good - let it rip */ > - if (vma->vm_flags & VM_LOCKED) > - mm->locked_vm += grow; > vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow); > return 0; > } > @@ -2210,6 +2207,8 @@ int expand_upwards(struct vm_area_struct > * against concurrent vma expansions. > */ > spin_lock(&vma->vm_mm->page_table_lock); > + if (vma->vm_flags & VM_LOCKED) > + mm->locked_vm += grow; > anon_vma_interval_tree_pre_update_vma(vma); > vma->vm_end = address; > anon_vma_interval_tree_post_update_vma(vma); > @@ -2281,6 +2280,8 @@ int expand_downwards(struct vm_area_stru > * against concurrent vma expansions. > */ > spin_lock(&vma->vm_mm->page_table_lock); > + if (vma->vm_flags & VM_LOCKED) > + mm->locked_vm += grow; > anon_vma_interval_tree_pre_update_vma(vma); > vma->vm_start = address; > vma->vm_pgoff -= grow; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web