From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9EC9BA0C44; Wed, 9 Jun 2021 01:03:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1994D40689; Wed, 9 Jun 2021 01:03:52 +0200 (CEST) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by mails.dpdk.org (Postfix) with ESMTP id D80BB4067A for ; Wed, 9 Jun 2021 01:03:50 +0200 (CEST) Received: by mail-lj1-f180.google.com with SMTP id e2so29220319ljk.4 for ; Tue, 08 Jun 2021 16:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1Q9wYXuQKCTfDHJktJ9Ufg7FnmHHWxOg+z9OPULTRw4=; b=rS/zZWEnqsV+eQeSswN66s1h0tCZXfw03aVxXBDT/A2BWKPEk6nhH0IjMpZlRlMSFk EDk9N4myOjLEs66SqjsHCqSxobynNl6fBaHhWqA7Femgh6gPYqI3dgACfJXLI8iPwRbG URAbyII9Cabf0wz4dUf0VI3VnvVmGzwUoe+nouDVGW5gIkoCNEb1Cio5uYdFm2RXLBuy fXith86fm11rN3d+8yzBdSoIDOsgswKTrQym3wQiU5g2kCzAENIfeJaS/zjKqjtWCXqu aMJihQkuR+mZ3ZEGM5StH7tdG7/PK7/dVqW9yx6Bwv/Bq7EIJzyGj7dwuR94f7GXYZwi vkhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1Q9wYXuQKCTfDHJktJ9Ufg7FnmHHWxOg+z9OPULTRw4=; b=O+6bIWZlWEkkIGFD0JMcXEbd4RkHqIUfYQMeKNQnZcuphn9uZaDc5wBOp5EgzGmYxt qtWOyXKJG9awZun7JYzsnJO7RPs1pt3mFR0ObNEi/J4e9ZF8evCRjay6slB8XKy4RbcN 2YbA4RRSUFmBi94KLv9vHyffUxM5gnwt6ibn4bHaZ8QBvrxD5v3Lbwx0ExP22x/YmMyr vDb7zTaDzAHfvcszAbmzMUjk92rZVhOpst3Gx6x3d2UbeT5RmIg9qa/zVcBBDPoM5suA 0xaCzYIMlElILiVxh1FzmS18NhJ6BwMCpDpNdpYVdcWkEwYhTYlYJJNUwfXbUW2VUOiH a6fA== X-Gm-Message-State: AOAM531j2x0Z4z0u3VGTJP4vQVQQwURQGs0qFbXNtvwghD/0CxE3w5zv j4MIVTfSG6CCK1El1mVlkHs= X-Google-Smtp-Source: ABdhPJzuIGt4/P/SaUtPuZOJo8gJJWyYLhYQnFRtp98pMvZvFWlYJtmT1zgR50lfAEnAizH2nqtN3g== X-Received: by 2002:a2e:a594:: with SMTP id m20mr20914991ljp.114.1623193430367; Tue, 08 Jun 2021 16:03:50 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id n12sm120069lft.307.2021.06.08.16.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 16:03:49 -0700 (PDT) Date: Wed, 9 Jun 2021 02:03:48 +0300 From: Dmitry Kozlyuk To: Narcisa Ana Maria Vasile Cc: dev@dpdk.org, thomas@monjalon.net, khot@microsoft.com, navasile@microsoft.com, dmitrym@microsoft.com, roretzla@microsoft.com, talshn@nvidia.com, ocardona@microsoft.com, bruce.richardson@intel.com, david.marchand@redhat.com, pallavi.kadam@intel.com Message-ID: <20210609020348.20a0cad2@sovereign> In-Reply-To: <1622850274-6946-2-git-send-email-navasile@linux.microsoft.com> References: <1622849908-5710-1-git-send-email-navasile@linux.microsoft.com> <1622850274-6946-1-git-send-email-navasile@linux.microsoft.com> <1622850274-6946-2-git-send-email-navasile@linux.microsoft.com> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v9 01/10] eal: add thread id and simple thread functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" 2021-06-04 16:44 (UTC-0700), Narcisa Ana Maria Vasile: > From: Narcisa Vasile > > Use a portable, type-safe representation for the thread identifier. > Add functions for comparing thread ids and obtaining the thread id > for the current thread. > > Signed-off-by: Narcisa Vasile > --- > lib/eal/common/rte_thread.c | 105 ++++++++++++++++++ > lib/eal/include/rte_thread.h | 53 +++++++-- > lib/eal/include/rte_thread_types.h | 10 ++ > .../include/rte_windows_thread_types.h | 10 ++ > lib/eal/windows/rte_thread.c | 17 +++ > 5 files changed, 186 insertions(+), 9 deletions(-) > create mode 100644 lib/eal/common/rte_thread.c > create mode 100644 lib/eal/include/rte_thread_types.h > create mode 100644 lib/eal/windows/include/rte_windows_thread_types.h It is strange that new files are being filled in the series, but are neither compiled nor installed until the last patch. Any reason not to replace lib/eal/unix/rte_thread.c starting from this patch? A better name for rte_thread_types.h would be rte_posix_thread_types.h to indicate this file is not really common. > > diff --git a/lib/eal/common/rte_thread.c b/lib/eal/common/rte_thread.c > new file mode 100644 > index 0000000000..1292f7a8f8 > --- /dev/null > +++ b/lib/eal/common/rte_thread.c > @@ -0,0 +1,105 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright 2021 Mellanox Technologies, Ltd > + * Copyright(c) 2021 Microsoft Corporation > + */ > + > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > + > +struct eal_tls_key { > + pthread_key_t thread_index; > +}; > + > +rte_thread_t > +rte_thread_self(void) > +{ > + rte_thread_t thread_id = { 0 }; (Applies to entire series.) Please do not initialize variables when you intend to overwrite them. This prevents compiler from reporting code paths where the variable is used before a proper assignment. > + > + thread_id.opaque_id = pthread_self(); > + > + return thread_id; > +} > + [...] > diff --git a/lib/eal/include/rte_thread.h b/lib/eal/include/rte_thread.h > index 8be8ed8f36..347df1a6ae 100644 > --- a/lib/eal/include/rte_thread.h > +++ b/lib/eal/include/rte_thread.h > @@ -1,6 +1,8 @@ > /* SPDX-License-Identifier: BSD-3-Clause > * Copyright(c) 2021 Mellanox Technologies, Ltd > + * Copyright(c) 2021 Microsoft Corporation > */ > +#include > > #include > #include > @@ -20,11 +22,50 @@ > extern "C" { > #endif > > +#include > +#if defined(RTE_USE_WINDOWS_THREAD_TYPES) Redundant braces are discouraged in DPDK codebase. [...] > diff --git a/lib/eal/include/rte_thread_types.h b/lib/eal/include/rte_thread_types.h > new file mode 100644 > index 0000000000..d67b24a563 > --- /dev/null > +++ b/lib/eal/include/rte_thread_types.h > @@ -0,0 +1,10 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2021 Microsoft Corporation > + */ > + > +#ifndef _RTE_THREAD_TYPES_H_ > +#define _RTE_THREAD_TYPES_H_ > + > +#include > + > +#endif /* _RTE_THREAD_TYPES_H_ */ > diff --git a/lib/eal/windows/include/rte_windows_thread_types.h b/lib/eal/windows/include/rte_windows_thread_types.h > new file mode 100644 > index 0000000000..60e6d94553 > --- /dev/null > +++ b/lib/eal/windows/include/rte_windows_thread_types.h > @@ -0,0 +1,10 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2021 Microsoft Corporation > + */ > + > +#ifndef _RTE_THREAD_TYPES_H_ > +#define _RTE_THREAD_TYPES_H_ > + > +#include > + > +#endif /* _RTE_THREAD_TYPES_H_ */ Thread types headers should have a check that forbids including them directly, see lib/eal/$arch/rte_atomic_64.h for examples. Note that rte_*_thread_types.h should be `indirect_headers`, not `headers` in `meson.build` so that they're not checked by `buildtools/chkincs` when is gets enabled for Windows. This is especially true for lib/eal/common/rte_thread.h that cannot work without pthread. However, in later patches these headers only contain mutex bits, see the comment to pathc 07/10 about them. Maybe we don't need these files after all.