eal: remove redundant code
PATCH 1/2 eal: remove redundant code
The event status has been cleaned up by the CAS operation when we free the event data, so there is no need to set it to invalid after that.
--- lib/librte_eal/linux/eal_interrupts.c | 1 - 1 file changed, 1 deletion(-)
lib/librte_eal/linux/eal_interrupts.c +0 -1
@@ -1431,7 +1431,6 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)if (rte_epoll_ctl (rev->epfd,EPOLL_CTL_DEL , rev->fd, rev)) {/* force free if the entry valid */ eal_epoll_data_safe_free (rev); - rev->status =RTE_EPOLL_INVALID ; } } }
Signature · 1 line
2.7.4
PATCH 2/2 eal: use c11 atomics for interrupt status
The event status is defined as a volatile variable and shared between threads. Use c11 atomics with explicit ordering instead of rte_atomic ops which enforce unnecessary barriers on aarch64.
--- lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 47 ++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 15 deletions(-)
lib/librte_eal/include/rte_eal_interrupts.h +1 -1
@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;
lib/librte_eal/linux/eal_interrupts.c +33 -14
108 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
<snip>
Quoted 1 line
Subject: [PATCH 2/2] eal: use c11 atomics for interrupt status
nit, C11 atomic built-ins ^^^^^^^^^^
Quoted 3 lines
The event status is defined as a volatile variable and shared between threads. Use c11 atomics with explicit ordering instead of
rte_atomicops which
nit, ^^^^^^^^^^ same here
Quoted 4 lines
enforce unnecessary barriers on aarch64.
Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Otherwise, it looks fine.
Quoted 153 lines
--- lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 47 ++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 15 deletions(-)lib/librte_eal/include/rte_eal_interrupts.h +1
-1@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;lib/librte_eal/linux/eal_interrupts.c +9
-3@@ -26,7 +26,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_debug.h> #include <rte_log.h> @@ -1221,11 +1220,18 @@ eal_epoll_process_event(struct epoll_event *evs, unsigned int n, {unsigned int i, count =0 ;struct rte_epoll_event *rev; +uint32_t valid_status;for (i =0 ; i < n; i++) { rev = evs[i].data.ptr; -if (!rev || !rte_atomic32_cmpset (&rev->status,RTE_EPOLL_VALID , -RTE_EPOLL_EXEC )) + valid_status =RTE_EPOLL_VALID ; +/* ACQUIRE memory ordering here pairs with RELEASE +* ordering bellow acting as a lock to synchronize +* the event data updating. +*/ +if (!rev || !__atomic_compare_exchange_n (&rev->status, + &valid_status,RTE_EPOLL_EXEC ,0 , + __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))continue ;lib/librte_eal/linux/eal_interrupts.c +5
-2events[count].status =RTE_EPOLL_VALID ;@@ -1237,8 +1243,11 @@ eal_epoll_process_event(struct epoll_event *evs,unsigned int n, rev->epdata.cb_fun(rev->fd, rev->epdata.cb_arg); -rte_compiler_barrier (); - rev->status =RTE_EPOLL_VALID ; +/* the status update should be observed after +* the other fields changes. +*/ +__atomic_store_n (&rev->status,RTE_EPOLL_VALID , + __ATOMIC_RELEASE); count++; }lib/librte_eal/linux/eal_interrupts.c +13
-6return count;@@ -1308,10 +1317,14 @@ rte_epoll_wait(int epfd, struct rte_epoll_event *events, static inline void eal_epoll_data_safe_free(struct rte_epoll_event *ev) { -while (!rte_atomic32_cmpset (&ev->status,RTE_EPOLL_VALID , -RTE_EPOLL_INVALID )) -while (ev->status !=RTE_EPOLL_VALID ) +uint32_t valid_status =RTE_EPOLL_VALID ; +while (!__atomic_compare_exchange_n (&ev->status, &valid_status, +RTE_EPOLL_INVALID ,0 , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { +while (__atomic_load_n (&ev->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_VALID )rte_pause (); + valid_status =RTE_EPOLL_VALID ; + }memset (&ev->epdata,0 ,sizeof (ev->epdata)); ev->fd =-1 ; ev->epfd =-1 ;@@ -1333,7 +1346,8 @@ rte_epoll_ctl(int epfd, int op, int fd, epfd =rte_intr_tls_epfd ();if (op ==EPOLL_CTL_ADD ) { - event->status =RTE_EPOLL_VALID ; +__atomic_store_n (&event->status,RTE_EPOLL_VALID , + __ATOMIC_RELAXED); event->fd = fd;/* ignore fd in event */ event->epfd = epfd; ev.data.ptr = (void *)event;@@ -1345,11 +1359,13 @@ rte_epoll_ctl(int epfd, int op, int fd, op, fd, strerror(errno));if (op ==EPOLL_CTL_ADD )/* rollback status when CTL_ADD fail */ - event->status =RTE_EPOLL_INVALID ; +__atomic_store_n (&event->status,RTE_EPOLL_INVALID , + __ATOMIC_RELAXED);return -1 ; } -if (op ==EPOLL_CTL_DEL && event->status !=RTE_EPOLL_INVALID ) +if (op ==EPOLL_CTL_DEL &&__atomic_load_n (&event->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_INVALID )eal_epoll_data_safe_free (event);lib/librte_eal/linux/eal_interrupts.c +2
-1return 0 ;@@ -1378,7 +1394,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle,int epfd, case RTE_INTR_EVENT_ADD: epfd_op =EPOLL_CTL_ADD ; rev = &intr_handle->elist[efd_idx]; -if (rev->status !=RTE_EPOLL_INVALID ) { +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_INVALID ) {RTE_LOG (INFO ,EAL ,"Event already been added.\n" );lib/librte_eal/linux/eal_interrupts.c +2
-1return -EEXIST ; }@@ -1401,7 +1418,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle,int epfd, case RTE_INTR_EVENT_DEL: epfd_op =EPOLL_CTL_DEL ; rev = &intr_handle->elist[efd_idx]; -if (rev->status ==RTE_EPOLL_INVALID ) { +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) ==RTE_EPOLL_INVALID ) {RTE_LOG (INFO ,EAL ,"Event does not exist.\n" );lib/librte_eal/linux/eal_interrupts.c +2
-1return -EPERM ; }@@ -1426,7 +1444,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)for (i =0 ; i < intr_handle->nb_efd; i++) { rev = &intr_handle->elist[i]; -if (rev->status ==RTE_EPOLL_INVALID ) +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) ==RTE_EPOLL_INVALID )continue ;lib/librte_eal/linux/eal_interrupts.c +0
-1if (rte_epoll_ctl (rev->epfd,EPOLL_CTL_DEL , rev->fd, rev)) {/* force free if the entry valid */ --2.7.4
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
In reply to Phil YangQuoted 7 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
Patches looks fine to me with commit message changes suggested by Honnappa, i.e. using C11 atomic built-ins.
Since first patch of the series will not be backported, so I think both patches can be combined into one.
Quoted 141 lines
lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 47 ++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 15 deletions(-)lib/librte_eal/include/rte_eal_interrupts.h +1
-1@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;lib/librte_eal/linux/eal_interrupts.c +33
-14@@ -26,7 +26,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_debug.h> #include <rte_log.h> @@ -1221,11 +1220,18 @@ eal_epoll_process_event(struct epoll_event *evs, unsigned int n, {unsigned int i, count =0 ;struct rte_epoll_event *rev; +uint32_t valid_status;for (i =0 ; i < n; i++) { rev = evs[i].data.ptr; -if (!rev || !rte_atomic32_cmpset (&rev->status,RTE_EPOLL_VALID , -RTE_EPOLL_EXEC )) + valid_status =RTE_EPOLL_VALID ; +/* ACQUIRE memory ordering here pairs with RELEASE +* ordering bellow acting as a lock to synchronize +* the event data updating. +*/ +if (!rev || !__atomic_compare_exchange_n (&rev->status, + &valid_status,RTE_EPOLL_EXEC ,0 , + __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))continue ; events[count].status =RTE_EPOLL_VALID ;@@ -1237,8 +1243,11 @@ eal_epoll_process_event(struct epoll_event *evs, unsigned int n, rev->epdata.cb_fun (rev->fd, rev->epdata.cb_arg); -rte_compiler_barrier (); - rev->status =RTE_EPOLL_VALID ; +/* the status update should be observed after +* the other fields changes. +*/ +__atomic_store_n (&rev->status,RTE_EPOLL_VALID , + __ATOMIC_RELEASE); count++; }return count;@@ -1308,10 +1317,14 @@ rte_epoll_wait(int epfd, struct rte_epoll_event *events,static inline void eal_epoll_data_safe_free (struct rte_epoll_event *ev) { -while (!rte_atomic32_cmpset (&ev->status,RTE_EPOLL_VALID , -RTE_EPOLL_INVALID )) -while (ev->status !=RTE_EPOLL_VALID ) +uint32_t valid_status =RTE_EPOLL_VALID ; +while (!__atomic_compare_exchange_n (&ev->status, &valid_status, +RTE_EPOLL_INVALID ,0 , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { +while (__atomic_load_n (&ev->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_VALID )rte_pause (); + valid_status =RTE_EPOLL_VALID ; + }memset (&ev->epdata,0 ,sizeof (ev->epdata)); ev->fd =-1 ; ev->epfd =-1 ;@@ -1333,7 +1346,8 @@ rte_epoll_ctl(int epfd, int op, int fd, epfd =rte_intr_tls_epfd ();if (op ==EPOLL_CTL_ADD ) { - event->status =RTE_EPOLL_VALID ; +__atomic_store_n (&event->status,RTE_EPOLL_VALID , + __ATOMIC_RELAXED); event->fd = fd;/* ignore fd in event */ event->epfd = epfd; ev.data.ptr = (void *)event;@@ -1345,11 +1359,13 @@ rte_epoll_ctl(int epfd, int op, int fd, op, fd, strerror(errno));if (op ==EPOLL_CTL_ADD )/* rollback status when CTL_ADD fail */ - event->status =RTE_EPOLL_INVALID ; +__atomic_store_n (&event->status,RTE_EPOLL_INVALID , + __ATOMIC_RELAXED);return -1 ; } -if (op ==EPOLL_CTL_DEL && event->status !=RTE_EPOLL_INVALID ) +if (op ==EPOLL_CTL_DEL &&__atomic_load_n (&event->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_INVALID )eal_epoll_data_safe_free (event);return 0 ;@@ -1378,7 +1394,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,case RTE_INTR_EVENT_ADD : epfd_op =EPOLL_CTL_ADD ; rev = &intr_handle->elist[efd_idx]; -if (rev->status !=RTE_EPOLL_INVALID ) { +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_INVALID ) {RTE_LOG (INFO ,EAL ,"Event already been added.\n" );return -EEXIST ; }@@ -1401,7 +1418,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,case RTE_INTR_EVENT_DEL : epfd_op =EPOLL_CTL_DEL ; rev = &intr_handle->elist[efd_idx]; -if (rev->status ==RTE_EPOLL_INVALID ) { +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) ==RTE_EPOLL_INVALID ) {RTE_LOG (INFO ,EAL ,"Event does not exist.\n" );return -EPERM ; }@@ -1426,7 +1444,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)for (i =0 ; i < intr_handle->nb_efd; i++) { rev = &intr_handle->elist[i]; -if (rev->status ==RTE_EPOLL_INVALID ) +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) ==RTE_EPOLL_INVALID )continue ;if (rte_epoll_ctl (rev->epfd,EPOLL_CTL_DEL , rev->fd, rev)) {/* force free if the entry valid */ Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
Quoted 14 lines
-----Original Message-----
From: Harman Kalra <[email protected]>
Sent: Wednesday, July 8, 2020 7:41 PM
To: Phil Yang <[email protected]>
Cc: [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt statusQuoted 4 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.
Quoted 8 lines
Quoted 3 lines
Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
Patches looks fine to me with commit message changes suggested by Honnappa, i.e. using C11 atomic built-ins.
Since first patch of the series will not be backported, so I think both patches can be combined into one.
OK. Thanks.
I will update in the next version.
Thanks,
Phil
Quoted 3 lines
Reviewed-by Harman Kalra <[email protected]>
<snip>
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
In reply to Phil YangQuoted 17 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 47 ++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 15 deletions(-)lib/librte_eal/include/rte_eal_interrupts.h +0
-0
lib/librte_eal/include/rte_eal_interrupts.h enum { · line 65
Quoted 8 lines
lib/librte_eal/include/rte_eal_interrupts.h +1
-1@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;
I got a reject from the ABI check in my env.
1 function with some indirect sub-type change:
[C]'function int rte_pci_ioport_map(rte_pci_device*, int,
rte_pci_ioport*)' at pci.c:756:1 has some indirect sub-type changes:
parameter 1 of type 'rte_pci_device*' has sub-type changes:
in pointed to type 'struct rte_pci_device' at rte_bus_pci.h:57:1:
type size hasn't changed
1 data member changes (2 filtered):
type of 'rte_intr_handle rte_pci_device::intr_handle' changed:
type size hasn't changed
1 data member change:
type of 'rte_epoll_event rte_intr_handle::elist[512]' changed:
array element type 'struct rte_epoll_event' changed:
type size hasn't changed
1 data member change:
type of 'volatile uint32_t rte_epoll_event::status' changed:
entity changed from 'volatile uint32_t' to 'typedefuint32_t' at stdint-uintn.h:26:1
type size hasn't changed
type size hasn't changed
This is probably harmless in our case (going from volatile to non volatile), but it won't pass the check in the CI without an exception rule.
Note: checking on the test-report ml, I saw nothing, but ovsrobot did catch the issue with this change too, Aaron?
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
Quoted 52 lines · David Marchand
Quoted 17 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 47 ++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 15 deletions(-)lib/librte_eal/include/rte_eal_interrupts.h +0
-0lib/librte_eal/include/rte_eal_interrupts.h enum { · line 65
Quoted 8 lines
lib/librte_eal/include/rte_eal_interrupts.h +1
-1@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;I got a reject from the ABI check in my env.
1 function with some indirect sub-type change:
[C]'function int rte_pci_ioport_map(rte_pci_device*, int,
rte_pci_ioport*)' at pci.c:756:1 has some indirect sub-type changes:
parameter 1 of type 'rte_pci_device*' has sub-type changes:
in pointed to type 'structrte_pci_device' at rte_bus_pci.h:57:1:
type size hasn't changed
1 data member changes (2 filtered):
type of 'rte_intr_handlerte_pci_device::intr_handle' changed:
type size hasn't changed
1 data member change:
type of 'rte_epoll_eventrte_intr_handle::elist[512]' changed:
array element type 'structrte_epoll_event' changed:
type size hasn't changed
1 data member change:
type of 'volatileuint32_trte_epoll_event::status' changed:
entity changed from 'volatileuint32_t' to 'typedefuint32_t' at stdint-uintn.h:26:1
type size hasn't changedtype size hasn't changed
Quoted 6 lines
This is probably harmless in our case (going from volatile to non volatile), but it won't pass the check in the CI without an exception rule.
Note: checking on the test-report ml, I saw nothing, but ovsrobot did catch the issue with this change too, Aaron?
I don't have archives back to Jun 11 on the robot server. I think it doesn't preserve forever (and the archives seem to go back only until Jul 03). I will update it.
I do see that we have a failed travis job:
https://travis-ci.org/github/ovsrobot/dpdk/builds/697180855
I'm surprised this didn't go out. Have we seen other failures to report of the ovs robot recently? I can double check the job config.
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
Quoted 7 lines · Aaron Conole
Quoted 2 lines
Note: checking on the test-report ml, I saw nothing, but ovsrobot did catch the issue with this change too, Aaron?
I don't have archives back to Jun 11 on the robot server. I think it doesn't preserve forever (and the archives seem to go back only until Jul 03). I will update it.
Quoted 7 lines
I do see that we have a failed travis job:
https://travis-ci.org/github/ovsrobot/dpdk/builds/697180855
I'm surprised this didn't go out. Have we seen other failures to report of the ovs robot recently? I can double check the job config.
We do receive reports from the robot atm.
And I found one failure reported this morning.
http://mails.dpdk.org/archives/test-report/2020-July/142421.html
Maybe transient failures wrt mail delivery?
Just throwing an idea..
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
Quoted 16 lines · David Marchand
Quoted 7 lines · Aaron Conole
Quoted 2 lines
Note: checking on the test-report ml, I saw nothing, but ovsrobot did catch the issue with this change too, Aaron?
I don't have archives back to Jun 11 on the robot server. I think it doesn't preserve forever (and the archives seem to go back only until Jul 03). I will update it.
Quoted 7 lines
I do see that we have a failed travis job:
https://travis-ci.org/github/ovsrobot/dpdk/builds/697180855
I'm surprised this didn't go out. Have we seen other failures to report of the ovs robot recently? I can double check the job config.
Quoted 6 lines
We do receive reports from the robot atm.
And I found one failure reported this morning.
http://mails.dpdk.org/archives/test-report/2020-July/142421.htmlMaybe transient failures wrt mail delivery?
Just throwing an idea..
It's possible. I'll check out the mail server.
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
In reply to David MarchandQuoted 52 lines · David Marchand
Quoted 17 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 47 ++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 15 deletions(-)lib/librte_eal/include/rte_eal_interrupts.h +0
-0lib/librte_eal/include/rte_eal_interrupts.h enum { · line 65
Quoted 8 lines
lib/librte_eal/include/rte_eal_interrupts.h +1
-1@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;I got a reject from the ABI check in my env.
1 function with some indirect sub-type change:
[C]'function int rte_pci_ioport_map(rte_pci_device*, int,
rte_pci_ioport*)' at pci.c:756:1 has some indirect sub-type changes:
parameter 1 of type 'rte_pci_device*' has sub-type changes:
in pointed to type 'structrte_pci_device' at rte_bus_pci.h:57:1:
type size hasn't changed
1 data member changes (2 filtered):
type of 'rte_intr_handlerte_pci_device::intr_handle' changed:
type size hasn't changed
1 data member change:
type of 'rte_epoll_eventrte_intr_handle::elist[512]' changed:
array element type 'structrte_epoll_event' changed:
type size hasn't changed
1 data member change:
type of 'volatileuint32_trte_epoll_event::status' changed:
entity changed from 'volatileuint32_t' to 'typedefuint32_t' at stdint-uintn.h:26:1
type size hasn't changedtype size hasn't changed
Quoted 8 lines
This is probably harmless in our case (going from volatile to non volatile), but it won't pass the check in the CI without an exception rule.
Note: checking on the test-report ml, I saw nothing, but ovsrobot did catch the issue with this change too, Aaron?
Agreed, probably harmless and requires something in libagigail.ignore.
Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt status
Quoted 73 lines
-----Original Message-----
From: Kinsella, Ray <[email protected]>
Sent: Wednesday, July 8, 2020 11:05 PM
To: David Marchand <[email protected]>; Phil Yang <[email protected]>; Aaron Conole <[email protected]>
Cc: dev <[email protected]>; David Christensen <[email protected]>; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>; Dodji Seketeli <[email protected]>; Neil Horman <[email protected]>; Harman Kalra <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] eal: use c11 atomics for interrupt statusQuoted 11 lines · David Marchand
Quoted 10 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomics with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 47 ++++++++++++++++++++---------
Quoted 3 lines
Review
Quoted 3 lines
2 files changed, 34 insertions(+), 15 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/include/rte_eal_interrupts.hQuoted 42 lines
lib/librte_eal/include/rte_eal_interrupts.h enum { · line 65
Quoted 12 lines
index 773a34a..b1e8a29 100644
lib/librte_eal/include/rte_eal_interrupts.h +1
-1@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;I got a reject from the ABI check in my env.
1 function with some indirect sub-type change:
[C]'function int rte_pci_ioport_map(rte_pci_device*, int,
rte_pci_ioport*)' at pci.c:756:1 has some indirect sub-type changes:
parameter 1 of type 'rte_pci_device*' has sub-type changes:
in pointed to type 'structrte_pci_device' at rte_bus_pci.h:57:1:
type size hasn't changed
1 data member changes (2 filtered):
type of 'rte_intr_handlerte_pci_device::intr_handle' changed:
type size hasn't changed
1 data member change:
type of 'rte_epoll_eventrte_intr_handle::elist[512]' changed:
array element type 'structrte_epoll_event' changed:
type size hasn't changed
1 data member change:
type of 'volatileuint32_trte_epoll_event::status' changed:
entity changed from 'volatileuint32_t' to 'typedefuint32_t' at stdint-uintn.h:26:1
type size hasn't changedtype size hasn't changed
This is probably harmless in our case (going from volatile to non volatile), but it won't pass the check in the CI without an exception rule.
Quoted 5 lines
Quoted 4 lines
Note: checking on the test-report ml, I saw nothing, but ovsrobot did catch the issue with this change too, Aaron?
Agreed, probably harmless and requires something in libagigail.ignore.
OK. Will update libagigail.ignore in the next version.
Thanks,
Phil
<snip>
Quoted 8 lines
Subject: [PATCH 1/2] eal: remove redundant code
The event status has been cleaned up by the CAS operation when we free the event data, so there is no need to set it to invalid after that.
Fixes 49e2f374e45a ("eal/linux: support external Rx interrupt")
This is not a bug fix. I think it is not worth backporting, suggest removing this.
Quoted 3 lines
Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Otherwise
Quoted 20 lines
--- lib/librte_eal/linux/eal_interrupts.c | 1 - 1 file changed, 1 deletion(-)lib/librte_eal/linux/eal_interrupts.c +0
-1@@ -1431,7 +1431,6 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)if (rte_epoll_ctl (rev->epfd,EPOLL_CTL_DEL , rev->fd, rev)) {/* force free if the entry valid */ eal_epoll_data_safe_free (rev); - rev->status =RTE_EPOLL_INVALID ; } }}
--
2.7.4
Quoted 13 lines
-----Original Message-----
From: Honnappa Nagarahalli <[email protected]>
Sent: Wednesday, July 8, 2020 1:15 PM
To: Phil Yang <[email protected]>; [email protected]
Cc: [email protected]; Ruifeng Wang <[email protected]>; nd <[email protected]>; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: RE: [PATCH 1/2] eal: remove redundant code<snip>
Quoted 2 lines
Subject: [PATCH 1/2] eal: remove redundant code
Quoted 7 lines
Quoted 6 lines
The event status has been cleaned up by the CAS operation when we free the event data, so there is no need to set it to invalid after that.
Fixes 49e2f374e45a ("eal/linux: support external Rx interrupt")This is not a bug fix. I think it is not worth backporting, suggest removing this.
OK.
Quoted 28 lines
Quoted 4 lines
Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Otherwise
Reviewed-by Honnappa Nagarahalli <[email protected]>Quoted 20 lines
--- lib/librte_eal/linux/eal_interrupts.c | 1 - 1 file changed, 1 deletion(-)lib/librte_eal/linux/eal_interrupts.c +0
-1@@ -1431,7 +1431,6 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)if (rte_epoll_ctl (rev->epfd,EPOLL_CTL_DEL , rev->fd, rev)) {/* force free if the entry valid */ eal_epoll_data_safe_free (rev); - rev->status =RTE_EPOLL_INVALID ; } }}
--
2.7.4
PATCH v2 1/1 eal: use c11 atomic built-ins for interrupt status
In reply to Phil YangThe event status is defined as a volatile variable and shared between threads. Use c11 atomic built-ins with explicit ordering instead of rte_atomic ops which enforce unnecessary barriers on aarch64.
The event status has been cleaned up by the compare-and-swap operation when we free the event data, so there is no need to set it to invalid after that.
---
v2:
1. Fixed typo.
2. Updated libabigail.abignore to pass ABI check.
3. Merged v1 two patches into one patch.
devtools/libabigail.abignore | 4 +++ lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 48 ++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 16 deletions(-)
devtools/libabigail.abignore +4 -0
@@ -48,6 +48,10 @@ changed_enumerators = RTE_CRYPTO_AEAD_LIST_END [suppress_variable] name = rte_crypto_aead_algorithm_strings +; Ignore updates of epoll event +[suppress_type] + type_kind = struct + name = rte_epoll_event ;;;;;;;;;;;;;;;;;;;;;; ; Temporary exceptions till DPDK 20.11
lib/librte_eal/include/rte_eal_interrupts.h +1 -1
@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;
lib/librte_eal/linux/eal_interrupts.c +33 -15
113 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v2] eal: use c11 atomic built-ins for interrupt status
Hi,
Noticed 2 typos:
Quoted 67 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.The event status has been cleaned up by the compare-and-swap operation when we free the event data, so there is no need to set it to invalid after that.
Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>Reviewed-by Harman Kalra <[email protected]>---
v2:
1. Fixed typo.
2. Updated libabigail.abignore to pass ABI check.
3. Merged v1 two patches into one patch.devtools/libabigail.abignore | 4 +++ lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 48 ++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 16 deletions(-)devtools/libabigail.abignore +4
-0@@ -48,6 +48,10 @@ changed_enumerators = RTE_CRYPTO_AEAD_LIST_END [suppress_variable] name = rte_crypto_aead_algorithm_strings +; Ignore updates of epoll event +[suppress_type] + type_kind = struct + name = rte_epoll_event ;;;;;;;;;;;;;;;;;;;;;; ; Temporary exceptions till DPDK 20.11lib/librte_eal/include/rte_eal_interrupts.h +1
-1@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;lib/librte_eal/linux/eal_interrupts.c +0
-1@@ -26,7 +26,6 @@#include <rte_eal.h> #include <rte_per_lcore.h> #include <rte_lcore.h> -#include <rte_atomic.h> #include <rte_branch_prediction.h> #include <rte_debug.h> #include <rte_log.h> @@ -1221,11 +1220,18 @@ eal_epoll_process_event(struct epoll_event *evs, unsigned int n, {unsigned int i, count =0 ;
lib/librte_eal/linux/eal_interrupts.c eal_epoll_process_event(struct epoll_event *evs, unsigned int n, · line 1229
Quoted 10 lines
lib/librte_eal/linux/eal_interrupts.c +4
-2struct rte_epoll_event *rev; +uint32_t valid_status;for (i =0 ; i < n; i++) { rev = evs[i].data.ptr; -if (!rev || !rte_atomic32_cmpset (&rev->status,RTE_EPOLL_VALID , -RTE_EPOLL_EXEC )) + valid_status =RTE_EPOLL_VALID ; +/* ACQUIRE memory ordering here pairs with RELEASE +* ordering bellow acting as a lock to synchronize
s/bellow/below
Quoted 9 lines
lib/librte_eal/linux/eal_interrupts.c +5
-0+* the event data updating. +*/ +if (!rev || !__atomic_compare_exchange_n (&rev->status, + &valid_status,RTE_EPOLL_EXEC ,0 , + __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))continue ; events[count].status =RTE_EPOLL_VALID ;
lib/librte_eal/linux/eal_interrupts.c eal_epoll_process_event(struct epoll_event *evs, unsigned int n, · line 1247
Quoted 7 lines
lib/librte_eal/linux/eal_interrupts.c +2
-2@@ -1237,8 +1243,11 @@ eal_epoll_process_event(struct epoll_event *evs, unsigned int n, rev->epdata.cb_fun (rev->fd, rev->epdata.cb_arg); -rte_compiler_barrier (); - rev->status =RTE_EPOLL_VALID ; +/* the status update should be observed after +* the other fields changes.
s/fields changes/fields change/
Thanks,
Stefan.
Quoted 88 lines
lib/librte_eal/linux/eal_interrupts.c +22
-11+*/ +__atomic_store_n (&rev->status,RTE_EPOLL_VALID , + __ATOMIC_RELEASE); count++; }return count;@@ -1308,10 +1317,14 @@ rte_epoll_wait(int epfd, struct rte_epoll_event *events,static inline void eal_epoll_data_safe_free (struct rte_epoll_event *ev) { -while (!rte_atomic32_cmpset (&ev->status,RTE_EPOLL_VALID , -RTE_EPOLL_INVALID )) -while (ev->status !=RTE_EPOLL_VALID ) +uint32_t valid_status =RTE_EPOLL_VALID ; +while (!__atomic_compare_exchange_n (&ev->status, &valid_status, +RTE_EPOLL_INVALID ,0 , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { +while (__atomic_load_n (&ev->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_VALID )rte_pause (); + valid_status =RTE_EPOLL_VALID ; + }memset (&ev->epdata,0 ,sizeof (ev->epdata)); ev->fd =-1 ; ev->epfd =-1 ;@@ -1333,7 +1346,8 @@ rte_epoll_ctl(int epfd, int op, int fd, epfd =rte_intr_tls_epfd ();if (op ==EPOLL_CTL_ADD ) { - event->status =RTE_EPOLL_VALID ; +__atomic_store_n (&event->status,RTE_EPOLL_VALID , + __ATOMIC_RELAXED); event->fd = fd;/* ignore fd in event */ event->epfd = epfd; ev.data.ptr = (void *)event;@@ -1345,11 +1359,13 @@ rte_epoll_ctl(int epfd, int op, int fd, op, fd, strerror(errno));if (op ==EPOLL_CTL_ADD )/* rollback status when CTL_ADD fail */ - event->status =RTE_EPOLL_INVALID ; +__atomic_store_n (&event->status,RTE_EPOLL_INVALID , + __ATOMIC_RELAXED);return -1 ; } -if (op ==EPOLL_CTL_DEL && event->status !=RTE_EPOLL_INVALID ) +if (op ==EPOLL_CTL_DEL &&__atomic_load_n (&event->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_INVALID )eal_epoll_data_safe_free (event);return 0 ;@@ -1378,7 +1394,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,case RTE_INTR_EVENT_ADD : epfd_op =EPOLL_CTL_ADD ; rev = &intr_handle->elist[efd_idx]; -if (rev->status !=RTE_EPOLL_INVALID ) { +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) !=RTE_EPOLL_INVALID ) {RTE_LOG (INFO ,EAL ,"Event already been added.\n" );return -EEXIST ; }@@ -1401,7 +1418,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,case RTE_INTR_EVENT_DEL : epfd_op =EPOLL_CTL_DEL ; rev = &intr_handle->elist[efd_idx]; -if (rev->status ==RTE_EPOLL_INVALID ) { +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) ==RTE_EPOLL_INVALID ) {RTE_LOG (INFO ,EAL ,"Event does not exist.\n" );return -EPERM ; }@@ -1426,12 +1444,12 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)for (i =0 ; i < intr_handle->nb_efd; i++) { rev = &intr_handle->elist[i]; -if (rev->status ==RTE_EPOLL_INVALID ) +if (__atomic_load_n (&rev->status, + __ATOMIC_RELAXED) ==RTE_EPOLL_INVALID )continue ;if (rte_epoll_ctl (rev->epfd,EPOLL_CTL_DEL , rev->fd, rev)) {/* force free if the entry valid */ eal_epoll_data_safe_free (rev); - rev->status =RTE_EPOLL_INVALID ; } } } --2.7.4
Re: [dpdk-dev] [PATCH v2] eal: use c11 atomic built-ins for interrupt status
Quoted 12 lines
-----Original Message-----
From: Stefan Puiu <[email protected]>
Sent: Thursday, July 9, 2020 4:02 PM
To: Phil Yang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>; nd <[email protected]>; [email protected]; Neil Horman <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] eal: use c11 atomic built-ins for interrupt status
Quoted 3 lines
Hi,
Noticed 2 typos:
Hi Stefan,
Thanks for your feedback.
Will do.
Thanks,
Phil
<snip>
PATCH v3 1/1 eal: use c11 atomic built-ins for interrupt status
In reply to Phil YangThe event status is defined as a volatile variable and shared between threads. Use c11 atomic built-ins with explicit ordering instead of rte_atomic ops which enforce unnecessary barriers on aarch64.
The event status has been cleaned up by the compare-and-swap operation when we free the event data, so there is no need to set it to invalid after that.
---
v3:
Fixed typo.
v2:
1. Fixed typo.
2. Updated libabigail.abignore to pass ABI check.
3. Merged v1 two patches into one patch.
devtools/libabigail.abignore | 4 +++ lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 48 ++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 16 deletions(-)
devtools/libabigail.abignore +4 -0
@@ -48,6 +48,10 @@ changed_enumerators = RTE_CRYPTO_AEAD_LIST_END [suppress_variable] name = rte_crypto_aead_algorithm_strings +; Ignore updates of epoll event +[suppress_type] + type_kind = struct + name = rte_epoll_event ;;;;;;;;;;;;;;;;;;;;;; ; Temporary exceptions till DPDK 20.11
lib/librte_eal/include/rte_eal_interrupts.h +1 -1
@@ -59,7 +59,7 @@ enum {/** interrupt epoll event obj, taken by epoll_event.ptr */ struct rte_epoll_event { -volatile uint32_t status;/**< OUT: event status */ +uint32_t status;/**< OUT: event status */ int fd;/**< OUT: event fd */ int epfd;/**< OUT: epoll instance the ev associated with */ struct rte_epoll_data epdata;
lib/librte_eal/linux/eal_interrupts.c +33 -15
113 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v3] eal: use c11 atomic built-ins for interrupt status
Quoted 32 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.The event status has been cleaned up by the compare-and-swap operation when we free the event data, so there is no need to set it to invalid after that.
Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>Reviewed-by Harman Kalra <[email protected]>---
v3:
Fixed typo.v2:
1. Fixed typo.
2. Updated libabigail.abignore to pass ABI check.
3. Merged v1 two patches into one patch.devtools/libabigail.abignore | 4 +++ lib/librte_eal/include/rte_eal_interrupts.h | 2 +- lib/librte_eal/linux/eal_interrupts.c | 48 ++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 16 deletions(-)devtools/libabigail.abignore +0
-0
devtools/libabigail.abignore line 54
Quoted 7 lines
devtools/libabigail.abignore +4
-0@@ -48,6 +48,10 @@ changed_enumerators = RTE_CRYPTO_AEAD_LIST_END [suppress_variable] name = rte_crypto_aead_algorithm_strings +; Ignore updates of epoll event +[suppress_type] + type_kind = struct + name = rte_epoll_event
In general, ignoring all changes on a structure is risky. But the risk is acceptable as long as we remember this for the rest of the 20.08 release (and we will start from scratch for 20.11).
Without any comment from others, I'll merge this by the end of (my) day.
Thanks.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v3] eal: use c11 atomic built-ins for interrupt status
David Marchand <[email protected]> writes:
[...]
Quoted 6 lines
Quoted 6 lines
devtools/libabigail.abignore +0
-0@@ -48,6 +48,10 @@ changed_enumerators = RTE_CRYPTO_AEAD_LIST_END [suppress_variable] name = rte_crypto_aead_algorithm_strings
Quoted 8 lines
devtools/libabigail.abignore line 54
Quoted 4 lines
devtools/libabigail.abignore +4
-0+; Ignore updates of epoll event +[suppress_type] + type_kind = struct + name = rte_epoll_eventIn general, ignoring all changes on a structure is risky. But the risk is acceptable as long as we remember this for the rest of the 20.08 release (and we will start from scratch for 20.11).
Right, I thought about this too when I saw that change. If that struct is inherently *not* part of the logically exposed ABI, the risk is really minimal as well. In that case, maybe a comment saying so in the .abignore file could be useful for future reference.
[...]
Cheers,
Signature · 1 line
Dodji
David Marchand
AppliedRe: [dpdk-dev] [PATCH v3] eal: use c11 atomic built-ins for interrupt status
In reply to Phil YangQuoted 5 lines · Phil Yang
The event status is defined as a volatile variable and shared between threads. Use c11 atomic built-ins with explicit ordering instead of
rte_atomicops which enforce unnecessary barriers on aarch64.
Quoted 8 lines
The event status has been cleaned up by the compare-and-swap operation when we free the event data, so there is no need to set it to invalid after that.
Signed-off-by Phil Yang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>Reviewed-by Harman Kalra <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand