From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 815F7A00E6 for ; Tue, 9 Jul 2019 14:14:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2553C1B958; Tue, 9 Jul 2019 14:14:15 +0200 (CEST) Received: from huawei.com (szxga01-in.huawei.com [45.249.212.187]) by dpdk.org (Postfix) with ESMTP id 616721B955 for ; Tue, 9 Jul 2019 14:14:13 +0200 (CEST) Received: from DGGEML402-HUB.china.huawei.com (unknown [172.30.72.53]) by Forcepoint Email with ESMTP id BD383C6A07B4CDD6AE82; Tue, 9 Jul 2019 20:14:11 +0800 (CST) Received: from DGGEML512-MBX.china.huawei.com ([169.254.2.81]) by DGGEML402-HUB.china.huawei.com ([fe80::fca6:7568:4ee3:c776%31]) with mapi id 14.03.0439.000; Tue, 9 Jul 2019 20:14:02 +0800 From: "Xuanziyang (William, Chip Application Design Logic and Hardware Development Dept IT_Products & Solutions)" To: Stephen Hemminger CC: "dev@dpdk.org" , "ferruh.yigit@intel.com" , "Wangxiaoyun (Cloud, Network Chip Application Development Dept)" , Luoxianjun , Tanya Brokhman Thread-Topic: [dpdk-dev] [PATCH v1 1/1] net/hinic: use mutex replace spin lock Thread-Index: AdU2T8hPc9GrsyUfS56rzoIbrqZNTg== Date: Tue, 9 Jul 2019 12:14:02 +0000 Message-ID: Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.22.62] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH v1 1/1] net/hinic: use mutex replace spin lock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > On Wed, 3 Jul 2019 23:35:42 +0800 > Ziyang Xuan wrote: >=20 > > > > +static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex, > > + const pthread_mutexattr_t *mattr) { > > + int err; > > + > > + err =3D 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 =3D pthread_mutex_destroy(pthreadmutex); > > + if (unlikely(err)) > > + PMD_DRV_LOG(ERR, "Fail to destroy mutex, error: %d", err); > > + > > + return err; > > +} > > + >=20 > I don't think the wrapper functions add much. > pthread_mutex_init just sets internals of data structure and won't fail e= ver if > mutexattr_t is NULL. >=20 > Just use pthread_mutex_init/pthread_mutex_destroy directly and ignore > errors. I think pthread_mutex_init/pthread_mutex_destroy may fail under some situat= ions. https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_mutex_init.html I want some logs when they failed to position problems conveniently and I w= ould also detect their failures. So I encapsulate the functions. And I think it is be= tter.