2021-04-14 09:03:51 -04:00
|
|
|
#ifndef _HAPROXY_CPUSET_H
|
|
|
|
|
#define _HAPROXY_CPUSET_H
|
|
|
|
|
|
|
|
|
|
#include <haproxy/cpuset-t.h>
|
|
|
|
|
|
2023-07-12 05:35:32 -04:00
|
|
|
extern struct cpu_map *cpu_map;
|
2021-04-27 04:46:36 -04:00
|
|
|
|
2021-04-14 09:03:51 -04:00
|
|
|
/* Unset all indexes in <set>.
|
|
|
|
|
*/
|
|
|
|
|
void ha_cpuset_zero(struct hap_cpuset *set);
|
|
|
|
|
|
|
|
|
|
/* Set <cpu> index in <set> if not present.
|
|
|
|
|
* Returns 0 on success otherwise non-zero.
|
|
|
|
|
*/
|
|
|
|
|
int ha_cpuset_set(struct hap_cpuset *set, int cpu);
|
|
|
|
|
|
|
|
|
|
/* Clear <cpu> index in <set> if present.
|
|
|
|
|
* Returns 0 on success otherwise non-zero.
|
|
|
|
|
*/
|
|
|
|
|
int ha_cpuset_clr(struct hap_cpuset *set, int cpu);
|
|
|
|
|
|
|
|
|
|
/* Bitwise and equivalent operation between <src> and <dst> stored in <dst>.
|
|
|
|
|
*/
|
2022-01-28 03:10:52 -05:00
|
|
|
void ha_cpuset_and(struct hap_cpuset *dst, struct hap_cpuset *src);
|
2021-04-14 09:03:51 -04:00
|
|
|
|
2023-07-12 06:08:36 -04:00
|
|
|
/* Bitwise OR equivalent operation between <src> and <dst> stored in <dst>.
|
|
|
|
|
*/
|
|
|
|
|
void ha_cpuset_or(struct hap_cpuset *dst, struct hap_cpuset *src);
|
|
|
|
|
|
2023-07-06 10:39:08 -04:00
|
|
|
/* returns non-zero if CPU index <cpu> is set in <set>, otherwise 0. */
|
|
|
|
|
int ha_cpuset_isset(const struct hap_cpuset *set, int cpu);
|
|
|
|
|
|
2021-04-14 09:03:51 -04:00
|
|
|
/* Returns the count of set index in <set>.
|
|
|
|
|
*/
|
|
|
|
|
int ha_cpuset_count(const struct hap_cpuset *set);
|
|
|
|
|
|
|
|
|
|
/* Returns the first index set plus one in <set> starting from the lowest.
|
|
|
|
|
* Returns 0 if no index set.
|
2021-04-24 04:25:42 -04:00
|
|
|
* Do not forget to subtract the result by one if using it for set/clr.
|
2021-04-14 09:03:51 -04:00
|
|
|
*/
|
|
|
|
|
int ha_cpuset_ffs(const struct hap_cpuset *set);
|
|
|
|
|
|
|
|
|
|
/* Copy <src> set into <dst>.
|
|
|
|
|
*/
|
2022-01-28 03:10:52 -05:00
|
|
|
void ha_cpuset_assign(struct hap_cpuset *dst, struct hap_cpuset *src);
|
2021-04-14 09:03:51 -04:00
|
|
|
|
|
|
|
|
/* Returns the biggest index plus one usable on the platform.
|
|
|
|
|
*/
|
CLEANUP: tree-wide: fix prototypes for functions taking no arguments.
"f(void)" is the correct and preferred form for a function taking no
argument, while some places use the older "f()". These were reported
by clang's -Wmissing-prototypes, for example:
src/cpuset.c:111:5: warning: no previous prototype for function 'ha_cpuset_size' [-Wmissing-prototypes]
int ha_cpuset_size()
include/haproxy/cpuset.h:42:5: note: this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function
int ha_cpuset_size();
^
void
This aggregate patch fixes this for the following functions:
ha_backtrace_to_stderr(), ha_cpuset_size(), ha_panic(), ha_random64(),
ha_thread_dump_all_to_trash(), get_exec_path(), check_config_validity(),
mworker_child_nb(), mworker_cli_proxy_(create|stop)(),
mworker_cleantasks(), mworker_cleanlisteners(), mworker_ext_launch_all(),
mworker_reload(), mworker_(env|proc_list)_to_(proc_list|env)(),
mworker_(un|)block_signals(), proxy_adjust_all_maxconn(),
proxy_destroy_all_defaults(), get_tainted(),
pool_total_(allocated|used)(), thread_isolate(_full|)(),
thread(_sync|)_release(), thread_harmless_till_end(),
thread_cpu_mask_forced(), dequeue_all_listeners(), next_timer_expiry(),
wake_expired_tasks(), process_runnable_tasks(), init_acl(),
init_buffer(), (de|)init_log_buffers(), (de|)init_pollers(),
fork_poller(), pool_destroy_all(), pool_evict_from_local_caches(),
pool_total_failures(), dump_pools_to_trash(), cfg_run_diagnostics(),
tv_init_(process|thread)_date(), __signal_process_queue(),
deinit_signals(), haproxy_unblock_signals()
2021-09-12 06:49:33 -04:00
|
|
|
int ha_cpuset_size(void);
|
2021-04-14 09:03:51 -04:00
|
|
|
|
2023-07-11 10:51:22 -04:00
|
|
|
/* Detects CPUs that are bound to the current process. Returns the number of
|
|
|
|
|
* CPUs detected or 0 if the detection failed.
|
|
|
|
|
*/
|
|
|
|
|
int ha_cpuset_detect_bound(struct hap_cpuset *set);
|
|
|
|
|
|
2023-07-06 08:35:11 -04:00
|
|
|
/* 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
|
|
|
|
|
* a comma. It is also possible to specify multiple cpu numbers or ranges in
|
|
|
|
|
* distinct argument in <args>. On success, it returns 0, otherwise it returns
|
|
|
|
|
* 1 with an error message in <err>.
|
|
|
|
|
*/
|
|
|
|
|
int parse_cpu_set(const char **args, struct hap_cpuset *cpu_set, char **err);
|
|
|
|
|
|
|
|
|
|
/* Parse a linux cpu map string representing to a numeric cpu mask map
|
|
|
|
|
* The cpu map string is a list of 4-byte hex strings separated by commas, with
|
|
|
|
|
* most-significant byte first, one bit per cpu number.
|
|
|
|
|
*/
|
|
|
|
|
void parse_cpumap(char *cpumap_str, struct hap_cpuset *cpu_set);
|
|
|
|
|
|
2023-07-18 11:14:10 -04:00
|
|
|
/* Returns true if at least one cpu-map directive was configured, otherwise
|
|
|
|
|
* false.
|
|
|
|
|
*/
|
|
|
|
|
int cpu_map_configured(void);
|
|
|
|
|
|
2021-04-14 09:03:51 -04:00
|
|
|
#endif /* _HAPROXY_CPUSET_H */
|