aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_cpu_topology.h
blob: 45324ac4a05679991895f3ce0fb7f3ddea8b0c97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * %CopyrightBegin%
 *
 * Copyright Ericsson AB 2010-2016. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * %CopyrightEnd%
 */

/*
 * Description:	CPU topology and related functionality
 *
 * Author: 	Rickard Green
 */

#ifndef ERL_CPU_TOPOLOGY_H__
#define ERL_CPU_TOPOLOGY_H__

void erts_pre_early_init_cpu_topology(int *max_rg_p,
				      int *conf_p,
				      int *onln_p,
				      int *avail_p);
void erts_early_init_cpu_topology(int no_schedulers,
				  int *max_main_threads_p,
				  int max_reader_groups,
				  int *reader_groups_p);
void erts_init_cpu_topology(void);


#define ERTS_INIT_SCHED_BIND_TYPE_SUCCESS		0
#define ERTS_INIT_SCHED_BIND_TYPE_NOT_SUPPORTED		1
#define ERTS_INIT_SCHED_BIND_TYPE_ERROR_NO_CPU_TOPOLOGY	2
#define ERTS_INIT_SCHED_BIND_TYPE_ERROR_BAD_TYPE	3

int erts_init_scheduler_bind_type_string(char *how);


#define ERTS_INIT_CPU_TOPOLOGY_OK			0
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_ID		1
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_ID_RANGE		2
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_HIERARCHY	3
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_ID_TYPE		4
#define ERTS_INIT_CPU_TOPOLOGY_INVALID_NODES		5
#define ERTS_INIT_CPU_TOPOLOGY_MISSING_LID		6
#define ERTS_INIT_CPU_TOPOLOGY_NOT_UNIQUE_LIDS		7
#define ERTS_INIT_CPU_TOPOLOGY_NOT_UNIQUE_ENTITIES	8
#define ERTS_INIT_CPU_TOPOLOGY_MISSING			9

int erts_init_cpu_topology_string(char *topology_str);

void erts_sched_check_cpu_bind(ErtsSchedulerData *esdp);
#ifdef ERTS_SMP
void erts_sched_init_check_cpu_bind(ErtsSchedulerData *esdp);
void erts_sched_check_cpu_bind_prep_suspend(ErtsSchedulerData *esdp);
void erts_sched_check_cpu_bind_post_suspend(ErtsSchedulerData *esdp);
#endif

int erts_update_cpu_info(void);

Eterm erts_bind_schedulers(Process *c_p, Eterm how);
Eterm erts_get_schedulers_binds(Process *c_p);

Eterm erts_get_reader_groups_map(Process *c_p);

Eterm erts_set_cpu_topology(Process *c_p, Eterm term);
Eterm erts_get_cpu_topology_term(Process *c_p, Eterm which);

int erts_update_cpu_info(void);
void erts_get_logical_processors(int *conf, int *onln, int *avail);

int erts_sched_bind_atthrcreate_prepare(void);
int erts_sched_bind_atthrcreate_child(int unbind);
void erts_sched_bind_atthrcreate_parent(int unbind);

int erts_sched_bind_atfork_prepare(void);
int erts_sched_bind_atfork_child(int unbind);
char *erts_sched_bind_atvfork_child(int unbind);
void erts_sched_bind_atfork_parent(int unbind);

Eterm erts_fake_scheduler_bindings(Process *p, Eterm how);
Eterm erts_debug_cpu_groups_map(Process *c_p, int groups);


typedef void (*erts_cpu_groups_callback_t)(int,
					   ErtsSchedulerData *,
					   int,
					   void *);

void erts_add_cpu_groups(int groups,
			 erts_cpu_groups_callback_t callback,
			 void *arg);
void erts_remove_cpu_groups(erts_cpu_groups_callback_t callback,
			    void *arg);

#endif