mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
base-nova: Changed mapping of cores so that for each cores x and y, it is guaranteed that if x is greater than y, the NUMA ID of x is always greater than or equal to that of y.
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
#define _INCLUDE__NOVA__SYSCALL_GENERIC_H_
|
#define _INCLUDE__NOVA__SYSCALL_GENERIC_H_
|
||||||
|
|
||||||
#include <nova/stdint.h>
|
#include <nova/stdint.h>
|
||||||
|
#include <base/log.h>
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ namespace Nova {
|
|||||||
NOVA_CORE_ALLOC = 0x13,
|
NOVA_CORE_ALLOC = 0x13,
|
||||||
NOVA_CREATE_CELL= 0x14,
|
NOVA_CREATE_CELL= 0x14,
|
||||||
NOVA_CELL_CTRL = 0x15,
|
NOVA_CELL_CTRL = 0x15,
|
||||||
|
NOVA_CONS_CTRL = 0x16,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,12 +191,28 @@ namespace Nova {
|
|||||||
return desc ? desc->flags & 0x1 : false;
|
return desc ? desc->flags & 0x1 : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned numa_nodes() const {
|
||||||
|
unsigned node_num = 1;
|
||||||
|
unsigned long nodes = 0x0;
|
||||||
|
unsigned long last_node = 0;
|
||||||
|
|
||||||
|
for (unsigned cpu = 0; cpu < cpu_max(); cpu++) {
|
||||||
|
Cpu_desc const *c = cpu_desc_of_cpu(cpu);
|
||||||
|
if (c->numa_id != last_node && !(nodes & (1<<c->numa_id))) {
|
||||||
|
node_num++;
|
||||||
|
nodes |= (1 << c->numa_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return node_num;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map kernel cpu ids to virtual cpu ids.
|
* Map kernel cpu ids to virtual cpu ids.
|
||||||
*/
|
*/
|
||||||
bool remap_cpu_ids(uint8_t *map_cpus, uint8_t *cpu_numa_map, unsigned const boot_cpu) const {
|
bool remap_cpu_ids(uint8_t *map_cpus, uint8_t *cpu_numa_map, unsigned const boot_cpu) const {
|
||||||
unsigned const num_cpus = cpus();
|
unsigned const num_cpus = cpus();
|
||||||
unsigned cpu_i = 0;
|
unsigned cpu_i = 0;
|
||||||
|
unsigned const num_nodes = numa_nodes();
|
||||||
|
|
||||||
/* assign boot cpu ever the virtual cpu id 0 */
|
/* assign boot cpu ever the virtual cpu id 0 */
|
||||||
Cpu_desc const * const boot = cpu_desc_of_cpu(boot_cpu);
|
Cpu_desc const * const boot = cpu_desc_of_cpu(boot_cpu);
|
||||||
@@ -205,30 +223,23 @@ namespace Nova {
|
|||||||
if (cpu_i >= num_cpus)
|
if (cpu_i >= num_cpus)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* assign remaining cores and afterwards all threads to the ids */
|
for (uint8_t node = 0; node < num_nodes; node++) {
|
||||||
for (uint8_t package = 0; package < 255; package++) {
|
for (unsigned i = 0; i < num_cpus; i++) {
|
||||||
for (uint8_t core = 0; core < 255; core++) {
|
if (i == boot_cpu || !is_cpu_enabled(i))
|
||||||
for (uint8_t thread = 0; thread < 255; thread++) {
|
continue;
|
||||||
for (unsigned i = 0; i < cpu_max(); i++) {
|
|
||||||
if (i == boot_cpu || !is_cpu_enabled(i))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Cpu_desc const * const c = cpu_desc_of_cpu(i);
|
Cpu_desc const *c = cpu_desc_of_cpu(i);
|
||||||
if (!c)
|
if (!(c->numa_id == node))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(c->package == package && c->core == core &&
|
cpu_numa_map[i] = c->numa_id;
|
||||||
c->thread == thread))
|
map_cpus[cpu_i++] = (uint8_t)i;
|
||||||
continue;
|
|
||||||
|
|
||||||
cpu_numa_map[i] = c->numa_id;
|
if (cpu_i >= num_cpus)
|
||||||
map_cpus[cpu_i++] = (uint8_t)i;
|
return true;
|
||||||
if (cpu_i >= num_cpus)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,5 +868,13 @@ namespace Nova {
|
|||||||
SM_SEL_EC = 0x1d, /* convention on Genode */
|
SM_SEL_EC = 0x1d, /* convention on Genode */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Console operations
|
||||||
|
*/
|
||||||
|
enum Cons_op
|
||||||
|
{
|
||||||
|
LOCK = 0,
|
||||||
|
UNLOCK = 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
#endif /* _INCLUDE__NOVA__SYSCALL_GENERIC_H_ */
|
#endif /* _INCLUDE__NOVA__SYSCALL_GENERIC_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user