diff mbox series

[v2,1/2] mmap locking API: add mmap_lock_is_contended()

Message ID 1597284810-17454-2-git-send-email-chinwen.chang@mediatek.com (mailing list archive)
State New, archived
Headers show
Series Try to release mmap_lock temporarily in smaps_rollup | expand

Commit Message

Chinwen Chang Aug. 13, 2020, 2:13 a.m. UTC
Add new API to query if someone wants to acquire mmap_lock
for write attempts.

Using this instead of rwsem_is_contended makes it more tolerant
of future changes to the lock type.

Signed-off-by: Chinwen Chang <chinwen.chang@mediatek.com>
---
 include/linux/mmap_lock.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Steven Price Aug. 13, 2020, 8:21 a.m. UTC | #1
On 13/08/2020 03:13, Chinwen Chang wrote:
> Add new API to query if someone wants to acquire mmap_lock
> for write attempts.
> 
> Using this instead of rwsem_is_contended makes it more tolerant
> of future changes to the lock type.
> 
> Signed-off-by: Chinwen Chang <chinwen.chang@mediatek.com>

Reviewed-by: Steven Price <steven.price@arm.com>

> ---
>   include/linux/mmap_lock.h | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h
> index 0707671..18e7eae 100644
> --- a/include/linux/mmap_lock.h
> +++ b/include/linux/mmap_lock.h
> @@ -87,4 +87,9 @@ static inline void mmap_assert_write_locked(struct mm_struct *mm)
>   	VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm);
>   }
>   
> +static inline int mmap_lock_is_contended(struct mm_struct *mm)
> +{
> +	return rwsem_is_contended(&mm->mmap_lock);
> +}
> +
>   #endif /* _LINUX_MMAP_LOCK_H */
>
Michel Lespinasse Aug. 14, 2020, 8:30 a.m. UTC | #2
On Wed, Aug 12, 2020 at 7:14 PM Chinwen Chang
<chinwen.chang@mediatek.com> wrote:
>
> Add new API to query if someone wants to acquire mmap_lock
> for write attempts.
>
> Using this instead of rwsem_is_contended makes it more tolerant
> of future changes to the lock type.
>
> Signed-off-by: Chinwen Chang <chinwen.chang@mediatek.com>

Acked-by: Michel Lespinasse <walken@google.com>
diff mbox series

Patch

diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h
index 0707671..18e7eae 100644
--- a/include/linux/mmap_lock.h
+++ b/include/linux/mmap_lock.h
@@ -87,4 +87,9 @@  static inline void mmap_assert_write_locked(struct mm_struct *mm)
 	VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm);
 }
 
+static inline int mmap_lock_is_contended(struct mm_struct *mm)
+{
+	return rwsem_is_contended(&mm->mmap_lock);
+}
+
 #endif /* _LINUX_MMAP_LOCK_H */