Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkpoint-and-restore support for sysfs #2

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LibOS/shim/include/shim_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void* shim_init(int argc, void* args);
extern int g_log_level;

extern const PAL_CONTROL* g_pal_control;
extern PAL_TOPO_INFO* g_topo_info;

// TODO(mkow): We should make it cross-object-inlinable, ideally by enabling LTO, less ideally by
// pasting it here and making `inline`, but our current linker scripts prevent both.
Expand Down
7 changes: 4 additions & 3 deletions LibOS/shim/src/fs/proc/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ int proc_cpuinfo_load(struct shim_dentry* dent, char** out_data, size_t* out_siz
size += ret; \
} while (0)

for (size_t n = 0; n < g_pal_control->cpu_info.online_logical_cores; n++) {
uint64_t online_logical_cores = g_topo_info->online_logical_cores.resource_count;
for (size_t n = 0; n < online_logical_cores; n++) {
/* Below strings must match exactly the strings retrieved from /proc/cpuinfo
* (see Linux's arch/x86/kernel/cpu/proc.c) */
ADD_INFO("processor\t: %lu\n", n);
Expand All @@ -122,9 +123,9 @@ int proc_cpuinfo_load(struct shim_dentry* dent, char** out_data, size_t* out_siz
ADD_INFO("model\t\t: %lu\n", g_pal_control->cpu_info.cpu_model);
ADD_INFO("model name\t: %s\n", g_pal_control->cpu_info.cpu_brand);
ADD_INFO("stepping\t: %lu\n", g_pal_control->cpu_info.cpu_stepping);
ADD_INFO("physical id\t: %d\n", g_pal_control->cpu_info.cpu_socket[n]);
ADD_INFO("physical id\t: %d\n", g_topo_info->core_topology[n].cpu_socket);
ADD_INFO("core id\t\t: %lu\n", n);
ADD_INFO("cpu cores\t: %lu\n", g_pal_control->cpu_info.physical_cores_per_socket);
ADD_INFO("cpu cores\t: %lu\n", g_topo_info->physical_cores_per_socket);
double bogomips = g_pal_control->cpu_info.cpu_bogomips;
// Apparently graphene snprintf cannot into floats.
ADD_INFO("bogomips\t: %lu.%02lu\n", (unsigned long)bogomips,
Expand Down
4 changes: 2 additions & 2 deletions LibOS/shim/src/fs/sys/cache_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ int sys_cache_load(struct shim_dentry* dent, char** out_data, size_t* out_size)
return ret;

const char* name = dent->name;
PAL_CORE_CACHE_INFO* cache = &g_pal_control->topo_info.core_topology[cpu_num].cache[cache_num];
const char* str;
PAL_CORE_CACHE_INFO* cache = &g_topo_info->core_topology[cpu_num].cache[cache_num];
char str[PAL_SYSFS_MAP_FILESZ] = {'\0'};
if (strcmp(name, "shared_cpu_map") == 0) {
str = cache->shared_cpu_map;
} else if (strcmp(name, "level") == 0) {
Expand Down
10 changes: 6 additions & 4 deletions LibOS/shim/src/fs/sys/cpu_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ int sys_cpu_general_load(struct shim_dentry* dent, char** out_data, size_t* out_
const char* str;

if (strcmp(name, "online") == 0) {
str = g_pal_control->topo_info.online_logical_cores;
ret = sys_convert_range_info_str(g_topo_info->online_logical_cores, str,
PAL_SYSFS_BUF_FILESZ, ",");
} else if (strcmp(name, "possible") == 0) {
str = g_pal_control->topo_info.possible_logical_cores;
ret = sys_convert_range_info_str(g_topo_info->possible_logical_cores, str,
PAL_SYSFS_BUF_FILESZ, ",");
} else {
log_debug("unrecognized file: %s", name);
return -ENOENT;
Expand All @@ -36,8 +38,8 @@ int sys_cpu_load(struct shim_dentry* dent, char** out_data, size_t* out_size) {
return ret;

const char* name = dent->name;
PAL_CORE_TOPO_INFO* core_topology = &g_pal_control->topo_info.core_topology[cpu_num];
const char* str;
PAL_CORE_TOPO_INFO* core_topology = &g_topo_info->core_topology[cpu_num];
char str[PAL_SYSFS_MAP_FILESZ] = {'\0'};
if (strcmp(name, "online") == 0) {
/* `cpu/cpuX/online` is not present for cpu0 */
if (cpu_num == 0)
Expand Down
Loading