mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-18 01:14:38 +00:00
MINOR: cpuset: update CPU topology from excluded CPUs at boot
Now before trying to resolve the thread assignment to groups, we detect which CPUs are not bound at boot so that we can mark them with HA_CPU_F_EXCLUDED. This will be useful to better know on which CPUs we can count later. Note that we purposely ignore cpu-map here as we don't know how threads and groups will map to cpu-map entries, hence which CPUs will really be used. It's important to proceed this way so that when we have no info we assume they're all available.
This commit is contained in:
parent
e9fd787b96
commit
3f83b78961
@ -54,6 +54,13 @@ int ha_cpuset_size(void);
|
||||
*/
|
||||
int ha_cpuset_detect_bound(struct hap_cpuset *set);
|
||||
|
||||
/* Detects the CPUs that will be used based on the ones the process is bound to.
|
||||
* Returns non-zero on success, zero on failure. Note that it may not be
|
||||
* performed in the function above because some calls may rely on other items
|
||||
* being allocated (e.g. trash).
|
||||
*/
|
||||
int cpu_detect_usable(void);
|
||||
|
||||
/* Parse cpu sets. Each CPU set is either a unique number between 0 and
|
||||
* ha_cpuset_size() - 1 or a range with two such numbers delimited by a dash
|
||||
* ('-'). Each CPU set can be a list of unique numbers or ranges separated by
|
||||
|
26
src/cpuset.c
26
src/cpuset.c
@ -176,6 +176,32 @@ int ha_cpuset_detect_bound(struct hap_cpuset *set)
|
||||
return ha_cpuset_count(set);
|
||||
}
|
||||
|
||||
/* Detects the CPUs that will be used based on the ones the process is bound to
|
||||
* at boot. The principle is the following: all CPUs from the boot cpuset will
|
||||
* be used since we don't know upfront how individual threads will be mapped to
|
||||
* groups and CPUs.
|
||||
*
|
||||
* Returns non-zero on success, zero on failure. Note that it may not be
|
||||
* performed in the function above because some calls may rely on other items
|
||||
* being allocated (e.g. trash).
|
||||
*/
|
||||
int cpu_detect_usable(void)
|
||||
{
|
||||
struct hap_cpuset boot_set = { };
|
||||
int maxcpus = ha_cpuset_size();
|
||||
int cpu;
|
||||
|
||||
/* update the list with the CPUs currently bound to the current process */
|
||||
ha_cpuset_detect_bound(&boot_set);
|
||||
|
||||
/* remove the known-excluded CPUs */
|
||||
for (cpu = 0; cpu < maxcpus; cpu++)
|
||||
if (!ha_cpuset_isset(&boot_set, cpu))
|
||||
ha_cpu_topo[cpu].st |= HA_CPU_F_EXCLUDED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parse cpu sets. Each CPU set is either a unique number between 0 and
|
||||
* ha_cpuset_size() - 1 or a range with two such numbers delimited by a dash
|
||||
* ('-'). Each CPU set can be a list of unique numbers or ranges separated by
|
||||
|
@ -2234,6 +2234,12 @@ static void init(int argc, char **argv)
|
||||
clock_adjust_now_offset();
|
||||
ready_date = date;
|
||||
|
||||
#ifdef USE_CPU_AFFINITY
|
||||
/* we've already read the config and know what CPUs are expected
|
||||
* to be used. Let's check which of these are usable.
|
||||
*/
|
||||
cpu_detect_usable();
|
||||
#endif
|
||||
|
||||
/* Note: global.nbthread will be initialized as part of this call */
|
||||
err_code |= check_config_validity();
|
||||
|
Loading…
Reference in New Issue
Block a user