MINOR: cpu-topo: add ha_cpu_topo definition

This structure will be used to store information about each CPU's
topology (package ID, L3 cache ID, NUMA node ID etc). This will be used
in conjunction with CPU affinity setting to try to perform a mostly
optimal binding between threads and CPU numbers by default. Since it
was noticed during tests that absolutely none of the many machines
tested reports different die numbers, the die_id is not stored.
Also, it was found along experiments that the cluster ID will be used
a lot, half of the time as a node-local identifier, and half of the
time as a global identifier. So let's store the two versions at once
(cl_gid, cl_lid).

Some flags are added to indicate causes of exclusion (offline, excluded
at boot, excluded by rules, ignored by policy).
This commit is contained in:
Willy Tarreau 2023-07-06 15:24:02 +02:00
parent 05a4efb102
commit d165f5d3ab

View File

@ -0,0 +1,44 @@
#ifndef _HAPROXY_CPU_TOPO_T_H
#define _HAPROXY_CPU_TOPO_T_H
#include <haproxy/api-t.h>
#include <haproxy/cpuset-t.h>
/* CPU state flags used with CPU topology detection (ha_cpu_topo.st). We try
* hard to rely on known info. For example we don't claim a CPU is bound or
* online if we don't know, reason why instead we store offline or excluded.
* Other flags like DONT_USE indicate a user's choice while IGNORED indicates
* the result of an automated selection. Two marks are available for allocation
* algorithms to temporarily compare/select/evict CPUs. These must be cleared
* after use.
*/
#define HA_CPU_F_EXCLUDED 0x0001 // this CPU was excluded at boot
#define HA_CPU_F_OFFLINE 0x0002 // this CPU is known to be offline
#define HA_CPU_F_DONT_USE 0x0004 // this CPU must not be used
#define HA_CPU_F_IGNORED 0x0008 // this CPU will not be used
#define HA_CPU_F_EXCL_MASK 0x000F // mask of bits that exclude a CPU
#define HA_CPU_F_MARK1 0x0010 // for temporary internal use only
#define HA_CPU_F_MARK2 0x0020 // for temporary internal use only
#define HA_CPU_F_MARK_MASK 0x0030 // mask to drop the two marks above
/* CPU topology descriptor. All the ID and IDX fields are initialized to -1
* when not known. The identifiers there are mostly assigned on the fly using
* increments and have no particular representation except the fact that CPUs
* having the same ID there share the same designated resource. The flags are
* preset to zero.
*/
struct ha_cpu_topo {
ushort st; // state flags (HA_CPU_F_*)
short idx; // CPU index as passed to the OS. Initially the entry index.
short ca_id[5]; // cache ID for each level (L0 to L4)
short ts_id; // thread-set identifier (generally core number)
short cl_gid; // cluster global identifier (group of more intimate cores)
short cl_lid; // cluster local identifier (per {pkg,node})
short no_id; // NUMA node identifier
short pk_id; // package identifier
short th_cnt; // number of siblings threads
short th_id; // thread ID among siblings of the same core
short capa; // estimated CPU relative capacity; more is better
};
#endif /* _HAPROXY_CPU_TOPO_T_H */