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 6FF47A0C4D; Thu, 10 Jun 2021 00:37:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 092D24067C; Thu, 10 Jun 2021 00:37:21 +0200 (CEST) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by mails.dpdk.org (Postfix) with ESMTP id E3B8F4003C for ; Thu, 10 Jun 2021 00:37:19 +0200 (CEST) Received: by mail-lj1-f181.google.com with SMTP id d2so1883061ljj.11 for ; Wed, 09 Jun 2021 15:37:19 -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=uDtTOiZmBdviOi1ifb85Rs2HGiwybp6v7oIDUdyzMoc=; b=D5cunZpSsETSWSWEbpF2ZFyYcIMJ1/j6Jd354nsiTzQfKMsbmcyHfZxP7TSKCNr7Db cp/lFSHjo5CJLctFwF8FOwb58oj2S63J7omdDOYWynUKuVKkZ9WY0X3vE1BmziMN6vDE /6dGwtrkP4FQmlC925i02AfjK3f22E1VEGItXwVoqD41IxJsX/xMrueBXKjNg3Giukbn EvRnAX4HUj4g5HLRkCRyUiSkJEVsL950ZtKNNNbwAqjRhSfNjLf0OLIsQKJuF/Oggcol erDO/duEn9alGSOnfhTEL49ZgNJCcLtV5BCYQoV3elceQR0s7e/vjg5hpFhI60RN3p8E 7B5Q== 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=uDtTOiZmBdviOi1ifb85Rs2HGiwybp6v7oIDUdyzMoc=; b=NgyLT2D0YB8C2DIAwClgohf/tLRdGPa3QDEEb08JypJmXAVBP3Ymd6PlcVBpc+pq3m 6Tn0SE/EX04wIO2QsZXZVDiGiiJG2tVsaVNWUhiM+BJocH+8K5vN9jpaF2+lfKISkoKj 6ZX1g+SvhbAJ++ML8iECEJGHMtAlo4ur3mNcyoNVjfE9ZORiqrwiM/TSD9QoOEf3yOaV pKQuYedwCpIG/RT8RJsLzAlEfd4E4kPnoSw8IMbYn32Yw9DJ66271rwVu1d8u+SXxN88 qXKnF+B3fxrVaTmpcjFPde5tQlKhhxmKG5W7P/m33rBTHh0XIlqirEZCXNOh0yg+1PKm h7Vg== X-Gm-Message-State: AOAM532q5XWYcYu5c/HWldoNcs3PDJtkthRi0ReNlp8Y8HI8QNfgdTbM eBqchc8AT6PNPdO3So8pJ7w= X-Google-Smtp-Source: ABdhPJwk1azy+TwSYL2Wmu9AezokCFZbKbf5k4/bwbOJiH5z5VWBZ6Mh1zmvYWhoQq1MvKrZXStijg== X-Received: by 2002:a2e:9b0e:: with SMTP id u14mr1482350lji.123.1623278239393; Wed, 09 Jun 2021 15:37:19 -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 b10sm119477ljf.72.2021.06.09.15.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 15:37:18 -0700 (PDT) Date: Thu, 10 Jun 2021 01:37:17 +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: <20210610013717.00a96602@sovereign> In-Reply-To: <20210609020419.6671302f@sovereign> References: <1622849908-5710-1-git-send-email-navasile@linux.microsoft.com> <1622850274-6946-1-git-send-email-navasile@linux.microsoft.com> <1622850274-6946-8-git-send-email-navasile@linux.microsoft.com> <20210609020419.6671302f@sovereign> 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: quoted-printable Subject: Re: [dpdk-dev] [PATCH v9 07/10] eal: implement functions for mutex management 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-09 02:04 (UTC+0300), Dmitry Kozlyuk: > 2021-06-04 16:44 (UTC-0700), Narcisa Ana Maria Vasile: > [...] > > diff --git a/lib/eal/include/rte_thread_types.h b/lib/eal/include/rte_t= hread_types.h > > index d67b24a563..7bb0d2948c 100644 > > --- a/lib/eal/include/rte_thread_types.h > > +++ b/lib/eal/include/rte_thread_types.h > > @@ -7,4 +7,8 @@ > > =20 > > #include > > =20 > > +#define RTE_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER > > + > > +typedef pthread_mutex_t rte_thread_mutex_t; > > + > > #endif /* _RTE_THREAD_TYPES_H_ */ > > diff --git a/lib/eal/windows/include/rte_windows_thread_types.h b/lib/e= al/windows/include/rte_windows_thread_types.h > > index 60e6d94553..c6c8502bfb 100644 > > --- a/lib/eal/windows/include/rte_windows_thread_types.h > > +++ b/lib/eal/windows/include/rte_windows_thread_types.h > > @@ -7,4 +7,13 @@ > > =20 > > #include > > =20 > > +#define WINDOWS_MUTEX_INITIALIZER (void*)-1 > > +#define RTE_THREAD_MUTEX_INITIALIZER {WINDOWS_MUTEX_INITIAL= IZER} > > + > > +struct thread_mutex_t { > > + void* mutex_id; > > +}; > > + > > +typedef struct thread_mutex_t rte_thread_mutex_t; > > + > > #endif /* _RTE_THREAD_TYPES_H_ */ =20 >=20 > In previous patches rte_thread content was made opaque and of equal size > for pthread (most implementations) and non-pthread variant. > AFAIU, we agree on the requirement of compatible ABI between variants, > that is, a compiled app can work with any threading variant of DPDK. > Above definition of `rte_thread_mutex_t` does not satisfy it. > Or do we only promise API compatibility? > This is the most important question now. =46rom Windows community call 2021-06-10, for everyone's information. 1. Yes, binary compatibility is a requirement. 2. Static mutex initializer for Windows is tricky (an old topic). This patch proposes `rte_mutex` to hold a pointer to actual mutex and use NULL as static initializer, then allocate on first use. At the same time we want to use the same initializer for pthread variant. This means it would also need indirection, allocation, and tricky logic. My opinion: New threading API can just be without static initilizer. All it usages in DPDK could be converted to dynamic initialization either in appropriate function or using `RTE_INIT`. Maybe create a convenient macro to declare a static mutex and its initialization code, what do others think? RTE_STATIC_MUTEX(private_lock) Expanding to: static RTE_DECLARE_MUTEX(private_lock) RTE_DEFINE_MUTEX(private_lock) Expanding to: static rte_mutex private_lock; RTE_INIT(__rte_private_lock_init) { RTE_VERIFY(rte_thread_mutex_init(&private_lock)); } As a bonus it removes the need of `rte_*_thread_types.h`.