mm: remove extra check for VMA_LOCK_OFFSET when read-locking a vma
Subsystems (3)
Suren Baghdasaryan
reviewerPATCH 1/1 mm: remove extra check for VMA_LOCK_OFFSET when read-locking a vma
Since we limit vm_refcnt at VMA_REF_LIMIT and it's smaller than VMA_LOCK_OFFSET, there is no need to check again if VMA_LOCK_OFFSET bit is set. Remove the extra check and add a clarifying comment.
---
Applies over mm-unstable
include/linux/mm.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
include/linux/mm.h +6 -3
@@ -747,7 +747,11 @@ static inline bool vma_start_read(struct mm_struct *mm, struct vm_area_struct *vrwsem_acquire_read (&vma->vmlock_dep_map,0 ,0 , _RET_IP_); -/* Limit at VMA_REF_LIMIT to leave one count for a writer */ +/* +* Limit at VMA_REF_LIMIT to leave one count for a writer. +* If VMA_LOCK_OFFSET is set, __refcount_inc_not_zero_limited() will fail +* because VMA_REF_LIMIT is less than VMA_LOCK_OFFSET. +*/ if (unlikely (!__refcount_inc_not_zero_limited (&vma->vm_refcnt, &oldcnt,VMA_REF_LIMIT ))) {rwsem_release (&vma->vmlock_dep_map, _RET_IP_);
@@ -766,8 +770,7 @@ static inline bool vma_start_read(struct mm_struct *mm, struct vm_area_struct *v* after it has been unlocked. * This pairs with RELEASE semantics in vma_end_write_all(). */ -if (unlikely (oldcnt &VMA_LOCK_OFFSET || - vma->vm_lock_seq ==raw_read_seqcount (&mm->mm_lock_seq))) { +if (unlikely (vma->vm_lock_seq ==raw_read_seqcount (&mm->mm_lock_seq))) {vma_refcount_put (vma);return false; }
base-commit: f349e79bfbf3abfade8011797ff6d0d47b67dab7
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
Quoted 7 lines · Suren Baghdasaryan
Since we limit
vm_refcntatVMA_REF_LIMITand it's smaller thanVMA_LOCK_OFFSET, there is no need to check again ifVMA_LOCK_OFFSETbit is set. Remove the extra check and add a clarifying comment.Fixes e8f32ff00a66 ("mm: replace vm_lock and detached flag with a reference count")Suggested-by Wei Yang <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>
Quoted 37 lines
---
Applies over mm-unstable
include/linux/mm.h| 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)include/linux/mm.h +6
-3@@ -747,7 +747,11 @@ static inline bool vma_start_read(struct mm_struct *mm, struct vm_area_struct *vrwsem_acquire_read (&vma->vmlock_dep_map,0 ,0 , _RET_IP_); -/* Limit at VMA_REF_LIMIT to leave one count for a writer */ +/* +* Limit at VMA_REF_LIMIT to leave one count for a writer. +* If VMA_LOCK_OFFSET is set, __refcount_inc_not_zero_limited() will fail +* because VMA_REF_LIMIT is less than VMA_LOCK_OFFSET. +*/ if (unlikely (!__refcount_inc_not_zero_limited (&vma->vm_refcnt, &oldcnt,VMA_REF_LIMIT ))) {rwsem_release (&vma->vmlock_dep_map, _RET_IP_);@@ -766,8 +770,7 @@ static inline bool vma_start_read(struct mm_struct *mm, struct vm_area_struct *v* after it has been unlocked. * This pairs with RELEASE semantics in vma_end_write_all(). */ -if (unlikely (oldcnt &VMA_LOCK_OFFSET || - vma->vm_lock_seq ==raw_read_seqcount (&mm->mm_lock_seq))) { +if (unlikely (vma->vm_lock_seq ==raw_read_seqcount (&mm->mm_lock_seq))) {vma_refcount_put (vma);return false; }base-commit:
f349e79bfbf3abfade8011797ff6d0d47b67dab7Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
Signature · 2 lines
Wei Yang Help you, Help me
Suren Baghdasaryan
reviewerQuoted 11 lines · Wei Yang
Quoted 7 lines · Suren Baghdasaryan
Since we limit
vm_refcntatVMA_REF_LIMITand it's smaller thanVMA_LOCK_OFFSET, there is no need to check again ifVMA_LOCK_OFFSETbit is set. Remove the extra check and add a clarifying comment.Fixes e8f32ff00a66 ("mm: replace vm_lock and detached flag with a reference count")Suggested-by Wei Yang <[email protected]>Signed-off-by Suren Baghdasaryan <[email protected]>Reviewed-by Wei Yang <[email protected]>
Since I have to respin v8, I'll fold this fix into the original patch.
Quoted 42 lines
Quoted 35 lines
---
Applies over mm-unstable
include/linux/mm.h| 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)include/linux/mm.h +6
-3@@ -747,7 +747,11 @@ static inline bool vma_start_read(struct mm_struct *mm, struct vm_area_struct *vrwsem_acquire_read (&vma->vmlock_dep_map,0 ,0 , _RET_IP_); -/* Limit at VMA_REF_LIMIT to leave one count for a writer */ +/* +* Limit at VMA_REF_LIMIT to leave one count for a writer. +* If VMA_LOCK_OFFSET is set, __refcount_inc_not_zero_limited() will fail +* because VMA_REF_LIMIT is less than VMA_LOCK_OFFSET. +*/ if (unlikely (!__refcount_inc_not_zero_limited (&vma->vm_refcnt, &oldcnt,VMA_REF_LIMIT ))) {rwsem_release (&vma->vmlock_dep_map, _RET_IP_);@@ -766,8 +770,7 @@ static inline bool vma_start_read(struct mm_struct *mm, struct vm_area_struct *v* after it has been unlocked. * This pairs with RELEASE semantics in vma_end_write_all(). */ -if (unlikely (oldcnt &VMA_LOCK_OFFSET || - vma->vm_lock_seq ==raw_read_seqcount (&mm->mm_lock_seq))) { +if (unlikely (vma->vm_lock_seq ==raw_read_seqcount (&mm->mm_lock_seq))) {vma_refcount_put (vma);return false; }Quoted 3 lines
base-commit:
f349e79bfbf3abfade8011797ff6d0d47b67dab7--
2.47.1.613.gc27f4b7a9f-goog--
Wei Yang
Help you, Help me