From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <cunming.liang@intel.com>
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by dpdk.org (Postfix) with ESMTP id 52F3FCE7
 for <dev@dpdk.org>; Tue, 10 Feb 2015 07:57:27 +0100 (CET)
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by orsmga101.jf.intel.com with ESMTP; 09 Feb 2015 22:57:26 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.09,548,1418112000"; d="scan'208";a="664122920"
Received: from pgsmsx103.gar.corp.intel.com ([10.221.44.82])
 by fmsmga001.fm.intel.com with ESMTP; 09 Feb 2015 22:57:24 -0800
Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by
 PGSMSX103.gar.corp.intel.com (10.221.44.82) with Microsoft SMTP Server (TLS)
 id 14.3.195.1; Tue, 10 Feb 2015 14:57:23 +0800
Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.62]) by
 SHSMSX104.ccr.corp.intel.com ([169.254.5.161]) with mapi id 14.03.0195.001;
 Tue, 10 Feb 2015 14:57:23 +0800
From: "Liang, Cunming" <cunming.liang@intel.com>
To: Olivier MATZ <olivier.matz@6wind.com>, "dev@dpdk.org" <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH v4 07/17] eal: add rte_gettid() to acquire
 unique system tid
Thread-Index: AQHQPoxlK7byiujpnkC07bixNU4v85zmsJOAgALNhvA=
Date: Tue, 10 Feb 2015 06:57:23 +0000
Message-ID: <D0158A423229094DA7ABF71CF2FA0DA3118D8371@shsmsx102.ccr.corp.intel.com>
References: <1422491072-5114-1-git-send-email-cunming.liang@intel.com>
 <1422842559-13617-1-git-send-email-cunming.liang@intel.com>
 <1422842559-13617-8-git-send-email-cunming.liang@intel.com>
 <54D7C05F.9090501@6wind.com>
In-Reply-To: <54D7C05F.9090501@6wind.com>
Accept-Language: zh-CN, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.239.127.40]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH v4 07/17] eal: add rte_gettid() to acquire
 unique system tid
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 10 Feb 2015 06:57:28 -0000



> -----Original Message-----
> From: Olivier MATZ [mailto:olivier.matz@6wind.com]
> Sent: Monday, February 09, 2015 4:01 AM
> To: Liang, Cunming; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v4 07/17] eal: add rte_gettid() to acquire=
 unique
> system tid
>=20
> Hi,
>=20
> On 02/02/2015 03:02 AM, Cunming Liang wrote:
> > The rte_gettid() wraps the linux and freebsd syscall gettid().
> > It provides a persistent unique thread id for the calling thread.
> > It will save the unique id in TLS on the first time.
> >
> > [...]
> >
> > +/**
> > + * A wrap API for syscall gettid.
> > + *
> > + * @return
> > + *   On success, returns the thread ID of calling process.
> > + *   It always successful.
> > + */
> > +int rte_sys_gettid(void);
> > +
> > +/**
> > + * Get system unique thread id.
> > + *
> > + * @return
> > + *   On success, returns the thread ID of calling process.
> > + *   It always successful.
> > + */
> > +static inline int rte_gettid(void)
> > +{
> > +	static RTE_DEFINE_PER_LCORE(int, _thread_id) =3D -1;
> > +	if (RTE_PER_LCORE(_thread_id) =3D=3D -1)
> > +		RTE_PER_LCORE(_thread_id) =3D rte_sys_gettid();
> > +	return RTE_PER_LCORE(_thread_id);
> > +}
>=20
> Instead of doing the test each time rte_gettid() is called, why not
> having 2 functions:
>   rte_init_tid() -> assign the per_lcore variable
>   rte_gettid() -> return the per_lcore variable

[LCM] The rte_gettid() mainly used in recursive spinlock.
For non-EAL thread, we don't expect new user thread has to explicit call so=
mething.
The purpose to call it in EAL thread init, is to lower down the overhead of=
 the first calling for EAL thread.

>=20
>=20
>=20
> Regards,
> Olivier