raw/ifpga: fix pthread cannot join
A message that is not in the archive (sent off-list or not yet received): 20220121033246.10339-1-wei.huang
PATCH v6 1/1 raw/ifpga: fix pthread cannot join
From: Tianfei Zhang <[email protected]>
When we want to close a thread, we should set a flag to notify thread handler function.
---
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(-)
drivers/raw/ifpga/ifpga_rawdev.c +6 -6
@@ -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; }
Signature · 1 line
1.8.3.1
PATCH v7 1/1 raw/ifpga: fix pthread cannot join
From: Tianfei Zhang <[email protected]>
When we want to close a thread, we should set a flag to notify thread handler function.
---
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(-)
drivers/raw/ifpga/ifpga_rawdev.c +7 -7
@@ -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; }
Signature · 1 line
1.8.3.1
PATCH v8 1/1 raw/ifpga: fix pthread cannot join
From: Tianfei Zhang <[email protected]>
When we want to close a thread, we should set a flag to notify thread handler function.
---
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(-)
drivers/raw/ifpga/ifpga_rawdev.c +6 -6
@@ -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; }
Signature · 1 line
1.8.3.1
Hi,
Quoted 91 lines
-----Original Message-----
From: Huang, Wei <[email protected]>
Sent: Monday, January 24, 2022 11:50
To: [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Zhang, Tianfei <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v8] raw/ifpga: fix pthread cannot joinFrom: Tianfei Zhang <[email protected]>
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")Signed-off-by Tianfei Zhang <[email protected]>---
v2: update commit log
---
v3: set thread id to 0 afterpthread_join
---
v4: do not evaluate and setpthread_tvariable
---
v5: use builtin atomic function to accessifpga_monitor_startflag
---
v6: use__atomic_xxx_nto replacerte_atomicNN_xxx
---
v7: fix typo
---
v8: solve patch applying issue--- drivers/raw/ifpga/ifpga_rawdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/raw/ifpga/ifpga_rawdev.c +1
-1@@ -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++) {drivers/raw/ifpga/ifpga_rawdev.c +2
-2ifpga_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); }drivers/raw/ifpga/ifpga_rawdev.c +3
-1return 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 thethread"); @@ -553,8 +555,6 @@ static int set_surprise_link_check_aer(
drivers/raw/ifpga/ifpga_rawdev.c +0
-3if (ret)IFPGA_RAWDEV_PMD_ERR ("Can't join the thread" ); - ifpga_monitor_start =0 ; -return ret; } --
Quoted 1 line
1.8.3.1
Zhang, Qi Z
AppliedQuoted 107 lines
-----Original Message-----
From: Xu, Rosen <[email protected]>
Sent: Tuesday, January 25, 2022 9:43 AM
To: Huang, Wei <[email protected]>; [email protected]; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Zhang, Tianfei <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v8] raw/ifpga: fix pthread cannot joinHi,
Quoted 51 lines
-----Original Message-----
From: Huang, Wei <[email protected]>
Sent: Monday, January 24, 2022 11:50
To: [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Zhang, Tianfei <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v8] raw/ifpga: fix pthread cannot joinFrom: Tianfei Zhang <[email protected]>
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")Signed-off-by Tianfei Zhang <[email protected]>---
v2: update commit log
---
v3: set thread id to 0 afterpthread_join
---
v4: do not evaluate and setpthread_tvariable
---
v5: use builtin atomic function to accessifpga_monitor_startflag
---
v6: use__atomic_xxx_nto replacerte_atomicNN_xxx
---
v7: fix typo
---
v8: solve patch applying issue--- drivers/raw/ifpga/ifpga_rawdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/raw/ifpga/ifpga_rawdev.c +1
-1@@ -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++) {Quoted 1 line
ifpga_rdev= &ifpga_rawdevices[i]; @@ -525,7 +525,7@@ static int
Quoted 8 lines
set_surprise_link_check_aer( {
drivers/raw/ifpga/ifpga_rawdev.c +1
-1int 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 );(quoted diff) +0
-0@@ -534,7 +534,7 @@ staticQuoted 11 lines
int set_surprise_link_check_aer(
drivers/raw/ifpga/ifpga_rawdev.c +1
-1"Fail to create ifpga monitor thread");return -1 ; } - ifpga_monitor_start =1 ; + __atomic_store_n(&ifpga_monitor_start, 1,
__ATOMIC_RELAXED);drivers/raw/ifpga/ifpga_rawdev.c +0
-0}return 0 ;drivers/raw/ifpga/ifpga_rawdev.c static int set_surprise_link_check_aer( { · line 552
Quoted 10 lines
drivers/raw/ifpga/ifpga_rawdev.c +3
-1@@ -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 thethread"); @@ -553,8 +555,6
Quoted 9 lines
@@ static int set_surprise_link_check_aer(
drivers/raw/ifpga/ifpga_rawdev.c +0
-2if (ret)IFPGA_RAWDEV_PMD_ERR ("Can't join the thread" ); - ifpga_monitor_start =0 ; -return ret; }
Quoted 4 lines
Quoted 2 lines
--
1.8.3.1Acked-by Rosen Xu <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi