-
Notifications
You must be signed in to change notification settings - Fork 2
/
node.h
200 lines (163 loc) · 3.96 KB
/
node.h
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
* Copyright (c) 2016-2018 Wuklab, Purdue University. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
/*
* This file defines all the node related helpers.
* You should always should these functions to get corresponding node id.
*/
#ifndef _LEGO_PROCESSOR_NODE_H_
#define _LEGO_PROCESSOR_NODE_H_
#include <lego/comp_common.h>
#include <lego/sched.h>
#ifdef CONFIG_COMP_PROCESSOR
static inline int get_memory_home_node(struct task_struct *tsk)
{
return tsk->pm_data.home_node;
}
static inline void set_memory_home_node(struct task_struct *tsk, int node)
{
tsk->pm_data.home_node = node;
}
static inline int get_replica_node(struct task_struct *tsk)
{
return tsk->pm_data.replica_node;
}
static inline void set_replica_node(struct task_struct *tsk, int node)
{
tsk->pm_data.replica_node = node;
}
static inline int current_memory_home_node(void)
{
return get_memory_home_node(current);
}
static inline int current_replica_node(void)
{
return get_replica_node(current);
}
static inline int get_vnode_id(struct task_struct *tsk)
{
return 0;
}
static inline int current_vnode_id(void)
{
return 0;
}
/*
* - default_pgcache_home_node = get_memory_home_node
* - default_storage_home_node = STORAGE_NODE
* - used in UNSET case
*/
static inline int default_pgcache_home_node(struct task_struct *tsk)
{
return get_memory_home_node(tsk);
}
static inline int default_storage_home_node(struct task_struct *tsk)
{
return STORAGE_NODE;
}
#ifdef CONFIG_GSM
int get_info_from_gsm(int my_vnode_id);
static inline int get_pgcache_home_node(struct task_struct *tsk)
{
return tsk->pm_data.pgcache_node;
}
static inline void set_pgcache_home_node(struct task_struct *tsk, int node)
{
tsk->pm_data.pgcache_node = node;
}
static inline int get_storage_home_node(struct task_struct *tsk)
{
return tsk->pm_data.storage_node;
}
static inline void set_storage_home_node(struct task_struct *tsk, int node)
{
tsk->pm_data.storage_node = node;
}
static inline int current_pgcache_home_node(void)
{
int pgcache_node;
retry:
pgcache_node = get_pgcache_home_node(current);
if (unlikely(pgcache_node == UNSET_PGCACHE_NODE)) {
get_info_from_gsm(current_vnode_id());
goto retry;
}
return pgcache_node;
}
static inline int current_storage_home_node(void)
{
int storage_node;
retry:
storage_node = get_storage_home_node(current);
if (unlikely(storage_node == UNSET_STORAGE_NODE)) {
get_info_from_gsm(current_vnode_id());
goto retry;
}
return storage_node;
}
#else
/*
* TODO:
*
* Temporary pgcache_node. If GSM is not configured, pgcache is too.
* Should be patched in the next pgcache patch.
*/
static inline int get_pgcache_home_node(struct task_struct *tsk)
{
return default_pgcache_home_node(tsk);
}
static inline void set_pgcache_home_node(struct task_struct *tsk, int node)
{
}
static inline int get_storage_home_node(struct task_struct *tsk)
{
return default_storage_home_node(tsk);
}
static inline void set_storage_home_node(struct task_struct *tsk, int node)
{
}
static inline int current_pgcache_home_node(void)
{
return default_pgcache_home_node(current);
}
static inline int current_storage_home_node(void)
{
return default_storage_home_node(current);
}
#endif /* CONFIG_GSM */
#else
/*
* Not a processor manager.
* These helpers should never be used.
*/
static inline int get_memory_home_node(struct task_struct *p)
{
BUG();
}
static inline void set_memory_home_node(struct task_struct *tsk, int node)
{
BUG();
}
static inline int get_replica_node(struct task_struct *tsk)
{
BUG();
}
static inline void set_replica_node(struct task_struct *tsk, int node)
{
BUG();
}
static inline int current_memory_home_node(void)
{
BUG();
}
static inline int current_replica_node(void)
{
BUG();
}
#endif /* CONFIG_COMP_PROCESSOR */
#endif /* _LEGO_PROCESSOR_NODE_H_ */