Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Suren Baghdasaryan
On Tue, Jan 17, 2023 at 12:31 PM Michal Hocko wrote: > > On Tue 17-01-23 10:28:40, Suren Baghdasaryan wrote: > [...] > > > Then yes, that's a starvable lock. Preventing starvation on the mmap > > > sem was the original motivation for making rwsems non-starvable, so > > > changing that behaviour

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Michal Hocko
On Tue 17-01-23 10:28:40, Suren Baghdasaryan wrote: [...] > > Then yes, that's a starvable lock. Preventing starvation on the mmap > > sem was the original motivation for making rwsems non-starvable, so > > changing that behaviour now seems like a bad idea. For efficiency, I'd > > suggest that a

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Suren Baghdasaryan
On Tue, Jan 17, 2023 at 11:00 AM Jann Horn wrote: > > On Tue, Jan 17, 2023 at 7:55 PM Suren Baghdasaryan wrote: > > On Tue, Jan 17, 2023 at 10:47 AM Matthew Wilcox wrote: > > > > > > On Tue, Jan 17, 2023 at 10:36:42AM -0800, Suren Baghdasaryan wrote: > > > > On Tue, Jan 17, 2023 at 10:31 AM

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Jann Horn
On Tue, Jan 17, 2023 at 7:55 PM Suren Baghdasaryan wrote: > On Tue, Jan 17, 2023 at 10:47 AM Matthew Wilcox wrote: > > > > On Tue, Jan 17, 2023 at 10:36:42AM -0800, Suren Baghdasaryan wrote: > > > On Tue, Jan 17, 2023 at 10:31 AM Matthew Wilcox > > > wrote: > > > > > > > > On Tue, Jan 17, 2023

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Suren Baghdasaryan
On Tue, Jan 17, 2023 at 10:47 AM Matthew Wilcox wrote: > > On Tue, Jan 17, 2023 at 10:36:42AM -0800, Suren Baghdasaryan wrote: > > On Tue, Jan 17, 2023 at 10:31 AM Matthew Wilcox wrote: > > > > > > On Tue, Jan 17, 2023 at 10:26:32AM -0800, Suren Baghdasaryan wrote: > > > > On Tue, Jan 17, 2023

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Suren Baghdasaryan
On Tue, Jan 17, 2023 at 10:36 AM Jann Horn wrote: > > On Tue, Jan 17, 2023 at 7:31 PM Matthew Wilcox wrote: > > > > On Tue, Jan 17, 2023 at 10:26:32AM -0800, Suren Baghdasaryan wrote: > > > On Tue, Jan 17, 2023 at 10:12 AM Jann Horn wrote: > > > > > > > > On Mon, Jan 9, 2023 at 9:55 PM Suren

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Matthew Wilcox
On Tue, Jan 17, 2023 at 10:36:42AM -0800, Suren Baghdasaryan wrote: > On Tue, Jan 17, 2023 at 10:31 AM Matthew Wilcox wrote: > > > > On Tue, Jan 17, 2023 at 10:26:32AM -0800, Suren Baghdasaryan wrote: > > > On Tue, Jan 17, 2023 at 10:12 AM Jann Horn wrote: > > > > > > > > On Mon, Jan 9, 2023 at

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Suren Baghdasaryan
On Tue, Jan 17, 2023 at 10:31 AM Matthew Wilcox wrote: > > On Tue, Jan 17, 2023 at 10:26:32AM -0800, Suren Baghdasaryan wrote: > > On Tue, Jan 17, 2023 at 10:12 AM Jann Horn wrote: > > > > > > On Mon, Jan 9, 2023 at 9:55 PM Suren Baghdasaryan > > > wrote: > > > > rw_semaphore is a sizable

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Jann Horn
On Tue, Jan 17, 2023 at 7:31 PM Matthew Wilcox wrote: > > On Tue, Jan 17, 2023 at 10:26:32AM -0800, Suren Baghdasaryan wrote: > > On Tue, Jan 17, 2023 at 10:12 AM Jann Horn wrote: > > > > > > On Mon, Jan 9, 2023 at 9:55 PM Suren Baghdasaryan > > > wrote: > > > > rw_semaphore is a sizable

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Matthew Wilcox
On Tue, Jan 17, 2023 at 10:26:32AM -0800, Suren Baghdasaryan wrote: > On Tue, Jan 17, 2023 at 10:12 AM Jann Horn wrote: > > > > On Mon, Jan 9, 2023 at 9:55 PM Suren Baghdasaryan wrote: > > > rw_semaphore is a sizable structure of 40 bytes and consumes > > > considerable space for each

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Suren Baghdasaryan
On Tue, Jan 17, 2023 at 10:23 AM Matthew Wilcox wrote: > > On Mon, Jan 16, 2023 at 09:58:35PM -0800, Suren Baghdasaryan wrote: > > On Mon, Jan 16, 2023 at 9:46 PM Matthew Wilcox wrote: > > > > > > On Mon, Jan 16, 2023 at 08:34:36PM -0800, Suren Baghdasaryan wrote: > > > > On Mon, Jan 16, 2023 at

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Suren Baghdasaryan
On Tue, Jan 17, 2023 at 10:12 AM Jann Horn wrote: > > On Mon, Jan 9, 2023 at 9:55 PM Suren Baghdasaryan wrote: > > rw_semaphore is a sizable structure of 40 bytes and consumes > > considerable space for each vm_area_struct. However vma_lock has > > two important specifics which can be used to

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Matthew Wilcox
On Mon, Jan 16, 2023 at 09:58:35PM -0800, Suren Baghdasaryan wrote: > On Mon, Jan 16, 2023 at 9:46 PM Matthew Wilcox wrote: > > > > On Mon, Jan 16, 2023 at 08:34:36PM -0800, Suren Baghdasaryan wrote: > > > On Mon, Jan 16, 2023 at 8:14 PM Matthew Wilcox > > > wrote: > > > > > > > > On Mon, Jan

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-17 Thread Jann Horn
On Mon, Jan 9, 2023 at 9:55 PM Suren Baghdasaryan wrote: > rw_semaphore is a sizable structure of 40 bytes and consumes > considerable space for each vm_area_struct. However vma_lock has > two important specifics which can be used to replace rw_semaphore > with a simpler structure: [...] >

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-16 Thread Suren Baghdasaryan
On Mon, Jan 16, 2023 at 9:46 PM Matthew Wilcox wrote: > > On Mon, Jan 16, 2023 at 08:34:36PM -0800, Suren Baghdasaryan wrote: > > On Mon, Jan 16, 2023 at 8:14 PM Matthew Wilcox wrote: > > > > > > On Mon, Jan 16, 2023 at 11:14:38AM +, Hyeonggon Yoo wrote: > > > > > @@ -643,20 +647,28 @@

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-16 Thread Matthew Wilcox
On Mon, Jan 16, 2023 at 08:34:36PM -0800, Suren Baghdasaryan wrote: > On Mon, Jan 16, 2023 at 8:14 PM Matthew Wilcox wrote: > > > > On Mon, Jan 16, 2023 at 11:14:38AM +, Hyeonggon Yoo wrote: > > > > @@ -643,20 +647,28 @@ static inline void vma_write_lock(struct > > > > vm_area_struct *vma) >

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-16 Thread Suren Baghdasaryan
On Mon, Jan 16, 2023 at 8:14 PM Matthew Wilcox wrote: > > On Mon, Jan 16, 2023 at 11:14:38AM +, Hyeonggon Yoo wrote: > > > @@ -643,20 +647,28 @@ static inline void vma_write_lock(struct > > > vm_area_struct *vma) > > > static inline bool vma_read_trylock(struct vm_area_struct *vma) > > > {

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-16 Thread Matthew Wilcox
On Mon, Jan 16, 2023 at 11:14:38AM +, Hyeonggon Yoo wrote: > > @@ -643,20 +647,28 @@ static inline void vma_write_lock(struct > > vm_area_struct *vma) > > static inline bool vma_read_trylock(struct vm_area_struct *vma) > > { > > /* Check before locking. A race might cause false locked

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-16 Thread Suren Baghdasaryan
On Mon, Jan 16, 2023 at 3:15 AM Hyeonggon Yoo <42.hye...@gmail.com> wrote: > > On Mon, Jan 09, 2023 at 12:53:36PM -0800, Suren Baghdasaryan wrote: > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index d40bf8a5e19e..294dd44b2198 100644 > > --- a/include/linux/mm.h > > +++

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-16 Thread Hyeonggon Yoo
On Mon, Jan 09, 2023 at 12:53:36PM -0800, Suren Baghdasaryan wrote: > diff --git a/include/linux/mm.h b/include/linux/mm.h > index d40bf8a5e19e..294dd44b2198 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -627,12 +627,16 @@ static inline void vma_write_lock(struct vm_area_struct

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-10 Thread Suren Baghdasaryan
On Tue, Jan 10, 2023 at 12:04 AM Vlastimil Babka wrote: > > On 1/9/23 21:53, Suren Baghdasaryan wrote: > > rw_semaphore is a sizable structure of 40 bytes and consumes > > considerable space for each vm_area_struct. However vma_lock has > > two important specifics which can be used to replace

Re: [PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-10 Thread Vlastimil Babka
On 1/9/23 21:53, Suren Baghdasaryan wrote: > rw_semaphore is a sizable structure of 40 bytes and consumes > considerable space for each vm_area_struct. However vma_lock has > two important specifics which can be used to replace rw_semaphore > with a simpler structure: > 1. Readers never wait. They

[PATCH 41/41] mm: replace rw_semaphore with atomic_t in vma_lock

2023-01-09 Thread Suren Baghdasaryan
rw_semaphore is a sizable structure of 40 bytes and consumes considerable space for each vm_area_struct. However vma_lock has two important specifics which can be used to replace rw_semaphore with a simpler structure: 1. Readers never wait. They try to take the vma_lock and fall back to mmap_lock