[dpdk-dev] [PATCH] common/mlx5: fix CPU detection for PCI relaxed ordering

Thomas Monjalon thomas at monjalon.net
Sun Jul 19 13:13:09 CEST 2020


19/07/2020 12:56, Matan Azrad:
> 
> From: Thomas Monjalon
> > The detection of the CPU was done in a constructor and shared in a global
> > variable.
> > 
> > This variable may not be visible in the net PMD because it was not exported
> > as part of the .map file.
> 
> Can you explain exactly when it is not visible?

I depends on linker options.

> > It is fixed by exporting a function, which is cleaner than a variable.
> 
> Can you explain why?
> We have classic example - rte_eth_devices.

There is more control and more abstraction in functions,
it can provide futre-proof abstraction.

We should not export variables at all,
it is a basic rule of writing API.
Having a bad example in ethdev doesn't mean we should follow it.

> > By checking the CPU only at the first call of the function, doing the check in a
> > constructor becomes useless.
> 
> Yes, but why not to do it in constructor? this variable is initialized only once and doesn't depend in any parameter.

Constructor must remain minimal.
If constructor can be avoided, it must be.
This is a golden rule.

> > Note: the priority of the constructor was probably irrelevant.

No comment about the constructor priority which was set as LOG
for no good reason, proving that this code was not well reviewed?

> > At the same time, the comments are reworded or dropped if useless.
> > 
> > Fixes: 4c204fe5e5d2 ("common/mlx5: disable relaxed ordering in unsuitable
> > CPUs")
> > Cc: shirik at mellanox.com
> > Cc: stable at dpdk.org
> > 
> > Signed-off-by: Thomas Monjalon <thomas at monjalon.net>





More information about the dev mailing list