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 04375A0487 for ; Thu, 4 Jul 2019 11:10:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C627E1B965; Thu, 4 Jul 2019 11:10:03 +0200 (CEST) Received: from mail-vs1-f66.google.com (mail-vs1-f66.google.com [209.85.217.66]) by dpdk.org (Postfix) with ESMTP id 2E16E1B959 for ; Thu, 4 Jul 2019 11:10:02 +0200 (CEST) Received: by mail-vs1-f66.google.com with SMTP id u124so1545596vsu.2 for ; Thu, 04 Jul 2019 02:10:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z7jAiqqFnkx6q9GddtyE+xIZoposs8wictTjYtOJtfo=; b=UDSdGiZMeh/e6Y/ZrsYPm2EwFWcQn3eGF18KVzttxnC2Yho6Oa18VEgCO4gWeHO93n bhjgcCn0g0vTj23u+OsYSX7sv8xTgZiynn4lX3W4dfQnhTiHeX0zIFBXtVuS5gV9p/HE oz0vybPABQT0aTjh2lIkbypHw4jtmxlaP11bvktXt2dyGNbQ8DLyZe2EutfU2w76/Z9p hW1uAqAZfHBR9XqBpQUbWXeT1fJ96fcrHqwygRROrfnxgfa92VydrePUGSgqYbK6lSab KJ1uTRFWXrj2kdfZqrmqo+Z+acimCNTpyedFR225r3NE7oGVp6lPdvsRIC4ELzY78mjB xkKA== X-Gm-Message-State: APjAAAU3rIyHrWFRn0d3xnfxgso0LckvdUffnLz4/++EBtAjczRXZoUg Rcp9ZIJjmTjHMjvuSl0MRP7FkzPALCNUkxO5LGj83A== X-Google-Smtp-Source: APXvYqxEg8Qavn02gp1SyF9yNOtw9YVE/5/OaD+mu4OriCRorX8W5bkdQ/j1rYuu2gyF1WyIjYCOkL5jGOfqklVtag8= X-Received: by 2002:a67:2ec8:: with SMTP id u191mr21861979vsu.39.1562231401577; Thu, 04 Jul 2019 02:10:01 -0700 (PDT) MIME-Version: 1.0 References: <1557354906-2500-1-git-send-email-erik.g.carrillo@intel.com> <0743551eba840752223a6447ab4dcaf0731add39.1561478924.git.anatoly.burakov@intel.com> In-Reply-To: <0743551eba840752223a6447ab4dcaf0731add39.1561478924.git.anatoly.burakov@intel.com> From: David Marchand Date: Thu, 4 Jul 2019 11:09:50 +0200 Message-ID: To: Anatoly Burakov Cc: dev , Erik Gabriel Carrillo Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH 1/2] eal: add internal locks for timer lib into EAL 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 Tue, Jun 25, 2019 at 6:12 PM Anatoly Burakov wrote: > Currently, timer library has a memory leak because there is no > way to concurrently initialize/deinitialize shared memory because > of race conditions [1]. > > Add a spinlock to the shared mem config to have a way to > exclusively initialize/deinitialize the timer library without > any races. > > [1] See the following email thread: > https://mails.dpdk.org/archives/dev/2019-May/131498.html > > Signed-off-by: Anatoly Burakov > --- > lib/librte_eal/common/eal_common_mcfg.c | 14 ++++++++++++++ > lib/librte_eal/common/eal_memcfg.h | 2 ++ > .../common/include/rte_eal_memconfig.h | 18 ++++++++++++++++++ > lib/librte_eal/rte_eal_version.map | 2 ++ > 4 files changed, 36 insertions(+) > > diff --git a/lib/librte_eal/common/eal_common_mcfg.c > b/lib/librte_eal/common/eal_common_mcfg.c > index 1825d9083..066549432 100644 > --- a/lib/librte_eal/common/eal_common_mcfg.c > +++ b/lib/librte_eal/common/eal_common_mcfg.c > @@ -147,3 +147,17 @@ rte_mcfg_mempool_write_unlock(void) > struct rte_mem_config *mcfg = > rte_eal_get_configuration()->mem_config; > rte_rwlock_write_unlock(&mcfg->mplock); > } > + > +void > +rte_mcfg_timer_lock(void) > +{ > + struct rte_mem_config *mcfg = > rte_eal_get_configuration()->mem_config; > + rte_spinlock_lock(&mcfg->tlock); > +} > + > +void > +rte_mcfg_timer_unlock(void) > +{ > + struct rte_mem_config *mcfg = > rte_eal_get_configuration()->mem_config; > + rte_spinlock_unlock(&mcfg->tlock); > +} > diff --git a/lib/librte_eal/common/eal_memcfg.h > b/lib/librte_eal/common/eal_memcfg.h > index e1aae32df..00370cece 100644 > --- a/lib/librte_eal/common/eal_memcfg.h > +++ b/lib/librte_eal/common/eal_memcfg.h > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -38,6 +39,7 @@ struct rte_mem_config { > rte_rwlock_t mlock; /**< only used by memzone LIB for > thread-safe. */ > rte_rwlock_t qlock; /**< used for tailq operation for thread > safe. */ > rte_rwlock_t mplock; /**< only used by mempool LIB for > thread-safe. */ > + rte_spinlock_t tlock; /**< needed for timer lib thread safety. */ > > rte_rwlock_t memory_hotplug_lock; > /**< indicates whether memory hotplug request is in progress. */ > diff --git a/lib/librte_eal/common/include/rte_eal_memconfig.h > b/lib/librte_eal/common/include/rte_eal_memconfig.h > index 1b615c892..05a32e12a 100644 > --- a/lib/librte_eal/common/include/rte_eal_memconfig.h > +++ b/lib/librte_eal/common/include/rte_eal_memconfig.h > @@ -109,6 +109,24 @@ rte_mcfg_mempool_write_lock(void); > void > rte_mcfg_mempool_write_unlock(void); > > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > + * Lock the internal EAL Timer Library lock for exclusive access. > + */ > +void __rte_experimental > As mentionned by Erik, rte_experimental void +rte_mcfg_timer_lock(void); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > + * Unlock the internal EAL Timer Library lock for exclusive access. > + */ > +void __rte_experimental > rte_experimental void > +rte_mcfg_timer_unlock(void); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_eal/rte_eal_version.map > b/lib/librte_eal/rte_eal_version.map > index c28951f65..bc08fc4df 100644 > --- a/lib/librte_eal/rte_eal_version.map > +++ b/lib/librte_eal/rte_eal_version.map > @@ -367,6 +367,8 @@ EXPERIMENTAL { > rte_malloc_heap_memory_detach; > rte_malloc_heap_memory_remove; > rte_malloc_heap_socket_is_external; > + rte_mcfg_timer_lock; > + rte_mcfg_timer_unlock; > rte_mem_alloc_validator_register; > rte_mem_alloc_validator_unregister; > rte_mem_check_dma_mask; > -- > 2.17.1 > Can you put this at the end of the EXPERIMENTAL block under the 19.08 comment? -- David Marchand