Loading...
Searching...
No Matches
Cpu_sched_vty

CPU Scheduling related VTY API. More...

## Files

file | cpu_sched_vty.c
| Implementation to CPU / Threading / Scheduler properties from VTY configuration.

## Data Structures

struct | cpu_affinity_it
struct | sched_vty_opts

## Enumerations

enum | sched_vty_thread_id { SCHED_VTY_THREAD_SELF , SCHED_VTY_THREAD_ALL , SCHED_VTY_THREAD_ID , SCHED_VTY_THREAD_NAME , SCHED_VTY_THREAD_UNKNOWN }

## Functions

static int | get_num_cpus (void)
static int | parse_cpu_hex_mask (const char *str, cpu_set_t *cpuset, size_t cpuset_size)
static int | generate_cpu_hex_mask (char *str, size_t str_buf_size, cpu_set_t *cpuset, size_t cpuset_size)
static bool | proc_tid_exists (pid_t tid)
static bool | proc_name_exists (const char *name, pid_t *res_pid)
static enum sched_vty_thread_id | procname2pid (pid_t *res_pid, const char *str, bool applynow)
static int | my_sched_setaffinity (enum sched_vty_thread_id tid_type, pid_t pid, cpu_set_t *cpuset, size_t cpuset_size)

DEFUN_ATTR (cfg_sched_cpu_affinity, cfg_sched_cpu_affinity_cmd, "cpu-affinity (self|all|<0-4294967295>|THREADNAME) CPUHEXMASK [delay]", "Set CPU affinity mask on a (group of) thread(s)\n" "Set CPU affinity mask on thread running the VTY\n" "Set CPU affinity mask on all process' threads\n" "Set CPU affinity mask on a thread with specified PID\n" "Set CPU affinity mask on a thread with specified thread name\n" "CPU affinity mask\n" "If set, delay applying the affinity mask now and let the app handle it at a later point\n", CMD_ATTR_IMMEDIATE)

static int | set_sched_rr (unsigned int prio)
| DEFUN_ATTR (cfg_sched_policy, cfg_sched_policy_cmd, "policy rr <1-32>", "Set the scheduling policy to use for the process\n" "Use the SCHED_RR real-time scheduling algorithm\n" "Set the SCHED_RR real-time priority\n", CMD_ATTR_IMMEDIATE)
| DEFUN (cfg_sched, cfg_sched_cmd, "cpu-sched", "Configure CPU Scheduler related settings")
| DEFUN (show_sched_threads, show_sched_threads_cmd, "show cpu-sched threads", SHOW_STR "Show Sched section information\n" "Show information about running threads)\n")
static int | config_write_sched (struct vty *vty)
int | osmo_cpu_sched_vty_init (void *tall_ctx)
| Initialize sched VTY nodes.
int | osmo_cpu_sched_vty_apply_localthread (void)
| Apply cpu-affinity on calling thread based on VTY configuration.

## Variables

static struct sched_vty_opts * | sched_vty_opts
static struct cmd_node | sched_node

## Detailed Description

CPU Scheduling related VTY API.

## Enumeration Type Documentation

## sched_vty_thread_id

enum sched_vty_thread_id

Enumerator
SCHED_VTY_THREAD_SELF |
SCHED_VTY_THREAD_ALL |
SCHED_VTY_THREAD_ID |
SCHED_VTY_THREAD_NAME |
SCHED_VTY_THREAD_UNKNOWN |

## Function Documentation

## config_write_sched()

int config_write_sched | ( | struct vty * | vty | ) |

static

References cpu_affinity_it::bufname, CMD_SUCCESS, sched_vty_opts::cpu_affinity_li, cpu_affinity_it::cpuset, cpu_affinity_it::cpuset_size, cpu_affinity_it::delay, cpu_affinity_it::entry, generate_cpu_hex_mask(), sched_vty_opts::sched_rr_prio, VTY_NEWLINE, and vty_out().

Referenced by osmo_cpu_sched_vty_init().

## DEFUN() [1/2]

DEFUN | ( | cfg_sched | ,
|  | cfg_sched_cmd | ,
|  | "cpu-sched" | ,
|  | "Configure CPU Scheduler related settings" | )

References CMD_SUCCESS, vty::index, L_CPU_SCHED_NODE, and vty::node.

## DEFUN() [2/2]

