4
* Copyright Ericsson AB 2010. All Rights Reserved.
6
* The contents of this file are subject to the Erlang Public License,
7
* Version 1.1, (the "License"); you may not use this file except in
8
* compliance with the License. You should have received a copy of the
9
* Erlang Public License along with this software. If not, it can be
10
* retrieved online at http://www.erlang.org/.
12
* Software distributed under the License is distributed on an "AS IS"
13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
* the License for the specific language governing rights and limitations
21
* Description: CPU topology and related functionality
23
* Author: Rickard Green
26
#ifndef ERL_CPU_TOPOLOGY_H__
27
#define ERL_CPU_TOPOLOGY_H__
29
void erts_pre_early_init_cpu_topology(int *max_rg_p,
33
void erts_early_init_cpu_topology(int no_schedulers,
34
int *max_main_threads_p,
35
int max_reader_groups,
36
int *reader_groups_p);
37
void erts_init_cpu_topology(void);
40
#define ERTS_INIT_SCHED_BIND_TYPE_SUCCESS 0
41
#define ERTS_INIT_SCHED_BIND_TYPE_NOT_SUPPORTED 1
42
#define ERTS_INIT_SCHED_BIND_TYPE_ERROR_NO_CPU_TOPOLOGY 2
43
#define ERTS_INIT_SCHED_BIND_TYPE_ERROR_NO_BAD_TYPE 3
45
int erts_init_scheduler_bind_type_string(char *how);
48
#define ERTS_INIT_CPU_TOPOLOGY_OK 0
49
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_ID 1
50
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_ID_RANGE 2
51
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_HIERARCHY 3
52
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_ID_TYPE 4
53
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_NODES 5
54
#define ERTS_INIT_CPU_TOPOLOGY_MISSING_LID 6
55
#define ERTS_INIT_CPU_TOPOLOGY_NOT_UNIQUE_LIDS 7
56
#define ERTS_INIT_CPU_TOPOLOGY_NOT_UNIQUE_ENTITIES 8
57
#define ERTS_INIT_CPU_TOPOLOGY_MISSING 9
59
int erts_init_cpu_topology_string(char *topology_str);
61
void erts_sched_check_cpu_bind(ErtsSchedulerData *esdp);
63
void erts_sched_init_check_cpu_bind(ErtsSchedulerData *esdp);
64
void erts_sched_check_cpu_bind_prep_suspend(ErtsSchedulerData *esdp);
65
void erts_sched_check_cpu_bind_post_suspend(ErtsSchedulerData *esdp);
68
int erts_update_cpu_info(void);
70
Eterm erts_bind_schedulers(Process *c_p, Eterm how);
71
Eterm erts_get_schedulers_binds(Process *c_p);
73
Eterm erts_get_reader_groups_map(Process *c_p);
75
Eterm erts_set_cpu_topology(Process *c_p, Eterm term);
76
Eterm erts_get_cpu_topology_term(Process *c_p, Eterm which);
78
int erts_update_cpu_info(void);
79
void erts_get_logical_processors(int *conf, int *onln, int *avail);
81
int erts_sched_bind_atthrcreate_prepare(void);
82
int erts_sched_bind_atthrcreate_child(int unbind);
83
void erts_sched_bind_atthrcreate_parent(int unbind);
85
int erts_sched_bind_atfork_prepare(void);
86
int erts_sched_bind_atfork_child(int unbind);
87
char *erts_sched_bind_atvfork_child(int unbind);
88
void erts_sched_bind_atfork_parent(int unbind);
90
Eterm erts_fake_scheduler_bindings(Process *p, Eterm how);
91
Eterm erts_debug_cpu_groups_map(Process *c_p, int groups);
94
typedef void (*erts_cpu_groups_callback_t)(int,
99
void erts_add_cpu_groups(int groups,
100
erts_cpu_groups_callback_t callback,
102
void erts_remove_cpu_groups(erts_cpu_groups_callback_t callback,