On 7/5/2019 7:47 AM, Ziyang Xuan wrote: > Using spin lock to protect critical resources > of sending mgmt messages. This will make high > CPU usage for rte_delay_ms when sending mgmt > messages frequently. We can use mutex to protect > the critical resources and usleep to reduce CPU > usage while keep functioning properly. > > Signed-off-by: Ziyang Xuan <xuanziya...@huawei.com>
<...> > +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; > +} > + There was a comment from Stephen to use pthread APIs directly, can you please comment on that? > @@ -713,7 +718,7 @@ int hinic_aeq_poll_msg(struct hinic_eq *eq, u32 timeout, > void *param) > } > > if (timeout != 0) > - rte_delay_ms(1); > + usleep(1000); Why is this change required? Aren't these are same?