Print this page
patch as-lock-macro-simplification

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/vm/as.h
          +++ new/usr/src/uts/common/vm/as.h
↓ open down ↓ 232 lines elided ↑ open up ↑
 233  233   * be used without regard to lock order in conjunction with filesystem locks.
 234  234   * This allows filesystems to safely induce user-level page faults with
 235  235   * filesystem locks held while concurrently allowing filesystem entry points
 236  236   * acquiring those same locks to be called with the address space lock held as
 237  237   * reader.  RW_READER_STARVEWRITER thus prevents reader/reader+RW_WRITE_WANTED
 238  238   * deadlocks in the style of fop_write()+as_fault()/as_*()+fop_putpage() and
 239  239   * fop_read()+as_fault()/as_*()+fop_getpage().  (See the Big Theory Statement
 240  240   * in rwlock.c for more information on the semantics of and motivation behind
 241  241   * RW_READER_STARVEWRITER.)
 242  242   */
 243      -#define AS_LOCK_ENTER(as, lock, type)           rw_enter((lock), \
      243 +#define AS_LOCK_ENTER(as, type)         rw_enter(&(as)->a_lock, \
 244  244          (type) == RW_READER ? RW_READER_STARVEWRITER : (type))
 245      -#define AS_LOCK_EXIT(as, lock)                  rw_exit((lock))
 246      -#define AS_LOCK_DESTROY(as, lock)               rw_destroy((lock))
 247      -#define AS_LOCK_TRYENTER(as, lock, type)        rw_tryenter((lock), \
      245 +#define AS_LOCK_EXIT(as)                rw_exit(&(as)->a_lock)
      246 +#define AS_LOCK_DESTROY(as)             rw_destroy(&(as)->a_lock)
      247 +#define AS_LOCK_TRYENTER(as, type)      rw_tryenter(&(as)->a_lock, \
 248  248          (type) == RW_READER ? RW_READER_STARVEWRITER : (type))
 249  249  
 250  250  /*
 251  251   * Macros to test lock states.
 252  252   */
 253      -#define AS_LOCK_HELD(as, lock)          RW_LOCK_HELD((lock))
 254      -#define AS_READ_HELD(as, lock)          RW_READ_HELD((lock))
 255      -#define AS_WRITE_HELD(as, lock)         RW_WRITE_HELD((lock))
      253 +#define AS_LOCK_HELD(as)                RW_LOCK_HELD(&(as)->a_lock)
      254 +#define AS_READ_HELD(as)                RW_READ_HELD(&(as)->a_lock)
      255 +#define AS_WRITE_HELD(as)               RW_WRITE_HELD(&(as)->a_lock)
 256  256  
 257  257  /*
 258  258   * macros to walk thru segment lists
 259  259   */
 260  260  #define AS_SEGFIRST(as)         avl_first(&(as)->a_segtree)
 261  261  #define AS_SEGNEXT(as, seg)     AVL_NEXT(&(as)->a_segtree, (seg))
 262  262  #define AS_SEGPREV(as, seg)     AVL_PREV(&(as)->a_segtree, (seg))
 263  263  
 264  264  void    as_init(void);
 265  265  void    as_avlinit(struct as *);
↓ open down ↓ 52 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX