Skip to contentSkip to conversation

fix coredump when in secondary process

PATCH Applied Guoyang Zhou 2 participants 4 messages Mar 23, 2021 – Mar 30, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

v2 cover fix coredump when in secondary process

Some apps, such as fstack, will use secondary process to access the memory of eth_dev_ops, and they want to get the info of dev, but hinic driver does not initialized it when in secondary process.

--
v1->v2:
- modify the patch title

v1:
- fix coredump when PMD used by fstack

Guoyang Zhou (1):
net/hinic: fix coredump when in secondary process

 drivers/net/hinic/base/hinic_compat.h | 25 ++++++++-----------------
 drivers/net/hinic/hinic_pmd_ethdev.c  |  5 +++++
 2 files changed, 13 insertions(+), 17 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 net/hinic: fix coredump when in secondary process

Some apps, such as fstack, will use secondary process to access the memory of eth_dev_ops, and they want to get the info of dev, but hinic driver does not initialized it when in secondary process.

Fixes 66f64dd6dc86 ("net/hinic: fix secondary process")
---
 drivers/net/hinic/base/hinic_compat.h | 25 ++++++++-----------------
 drivers/net/hinic/hinic_pmd_ethdev.c  |  5 +++++
 2 files changed, 13 insertions(+), 17 deletions(-)
drivers/net/hinic/base/hinic_compat.h +8 -17
index 6dd210e..aea3320 100644
@@ -171,6 +171,7 @@ static inline u32 readl(const volatile void *addr)
 #else
 #define CLOCK_TYPE CLOCK_MONOTONIC
 #endif
+#define HINIC_MUTEX_TIMEOUT  10
 
 static inline unsigned long clock_gettime_ms(void)
 {
@@ -225,24 +226,14 @@ static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex)
 static inline int hinic_mutex_lock(pthread_mutex_t *pthreadmutex)
 {
 	int err;
+	struct timespec tout;
 
-	err = pthread_mutex_lock(pthreadmutex);
-	if (!err) {
-		return err;
-	} else if (err == EOWNERDEAD) {
-		PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", errno);
-#if defined(__GLIBC__)
-#if __GLIBC_PREREQ(2, 12)
-		(void)pthread_mutex_consistent(pthreadmutex);
-#else
-		(void)pthread_mutex_consistent_np(pthreadmutex);
-#endif
-#else
-		(void)pthread_mutex_consistent(pthreadmutex);
-#endif
-	} else {
-		PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", errno);
-	}
+	(void)clock_gettime(CLOCK_TYPE, &tout);
+
+	tout.tv_sec += HINIC_MUTEX_TIMEOUT;
+	err = pthread_mutex_timedlock(pthreadmutex, &tout);
+	if (err)
+		PMD_DRV_LOG(ERR, "Mutex lock failed. (ErrorNo=%d)", err);
 
 	return err;
 }
drivers/net/hinic/hinic_pmd_ethdev.c +5 -0
index 1d6b710..057e7b1 100644
@@ -3085,6 +3085,10 @@ static int hinic_dev_close(struct rte_eth_dev *dev)
 	.filter_ctrl                   = hinic_dev_filter_ctrl,
 };
 
+static const struct eth_dev_ops hinic_dev_sec_ops = {
+	.dev_infos_get                 = hinic_dev_infos_get,
+};
+
 static int hinic_func_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
@@ -3099,6 +3103,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)
 
 	/* EAL is SECONDARY and eth_dev is already created */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		eth_dev->dev_ops = &hinic_dev_sec_ops;
 		PMD_DRV_LOG(INFO, "Initialize %s in secondary process",
 			    eth_dev->data->name);
 
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 1/1] net/hinic: fix coredump when in secondary process

Quoted 7 lines · Guoyang Zhou

Some apps, such as fstack, will use secondary process to access the memory of eth_dev_ops, and they want to get the info of dev, but hinic driver does not initialized it when in secondary process.

Fixes 66f64dd6dc86 ("net/hinic: fix secondary process")

Some comments from previous versions seems outstanding, can you please check/comment on them please:

http://inbox.dpdk.org/dev/[email protected]/

Also can you please send a new version as reply to previous version?
This keeps different versions in same email thread and helps to find the comments/discussing to previous versions easier. You can do this via "git send-email", '--in-reply-to' argument.

Applied
#3 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v2 1/1] net/hinic: fix coredump when in secondary process

In reply to Guoyang Zhou
Quoted 7 lines · Guoyang Zhou

Some apps, such as fstack, will use secondary process to access the memory of eth_dev_ops, and they want to get the info of dev, but hinic driver does not initialized it when in secondary process.

Fixes 66f64dd6dc86 ("net/hinic: fix secondary process")

Applied to dpdk-next-net/main, thanks.