[dpdk-dev] [PATCH] eal: fix ctrl thread affinity with --lcores

David Marchand david.marchand at redhat.com
Tue Jul 30 11:46:48 CEST 2019


On Tue, Jul 30, 2019 at 11:45 AM Jerin Jacob Kollanukkaran
<jerinj at marvell.com> wrote:
>
> > -----Original Message-----
> > From: dev <dev-bounces at dpdk.org> On Behalf Of David Marchand
> > Sent: Tuesday, July 30, 2019 3:06 PM
> > To: dev at dpdk.org
> > Cc: johan.kallstrom at ericsson.com; anatoly.burakov at intel.com;
> > olivier.matz at 6wind.com; stable at dpdk.org
> > Subject: [dpdk-dev] [PATCH] eal: fix ctrl thread affinity with --lcores
> >
> > When using -l/-c options, each lcore is mapped to a physical cpu in a
> > 1:1 fashion.
> > On the contrary, when using --lcores, each lcore has its own cpuset on which the
> > associated EAL thread runs.
> >
> > To handle those two situations, rely on the per lcore cpuset.
> >
> > Introduced macros to manipulate cpusets in both Linux and FreeBSD.
> >
> > Examples in a 4 cores FreeBSD vm:
> >
> > $ ./build/app/testpmd --master-lcore 1 --lcores '0@(1,3),1 at 2' \  --no-huge --no-
> > pci -m 512 -- -i --total-num-mbufs=2048
> >
> >   PID    TID COMM                TDNAME              CPU CSID CPU MASK
> > 31733 100155 testpmd             -                     2    1 2
> > 31733 100286 testpmd             eal-intr-thread       0    1 0
> > 31733 100287 testpmd             rte_mp_handle         0    1 0
> > 31733 100288 testpmd             lcore-slave-0         3    1 1,3
> >
> > $ cpuset -l 1,2,3 \
> >  ./build/app/testpmd --master-lcore 1 --lcores '0@(1,3),1 at 2' \  --no-huge --no-
> > pci -m 512 -- -i --total-num-mbufs=2048
> >
> >   PID    TID COMM                TDNAME              CPU CSID CPU MASK
> > 31757 100139 testpmd             -                     2    2 2
> > 31757 100292 testpmd             eal-intr-thread       2    2 2
> > 31757 100293 testpmd             rte_mp_handle         2    2 2
> > 31757 100294 testpmd             lcore-slave-0         3    2 1,3
> >
> > $ cpuset -l 1,2,3 \
> >  ./build/app/testpmd --master-lcore 1 --lcores '0 at 1,1 at 2' \  --no-huge --no-pci -
> > m 512 -- -i --total-num-mbufs=2048
> >
> >   PID    TID COMM                TDNAME              CPU CSID CPU MASK
> > 31776 100166 testpmd             -                     2    2 2
> > 31776 100295 testpmd             eal-intr-thread       3    2 3
> > 31776 100296 testpmd             rte_mp_handle         3    2 3
> > 31776 100297 testpmd             lcore-slave-0         1    2 1
> >
> > Bugzilla ID: 322
> > Fixes: c3568ea37670 ("eal: restrict control threads to startup CPU affinity")
> > Cc: stable at dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand at redhat.com>
> > @@ -25,6 +25,19 @@ extern "C" {
> >  #if defined(__linux__)
>
> [snip]
>
> >  #elif defined(__FreeBSD__)
> >  #include <pthread_np.h>
> >  typedef cpuset_t rte_cpuset_t;
> > @@ -35,6 +48,21 @@ typedef cpuset_t rte_cpuset_t;
> >       CPU_AND(&tmp, src2); \
> >       CPU_COPY(&tmp, dst); \
> >  } while (0)
> > +#define RTE_CPU_OR(dst, src1, src2) do \ { \
> > +     cpuset_t tmp; \
> > +     CPU_COPY(src1, &tmp); \
> > +     CPU_OR(&tmp, src2); \
> > +     CPU_COPY(&tmp, dst); \
> > +} while (0)
> > +#define RTE_CPU_FILL(set) CPU_FILL(set) #define RTE_CPU_NOT(dst, src)
> > +do \ { \
> > +     cpuset_t tmp; \
> > +     CPU_FILL(&tmp); \
> > +     CPU_NAND(&tmp, src); \
> > +     CPU_COPY(&tmp, dst); \
> > +} while (0)
>
> Considering windows eal or a new eal in mind, IMO, it is better
> to move to lib/librte_eal/freebsd/eal/include/rte_os.h
> and it will avoid #ifdef clutter in common code too.
>
>
>


This patch will get backported in 18.11.
I would prefer we do this cleanup later when the windows port needs it.


-- 
David Marchand


More information about the dev mailing list