From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 6597FA045E for ; Wed, 29 May 2019 22:15:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 797AA1B945; Wed, 29 May 2019 22:15:10 +0200 (CEST) Received: from mail-vs1-f68.google.com (mail-vs1-f68.google.com [209.85.217.68]) by dpdk.org (Postfix) with ESMTP id 133121B944 for ; Wed, 29 May 2019 22:15:09 +0200 (CEST) Received: by mail-vs1-f68.google.com with SMTP id l20so2892054vsp.3 for ; Wed, 29 May 2019 13:15:09 -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=2LrAqp/7sObO4nLgEnXgWy+H7EpVs84ZbtAyGHo9XXE=; b=jPUv3LNoXrjNuqSf3V3YJg7Y7k1/F2c3F3blkwwTbQw2RYfi/qTZOaoyhthFF2zQY8 ZMIGupF05wA8/Kp0l2RzxPNnnE1EdeqxR6EbwxbpwQ+hg0XDzt6TObpXfPCwfVFMYg4B isG3rGBPTRSTav3tKg2LJc6uHHx8sDFO8e86qD9UiO8SNO/kZXJQVvRewhJK86WwfugZ 2XammxGHSRZQ6uyDOFixr7udD8Sp05L84ruL8VS2goKifwhlVnsdkGYqmnM5wMP9rij1 622ibT/fauP794+ZGcJeqHJOcr1jtVLiPRP0FWDDbgYbCgKTxo/cZwPvhXgxUhtJVWEg 6LAQ== X-Gm-Message-State: APjAAAWpYDSuL3XpKYePvKXmt8/Oa50NdW+x1RTvQOhvV9vxc6ZC/LAB RBmosoPI67tVl8BLGgBcEbBRMXgoAeU45a3lDHOCMq0c X-Google-Smtp-Source: APXvYqxQUjPKyRNIlaotjMxVkHuvaRgw91qX8T7tEMU8j9XEKM3CDqbJwwFbm1269FQxLv1rVDDzuois91IZLfV4rXE= X-Received: by 2002:a67:ef45:: with SMTP id k5mr58262390vsr.105.1559160908460; Wed, 29 May 2019 13:15:08 -0700 (PDT) MIME-Version: 1.0 References: <6551141356fbab88a06c94e54348177939be60b5.1559147228.git.anatoly.burakov@intel.com> In-Reply-To: <6551141356fbab88a06c94e54348177939be60b5.1559147228.git.anatoly.burakov@intel.com> From: David Marchand Date: Wed, 29 May 2019 22:14:57 +0200 Message-ID: To: Anatoly Burakov Cc: dev , Konstantin Ananyev , David Hunt , Bruce Richardson , Byron Marohn , Pablo de Lara Guarch , Yipeng Wang , Sameh Gobriel , Vladimir Medvedkin , Olivier Matz , Andrew Rybchenko , Reshma Pattan , Stephen Hemminger , Thomas Monjalon Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH 25/25] eal: hide shared memory config 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 Wed, May 29, 2019 at 6:32 PM Anatoly Burakov wrote: > diff --git a/lib/librte_eal/common/eal_memcfg.h > b/lib/librte_eal/common/eal_memcfg.h > new file mode 100644 > index 000000000..75891e6cb > --- /dev/null > +++ b/lib/librte_eal/common/eal_memcfg.h > @@ -0,0 +1,75 @@ > Missing a license banner here ? +#ifndef EAL_MEMCFG_H > +#define EAL_MEMCFG_H > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/** > + * the structure for the memory configuration for the RTE. > + * Used by the rte_config structure. It is separated out, as for > multi-process > + * support, the memory details should be shared across instances > + */ > +struct rte_mem_config { > + volatile uint32_t magic; /**< Magic number - Sanity check. */ > + > + /* memory topology */ > + uint32_t nchannel; /**< Number of channels (0 if unknown). */ > + uint32_t nrank; /**< Number of ranks (0 if unknown). */ > + > + /** > + * current lock nest order > + * - qlock->mlock (ring/hash/lpm) > + * - mplock->qlock->mlock (mempool) > + * Notice: > + * *ALWAYS* obtain qlock first if having to obtain both qlock and > mlock > + */ > + 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_rwlock_t memory_hotplug_lock; > + /**< indicates whether memory hotplug request is in progress. */ > + > + /* memory segments and zones */ > + struct rte_fbarray memzones; /**< Memzone descriptors. */ > + > + struct rte_memseg_list memsegs[RTE_MAX_MEMSEG_LISTS]; > + /**< list of dynamic arrays holding memsegs */ > + > + struct rte_tailq_head tailq_head[RTE_MAX_TAILQ]; > + /**< Tailqs for objects */ > + > + /* Heaps of Malloc */ > + struct malloc_heap malloc_heaps[RTE_MAX_HEAPS]; > + > + /* next socket ID for external malloc heap */ > + int next_socket_id; > + > + /* address of mem_config in primary process. used to map shared > config > + * into exact same address the primary process maps it. > + */ > + uint64_t mem_cfg_addr; > + > + /* legacy mem and single file segments options are shared */ > + uint32_t legacy_mem; > + uint32_t single_file_segments; > + > + /* keeps the more restricted dma mask */ > + uint8_t dma_maskbits; > +} __attribute__((packed)); > + > +static inline void > +rte_eal_mcfg_wait_complete(struct rte_mem_config *mcfg) > +{ > + /* wait until shared mem_config finish initialising */ > + while (mcfg->magic != RTE_MAGIC) > + rte_pause(); > +} > A bit similar to what Stephen said, this could be in a .c. -- David Marchand