* [PATCH] net/iavf: fix ASan error caused by watchdog
@ 2023-08-02 7:15 Zhichao Zeng
2023-08-14 9:09 ` [PATCH v2] net/iavf: refactor part of watchdog Zhichao Zeng
0 siblings, 1 reply; 3+ messages in thread
From: Zhichao Zeng @ 2023-08-02 7:15 UTC (permalink / raw)
To: dev; +Cc: qi.z.zhang, songx.jiale, Zhichao Zeng, Jingjing Wu, Beilei Xing
Cancel rte alarm when closing the watchdog at the same time to avoid
ASan error, and optimize the prompt when opening and closing
the watchdog.
Fixes: af801b0374e3 ("net/iavf: add devargs to control watchdog")
Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
drivers/net/iavf/iavf_ethdev.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index f2fc5a5621..c0ca733c67 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -324,24 +324,31 @@ iavf_dev_watchdog(void *cb_arg)
void
iavf_dev_watchdog_enable(struct iavf_adapter *adapter)
{
- if (adapter->devargs.watchdog_period && !adapter->vf.watchdog_enabled) {
- PMD_DRV_LOG(INFO, "Enabling device watchdog, period is %dμs",
- adapter->devargs.watchdog_period);
- adapter->vf.watchdog_enabled = true;
- if (rte_eal_alarm_set(adapter->devargs.watchdog_period,
- &iavf_dev_watchdog, (void *)adapter))
- PMD_DRV_LOG(ERR, "Failed to enabled device watchdog");
- } else {
+ if (!adapter->devargs.watchdog_period) {
PMD_DRV_LOG(INFO, "Device watchdog is disabled");
+ } else {
+ if (!adapter->vf.watchdog_enabled) {
+ PMD_DRV_LOG(INFO, "Enabling device watchdog, period is %dμs",
+ adapter->devargs.watchdog_period);
+ adapter->vf.watchdog_enabled = true;
+ if (rte_eal_alarm_set(adapter->devargs.watchdog_period,
+ &iavf_dev_watchdog, (void *)adapter))
+ PMD_DRV_LOG(ERR, "Failed to enable device watchdog");
+ }
}
}
void
iavf_dev_watchdog_disable(struct iavf_adapter *adapter)
{
- if (adapter->devargs.watchdog_period && adapter->vf.watchdog_enabled) {
- PMD_DRV_LOG(INFO, "Disabling device watchdog");
- adapter->vf.watchdog_enabled = false;
+ if (!adapter->devargs.watchdog_period) {
+ PMD_DRV_LOG(INFO, "Device watchdog is not enabled");
+ } else {
+ if (adapter->vf.watchdog_enabled) {
+ PMD_DRV_LOG(INFO, "Disabling device watchdog");
+ adapter->vf.watchdog_enabled = false;
+ rte_eal_alarm_cancel(&iavf_dev_watchdog, (void *)adapter);
+ }
}
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] net/iavf: refactor part of watchdog
2023-08-02 7:15 [PATCH] net/iavf: fix ASan error caused by watchdog Zhichao Zeng
@ 2023-08-14 9:09 ` Zhichao Zeng
2023-08-14 12:01 ` Zhang, Qi Z
0 siblings, 1 reply; 3+ messages in thread
From: Zhichao Zeng @ 2023-08-14 9:09 UTC (permalink / raw)
To: dev; +Cc: qi.z.zhang, songx.jiale, Zhichao Zeng, Jingjing Wu, Beilei Xing
This commit refactors two parts of the watchdog:
1. Cancel the rte_eal_alarm when closing the watchdog to avoid
ASAN heap-use-after-free error in some conditions.
2. Modify the logs when enabling and disabling the watchdog to be
more detailed.
Fixes: af801b0374e3 ("net/iavf: add devargs to control watchdog")
Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
v2: improve git log
---
drivers/net/iavf/iavf_ethdev.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index f2fc5a5621..c0ca733c67 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -324,24 +324,31 @@ iavf_dev_watchdog(void *cb_arg)
void
iavf_dev_watchdog_enable(struct iavf_adapter *adapter)
{
- if (adapter->devargs.watchdog_period && !adapter->vf.watchdog_enabled) {
- PMD_DRV_LOG(INFO, "Enabling device watchdog, period is %dμs",
- adapter->devargs.watchdog_period);
- adapter->vf.watchdog_enabled = true;
- if (rte_eal_alarm_set(adapter->devargs.watchdog_period,
- &iavf_dev_watchdog, (void *)adapter))
- PMD_DRV_LOG(ERR, "Failed to enabled device watchdog");
- } else {
+ if (!adapter->devargs.watchdog_period) {
PMD_DRV_LOG(INFO, "Device watchdog is disabled");
+ } else {
+ if (!adapter->vf.watchdog_enabled) {
+ PMD_DRV_LOG(INFO, "Enabling device watchdog, period is %dμs",
+ adapter->devargs.watchdog_period);
+ adapter->vf.watchdog_enabled = true;
+ if (rte_eal_alarm_set(adapter->devargs.watchdog_period,
+ &iavf_dev_watchdog, (void *)adapter))
+ PMD_DRV_LOG(ERR, "Failed to enable device watchdog");
+ }
}
}
void
iavf_dev_watchdog_disable(struct iavf_adapter *adapter)
{
- if (adapter->devargs.watchdog_period && adapter->vf.watchdog_enabled) {
- PMD_DRV_LOG(INFO, "Disabling device watchdog");
- adapter->vf.watchdog_enabled = false;
+ if (!adapter->devargs.watchdog_period) {
+ PMD_DRV_LOG(INFO, "Device watchdog is not enabled");
+ } else {
+ if (adapter->vf.watchdog_enabled) {
+ PMD_DRV_LOG(INFO, "Disabling device watchdog");
+ adapter->vf.watchdog_enabled = false;
+ rte_eal_alarm_cancel(&iavf_dev_watchdog, (void *)adapter);
+ }
}
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v2] net/iavf: refactor part of watchdog
2023-08-14 9:09 ` [PATCH v2] net/iavf: refactor part of watchdog Zhichao Zeng
@ 2023-08-14 12:01 ` Zhang, Qi Z
0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Qi Z @ 2023-08-14 12:01 UTC (permalink / raw)
To: Zeng, ZhichaoX, dev; +Cc: Jiale, SongX, Wu, Jingjing, Xing, Beilei
> -----Original Message-----
> From: Zeng, ZhichaoX <zhichaox.zeng@intel.com>
> Sent: Monday, August 14, 2023 5:10 PM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Jiale, SongX <songx.jiale@intel.com>;
> Zeng, ZhichaoX <zhichaox.zeng@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Subject: [PATCH v2] net/iavf: refactor part of watchdog
>
> This commit refactors two parts of the watchdog:
> 1. Cancel the rte_eal_alarm when closing the watchdog to avoid
> ASAN heap-use-after-free error in some conditions.
> 2. Modify the logs when enabling and disabling the watchdog to be
> more detailed.
>
> Fixes: af801b0374e3 ("net/iavf: add devargs to control watchdog")
> Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Applied to dpdk-next-net-intel.
Thanks
Qi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-14 12:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02 7:15 [PATCH] net/iavf: fix ASan error caused by watchdog Zhichao Zeng
2023-08-14 9:09 ` [PATCH v2] net/iavf: refactor part of watchdog Zhichao Zeng
2023-08-14 12:01 ` Zhang, Qi Z
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).