eal affinitize low priority threads to lcore 0
cover eal affinitize low priority threads to lcore 0
This patchset sets things up so that we can affinitize the interrupt, vfio management, and hpet timer management threads to lcore 0, so that they never interfere with data plane threads.
Bruce Richardson (3):
eal: add core id param to eal_thread_set_affinity
eal: increase scope of eal_thread_set_affinity
eal: affinitize low-priority threads to lcore 0
lib/librte_eal/bsdapp/eal/eal_thread.c | 12 ++++++------ lib/librte_eal/common/include/eal_private.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 6 ++++++ lib/librte_eal/linuxapp/eal/eal_thread.c | 12 ++++++------ lib/librte_eal/linuxapp/eal/eal_timer.c | 5 +++++ 6 files changed, 38 insertions(+), 12 deletions(-)
Signature · 1 line
1.9.3
A message that is not in the archive (sent off-list or not yet received): 1410445387-4849-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
PATCH 1/3 eal: add core id param to eal_thread_set_affinity
the function eal_thread_set_affinity always sets the affinity of the thread to the lcore_id of the thread as given by the thread-local variable. To allow this function to be used by arbitrary threads (e.g. eal utility threads such as those for interrupts, timers, etc.), add a parameter to specify the core id to be used for the affinity.
--- lib/librte_eal/bsdapp/eal/eal_thread.c | 10 +++++----- lib/librte_eal/linuxapp/eal/eal_thread.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-)
lib/librte_eal/bsdapp/eal/eal_thread.c +5 -5
@@ -96,7 +96,7 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)/* set affinity for current thread */ static int -eal_thread_set_affinity (void ) +eal_thread_set_affinity (unsigned lcore_id) {int s;pthread_t thread;
@@ -126,7 +126,7 @@ eal_thread_set_affinity(void) size =CPU_ALLOC_SIZE (RTE_MAX_LCORE );CPU_ZERO_S (size, cpusetp); -CPU_SET_S (rte_lcore_id (), size, cpusetp); +CPU_SET_S (lcore_id, size, cpusetp); thread =pthread_self (); s =pthread_setaffinity_np (thread, size, cpusetp);
@@ -140,7 +140,7 @@ eal_thread_set_affinity(void)#else /* CPU_ALLOC */ cpuset_t cpuset;CPU_ZERO ( &cpuset ); -CPU_SET (rte_lcore_id (), &cpuset ); +CPU_SET (lcore_id, &cpuset ); thread =pthread_self (); s =pthread_setaffinity_np (thread,sizeof ( cpuset ), &cpuset);
@@ -158,7 +158,7 @@ void eal_thread_init_master(unsigned lcore_id)RTE_PER_LCORE (_lcore_id) = lcore_id;/* set CPU affinity */ -if (eal_thread_set_affinity () <0 ) +if (eal_thread_set_affinity (lcore_id) <0 )rte_panic ("cannot set affinity\n" ); }
@@ -192,7 +192,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)RTE_PER_LCORE (_lcore_id) = lcore_id;/* set CPU affinity */ -if (eal_thread_set_affinity () <0 ) +if (eal_thread_set_affinity (lcore_id) <0 )rte_panic ("cannot set affinity\n" );/* read on our pipe to get commands */
lib/librte_eal/linuxapp/eal/eal_thread.c +5 -5
@@ -96,7 +96,7 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id)/* set affinity for current thread */ static int -eal_thread_set_affinity (void ) +eal_thread_set_affinity (unsigned lcore_id) {int s;pthread_t thread;
@@ -126,7 +126,7 @@ eal_thread_set_affinity(void) size =CPU_ALLOC_SIZE (RTE_MAX_LCORE );CPU_ZERO_S (size, cpusetp); -CPU_SET_S (rte_lcore_id (), size, cpusetp); +CPU_SET_S (lcore_id, size, cpusetp); thread =pthread_self (); s =pthread_setaffinity_np (thread, size, cpusetp);
@@ -140,7 +140,7 @@ eal_thread_set_affinity(void)#else /* CPU_ALLOC */ cpu_set_t cpuset;CPU_ZERO ( &cpuset ); -CPU_SET (rte_lcore_id (), &cpuset ); +CPU_SET (lcore_id, &cpuset); thread =pthread_self (); s =pthread_setaffinity_np (thread,sizeof ( cpuset ), &cpuset);
@@ -158,7 +158,7 @@ void eal_thread_init_master(unsigned lcore_id)RTE_PER_LCORE (_lcore_id) = lcore_id;/* set CPU affinity */ -if (eal_thread_set_affinity () <0 ) +if (eal_thread_set_affinity (lcore_id) <0 )rte_panic ("cannot set affinity\n" ); }
@@ -192,7 +192,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)RTE_PER_LCORE (_lcore_id) = lcore_id;/* set CPU affinity */ -if (eal_thread_set_affinity () <0 ) +if (eal_thread_set_affinity (lcore_id) <0 )rte_panic ("cannot set affinity\n" );/* read on our pipe to get commands */
Signature · 1 line
1.9.3
PATCH 2/3 eal: increase scope of eal_thread_set_affinity
In reply to a message not in the archiveThis patch changes eal_thread_set_affinity to the EAL-local function rte_eal_thread_set_affinity. This will allow us to use the function anywhere else in the EAL, while not having it part of the official APIs
--- lib/librte_eal/bsdapp/eal/eal_thread.c | 8 ++++---- lib/librte_eal/common/include/eal_private.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal_thread.c | 8 ++++---- 3 files changed, 18 insertions(+), 8 deletions(-)
lib/librte_eal/bsdapp/eal/eal_thread.c +4 -4
@@ -95,8 +95,8 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) }/* set affinity for current thread */ -static int -eal_thread_set_affinity (unsigned lcore_id) +int +rte_eal_thread_set_affinity (unsigned lcore_id) {int s;pthread_t thread;
@@ -158,7 +158,7 @@ void eal_thread_init_master(unsigned lcore_id)RTE_PER_LCORE (_lcore_id) = lcore_id;/* set CPU affinity */ -if (eal_thread_set_affinity (lcore_id) <0 ) +if (rte_eal_thread_set_affinity (lcore_id) <0 )rte_panic ("cannot set affinity\n" ); }
@@ -192,7 +192,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)RTE_PER_LCORE (_lcore_id) = lcore_id;/* set CPU affinity */ -if (eal_thread_set_affinity (lcore_id) <0 ) +if (rte_eal_thread_set_affinity (lcore_id) <0 )rte_panic ("cannot set affinity\n" );/* read on our pipe to get commands */
lib/librte_eal/common/include/eal_private.h +10 -0
@@ -196,4 +196,14 @@ int rte_eal_intr_init(void);*/ int rte_eal_alarm_init (void ); +/** +* Set the affinity of the current thread to a given core +* +* This function is private to EAL. +* +* @return +* 0 on success, negative on error +*/ +int rte_eal_thread_set_affinity (unsigned lcore_id); +#endif /* _EAL_PRIVATE_H_ */
lib/librte_eal/linuxapp/eal/eal_thread.c +4 -4
@@ -95,8 +95,8 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) }/* set affinity for current thread */ -static int -eal_thread_set_affinity (unsigned lcore_id) +int +rte_eal_thread_set_affinity (unsigned lcore_id) {int s;pthread_t thread;
@@ -158,7 +158,7 @@ void eal_thread_init_master(unsigned lcore_id)RTE_PER_LCORE (_lcore_id) = lcore_id;/* set CPU affinity */ -if (eal_thread_set_affinity (lcore_id) <0 ) +if (rte_eal_thread_set_affinity (lcore_id) <0 )rte_panic ("cannot set affinity\n" ); }
@@ -192,7 +192,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)RTE_PER_LCORE (_lcore_id) = lcore_id;/* set CPU affinity */ -if (eal_thread_set_affinity (lcore_id) <0 ) +if (rte_eal_thread_set_affinity (lcore_id) <0 )rte_panic ("cannot set affinity\n" );/* read on our pipe to get commands */
Signature · 1 line
1.9.3
PATCH 3/3 eal: affinitize low-priority threads to lcore 0
In reply to a message not in the archiveThere are extra utility threads inside the linuxapp EAL, for managing things like interrupts, requests for the vfio file handle for multi-process, and hpet timer management. These are mostly sleeping, but to avoid any possibility of conflict with threads handling packets, this patch affinitizes those threads to lcore 0 explicitly.
--- lib/librte_eal/linuxapp/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 6 ++++++ lib/librte_eal/linuxapp/eal/eal_timer.c | 5 +++++ 3 files changed, 16 insertions(+)
lib/librte_eal/linuxapp/eal/eal_interrupts.c +5 -0
@@ -739,6 +739,11 @@ eal_intr_thread_main(__rte_unused void *arg) {struct epoll_event ev; +/* set our affinity to lcore 0 so we never interfere with the normal +* data-plane threads. Lcore 0 is used by Linux so is subject to +* interruptions anyway. */ +rte_eal_thread_set_affinity (0 ); +/* host thread, never break out */ for (;;) {/* build up the epoll fd with all descriptors we are to
lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c +6 -0
@@ -53,6 +53,7 @@#include <rte_eal_memconfig.h> #include <rte_malloc.h> +#include <eal_private.h> #include "eal_filesystem.h" #include "eal_pci_init.h"
@@ -268,6 +269,11 @@ pci_vfio_mp_sync_thread(void __rte_unused * arg) {int ret, fd, vfio_group_no; +/* set our affinity to lcore 0 so we never interfere with the normal +* data-plane threads. Lcore 0 is used by Linux so is subject to +* interruptions anyway. */ +rte_eal_thread_set_affinity (0 ); +/* wait for requests on the socket */ for (;;) {int conn_sock;
lib/librte_eal/linuxapp/eal/eal_timer.c +5 -0
@@ -125,6 +125,11 @@ hpet_msb_inc(__attribute__((unused)) void *arg) {uint32_t t; +/* set our affinity to lcore 0 so we never interfere with the normal +* data-plane threads. Lcore 0 is used by Linux so is subject to +* interruptions anyway. */ +rte_eal_thread_set_affinity (0 ); +while (1 ) { t = (eal_hpet->counter_l >>30 );if (t != (eal_hpet_msb &3 ))
Signature · 1 line
1.9.3
Hi Bruce,
Quoted 5 lines
Subject: [dpdk-dev] [PATCH 0/3] eal affinitize low priority threads to lcore 0
This patchset sets things up so that we can affinitize the interrupt, vfio management, and hpet timer management threads to lcore 0, so that they never interfere with data plane threads.
I don't think it works well always.
The management threads can be floating all cpus on demand, because those threads are created before the master thread affinity is set. The kernel scheduler will take care of it. And we should isolate cpus which data plane threads are pinned to, so the management threads cannot run on those isolated cpus data plane thread run.
In some cases, the user may run data plane thread on lcore 0, but with this patchset the data plane pinned to lcore 0 always run with the management threads. That doesn't seem good.
I think this functionality should be conditional.
How about to add a parameter to specify the mask for the management threads instead of statically assignment to lcore 0?
thanks,
Hiroshi
Quoted 16 lines
Bruce Richardson (3):
eal: add core id param toeal_thread_set_affinity
eal: increase scope ofeal_thread_set_affinity
eal: affinitize low-priority threads to lcore 0lib/librte_eal/bsdapp/eal/eal_thread.c | 12 ++++++------ lib/librte_eal/common/include/eal_private.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 6 ++++++ lib/librte_eal/linuxapp/eal/eal_thread.c | 12 ++++++------ lib/librte_eal/linuxapp/eal/eal_timer.c | 5 +++++ 6 files changed, 38 insertions(+), 12 deletions(-)--
1.9.3
A message that is not in the archive (sent off-list or not yet received): 7F861DC0615E0C47A872E6F3C5FCDDBD011AC7A6-ZmjkEB1lVlLt6d3pZDjeaEtBU8KWyXPq@public.gmane.org
Quoted 18 lines · On Thu, 11 Sep 2014 23:47:52 +0000 Hiroshi Shimamoto…
Hi Bruce,
Quoted 5 lines
Subject: [dpdk-dev] [PATCH 0/3] eal affinitize low priority threads to lcore 0
This patchset sets things up so that we can affinitize the interrupt, vfio management, and hpet timer management threads to lcore 0, so that they never interfere with data plane threads.
I don't think it works well always.
The management threads can be floating all cpus on demand, because those threads are created before the master thread affinity is set. The kernel scheduler will take care of it. And we should isolate cpus which data plane threads are pinned to, so the management threads cannot run on those isolated cpus data plane thread run.
In some cases, the user may run data plane thread on lcore 0, but with this patchset the data plane pinned to lcore 0 always run with the management threads. That doesn't seem good.
Quoted 24 lines
I think this functionality should be conditional.
How about to add a parameter to specify the mask for the management threads instead of statically assignment to lcore 0?thanks,
HiroshiQuoted 16 lines
Bruce Richardson (3):
eal: add core id param toeal_thread_set_affinity
eal: increase scope ofeal_thread_set_affinity
eal: affinitize low-priority threads to lcore 0lib/librte_eal/bsdapp/eal/eal_thread.c | 12 ++++++------ lib/librte_eal/common/include/eal_private.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 6 ++++++ lib/librte_eal/linuxapp/eal/eal_thread.c | 12 ++++++------ lib/librte_eal/linuxapp/eal/eal_timer.c | 5 +++++ 6 files changed, 38 insertions(+), 12 deletions(-)--
1.9.3
We just set the non-master DPDK worker threads to be real time by using pthread_set_scheduler. This works very well and makes it clear to Linux scheduler what the intention is. This also improves wakeup behavior from sleeps.
Quoted 14 lines
-----Original Message-----
From: Hiroshi Shimamoto [mailto:h-shimamoto-ehU+Cx/zZe18UrSeD/[email protected]]
Sent: Friday, September 12, 2014 12:48 AM
To: Richardson, Bruce; [email protected]
Subject: RE: [dpdk-dev] [PATCH 0/3] eal affinitize low priority threads to lcore 0Hi Bruce,
Quoted 5 lines
Subject: [dpdk-dev] [PATCH 0/3] eal affinitize low priority threads to lcore 0
This patchset sets things up so that we can affinitize the interrupt, vfio management, and hpet timer management threads to lcore 0, so that they never interfere with data plane threads.
Quoted 6 lines
I don't think it works well always.
The management threads can be floating all cpus on demand, because those threads are created before the master thread affinity is set. The kernel scheduler will take care of it. And we should isolate cpus which data plane threads are pinned to, so the management threads cannot run on those isolated cpus data plane thread run.
Yes, this was my understanding as well of how things would work - we just had a report back of where the management threads were using the same core as the data-plane despite the core being isolated. I'll double-check to see if this really is happening and resubmit a new patch with a configurable core assignment if it is definitely needed.
/Bruce
Quoted 27 lines
In some cases, the user may run data plane thread on lcore 0, but with this patchset the data plane pinned to lcore 0 always run with the management threads. That doesn't seem good.
I think this functionality should be conditional.
How about to add a parameter to specify the mask for the management threads instead of statically assignment to lcore 0?thanks,
HiroshiQuoted 16 lines
Bruce Richardson (3):
eal: add core id param toeal_thread_set_affinity
eal: increase scope ofeal_thread_set_affinity
eal: affinitize low-priority threads to lcore 0lib/librte_eal/bsdapp/eal/eal_thread.c | 12 ++++++------ lib/librte_eal/common/include/eal_private.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 6 ++++++ lib/librte_eal/linuxapp/eal/eal_thread.c | 12 ++++++------ lib/librte_eal/linuxapp/eal/eal_timer.c | 5 +++++ 6 files changed, 38 insertions(+), 12 deletions(-)--
1.9.3