* [PATCH v6] raw/ifpga: fix pthread cannot join [not found] <20220121033246.10339-1-wei.huang> @ 2022-01-22 4:35 ` Wei Huang 2022-01-24 2:39 ` [PATCH v7] " Wei Huang 0 siblings, 1 reply; 5+ messages in thread From: Wei Huang @ 2022-01-22 4:35 UTC (permalink / raw) To: dev, rosen.xu, qi.z.zhang Cc: stable, tianfei.zhang, ferruh.yigit, stephen, david.marchand From: Tianfei Zhang <tianfei.zhang@intel.com> When we want to close a thread, we should set a flag to notify thread handler function. Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree") Cc: stable@dpdk.org Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com> --- v2: update commit log --- v3: set thread id to 0 after pthread_join --- v4: do not evaluate and set pthread_t variable --- v5: use builtin atomic function to access ifpga_monitor_start flag --- v6: use __atomic_xxx_n to replace rte_atomicNN_xxx --- drivers/raw/ifpga/ifpga_rawdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 8d9db58..19c2357 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -497,7 +497,7 @@ static int set_surprise_link_check_aer( int gsd_enable, ret; #define MS 1000 - while (1) { + while (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { gsd_enable = 0; for (i = 0; i < IFPGA_RAWDEV_NUM; i++) { ifpga_rdev = &ifpga_rawdevices[i]; @@ -525,7 +525,7 @@ static int set_surprise_link_check_aer( { int ret; - if (ifpga_monitor_start == 0) { + if (!__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { ret = rte_ctrl_thread_create(&ifpga_monitor_start_thread, "ifpga-monitor", NULL, ifpga_rawdev_gsd_handle, NULL); @@ -534,7 +534,7 @@ static int set_surprise_link_check_aer( "Fail to create ifpga nonitor thread"); return -1; } - ifpga_monitor_start = 1; + __atomic_store_n(&ifpga_monitor_start, 1, __ATOMIC_RELAXED); } return 0; @@ -544,7 +544,9 @@ static int set_surprise_link_check_aer( { int ret; - if (ifpga_monitor_start == 1) { + if (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { + __atomic_store_n(&ifpga_monitor_start, 0, __ATOMIC_RELAXED); + ret = pthread_cancel(ifpga_monitor_start_thread); if (ret) IFPGA_RAWDEV_PMD_ERR("Can't cancel the thread"); @@ -553,8 +555,6 @@ static int set_surprise_link_check_aer( if (ret) IFPGA_RAWDEV_PMD_ERR("Can't join the thread"); - ifpga_monitor_start = 0; - return ret; } -- 1.8.3.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v7] raw/ifpga: fix pthread cannot join 2022-01-22 4:35 ` [PATCH v6] raw/ifpga: fix pthread cannot join Wei Huang @ 2022-01-24 2:39 ` Wei Huang 2022-01-24 3:50 ` [PATCH v8] " Wei Huang 0 siblings, 1 reply; 5+ messages in thread From: Wei Huang @ 2022-01-24 2:39 UTC (permalink / raw) To: dev, rosen.xu, qi.z.zhang Cc: stable, tianfei.zhang, ferruh.yigit, stephen, david.marchand From: Tianfei Zhang <tianfei.zhang@intel.com> When we want to close a thread, we should set a flag to notify thread handler function. Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree") Cc: stable@dpdk.org Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com> --- v2: update commit log --- v3: set thread id to 0 after pthread_join --- v4: do not evaluate and set pthread_t variable --- v5: use builtin atomic function to access ifpga_monitor_start flag --- v6: use __atomic_xxx_n to replace rte_atomicNN_xxx --- v7: fix patch applying issue --- drivers/raw/ifpga/ifpga_rawdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 8d9db58..719f3b0 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -497,7 +497,7 @@ static int set_surprise_link_check_aer( int gsd_enable, ret; #define MS 1000 - while (1) { + while (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { gsd_enable = 0; for (i = 0; i < IFPGA_RAWDEV_NUM; i++) { ifpga_rdev = &ifpga_rawdevices[i]; @@ -525,16 +525,16 @@ static int set_surprise_link_check_aer( { int ret; - if (ifpga_monitor_start == 0) { + if (!__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { ret = rte_ctrl_thread_create(&ifpga_monitor_start_thread, "ifpga-monitor", NULL, ifpga_rawdev_gsd_handle, NULL); if (ret != 0) { IFPGA_RAWDEV_PMD_ERR( - "Fail to create ifpga nonitor thread"); + "Fail to create ifpga monitor thread"); return -1; } - ifpga_monitor_start = 1; + __atomic_store_n(&ifpga_monitor_start, 1, __ATOMIC_RELAXED); } return 0; @@ -544,7 +544,9 @@ static int set_surprise_link_check_aer( { int ret; - if (ifpga_monitor_start == 1) { + if (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { + __atomic_store_n(&ifpga_monitor_start, 0, __ATOMIC_RELAXED); + ret = pthread_cancel(ifpga_monitor_start_thread); if (ret) IFPGA_RAWDEV_PMD_ERR("Can't cancel the thread"); @@ -553,8 +555,6 @@ static int set_surprise_link_check_aer( if (ret) IFPGA_RAWDEV_PMD_ERR("Can't join the thread"); - ifpga_monitor_start = 0; - return ret; } -- 1.8.3.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v8] raw/ifpga: fix pthread cannot join 2022-01-24 2:39 ` [PATCH v7] " Wei Huang @ 2022-01-24 3:50 ` Wei Huang 2022-01-25 1:42 ` Xu, Rosen 0 siblings, 1 reply; 5+ messages in thread From: Wei Huang @ 2022-01-24 3:50 UTC (permalink / raw) To: dev, rosen.xu, qi.z.zhang Cc: stable, tianfei.zhang, ferruh.yigit, stephen, david.marchand From: Tianfei Zhang <tianfei.zhang@intel.com> When we want to close a thread, we should set a flag to notify thread handler function. Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree") Cc: stable@dpdk.org Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com> --- v2: update commit log --- v3: set thread id to 0 after pthread_join --- v4: do not evaluate and set pthread_t variable --- v5: use builtin atomic function to access ifpga_monitor_start flag --- v6: use __atomic_xxx_n to replace rte_atomicNN_xxx --- v7: fix typo --- v8: solve patch applying issue --- drivers/raw/ifpga/ifpga_rawdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 8d9db58..19c2357 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -497,7 +497,7 @@ static int set_surprise_link_check_aer( int gsd_enable, ret; #define MS 1000 - while (1) { + while (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { gsd_enable = 0; for (i = 0; i < IFPGA_RAWDEV_NUM; i++) { ifpga_rdev = &ifpga_rawdevices[i]; @@ -525,7 +525,7 @@ static int set_surprise_link_check_aer( { int ret; - if (ifpga_monitor_start == 0) { + if (!__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { ret = rte_ctrl_thread_create(&ifpga_monitor_start_thread, "ifpga-monitor", NULL, ifpga_rawdev_gsd_handle, NULL); @@ -534,7 +534,7 @@ static int set_surprise_link_check_aer( "Fail to create ifpga monitor thread"); return -1; } - ifpga_monitor_start = 1; + __atomic_store_n(&ifpga_monitor_start, 1, __ATOMIC_RELAXED); } return 0; @@ -544,7 +544,9 @@ static int set_surprise_link_check_aer( { int ret; - if (ifpga_monitor_start == 1) { + if (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { + __atomic_store_n(&ifpga_monitor_start, 0, __ATOMIC_RELAXED); + ret = pthread_cancel(ifpga_monitor_start_thread); if (ret) IFPGA_RAWDEV_PMD_ERR("Can't cancel the thread"); @@ -553,8 +555,6 @@ static int set_surprise_link_check_aer( if (ret) IFPGA_RAWDEV_PMD_ERR("Can't join the thread"); - ifpga_monitor_start = 0; - return ret; } -- 1.8.3.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v8] raw/ifpga: fix pthread cannot join 2022-01-24 3:50 ` [PATCH v8] " Wei Huang @ 2022-01-25 1:42 ` Xu, Rosen 2022-01-25 4:47 ` Zhang, Qi Z 0 siblings, 1 reply; 5+ messages in thread From: Xu, Rosen @ 2022-01-25 1:42 UTC (permalink / raw) To: Huang, Wei, dev, Zhang, Qi Z Cc: stable, Zhang, Tianfei, Yigit, Ferruh, stephen, david.marchand Hi, > -----Original Message----- > From: Huang, Wei <wei.huang@intel.com> > Sent: Monday, January 24, 2022 11:50 > To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z > <qi.z.zhang@intel.com> > Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, Ferruh > <ferruh.yigit@intel.com>; stephen@networkplumber.org; > david.marchand@redhat.com > Subject: [PATCH v8] raw/ifpga: fix pthread cannot join > > From: Tianfei Zhang <tianfei.zhang@intel.com> > > When we want to close a thread, we should set a flag to notify thread > handler function. > > Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree") > Cc: stable@dpdk.org > > Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com> > --- > v2: update commit log > --- > v3: set thread id to 0 after pthread_join > --- > v4: do not evaluate and set pthread_t variable > --- > v5: use builtin atomic function to access ifpga_monitor_start flag > --- > v6: use __atomic_xxx_n to replace rte_atomicNN_xxx > --- > v7: fix typo > --- > v8: solve patch applying issue > --- > drivers/raw/ifpga/ifpga_rawdev.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/raw/ifpga/ifpga_rawdev.c > b/drivers/raw/ifpga/ifpga_rawdev.c > index 8d9db58..19c2357 100644 > --- a/drivers/raw/ifpga/ifpga_rawdev.c > +++ b/drivers/raw/ifpga/ifpga_rawdev.c > @@ -497,7 +497,7 @@ static int set_surprise_link_check_aer( > int gsd_enable, ret; > #define MS 1000 > > - while (1) { > + while (__atomic_load_n(&ifpga_monitor_start, > __ATOMIC_RELAXED)) { > gsd_enable = 0; > for (i = 0; i < IFPGA_RAWDEV_NUM; i++) { > ifpga_rdev = &ifpga_rawdevices[i]; > @@ -525,7 +525,7 @@ static int set_surprise_link_check_aer( { > int ret; > > - if (ifpga_monitor_start == 0) { > + if (!__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { > ret = rte_ctrl_thread_create(&ifpga_monitor_start_thread, > "ifpga-monitor", NULL, > ifpga_rawdev_gsd_handle, NULL); > @@ -534,7 +534,7 @@ static int set_surprise_link_check_aer( > "Fail to create ifpga monitor thread"); > return -1; > } > - ifpga_monitor_start = 1; > + __atomic_store_n(&ifpga_monitor_start, 1, > __ATOMIC_RELAXED); > } > > return 0; > @@ -544,7 +544,9 @@ static int set_surprise_link_check_aer( { > int ret; > > - if (ifpga_monitor_start == 1) { > + if (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { > + __atomic_store_n(&ifpga_monitor_start, 0, > __ATOMIC_RELAXED); > + > ret = pthread_cancel(ifpga_monitor_start_thread); > if (ret) > IFPGA_RAWDEV_PMD_ERR("Can't cancel the > thread"); @@ -553,8 +555,6 @@ static int set_surprise_link_check_aer( > if (ret) > IFPGA_RAWDEV_PMD_ERR("Can't join the thread"); > > - ifpga_monitor_start = 0; > - > return ret; > } > > -- > 1.8.3.1 Acked-by: Rosen Xu <rosen.xu@intel.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v8] raw/ifpga: fix pthread cannot join 2022-01-25 1:42 ` Xu, Rosen @ 2022-01-25 4:47 ` Zhang, Qi Z 0 siblings, 0 replies; 5+ messages in thread From: Zhang, Qi Z @ 2022-01-25 4:47 UTC (permalink / raw) To: Xu, Rosen, Huang, Wei, dev Cc: stable, Zhang, Tianfei, Yigit, Ferruh, stephen, david.marchand > -----Original Message----- > From: Xu, Rosen <rosen.xu@intel.com> > Sent: Tuesday, January 25, 2022 9:43 AM > To: Huang, Wei <wei.huang@intel.com>; dev@dpdk.org; Zhang, Qi Z > <qi.z.zhang@intel.com> > Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, Ferruh > <ferruh.yigit@intel.com>; stephen@networkplumber.org; > david.marchand@redhat.com > Subject: RE: [PATCH v8] raw/ifpga: fix pthread cannot join > > Hi, > > > -----Original Message----- > > From: Huang, Wei <wei.huang@intel.com> > > Sent: Monday, January 24, 2022 11:50 > > To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z > > <qi.z.zhang@intel.com> > > Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, > > Ferruh <ferruh.yigit@intel.com>; stephen@networkplumber.org; > > david.marchand@redhat.com > > Subject: [PATCH v8] raw/ifpga: fix pthread cannot join > > > > From: Tianfei Zhang <tianfei.zhang@intel.com> > > > > When we want to close a thread, we should set a flag to notify thread > > handler function. > > > > Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree") > > Cc: stable@dpdk.org > > > > Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com> > > --- > > v2: update commit log > > --- > > v3: set thread id to 0 after pthread_join > > --- > > v4: do not evaluate and set pthread_t variable > > --- > > v5: use builtin atomic function to access ifpga_monitor_start flag > > --- > > v6: use __atomic_xxx_n to replace rte_atomicNN_xxx > > --- > > v7: fix typo > > --- > > v8: solve patch applying issue > > --- > > drivers/raw/ifpga/ifpga_rawdev.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/raw/ifpga/ifpga_rawdev.c > > b/drivers/raw/ifpga/ifpga_rawdev.c > > index 8d9db58..19c2357 100644 > > --- a/drivers/raw/ifpga/ifpga_rawdev.c > > +++ b/drivers/raw/ifpga/ifpga_rawdev.c > > @@ -497,7 +497,7 @@ static int set_surprise_link_check_aer( > > int gsd_enable, ret; > > #define MS 1000 > > > > - while (1) { > > + while (__atomic_load_n(&ifpga_monitor_start, > > __ATOMIC_RELAXED)) { > > gsd_enable = 0; > > for (i = 0; i < IFPGA_RAWDEV_NUM; i++) { > > ifpga_rdev = &ifpga_rawdevices[i]; @@ -525,7 +525,7 > @@ static int > > set_surprise_link_check_aer( { > > int ret; > > > > - if (ifpga_monitor_start == 0) { > > + if (!__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { > > ret = rte_ctrl_thread_create(&ifpga_monitor_start_thread, > > "ifpga-monitor", NULL, > > ifpga_rawdev_gsd_handle, NULL); > @@ -534,7 +534,7 @@ static > > int set_surprise_link_check_aer( > > "Fail to create ifpga monitor thread"); > > return -1; > > } > > - ifpga_monitor_start = 1; > > + __atomic_store_n(&ifpga_monitor_start, 1, > > __ATOMIC_RELAXED); > > } > > > > return 0; > > @@ -544,7 +544,9 @@ static int set_surprise_link_check_aer( { > > int ret; > > > > - if (ifpga_monitor_start == 1) { > > + if (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { > > + __atomic_store_n(&ifpga_monitor_start, 0, > > __ATOMIC_RELAXED); > > + > > ret = pthread_cancel(ifpga_monitor_start_thread); > > if (ret) > > IFPGA_RAWDEV_PMD_ERR("Can't cancel the > thread"); @@ -553,8 +555,6 > > @@ static int set_surprise_link_check_aer( > > if (ret) > > IFPGA_RAWDEV_PMD_ERR("Can't join the thread"); > > > > - ifpga_monitor_start = 0; > > - > > return ret; > > } > > > > -- > > 1.8.3.1 > > Acked-by: Rosen Xu <rosen.xu@intel.com> Applied to dpdk-next-net-intel. Thanks Qi > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-25 4:47 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20220121033246.10339-1-wei.huang> 2022-01-22 4:35 ` [PATCH v6] raw/ifpga: fix pthread cannot join Wei Huang 2022-01-24 2:39 ` [PATCH v7] " Wei Huang 2022-01-24 3:50 ` [PATCH v8] " Wei Huang 2022-01-25 1:42 ` Xu, Rosen 2022-01-25 4:47 ` 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).