From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by dpdk.org (Postfix) with ESMTP id E4DF927D for ; Fri, 13 Jul 2018 18:09:34 +0200 (CEST) Received: by mail-ed1-f53.google.com with SMTP id u11-v6so24978502eds.10 for ; Fri, 13 Jul 2018 09:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=f2+1xYBghZb6+7BvfkUVFKXoaOIfdTMFpIVuyOz86K4=; b=SpQ5oTlSC0b/CN+YLoZ1yu5/fQk31qgRx7p0lap1qYJ6pq/V7Qag00nSzFmIi1DO0W nQo1zbMOTjEbhVNUZ9gLhIQJabDCH+oYI/Yf5ZH7ipvadJniAHEfkqOR/gdXRRMU+NxA kmBSlPRFXJxM5e4szrpuOr0Zg4wa7TIMflp9ti+iXCLZ7OaRvu0HlFlc5vBXGO/bBD+N Np24bxV0vuUdd7mTQx+7E/tOtvvHtobWMsVktndW7GckBUYGhsvYy9OLhAyQqQ4axMDe ozbvB+eppXEcYY2Yb3bIiBwot3wkjvfZVy+2B/TiA2xZ0Z1IjnopLORZ1G2XkYbEv35T b0Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=f2+1xYBghZb6+7BvfkUVFKXoaOIfdTMFpIVuyOz86K4=; b=NH0+ppTdTNCFbwGIowPUHfRh8lQsEanOJMd37nAZgelbEg+NEQ0KWXHLBvOsXiRZn5 JMnx+TmoTiainOn7AI6m8YQkH7g/7UawWUVwdAdt+2OjmBnJTLx/RjppzksRtl1EdfCd ilulMndpI6wtwgXkEjfWTtt/I6XE1j9KC7PanuiQBx2Kflg/5sNC6Lx5KnbtAQElDRQ5 6nW4TRErsWwWh1fhl4N6shfy7hrkAhXNxi69lbE1fzaXc9DM25xtfbgI4qIiT0G+WXOk gr3ljs0biR10k1VsHZthuWz2e2cvqD86eIVyf9B5DZqyLUovXl3qJ+G2dkyAapBE6AuU 1aFw== X-Gm-Message-State: AOUpUlE9EJQ4XuyOdykiri8/jOKHgAcyLHP6CYYBi0LJtGuMDLep/NLF ITIMOcFyVoOOqTF0bKnyh//bB1WoQTRmCReulhrppg== X-Google-Smtp-Source: AAOMgpezWQZImFFk+o2QIoqAfsOygQOGaNLVUW0F85ZqEzfjoINUtlp3peYJvbRC3vNUMMBSs0FHza48A7osD22ohig= X-Received: by 2002:a50:b266:: with SMTP id o93-v6mr7869621edd.173.1531498174732; Fri, 13 Jul 2018 09:09:34 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a50:b194:0:0:0:0:0 with HTTP; Fri, 13 Jul 2018 09:09:34 -0700 (PDT) In-Reply-To: References: From: Alejandro Lucero Date: Fri, 13 Jul 2018 17:09:34 +0100 Message-ID: To: Anatoly Burakov Cc: dev , srinath.mannam@broadcom.com, scott.branden@broadcom.com, Ajit Khaparde Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [RFC 04/11] malloc: add name to malloc heaps 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: , X-List-Received-Date: Fri, 13 Jul 2018 16:09:35 -0000 On Fri, Jul 6, 2018 at 2:17 PM, Anatoly Burakov wrote: > We will need to refer to external heaps in some way. While we use > heap ID's internally, for external API use it has to be something > more user-friendly. So, we will be using a string to uniquely > identify a heap. > > Signed-off-by: Anatoly Burakov > --- > lib/librte_eal/common/include/rte_malloc_heap.h | 2 ++ > lib/librte_eal/common/malloc_heap.c | 13 +++++++++++++ > lib/librte_eal/common/rte_malloc.c | 1 + > 3 files changed, 16 insertions(+) > > diff --git a/lib/librte_eal/common/include/rte_malloc_heap.h > b/lib/librte_eal/common/include/rte_malloc_heap.h > index d43fa9097..bd64dff03 100644 > --- a/lib/librte_eal/common/include/rte_malloc_heap.h > +++ b/lib/librte_eal/common/include/rte_malloc_heap.h > @@ -12,6 +12,7 @@ > > /* Number of free lists per heap, grouped by size. */ > #define RTE_HEAP_NUM_FREELISTS 13 > +#define RTE_HEAP_NAME_MAX_LEN 32 > > /* dummy definition, for pointers */ > struct malloc_elem; > @@ -27,6 +28,7 @@ struct malloc_heap { > > unsigned alloc_count; > size_t total_size; > + char name[RTE_HEAP_NAME_MAX_LEN]; > } __rte_cache_aligned; > > #endif /* _RTE_MALLOC_HEAP_H_ */ > diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/ > malloc_heap.c > index e7e1838b1..8f22c062b 100644 > --- a/lib/librte_eal/common/malloc_heap.c > +++ b/lib/librte_eal/common/malloc_heap.c > @@ -848,6 +848,7 @@ malloc_heap_dump(struct malloc_heap *heap, FILE *f) > > rte_spinlock_lock(&heap->lock); > > + fprintf(f, "Heap name: %s\n", heap->name); > fprintf(f, "Heap size: 0x%zx\n", heap->total_size); > fprintf(f, "Heap alloc count: %u\n", heap->alloc_count); > > @@ -864,6 +865,18 @@ int > rte_eal_malloc_heap_init(void) > { > struct rte_mem_config *mcfg = rte_eal_get_configuration()-> > mem_config; > + unsigned int i; > + > + /* assign names to default DPDK heaps */ > + for (i = 0; i < rte_socket_count(); i++) { > + struct malloc_heap *heap = &mcfg->malloc_heaps[i]; > + char heap_name[RTE_HEAP_NAME_MAX_LEN]; > + int socket_id = rte_socket_id_by_idx(i); > + > + snprintf(heap_name, sizeof(heap_name) - 1, > + "socket_%i", socket_id); > + strlcpy(heap->name, heap_name, RTE_HEAP_NAME_MAX_LEN); > + } > > if (register_mp_requests()) { > RTE_LOG(ERR, EAL, "Couldn't register malloc multiprocess > actions\n"); > diff --git a/lib/librte_eal/common/rte_malloc.c > b/lib/librte_eal/common/rte_malloc.c > index 4387bc494..75d6e0b4d 100644 > --- a/lib/librte_eal/common/rte_malloc.c > +++ b/lib/librte_eal/common/rte_malloc.c > @@ -198,6 +198,7 @@ rte_malloc_dump_stats(FILE *f, __rte_unused const char > *type) > malloc_heap_get_stats(heap, &sock_stats); > > fprintf(f, "Heap id:%u\n", heap_id); > + fprintf(f, "\tHeap name:%s\n", heap->name); > fprintf(f, "\tHeap_size:%zu,\n", > sock_stats.heap_totalsz_bytes); > fprintf(f, "\tFree_size:%zu,\n", > sock_stats.heap_freesz_bytes); > fprintf(f, "\tAlloc_size:%zu,\n", > sock_stats.heap_allocsz_bytes); > -- > 2.17.1 > Acked: Alejandro Lucero