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 BB70EA04FD for ; Wed, 26 Oct 2022 22:15:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B527A40A7E; Wed, 26 Oct 2022 22:15:01 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 17DFE400D5 for ; Wed, 26 Oct 2022 22:14:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666815300; x=1698351300; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rla/WUE/20iqarM2vHY+BTZHv3GAuPANBF4NmRDABAg=; b=oIb2fi0OLK/OHlXwrd3pg7nv5qjHnrMHFtiWRDbABgcTBP+E2toQoQDp 6BlecKc+nXQ5peNLA/X50KF/6DFLA8SgpK6AraLGuGwCC5Rc+zkjbchUr rJy38Hv0bRtPTtLM+hIOO+Rny0PY/J4w4wm0qAylEi++hvuIwmXeKGISd kEmMVFrhFK5AT1tRLbu8M3tRvNiIaEW9Xivx8hEFcVhve3fdEmQJpMHd+ HDwT7mVuEy2RDWNWauKxxNTdRkbRskaoKP1C3tYnU2xmeqXfks7lecggL 1Fy8KbreP4HuKwAkDkwWVXaEbEolOnRvQHY+6z1UKYNhZzyLQ29T7DDd3 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="295457915" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="295457915" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 13:14:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="610096671" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="610096671" Received: from txandevlnx321.an.intel.com ([10.123.117.43]) by orsmga006.jf.intel.com with ESMTP; 26 Oct 2022 13:14:55 -0700 From: Erik Gabriel Carrillo To: stable@dpdk.org Cc: harry.van.haaren@intel.com Subject: [PATCH 21.11] service: fix early move to inactive status Date: Wed, 26 Oct 2022 15:14:42 -0500 Message-Id: <20221026201442.3062175-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: 6550113be62d ("service: fix lingering active status") Acked-by: Harry van Haaren Signed-off-by: Erik Gabriel Carrillo --- lib/eal/common/rte_service.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/eal/common/rte_service.c b/lib/eal/common/rte_service.c index e76c2baffc..a7775b99dd 100644 --- a/lib/eal/common/rte_service.c +++ b/lib/eal/common/rte_service.c @@ -478,6 +478,12 @@ service_runner_func(void *arg) cs->loops++; } + /* 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; + /* Use SEQ CST memory ordering to avoid any re-ordering around * this store, ensuring that once this store is visible, the service * lcore thread really is done in service cores code. @@ -774,11 +780,6 @@ rte_service_lcore_stop(uint32_t lcore) __atomic_load_n(&rte_services[i].num_mapped_cores, __ATOMIC_RELAXED)); - /* 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