From patchwork Tue Oct 4 09:44:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 117289 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C826A0543; Tue, 4 Oct 2022 11:45:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3459F42B72; Tue, 4 Oct 2022 11:44:58 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 3B20342B76 for ; Tue, 4 Oct 2022 11:44:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664876695; 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=p2CeqGuwdodcqTMN9W3anq3x+uDMol12LmR+/qVpb/E=; b=TQkxY1Tj50Qy9T5sOUpsqt+sfpW72Rp184Cp5XRd9NJYakfl1Pf6YZ61SaTvr0EbXspUWO hCRJSPxlf66nLX8ndYOLQTq70qz5MOu9sckVSJBprPytPSygWyfCPhRUnm6BaJ2haCiQFz Ezj7bS4sADttTD6fFNYLeinO2F+a9S8= 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-635-2_Y76tN3NUW9MSFh7SWruw-1; Tue, 04 Oct 2022 05:44:54 -0400 X-MC-Unique: 2_Y76tN3NUW9MSFh7SWruw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A420858F13; Tue, 4 Oct 2022 09:44:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3963D492B04; Tue, 4 Oct 2022 09:44:53 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: skori@mavell.com, jerinj@marvell.com, stable@dpdk.org, Sunil Kumar Kori Subject: [PATCH v2 6/9] trace: fix race in debug dump Date: Tue, 4 Oct 2022 11:44:15 +0200 Message-Id: <20221004094418.196544-7-david.marchand@redhat.com> In-Reply-To: <20221004094418.196544-1-david.marchand@redhat.com> References: <20220921120359.2201131-1-david.marchand@redhat.com> <20221004094418.196544-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Acked-by: Sunil Kumar Kori --- 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 6aa11a3b50..ec168e37b3 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -259,10 +259,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++) { @@ -273,6 +272,7 @@ trace_lcore_mem_dump(FILE *f) header->stream_header.lcore_id, header->stream_header.thread_name); } +out: rte_spinlock_unlock(&trace->lock); }