eal/windows: set Windows main lcore affinitization

Message ID 1648630829-4372-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series eal/windows: set Windows main lcore affinitization |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Tyler Retzlaff March 30, 2022, 9 a.m. UTC
  add missing code to affinitize main_lcore from lcore configuration.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/windows/eal.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

David Marchand April 7, 2022, 1:14 p.m. UTC | #1
Hello Tyler,

On Wed, Mar 30, 2022 at 11:00 AM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
>
> add missing code to affinitize main_lcore from lcore configuration.

Nit: Add*

>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  lib/eal/windows/eal.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
> index ca3c41a..9c61780 100644
> --- a/lib/eal/windows/eal.c
> +++ b/lib/eal/windows/eal.c
> @@ -401,6 +401,12 @@ enum rte_proc_type_t
>                 return -1;
>         }
>
> +       if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
> +                       &lcore_config[config->main_lcore].cpuset) != 0) {
> +               rte_eal_init_alert("Cannot set affinity");
> +               rte_errno = EINVAL;
> +               return -1;
> +       }
>         __rte_thread_init(config->main_lcore,
>                 &lcore_config[config->main_lcore].cpuset);
>

- It looks like the affinity is dumped for workers (see below), I
would dump affinity for the main lcore like other OS do:

    ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));

    RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
        config->main_lcore, thread_id, cpuset,
        ret == 0 ? "" : "...");


- Which makes me notice that windows/eal_thread.c probably dumps
random stuff in logs because it is missing a call to
eal_thread_dump_current_affinity() to format affinity as a string.

lib/eal/windows/eal_thread.c:   char cpuset[RTE_CPU_AFFINITY_STR_LEN];
lib/eal/windows/eal_thread.c:   __rte_thread_init(lcore_id,
&lcore_config[lcore_id].cpuset);
lib/eal/windows/eal_thread.c:   RTE_LOG(DEBUG, EAL, "lcore %u is ready
(tid=%zx;cpuset=[%s])\n",
lib/eal/windows/eal_thread.c:           lcore_id, (uintptr_t)thread_id, cpuset);
  
Tyler Retzlaff April 12, 2022, 4:30 p.m. UTC | #2
On Thu, Apr 07, 2022 at 03:14:33PM +0200, David Marchand wrote:
> Hello Tyler,
> 
> On Wed, Mar 30, 2022 at 11:00 AM Tyler Retzlaff
> <roretzla@linux.microsoft.com> wrote:
> >
> > add missing code to affinitize main_lcore from lcore configuration.
> 
> Nit: Add*
> 
> >
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
> >  lib/eal/windows/eal.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
> > index ca3c41a..9c61780 100644
> > --- a/lib/eal/windows/eal.c
> > +++ b/lib/eal/windows/eal.c
> > @@ -401,6 +401,12 @@ enum rte_proc_type_t
> >                 return -1;
> >         }
> >
> > +       if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
> > +                       &lcore_config[config->main_lcore].cpuset) != 0) {
> > +               rte_eal_init_alert("Cannot set affinity");
> > +               rte_errno = EINVAL;
> > +               return -1;
> > +       }
> >         __rte_thread_init(config->main_lcore,
> >                 &lcore_config[config->main_lcore].cpuset);
> >
> 
> - It looks like the affinity is dumped for workers (see below), I
> would dump affinity for the main lcore like other OS do:

yep, it's missing i should have noticed that. i'll submit a new version
to dump the affinity for the main lcore.

> 
>     ret = eal_thread_dump_current_affinity(cpuset, sizeof(cpuset));
> 
>     RTE_LOG(DEBUG, EAL, "Main lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
>         config->main_lcore, thread_id, cpuset,
>         ret == 0 ? "" : "...");
> 
> 
> - Which makes me notice that windows/eal_thread.c probably dumps
> random stuff in logs because it is missing a call to
> eal_thread_dump_current_affinity() to format affinity as a string.

oh yeah, that's not so good.

i think the series you submitted for eal_thread_loop should resolve this
shouldn't it? shall we ride your change to fix the issue or do you feel
it's worth me adding the missing call in this series?


--

ty
  
David Marchand April 14, 2022, 9:50 a.m. UTC | #3
Hello Tyler,

On Tue, Apr 12, 2022 at 6:30 PM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
> > - Which makes me notice that windows/eal_thread.c probably dumps
> > random stuff in logs because it is missing a call to
> > eal_thread_dump_current_affinity() to format affinity as a string.
>
> oh yeah, that's not so good.
>
> i think the series you submitted for eal_thread_loop should resolve this
> shouldn't it? shall we ride your change to fix the issue or do you feel
> it's worth me adding the missing call in this series?

This issue here is only for a log on cpu affinity.
Lcores cpu affinity is not correct for Windows in LTS releases, in any case.
So let's keep it as is and don't bother fixing it.


I'll add a note in my series about this log and apply it.
I marked this current patch as "Changes requested", wrt to my first comment.
  

Patch

diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c
index ca3c41a..9c61780 100644
--- a/lib/eal/windows/eal.c
+++ b/lib/eal/windows/eal.c
@@ -401,6 +401,12 @@  enum rte_proc_type_t
 		return -1;
 	}
 
+	if (pthread_setaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
+			&lcore_config[config->main_lcore].cpuset) != 0) {
+		rte_eal_init_alert("Cannot set affinity");
+		rte_errno = EINVAL;
+		return -1;
+	}
 	__rte_thread_init(config->main_lcore,
 		&lcore_config[config->main_lcore].cpuset);