From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 38CEB1B1BC for ; Wed, 24 Jan 2018 16:36:25 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E03752239B; Wed, 24 Jan 2018 10:36:24 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:36:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=pXKYvdkcX7O1deVZq NWg0hhYtSOxKrON5SnEsxdrPhc=; b=I1HvcUjbdZwivj5xJ2p+42SrAVGmUWqW2 BdPNIbOPjGnSs8AW5lM46oRqPJ9nyEzise/BkqDt9sYM7M0EiP9SYSVr2d307ONX RDjoUE4hu+SiHMkrsR2qFyZ5GUTCu2mWhSThXWdrjzUZG3QjNa8XHfgaS7cJMgBf 1YVPuiKXdFsC8tT6BDOxkaRYBVhHONidXyZfsbk5duB7/Qz8fCZ0yn96UWVKbN6C vhzHKeAg5LmCEO0wTw6x3OLipL4LTdattwZr3flNXplgaUK525ESUzGaw6abUWR2 HaG4IXVneyrGX24FeCS/5i7LylqCZQ7QT6TQbdld6wTds5vuDqIOA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=pXKYvdkcX7O1deVZqNWg0hhYtSOxKrON5SnEsxdrPhc=; b=cX0fyTXL X6jGYfqWFdxtDGhOKmZi2iQI7uoRFftrvgPcIXEtuRKEbB5XXlkZNUUgDDvYaFYh PNLzDQ3jXgS69hKdyi6UHKYrBVz2GWx4KV1HoaAqneUImEHg3A8evUSRC+QHSztX lw7EuNHoAUbGifngDR3vScPWDysQ/umYoh3NU7GUyUEvR94XZQH071XZ7V3z6E+9 3PkRt0E0spXuH4g8lg90nYmBssza3sj22b+NgyvS2sF9W84N6Iwc1LXXYfOaX1Fu TpGHMtYAwieP3U/9W/CBAIlzQl7qDtIChAUxnQOqa/D5YgY62XMJVfLfomh09T1R SrFQELlGnudWcw== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 7D80F7E1A2; Wed, 24 Jan 2018 10:36:23 -0500 (EST) From: Yuanhan Liu To: Anatoly Burakov Cc: dpdk stable Date: Wed, 24 Jan 2018 23:31:21 +0800 Message-Id: <1516808026-25523-13-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'malloc: protect stats with lock' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 15:36:25 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From fa38beb1544757d515247cf719148326738be146 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Thu, 21 Dec 2017 17:32:04 +0000 Subject: [PATCH] malloc: protect stats with lock [ upstream commit f13d705a619d7a7e04d51b686dd62e890ecf1bd5 ] When we're gathering statistics, we are traversing the freelist, which may change under our feet in multithreaded scenario. This is verified by occasional segfaults when running malloc autotest on a machine with big amount of cores. This patch protects malloc heap stats call with a lock. It changes its definition in the process due to locking invalidating the const-ness, but this isn't a public API, so that's OK. Fixes: 2a5c356e177d ("memory: stats for malloc") Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/malloc_heap.c | 6 +++++- lib/librte_eal/common/malloc_heap.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c index 267a4c6..c731f1c 100644 --- a/lib/librte_eal/common/malloc_heap.c +++ b/lib/librte_eal/common/malloc_heap.c @@ -178,12 +178,14 @@ malloc_heap_alloc(struct malloc_heap *heap, * Function to retrieve data for heap on given socket */ int -malloc_heap_get_stats(const struct malloc_heap *heap, +malloc_heap_get_stats(struct malloc_heap *heap, struct rte_malloc_socket_stats *socket_stats) { size_t idx; struct malloc_elem *elem; + rte_spinlock_lock(&heap->lock); + /* Initialise variables for heap */ socket_stats->free_count = 0; socket_stats->heap_freesz_bytes = 0; @@ -205,6 +207,8 @@ malloc_heap_get_stats(const struct malloc_heap *heap, socket_stats->heap_allocsz_bytes = (socket_stats->heap_totalsz_bytes - socket_stats->heap_freesz_bytes); socket_stats->alloc_count = heap->alloc_count; + + rte_spinlock_unlock(&heap->lock); return 0; } diff --git a/lib/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h index 3ccbef0..3b1166f 100644 --- a/lib/librte_eal/common/malloc_heap.h +++ b/lib/librte_eal/common/malloc_heap.h @@ -57,7 +57,7 @@ malloc_heap_alloc(struct malloc_heap *heap, const char *type, size_t size, unsigned flags, size_t align, size_t bound); int -malloc_heap_get_stats(const struct malloc_heap *heap, +malloc_heap_get_stats(struct malloc_heap *heap, struct rte_malloc_socket_stats *socket_stats); int -- 2.7.4