From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f173.google.com (mail-we0-f173.google.com [74.125.82.173]) by dpdk.org (Postfix) with ESMTP id A8DBC5A32 for ; Tue, 10 Feb 2015 18:16:18 +0100 (CET) Received: by mail-we0-f173.google.com with SMTP id w55so23503527wes.4 for ; Tue, 10 Feb 2015 09:16:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=dCKqqLO4IwBd1ipvRUVEEp1Y1IfXjZOAH+rHJAQM8Zk=; b=I8Qp+b5AkPmx0kU23BGJcbrhgwxzH2D0ZGcKe0mefL8rD71IDsLeS+pVT/kOSYq49D uZn+fK6aX2cf5mvlGxsCSA0V/DqGKnp7OXVYk+PjHepuO9mAYT620uh0ql/uxed0o9fW 9kL9a8Yuva/eZ4bC5QPHE/QpCQtEj+GZsAWVVzbe0rcqIfQHGpTOYB7QVImdV7znrtTG qoNCMAyHE8fqGO4vhu0ClUagccrWBRRh/mHly2wBPvh9GWuDBah/1igf6ihnt0fIL+Rb Ia9OLYv8uk9ADlXA4rTVw5jsUcMDQngsCKqT+36ga6cQg4BPZ99UwXy9X0y6tBxx9KYA ceEA== X-Gm-Message-State: ALoCoQn/byTKPzXWCFcG877k9X7nTF2heE4meHdwzxNv3Of7HZae7YuoiDI4paijPlcCa7h5Ghue X-Received: by 10.180.211.206 with SMTP id ne14mr47994147wic.79.1423588578496; Tue, 10 Feb 2015 09:16:18 -0800 (PST) Received: from [10.16.0.195] (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id cf12sm21611220wjb.10.2015.02.10.09.16.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Feb 2015 09:16:18 -0800 (PST) Message-ID: <54DA3CE1.1090608@6wind.com> Date: Tue, 10 Feb 2015 18:16:17 +0100 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-Version: 1.0 To: "Liang, Cunming" , "dev@dpdk.org" 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: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2015 17:16:18 -0000 Hi, On 02/10/2015 07:57 AM, Liang, Cunming wrote: >>> +/** >>> + * 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) = -1; >>> + if (RTE_PER_LCORE(_thread_id) == -1) >>> + RTE_PER_LCORE(_thread_id) = rte_sys_gettid(); >>> + return RTE_PER_LCORE(_thread_id); >>> +} >> >> 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 something. > The purpose to call it in EAL thread init, is to lower down the overhead of the first calling for EAL thread. Got it. So that's fine like you proposed. Olivier