From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 578BAA0540; Wed, 21 Sep 2022 14:04:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77FE542B7A; Wed, 21 Sep 2022 14:04:32 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 47B1442847 for ; Wed, 21 Sep 2022 14:04:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663761869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cifrWHw25GImlqkW1Bb56b2dUNHD3x9taFKDPFbRDFw=; b=UaSRNdgsXMir7Ed8LDC2TJcDgce5ll/qCP12w5sNLRJzXMF+PkFyGwMF171fDz2ej7o5/E DOnOctGA8PEjTRC5x9kH5FHJzoVOG0KSa87HH8Dg/SxhytRows6nel05u6iegFzhpBPnH1 3Cc//IC4CPBBn4dQwg+0sauX7jDxro4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-VyhllJaOMj6O1-almRoQhA-1; Wed, 21 Sep 2022 08:04:28 -0400 X-MC-Unique: VyhllJaOMj6O1-almRoQhA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56075185A7AB; Wed, 21 Sep 2022 12:04:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6526B40C6EC3; Wed, 21 Sep 2022 12:04:27 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Jerin Jacob , Sunil Kumar Kori Subject: [PATCH 5/8] trace: fix race in debug dump Date: Wed, 21 Sep 2022 14:03:56 +0200 Message-Id: <20220921120359.2201131-6-david.marchand@redhat.com> In-Reply-To: <20220921120359.2201131-1-david.marchand@redhat.com> References: <20220921120359.2201131-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org trace->nb_trace_mem_list access must be under trace->lock to avoid races with threads allocating/freeing their trace buffers. Fixes: f6b2d65dcd5d ("trace: implement debug dump") Cc: stable@dpdk.org Signed-off-by: David Marchand --- lib/eal/common/eal_common_trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c index afc4c6dbe5..5280aa7d62 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -255,10 +255,9 @@ trace_lcore_mem_dump(FILE *f) struct __rte_trace_header *header; uint32_t count; - if (trace->nb_trace_mem_list == 0) - return; - rte_spinlock_lock(&trace->lock); + if (trace->nb_trace_mem_list == 0) + goto out; fprintf(f, "nb_trace_mem_list = %d\n", trace->nb_trace_mem_list); fprintf(f, "\nTrace mem info\n--------------\n"); for (count = 0; count < trace->nb_trace_mem_list; count++) { @@ -269,6 +268,7 @@ trace_lcore_mem_dump(FILE *f) header->stream_header.lcore_id, header->stream_header.thread_name); } +out: rte_spinlock_unlock(&trace->lock); } -- 2.37.3