Skip to content

Commit

Permalink
procfs: add minimum subset of status file intended for linuma consump…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: Waldemar Kozaczuk <[email protected]>
  • Loading branch information
wkozaczuk committed Sep 5, 2019
1 parent 89472ab commit 70c72b3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions fs/procfs/procfs_vnops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,29 @@ static std::string procfs_stats()
exit_signal, cpu, rt_priority, policy
);
return os.str();
}

static std::string procfs_status()
{
// The /proc/self/status in Linux contains most of the same
// information /proc/self/stat does but presented to a human user
// OSv version exposes only bare minimum of it which is NUMA-related
// information about cpus and memory intended for numa library
// For details about the format read here: http://man7.org/linux/man-pages/man5/proc.5.html
// and here: http://man7.org/linux/man-pages/man7/cpuset.7.html (mask and list format)
auto cpu_count = sched::cpus.size();
uint32_t first_set = 0xffffffff >> (32 - cpu_count % 32);
int remaining_cpus_sets = cpu_count / 32;

std::ostringstream os;
osv::fprintf(os, "Cpus_allowed:\t%08x", first_set);
for (; remaining_cpus_sets > 0; remaining_cpus_sets--) {
osv::fprintf(os, ",%08x", 0xffffffff);
}
osv::fprintf(os, "\nCpus_allowed_list:\t0-%d\n"
"Mems_allowed:\t00000001\n"
"Mems_allowed_list:\t0\n", cpu_count - 1);
return os.str();
}

static std::string procfs_mounts()
Expand Down Expand Up @@ -371,6 +393,7 @@ procfs_mount(mount* mp, const char *dev, int flags, const void* data)
auto self = make_shared<proc_dir_node>(inode_count++);
self->add("maps", inode_count++, mmu::procfs_maps);
self->add("stat", inode_count++, procfs_stats);
self->add("status", inode_count++, procfs_status);

auto kernel = make_shared<proc_dir_node>(inode_count++);
kernel->add("hostname", inode_count++, procfs_hostname);
Expand Down

0 comments on commit 70c72b3

Please sign in to comment.