From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 25CC01B2C5 for ; Fri, 26 Jan 2018 14:14:13 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id b21so21149896wme.4 for ; Fri, 26 Jan 2018 05:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=51H6tAfmNEdnH2QbTc7yV+RwaA9YxEww7LZxwyo9Q08=; b=Qgnqq+ZEt3MlsWtJ+9BA78Z3fXxZc9N+kp0kiyNVvLMmZjrKlueFtxP6CNzogkx0YX s8f87Viol1i8KxeVpBQy82fcgJRZVTapgU9Ak29MYXBDUpN8gzbsMcumrlgM963VKFWP dczJkqA9m/i41bXOkxZ524NVDXv3jgu9fpm8SZuqBnwBkSw5rKqDs117ongiN28Y4LUk CeJwTV/FY3KsGVavz8jX05caTO86SSB2VYIYZWQY2UST2vCUyPVVtq2Kt/FzZAsGBAdY v8rL1PYwH30PVQZ3lVss1qew1miCD/+92f398OWtipXmO5OKO0fu1XtaLy6IGVPB/RiF RK2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=51H6tAfmNEdnH2QbTc7yV+RwaA9YxEww7LZxwyo9Q08=; b=gNj3u/T9WVWr5w/MVau43KHGZ0JBmNR+LlrQJ8a1um5un9XzI8e2GbyXSxMCBLRxE+ 1zOQZbdN/CGR6x+KXaL5lt2tpkKASJN9BKYGlZiJYTnwooynWDi5oPyAHjci6keiwyce bhTC6wr+qwPJ+CugDiEpGgVv1Eyz3IDOqILOm70jg9d9R2Ex18ZaZ+ReEHU4p9ftqbH7 biF4iM9FZVApGXbyDxDwmK0UhQ3IAe6J7/KpGgM8G70/TdXqoGjJr9YQhCejQjAGwBbH w75Eh5rF0/tD8uoEU58UF3rrkMePsaiHBevQofo1NSqJH6McdMg0A2NzYnoa06Vsbmfu bBLw== X-Gm-Message-State: AKwxytenKBqElyEWCyhISXNs2WAwmwFoV2mxutleQbNmPCjaUXap7aXH O1eNyAiSODGL5GGHJ0/g8RQGuAOi X-Google-Smtp-Source: AH8x2274qFpl6170uIQc5cQpYTCzYOUqLQajrpvJF9qPppe9g/Lg7UkdaiPbbzNF0LPBCBxkmrVtFw== X-Received: by 10.28.173.20 with SMTP id w20mr9667091wme.15.1516972452854; Fri, 26 Jan 2018 05:14:12 -0800 (PST) Received: from localhost ([2a00:23c5:bef3:400:9531:588b:44ae:bec4]) by smtp.gmail.com with ESMTPSA id b35sm14386866wra.13.2018.01.26.05.14.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2018 05:14:12 -0800 (PST) From: luca.boccassi@gmail.com To: Anatoly Burakov Cc: dpdk stable Date: Fri, 26 Jan 2018 13:12:39 +0000 Message-Id: <20180126131332.15346-9-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180126131332.15346-1-luca.boccassi@gmail.com> References: <20180126131332.15346-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'malloc: protect stats with lock' has been queued to LTS release 16.11.5 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: Fri, 26 Jan 2018 13:14:13 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.5 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/28/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From 4ef2031b7a89aa7bfb75e484dcf81c641cc2dc08 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 267a4c6cd..c731f1cd5 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 3ccbef0fd..3b1166f03 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.14.2