libosmovty 1.9.0.196-9975
Osmocom VTY library
cpu_sched_vty.c File Reference

Implementation to CPU / Threading / Scheduler properties from VTY configuration. More...

#include "config.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include <unistd.h>
#include <sched.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <pthread.h>
#include <inttypes.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/tdef_vty.h>
#include <osmocom/core/tdef.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/linuxlist.h>

Data Structures

struct  cpu_affinity_it
 
struct  sched_vty_opts
 

Macros

#define _GNU_SOURCE
 

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. More...
 
int osmo_cpu_sched_vty_apply_localthread (void)
 Apply cpu-affinity on calling thread based on VTY configuration. More...
 

Variables

static struct sched_vty_optssched_vty_opts
 
static struct cmd_node sched_node
 

Detailed Description

Implementation to CPU / Threading / Scheduler properties from VTY configuration.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE