From: Bruce Richardson <bruce.richardson@intel.com>
To: David Marchand <david.marchand@redhat.com>
Cc: <dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
<konstantin.v.ananyev@yandex.ru>, <ruifeng.wang@arm.com>,
<zhoumin@loongson.cn>, <drc@linux.vnet.ibm.com>,
<kda@semihalf.com>, <roretzla@linux.microsoft.com>
Subject: Re: [PATCH 1/2] eal: introduce x86 processor identification
Date: Fri, 22 Sep 2023 11:55:28 +0100 [thread overview]
Message-ID: <ZQ1yoK1YIOh0aKIm@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <ZQ1urgJWU7Rs4614@bricha3-MOBL.ger.corp.intel.com>
On Fri, Sep 22, 2023 at 11:38:38AM +0100, Bruce Richardson wrote:
> On Fri, Sep 22, 2023 at 11:37:20AM +0200, David Marchand wrote:
> > In some really specific cases, it may be needed to get a detailed
> > information on the processor running a DPDK application for drivers to
> > achieve better performance, or for matters that concern only them.
> >
> > Those information are highly arch-specific and require a specific API.
> >
> > Introduce a set of functions to get brand, family and model of a x86
> > processor.
> > Those functions do not make sense on other arches and a
> > driver must first check rte_cpu_is_x86() before anything else.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
>
> Couple of thoughts, having had a few minutes to process this.
>
> * Rather than rte_cpu_is_x86() API, we could go a general API called
> rte_cpu_arch() which returns either a string, or an enum value. Within
> that, rather than #ifdefs, the actual return value could just be a define
> placed by meson in the rte_build_config.h file. The list of families
> according to meson are [1] - we'd just need to merge the 32 and 64-bit
> variants into one in the meson file.
>
We already have the architecture family in meson computed as the
"arch_subdir". Exposing that to the C code and wrapping as EAL function
might look like below (adding to eal.h for convenience).
Thoughts?
/Bruce
diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h
index 53c4a5519e..39f65d0e0c 100644
--- a/lib/eal/include/rte_eal.h
+++ b/lib/eal/include/rte_eal.h
@@ -517,6 +517,24 @@ __rte_internal
int
rte_eal_parse_coremask(const char *coremask, int *cores);
+enum rte_arch_family {
+ rte_cpu_arch_arm,
+ rte_cpu_arch_loongarch,
+ rte_cpu_arch_ppc,
+ rte_cpu_arch_riscv,
+ rte_cpu_arch_x86,
+};
+
+/**
+ * Return the architecture family of the current CPU
+ */
+static inline enum rte_arch_family
+rte_eal_get_arch_family(void)
+{
+ /* take value from build config set by meson */
+ return RTE_ARCH_FAMILY;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/meson.build b/meson.build
index 2e6e546d20..45e22daeb1 100644
--- a/meson.build
+++ b/meson.build
@@ -63,6 +63,7 @@ elif host_machine.cpu_family().startswith('ppc')
elif host_machine.cpu_family().startswith('riscv')
arch_subdir = 'riscv'
endif
+dpdk_conf.set('RTE_ARCH_FAMILY', 'rte_cpu_arch_' + arch_subdir)
# configure the build, and make sure configs here and in config folder are
# able to be included in any file. We also store a global array of include dirs
next prev parent reply other threads:[~2023-09-22 10:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 9:37 [PATCH 0/2] Introduce x86 specific identification API David Marchand
2023-09-22 9:37 ` [PATCH 1/2] eal: introduce x86 processor identification David Marchand
2023-09-22 9:46 ` Bruce Richardson
2023-09-25 9:42 ` David Marchand
2023-09-22 10:38 ` Bruce Richardson
2023-09-22 10:55 ` Bruce Richardson [this message]
2023-09-25 9:46 ` David Marchand
2023-09-25 10:16 ` Bruce Richardson
2023-09-25 10:52 ` Morten Brørup
2023-09-22 9:37 ` [PATCH 2/2] common/mlx5: use EAL " David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQ1yoK1YIOh0aKIm@bricha3-MOBL.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=drc@linux.vnet.ibm.com \
--cc=ferruh.yigit@amd.com \
--cc=kda@semihalf.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=roretzla@linux.microsoft.com \
--cc=ruifeng.wang@arm.com \
--cc=thomas@monjalon.net \
--cc=zhoumin@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).