Merge branch 'locking-rwsem-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 16 May 2016 20:41:02 +0000 (13:41 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 16 May 2016 20:41:02 +0000 (13:41 -0700)
Pull support for killable rwsems from Ingo Molnar:
 "This, by Michal Hocko, implements down_write_killable().

  The main usecase will be to update mm_sem usage sites to use this new
  API, to allow the mm-reaper introduced in commit aac453635549 ("mm,
  oom: introduce oom reaper") to tear down oom victim address spaces
  asynchronously with minimum latencies and without deadlock worries"

[ The vfs will want it too as the inode lock is changed from a mutex to
  a rwsem due to the parallel lookup and readdir updates ]

* 'locking-rwsem-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  locking/rwsem: Fix comment on register clobbering
  locking/rwsem: Fix down_write_killable()
  locking/rwsem, x86: Add frame annotation for call_rwsem_down_write_failed_killable()
  locking/rwsem: Provide down_write_killable()
  locking/rwsem, x86: Provide __down_write_killable()
  locking/rwsem, s390: Provide __down_write_killable()
  locking/rwsem, ia64: Provide __down_write_killable()
  locking/rwsem, alpha: Provide __down_write_killable()
  locking/rwsem: Introduce basis for down_write_killable()
  locking/rwsem, sparc: Drop superfluous arch specific implementation
  locking/rwsem, sh: Drop superfluous arch specific implementation
  locking/rwsem, xtensa: Drop superfluous arch specific implementation
  locking/rwsem: Drop explicit memory barriers
  locking/rwsem: Get rid of __down_write_nested()

1  2 
include/linux/lockdep.h

diff --combined include/linux/lockdep.h
index d10ef06971b57d8783934333612cb196421716ab,accfe56d8c51bc70da87d7e311bb25007192d8c4..f75222ea7f16598920cef736e2c9fcc21d5fd1b7
@@@ -196,11 -196,9 +196,11 @@@ struct lock_list 
   * We record lock dependency chains, so that we can cache them:
   */
  struct lock_chain {
 -      u8                              irq_context;
 -      u8                              depth;
 -      u16                             base;
 +      /* see BUILD_BUG_ON()s in lookup_chain_cache() */
 +      unsigned int                    irq_context :  2,
 +                                      depth       :  6,
 +                                      base        : 24;
 +      /* 4 byte hole */
        struct hlist_node               entry;
        u64                             chain_key;
  };
@@@ -446,6 -444,18 +446,18 @@@ do {                                                             
        lock_acquired(&(_lock)->dep_map, _RET_IP_);                     \
  } while (0)
  
+ #define LOCK_CONTENDED_RETURN(_lock, try, lock)                       \
+ ({                                                            \
+       int ____err = 0;                                        \
+       if (!try(_lock)) {                                      \
+               lock_contended(&(_lock)->dep_map, _RET_IP_);    \
+               ____err = lock(_lock);                          \
+       }                                                       \
+       if (!____err)                                           \
+               lock_acquired(&(_lock)->dep_map, _RET_IP_);     \
+       ____err;                                                \
+ })
  #else /* CONFIG_LOCK_STAT */
  
  #define lock_contended(lockdep_map, ip) do {} while (0)
  #define LOCK_CONTENDED(_lock, try, lock) \
        lock(_lock)
  
+ #define LOCK_CONTENDED_RETURN(_lock, try, lock) \
+       lock(_lock)
  #endif /* CONFIG_LOCK_STAT */
  
  #ifdef CONFIG_LOCKDEP