Procfs

Overview

The module exposes inside the procfs several informations about every running scheduler thread and worker thread. In particular for every process that opens the UMS device the following tree is created:

/proc/ums/<pid>
├── schedulers
│   ├── ...
│   ├── <scheduler-pid>
│   │   ├── info
│   │   └── workers
│   │       ├── 0 -> /proc/ums/<pid>/workers/<worker-pid>
│   │       ├── ...
│   │       └── n -> /proc/ums/<pid>/workers/<worker-pid>
│   └── ...
└── workers
    ├── ...
    ├── <worker-pid>
    │   └── info
    └── ...

Inside the /proc/ums/<pid>/schedulers there is a folder for each UMS scheduler thread and inside the /proc/ums/<pid>/workers there is a folder for each UMS worker thread.

The info file shows some statistics as the pid of the UMS thread, the number of context switches and the current context state (idle/running).

The /proc/ums/<pid>/schedulers/<scheduler-pid>/workers folder contains a symbolic link for each UMS worker thread the UMS scheduler has dequeued from the completion list; in particular the links are named from 0 to n and they targets the /proc/ums/<pid>/workers/<worker-pid> which they refer to.

Structs

struct ums_proc_dirs

UMS procfs base directories for each process that opens the UMS device

Public Members

char *pid_dir_path

procfs base directory path, i.e. /proc/ums/<pid>

size_t pid_dir_path_size

procfs base directory path length

struct proc_dir_entry *pid_dir

procfs base directory

struct proc_dir_entry *sched_dir

procfs schedulers directory located at /proc/ums/<pid>/schedulers

char *workers_dir_path

procfs workers directory path, i.e. /proc/ums/<pid>/workers

size_t workers_dir_path_size

procfs workers directory path length

struct proc_dir_entry *workers_dir

procfs workers directory

struct ums_scheduler_proc_dirs

UMS scheduler procfs directories

Public Members

struct proc_dir_entry *scheduler_dir

procfs scheduler directory located at /proc/ums/<pid>/schedulers/<sched-pid>

struct proc_dir_entry *scheduler_info_dir

scheduler info file located at /proc/ums/<pid>/schedulers/<sched-pid>/info

struct proc_dir_entry *workers_dir

procfs scheduler’s workers directory located at /proc/ums/<pid>/schedulers/<sched-pid>/workers

unsigned long n_workers

number of UMS workers dequeued from the UMS scheduler’s completion list

unsigned long max_workers
struct ums_worker_complist_node

UMS completion list node with UMS worker

Public Members

Symbolic link targeting the UMS worker

struct ums_worker_proc_dirs

UMS worker procfs directories

Public Members

char *worker_dir_path

procfs worker directory path, i.e. /proc/ums/<pid>/workers/<worker-pid>

size_t worker_dir_path_size

procfs worker directory path length

struct proc_dir_entry *worker_dir

procfs worker directory

struct proc_dir_entry *worker_info_dir

worker info file located at /proc/ums/<pid>/workers/<worker-pid>/info

struct ums_worker_complist_node complist_node

procfs worker node with a completion list

Functions

int ums_proc_init(void)

Initialize the UMS procfs.

Returns

  • 0 - OK

  • -ENOMEM - No memory available

void ums_proc_destroy(void)

Destroy the UMS procfs.

int ums_proc_dirs_init(struct ums_proc_dirs *dirs)

Initialize the UMS procfs base directories.

Parameters
  • dirs[in] pointer to the UMS procfs directories

Returns

  • 0 - OK

  • -ENOMEM - No memory available

void ums_proc_dirs_destroy(struct ums_proc_dirs *dirs)

Destroy the UMS procfs base directories.

Parameters
  • dirs[in] pointer to the UMS procfs directories

const char *get_context_state(struct ums_context *context)

Get a string representation of the UMS context state.

Parameters
  • context[in] pointer to the UMS context

Returns

the context state representation

static inline int context_snprintf(char *buf, size_t size, struct ums_context *context)

Get a string representation of the UMS context.

Parameters
  • buf[inout] pointer to an allocated buffer

  • size[in] maximum number of bytes to write

  • context[in] pointer to the UMS context

Returns

the number of characters printed or truncated

int ums_scheduler_proc_register(struct ums_proc_dirs *dirs, struct ums_scheduler *scheduler)

Register the UMS scheduler to the UMS procfs.

Parameters
  • dirs[inout] pointer to the UMS procfs directories

  • scheduler[in] pointer to the UMS scheduler

Returns

  • 0 - OK

  • -ENOMEM - No memory available

void ums_scheduler_proc_unregister(struct ums_scheduler *scheduler)

Unregister the UMS scheduler to the UMS procfs.

Parameters
  • scheduler[in] pointer to the UMS scheduler

int ums_scheduler_proc_register_worker(struct ums_scheduler_proc_dirs *dirs, struct ums_worker_proc_dirs *worker_dirs)

Register the UMS worker to the UMS scheduler procfs.

Create a symlink inside /proc/ums/<pid>/schedulers/<sched-pid>/workers with the UMS worker as target.

Parameters
  • dirs[inout] pointer to the UMS scheduler procfs directories

  • worker_dirs[inout] pointer to the UMS worker procfs directories

Returns

  • 0 - OK

  • -ENOMEM - No memory available

void ums_scheduler_proc_unregister_worker(struct ums_scheduler_proc_dirs *dirs, struct ums_worker_proc_dirs *worker_dirs)

Unregister the UMS worker to the UMS scheduler procfs.

Remove the symlink inside /proc/ums/<pid>/schedulers/<sched-pid>/workers with the UMS worker as target.

Parameters
  • dirs[inout] pointer to the UMS scheduler procfs directories

  • worker_dirs[inout] pointer to the UMS worker procfs directories

int ums_worker_proc_register(struct ums_proc_dirs *dirs, struct ums_worker *worker)

Register the UMS worker to the UMS procfs.

Parameters
  • dirs[inout] pointer to the UMS procfs directories

  • worker[in] pointer to the UMS worker

Returns

  • 0 - OK

  • -ENOMEM - No memory available

void ums_worker_proc_unregister(struct ums_worker *worker)

Unregister the UMS worker to the UMS procfs.

Parameters
  • worker[in] pointer to the UMS worker