[dpdk-dev] [PATCH v1 1/1] net/hinic: use mutex replace spin lock

Stephen Hemminger stephen at networkplumber.org
Wed Jul 3 17:37:17 CEST 2019


On Wed, 3 Jul 2019 23:35:42 +0800
Ziyang Xuan <xuanziyang2 at huawei.com> wrote:

>  
> +static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
> +					const pthread_mutexattr_t *mattr)
> +{
> +	int err;
> +
> +	err = pthread_mutex_init(pthreadmutex, mattr);
> +	if (unlikely(err))
> +		PMD_DRV_LOG(ERR, "Fail to initialize mutex, error: %d", err);
> +
> +	return err;
> +}
> +
> +static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex)
> +{
> +	int err;
> +
> +	err = pthread_mutex_destroy(pthreadmutex);
> +	if (unlikely(err))
> +		PMD_DRV_LOG(ERR, "Fail to destroy mutex, error: %d", err);
> +
> +	return err;
> +}
> +

I don't think the wrapper functions add much. 
pthread_mutex_init just sets internals of data structure and won't fail ever
if mutexattr_t is NULL.

Just use pthread_mutex_init/pthread_mutex_destroy directly
and ignore errors.



More information about the dev mailing list