DEFUN | ( | show_sched_threads | ,
|  | show_sched_threads_cmd | ,
|  | "show cpu-sched threads" | ,
|  | SHOW_STR "Show Sched section information\n" "Show information about running | threads )

References CMD_SUCCESS, CMD_WARNING, generate_cpu_hex_mask(), get_num_cpus(), SHOW_STR, VTY_NEWLINE, and vty_out().

## DEFUN_ATTR() [1/2]

DEFUN_ATTR | ( | cfg_sched_cpu_affinity | ,
|  | cfg_sched_cpu_affinity_cmd | ,
|  | "cpu-affinity (self|all|<0-4294967295>|THREADNAME) CPUHEXMASK " | [delay],
|  | "Set CPU affinity mask on a (group of) thread(s)\n" "Set CPU affinity mask on thread running the VTY\n" "Set CPU affinity mask on all process' threads\n" "Set CPU affinity mask on a thread with specified PID\n" "Set CPU affinity mask on a thread with specified thread name\n" "CPU affinity mask\n" "If | set,
|  | delay applying the affinity mask now and let the app handle it at a later point\n" | ,
|  | CMD_ATTR_IMMEDIATE | )

References argc, argv, cpu_affinity_it::bufname, CMD_ATTR_IMMEDIATE, CMD_SUCCESS, CMD_WARNING, sched_vty_opts::cpu_affinity_li, sched_vty_opts::cpu_affinity_li_mutex, cpu_affinity_it::cpuset, cpu_affinity_it::cpuset_size, cpu_affinity_it::delay, cpu_affinity_it::entry, get_num_cpus(), my_sched_setaffinity(), parse_cpu_hex_mask(), procname2pid(), SCHED_VTY_THREAD_ALL, SCHED_VTY_THREAD_ID, SCHED_VTY_THREAD_NAME, SCHED_VTY_THREAD_SELF, SCHED_VTY_THREAD_UNKNOWN, sched_vty_opts::tall_ctx, cpu_affinity_it::tid_type, VTY_NEWLINE, and vty_out().

## DEFUN_ATTR() [2/2]

DEFUN_ATTR | ( | cfg_sched_policy | ,
|  | cfg_sched_policy_cmd | ,
|  | "policy rr <1-32>" | ,
|  | "Set the scheduling policy to use for the process\n" "Use the SCHED_RR real-time scheduling algorithm\n" "Set the SCHED_RR real-time priority\n" | ,
|  | CMD_ATTR_IMMEDIATE | )

References argv, CMD_ATTR_IMMEDIATE, CMD_SUCCESS, CMD_WARNING, sched_vty_opts::sched_rr_prio, set_sched_rr(), VTY_NEWLINE, and vty_out().

## generate_cpu_hex_mask()

int generate_cpu_hex_mask | ( | char * | str,
|  | size_t | str_buf_size,
|  | cpu_set_t * | cpuset,
|  | size_t | cpuset_size )

static

Referenced by config_write_sched(), DEFUN(), my_sched_setaffinity(), and osmo_cpu_sched_vty_apply_localthread().

## get_num_cpus()

int get_num_cpus | ( | void |  | ) |

static

Referenced by DEFUN(), DEFUN_ATTR(), and osmo_cpu_sched_vty_init().

## my_sched_setaffinity()

int my_sched_setaffinity | ( | enum sched_vty_thread_id | tid_type,
|  | pid_t | pid,
|  | cpu_set_t * | cpuset,
|  | size_t | cpuset_size )

static

References generate_cpu_hex_mask(), and SCHED_VTY_THREAD_ALL.

Referenced by DEFUN_ATTR(), and osmo_cpu_sched_vty_apply_localthread().

## osmo_cpu_sched_vty_apply_localthread()

int osmo_cpu_sched_vty_apply_localthread | ( | void |  | ) |

Apply cpu-affinity on calling thread based on VTY configuration.

Returns
  0 on success, non-zero on error.

References cpu_affinity_it::bufname, sched_vty_opts::cpu_affinity_li, sched_vty_opts::cpu_affinity_li_mutex, cpu_affinity_it::cpuset, cpu_affinity_it::cpuset_size, cpu_affinity_it::entry, generate_cpu_hex_mask(), my_sched_setaffinity(), SCHED_VTY_THREAD_ALL, SCHED_VTY_THREAD_NAME, SCHED_VTY_THREAD_SELF, and cpu_affinity_it::tid_type.

## osmo_cpu_sched_vty_init()

int osmo_cpu_sched_vty_init | ( | void * | tall_ctx | ) |

Initialize sched VTY nodes.

Parameters

  [in] | tall_ctx | Talloc context to use internally by vty_sched subsystem.

Returns
  0 on success, non-zero on error.

References CONFIG_NODE, config_write_sched(), sched_vty_opts::cpu_affinity_li, sched_vty_opts::cpu_affinity_li_mutex, get_num_cpus(), install_lib_element(), install_lib_element_ve(), install_node(), L_CPU_SCHED_NODE, sched_node, and sched_vty_opts::tall_ctx.

## parse_cpu_hex_mask()

int parse_cpu_hex_mask | ( | const char * | str,
|  | cpu_set_t * | cpuset,
|  | size_t | cpuset_size )

static

Referenced by DEFUN_ATTR().

## proc_name_exists()

bool proc_name_exists | ( | const char * | name,
|  | pid_t * | res_pid )

static

Referenced by procname2pid().

## proc_tid_exists()

bool proc_tid_exists | ( | pid_t | tid | ) |

static

Referenced by procname2pid().

## procname2pid()

enum sched_vty_thread_id procname2pid | ( | pid_t * | res_pid,
|  | const char * | str,
|  | bool | applynow )

static

References proc_name_exists(), proc_tid_exists(), SCHED_VTY_THREAD_ALL, SCHED_VTY_THREAD_ID, SCHED_VTY_THREAD_NAME, SCHED_VTY_THREAD_SELF, and SCHED_VTY_THREAD_UNKNOWN.

Referenced by DEFUN_ATTR().

## set_sched_rr()

int set_sched_rr | ( | unsigned int | prio | ) |

static

Referenced by DEFUN_ATTR().

## Variable Documentation

## sched_node

struct cmd_node sched_node

static

Initial value:
= {
L_CPU_SCHED_NODE,
"%s(config-cpu-sched)# ",
1,
}
L_CPU_SCHED_NODE
@ L_CPU_SCHED_NODE
CPU Sched related options node.
Definition command.h:102

Referenced by osmo_cpu_sched_vty_init().

## sched_vty_opts

struct sched_vty_opts* sched_vty_opts

static