From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 155E1A0679 for ; Mon, 1 Apr 2019 16:18:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 02293378E; Mon, 1 Apr 2019 16:18:55 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id BF44811A4; Mon, 1 Apr 2019 16:18:52 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 07:18:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,296,1549958400"; d="scan'208";a="136586901" Received: from ultraviolet.igk.intel.com ([10.102.17.137]) by fmsmga008.fm.intel.com with ESMTP; 01 Apr 2019 07:18:50 -0700 From: Darek Stojaczyk To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, Darek Stojaczyk , Qi Zhang , Anatoly Burakov , stable@dpdk.org Date: Mon, 1 Apr 2019 16:18:14 +0200 Message-Id: <20190401141814.8096-1-dariusz.stojaczyk@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190326184331.13850-1-dariusz.stojaczyk@intel.com> References: <20190326184331.13850-1-dariusz.stojaczyk@intel.com> Subject: [dpdk-dev] [PATCH v2] eal: initialize alarms early 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190401141814.AfTtbppZZminxWMVz73g7Wfux93pXot7NxiNpZQxfOk@z> On linux, we currently initialize rte_alarms after starting to listen for IPC hotplug requests, which gives us a data race window. Upon receiving such hotplug request we always try to set an alarm and this obviously doesn't work if the alarms weren't initialized yet. To fix it, we initialize alarms before starting to listen for IPC hotplug messages. Specifically, we move rte_eal_alarm_init() right after rte_eal_intr_init() as it makes some sense to keep those two close to each other. We update the bsd code as well to keep the initialization order the same in both eal implementations. Fixes: 244d5130719c ("eal: enable hotplug on multi-process") Cc: Qi Zhang Cc: Anatoly Burakov Cc: stable@dpdk.org Signed-off-by: Darek Stojaczyk --- v2: - updated the bsd code as well (Thomas) lib/librte_eal/freebsd/eal/eal.c | 12 ++++++------ lib/librte_eal/linux/eal/eal.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c index 4e86b10b1..790c6afa7 100644 --- a/lib/librte_eal/freebsd/eal/eal.c +++ b/lib/librte_eal/freebsd/eal/eal.c @@ -662,6 +662,12 @@ rte_eal_init(int argc, char **argv) return -1; } + if (rte_eal_alarm_init() < 0) { + rte_eal_init_alert("Cannot init interrupt-handling thread"); + /* rte_eal_alarm_init sets rte_errno on failure. */ + return -1; + } + /* Put mp channel init before bus scan so that we can init the vdev * bus through mp channel in the secondary process before the bus scan. */ @@ -751,12 +757,6 @@ rte_eal_init(int argc, char **argv) return -1; } - if (rte_eal_alarm_init() < 0) { - rte_eal_init_alert("Cannot init interrupt-handling thread"); - /* rte_eal_alarm_init sets rte_errno on failure. */ - return -1; - } - if (rte_eal_timer_init() < 0) { rte_eal_init_alert("Cannot init HPET or TSC timers"); rte_errno = ENOTSUP; diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c index 13f401684..75ed0cf10 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -1005,6 +1005,12 @@ rte_eal_init(int argc, char **argv) return -1; } + if (rte_eal_alarm_init() < 0) { + rte_eal_init_alert("Cannot init interrupt-handling thread"); + /* rte_eal_alarm_init sets rte_errno on failure. */ + return -1; + } + /* Put mp channel init before bus scan so that we can init the vdev * bus through mp channel in the secondary process before the bus scan. */ @@ -1125,12 +1131,6 @@ rte_eal_init(int argc, char **argv) return -1; } - if (rte_eal_alarm_init() < 0) { - rte_eal_init_alert("Cannot init interrupt-handling thread"); - /* rte_eal_alarm_init sets rte_errno on failure. */ - return -1; - } - if (rte_eal_timer_init() < 0) { rte_eal_init_alert("Cannot init HPET or TSC timers"); rte_errno = ENOTSUP; -- 2.17.1