2 * collectd - src/utils_config_cores.h
4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Kamil Wiatrowski <kamilx.wiatrowski@intel.com>
28 #ifndef UTILS_CONFIG_CORES_H
29 #define UTILS_CONFIG_CORES_H 1
40 typedef struct core_group_s core_group_t;
42 struct core_groups_list_s {
43 core_group_t *cgroups;
46 typedef struct core_groups_list_s core_groups_list_t;
53 * Convert strings from config item into list of core groups.
56 * `ci' Pointer to config item.
57 * `cgl' Pointer to core groups list to be filled.
60 * Zero upon success or non-zero if an error occurred.
63 * In case of an error, *cgl is not modified.
64 * Numbers can be in decimal or hexadecimal format.
65 * The memory allocated for *cgroups in list needs to be freed
66 * with config_cores_cleanup.
69 * If config is "0-3" "[4-15]" it means that cores 0-3 are aggregated
70 * into one group and cores 4 to 15 are stored individualily in
71 * separate groups. Examples of allowed formats:
72 * "0,3,4" "10-15" - cores collected into two groups
73 * "0" "0x3" "7" - 3 cores, each in individual group
74 * "[32-63]" - 32 cores, each in individual group
76 * For empty string "" *cgl is not modified and zero is returned.
78 int config_cores_parse(const oconfig_item_t *ci, core_groups_list_t *cgl);
82 * config_cores_default
85 * Set number of cores starting from zero into individual
86 * core groups in *cgl list.
89 * `num_cores' Number of cores to be configured.
90 * `cgl' Pointer to core groups list.
93 * Zero upon success or non-zero if an error occurred.
96 * The memory allocated for *cgroups in list needs to be freed
97 * with config_cores_cleanup. In case of error the memory is
98 * freed by the function itself.
100 int config_cores_default(int num_cores, core_groups_list_t *cgl);
104 * config_cores_cleanup
107 * Free the memory allocated for cgroups and set
108 * num_cgroups to zero.
111 * `cgl' Pointer to core groups list.
113 void config_cores_cleanup(core_groups_list_t *cgl);
117 * config_cores_cmp_cgroups
120 * Function to compare cores in 2 core groups.
123 * `cg_a' Pointer to core group a.
124 * `cg_b' Pointer to core group b.
127 * 1 if both groups contain the same cores
128 * 0 if none of their cores match
129 * -1 if some but not all cores match
131 int config_cores_cmp_cgroups(const core_group_t *cg_a,
132 const core_group_t *cg_b);
134 #endif /* UTILS_CONFIG_CORES_H */