[lkml]   [2020]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 5/8] mmap locking API: convert nested write lock sites
On Thu, Mar 26, 2020 at 12:02:33AM -0700, Michel Lespinasse wrote:
> @@ -47,9 +48,9 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
> * when the new ->mm is used for the first time.
> */
> __switch_mm(&new->;
> - down_write_nested(&new->mmap_sem, 1);
> + mmap_write_lock_nested(new, 1);
> uml_setup_stubs(new);
> - mmap_write_unlock(new);
> + mmap_write_unlock_nested(new);

This is a bit of an oddity. We don't usually have an unlock_nested()
variant (a quick grep finds only something complicated in reiserfs).
That's because it's legitimate to release locks in a different order from
the one they were acquired in (eg lock A, lock B, unlock A, unlock B), and
it's not clear whether "nested" would follow the lock (ie unlock_nested B)
or whether it would follow the code (ie unlock_nested A).

Does your future API require knowing the nested nature at the unlock
point? And if so, does it require it for A or B in the above scenario?
And how does it mix with lock A or B being of a different type (eg a
plain mutex or a spinlock)?

 \ /
  Last update: 2020-03-26 13:10    [W:0.065 / U:1.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site