From: "Xuanziyang (William, Chip Application Design Logic and Hardware Development Dept IT_Products & Solutions)" <xuanziyang2@huawei.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"ferruh.yigit@intel.com" <ferruh.yigit@intel.com>,
"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 v1 1/1] net/hinic: use mutex replace spin lock
Date: Tue, 9 Jul 2019 12:14:02 +0000 [thread overview]
Message-ID: <EA3B33EA29B44042A5337C4DC59AF4505EEFC7BF@dggeml512-mbx.china.huawei.com> (raw)
> On Wed, 3 Jul 2019 23:35:42 +0800
> Ziyang Xuan <xuanziyang2@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.
I think pthread_mutex_init/pthread_mutex_destroy may fail under some situations.
https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_mutex_init.html
I want some logs when they failed to position problems conveniently and I would also
detect their failures. So I encapsulate the functions. And I think it is better.
next reply other threads:[~2019-07-09 12:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 12:14 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-03 15:35 Ziyang Xuan
2019-07-03 15:37 ` Stephen Hemminger
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=EA3B33EA29B44042A5337C4DC59AF4505EEFC7BF@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=stephen@networkplumber.org \
--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).