DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xuanziyang (William, Chip Application Design Logic and Hardware Development Dept IT_Products & Solutions)" <xuanziyang2@huawei.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Wangxiaoyun (Cloud,
	Network Chip Application Development Dept)"
	<cloud.wangxiaoyun@huawei.com>,
	Luoxianjun <luoxianjun@huawei.com>,
	"Tanya Brokhman" <tanya.brokhman@huawei.com>
Subject: Re: [dpdk-dev] [PATCH v2 1/1] net/hinic: use mutex replace spin lock
Date: Tue, 9 Jul 2019 12:20:52 +0000	[thread overview]
Message-ID: <EA3B33EA29B44042A5337C4DC59AF4505EEFC7D2@dggeml512-mbx.china.huawei.com> (raw)

> 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 <xuanziyang2@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?

I have reply him already.

> 
> 
> > @@ -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?

The function rte_delay_ms is blocked and usleep is dispatched.
We get high CPU usage when we use rte_delay_ms but usleep.
It is the purpose of this patch.

Thanks!

             reply	other threads:[~2019-07-09 12:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09 12:20 Xuanziyang (William, Chip Application Design Logic and Hardware Development Dept IT_Products & Solutions) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-07-05  6:47 Ziyang Xuan
2019-07-08 18:15 ` Ferruh Yigit
2019-07-10  8:06 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EA3B33EA29B44042A5337C4DC59AF4505EEFC7D2@dggeml512-mbx.china.huawei.com \
    --to=xuanziyang2@huawei.com \
    --cc=cloud.wangxiaoyun@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=luoxianjun@huawei.com \
    --cc=tanya.brokhman@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).