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 13D34A00C4 for ; Wed, 16 Nov 2022 19:34:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 373F540E03; Wed, 16 Nov 2022 19:34:38 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id BDAEF40DFB for ; Wed, 16 Nov 2022 19:34:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668623676; x=1700159676; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PhW0NQXHdgLkKxO4NjrnnUyaB9iFSxNkhc6rhhJ5GV0=; b=A24Jok/OE5tpWPOGLU1WzhJpU+zMbmiWOj0IGWoW9G/IOnY3JuXU6nC8 BwaSDd36jVt0d+ThdcLkilNeKaHwghe/gQuLALK6PhjcwNED960hn95tW kDVisb954b9v89g3dLzZSSWlaYgvzFo43W4M2dj7DsSoAjKtZXx2cDxf/ tOHTotu70W6yinWPOwsRjU7I7inaQKg17EyMU0RC77OMrYLzjz2nSCU6U kvXO26c7ZSL2veUFP2JBRJAGOWqcQmOK6M2BzIG2QP7rsqInizWK3w9zA ayyr2gPQbJ1buaZrupOSgEMJEB5te1ypPYiT0l2JHq9mBlnXlfxgy66fz g==; X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="292334071" X-IronPort-AV: E=Sophos;i="5.96,169,1665471600"; d="scan'208";a="292334071" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2022 10:34:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="814186622" X-IronPort-AV: E=Sophos;i="5.96,169,1665471600"; d="scan'208";a="814186622" Received: from txandevlnx321.an.intel.com ([10.123.117.43]) by orsmga005.jf.intel.com with ESMTP; 16 Nov 2022 10:34:35 -0800 From: Erik Gabriel Carrillo To: harry.van.haaren@intel.com Cc: stable@dpdk.org Subject: [PATCH 19.11] service: fix early move to inactive status Date: Wed, 16 Nov 2022 12:34:30 -0600 Message-Id: <20221116183430.1926243-1-erik.g.carrillo@intel.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 329280c53e6d09002b67e4d052fe27a952bd19cf ] Assume thread T2 is a service lcore that is in the middle of executing a service function. Also, assume thread T1 concurrently calls rte_service_lcore_stop(), which will set the "service_active_on_lcore" state to false. If thread T1 then calls rte_service_may_be_active(), it can return zero even though T2 is still running the service function. If T1 then proceeds to free data being used by T2, a crash can ensue. Move the logic that clears the "service_active_on_lcore" state from the rte_service_lcore_stop() function to the service_runner_func() to ensure that we: - don't let the "service_active_on_lcore" state linger as 1 - don't clear the state early Fixes: 3d3bcdcee4 ("service: fix lingering active status") Signed-off-by: Erik Gabriel Carrillo --- lib/librte_eal/common/rte_service.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index d11027fcb..11cd5a538 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -447,6 +447,12 @@ service_runner_func(void *arg) rte_smp_rmb(); } + /* Switch off this core for all services, to ensure that future + * calls to may_be_active() know this core is switched off. + */ + for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) + cs->service_active_on_lcore[i] = 0; + return 0; } @@ -717,11 +723,6 @@ rte_service_lcore_stop(uint32_t lcore) int32_t only_core = (1 == rte_atomic32_read(&rte_services[i].num_mapped_cores)); - /* Switch off this core for all services, to ensure that future - * calls to may_be_active() know this core is switched off. - */ - cs->service_active_on_lcore[i] = 0; - /* if the core is mapped, and the service is running, and this * is the only core that is mapped, the service would cease to * run if this core stopped, so fail instead. -- 2.23.0