From patchwork Thu Jan 16 19:50:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Conole X-Patchwork-Id: 64818 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0D3FA051A; Thu, 16 Jan 2020 20:50:34 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2732D1D52C; Thu, 16 Jan 2020 20:50:34 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 2609F1D516 for ; Thu, 16 Jan 2020 20:50:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579204231; 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; bh=Hmqv1lA96IIzZun0UOC01oJUfAN6AbyRhPHDBx4FQyY=; b=gfMoncTdCeO1ykAEwvoVXj8ICcIg/PBiRcYheE4/4sk8glj1e8eCKAE6ICfytJy/aYW6BW sMloqNfLZoRz3CKQLpLayVZuxxSLbY/QWDrX/d83mHyyNXI25W1VJd1yZ56HB++zjn838y P5+yGTxdHRRSMTzCR0t/CeM5yK1qU2g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-FzU2DwLdOSa8CLKlAwAsmw-1; Thu, 16 Jan 2020 14:50:29 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC5BD8010C6; Thu, 16 Jan 2020 19:50:27 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (ovpn-124-121.rdu2.redhat.com [10.10.124.121]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 404F38889C; Thu, 16 Jan 2020 19:50:27 +0000 (UTC) From: Aaron Conole To: dev@dpdk.org Cc: Harry Van Haaren , David Marchand Date: Thu, 16 Jan 2020 14:50:26 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: FzU2DwLdOSa8CLKlAwAsmw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [RFC] service: stop lcore threads before 'finalize' 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" I've noticed an occasional segfault from the build system in the service_autotest and after talking with David (CC'd), it seems like it's due to the rte_service_finalize deleting the lcore_states object while active lcores are running. The below patch is an attempt to solve it by first reassigning all the lcores back to ROLE_RTE before releasing the memory. There is probably a larger question for DPDK proper about actually closing the pending lcore threads, but that's a separate issue. I've been running with the patch for a while, and haven't seen the crash anymore on my system. Thoughts? Is it acceptable as-is? --- --- diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index 7e537b8cd2..7d13287bee 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -71,6 +71,8 @@ static struct rte_service_spec_impl *rte_services; static struct core_state *lcore_states; static uint32_t rte_service_library_initialized; +static void service_lcore_uninit(void); + int32_t rte_service_init(void) { @@ -122,6 +124,9 @@ rte_service_finalize(void) if (!rte_service_library_initialized) return; + /* Ensure that all service threads are returned to the ROLE_RTE + */ + service_lcore_uninit(); rte_free(rte_services); rte_free(lcore_states); @@ -897,3 +902,14 @@ rte_service_dump(FILE *f, uint32_t id) return 0; } + +static void service_lcore_uninit(void) +{ + unsigned lcore_id; + RTE_LCORE_FOREACH(lcore_id) { + if (!lcore_states[lcore_id].is_service_core) + continue; + + while (rte_service_lcore_del(lcore_id) == -EBUSY); + } +}