On Mon, Apr 28, 2014 at 03:09:01PM -0700, Davidlohr Bueso wrote:
> @@ -26,6 +27,10 @@ struct rw_semaphore {
>       long                    count;
>       raw_spinlock_t          wait_lock;
>       struct list_head        wait_list;
> +#ifdef CONFIG_SMP
> +     struct task_struct           *owner; /* write owner */
> +     struct optimistic_spin_queue *osq;   /* spinner MCS lock */
> +#endif
>  #ifdef CONFIG_DEBUG_LOCK_ALLOC
>       struct lockdep_map      dep_map;
>  #endif
> @@ -55,11 +60,21 @@ static inline int rwsem_is_locked(struct rw_semaphore 
> *sem)
>  # define __RWSEM_DEP_MAP_INIT(lockname)
>  #endif
>  
> +#ifdef CONFIG_SMP
> +#define __RWSEM_INITIALIZER(name)                    \
> +     { RWSEM_UNLOCKED_VALUE,                         \
> +       __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock),     \
> +       LIST_HEAD_INIT((name).wait_list),             \
> +       NULL, /* owner */                             \
> +       NULL /* mcs lock */                           \
> +       __RWSEM_DEP_MAP_INIT(name) }
> +#else
>  #define __RWSEM_INITIALIZER(name)                    \
>       { RWSEM_UNLOCKED_VALUE,                         \
>         __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock),     \
>         LIST_HEAD_INIT((name).wait_list)              \
>         __RWSEM_DEP_MAP_INIT(name) }
> +#endif

I'm not saying you should change this; but something like:

#ifdef CONFIG_SMP
# define __RWSEM_SMP_INIT(name) , .owner = NULL, .osq = NULL
#else
# define __RWSEM_SMP_INIT(name)
#endif

#define __RWSEM_INITIALIZER(name)       {                       \
        .count = RWSEM_UNLOCKED_VALUE,                          \
        .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock),  \
        .wait_list = LIST_HEAD_INIT(name.wait_list)             \
        __RWSEM_SMP_INIT(name)                                  \
        __RWSEM_DEP_MAP_INIT(name)                              \
}

might be more readable in general.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to