mcx::utils

mcx::utils

Classes

Name
class mcx::utils::SpmcBuffer
class mcx::utils::MpmcQueue
struct mcx::utils::measure
struct mcx::utils::CommandLineArgs
struct mcx::utils::ProcessInfo
struct mcx::utils::PageFaults
Page faults.
struct mcx::utils::SchedAttr
struct mcx::utils::Timespec64

Types

Name
enum class SchedType { OTHER, DEADLINE, FIFO, RR}
using cmd_line::SystemMode SystemMode
template <typename ElementType >
using tcb::span< ElementType >
span

Functions

Name
template <typename T >
constexpr T
singleBit(unsigned int idx)
template <typename T >
constexpr bool
getBit(T x, unsigned int idx)
template <typename T >
constexpr T
setBit(T x, unsigned int idx)
template <typename T >
constexpr T
clearBit(T x, unsigned int idx)
template <typename T >
constexpr T
setBitTo(T x, unsigned int idx, bool val)
size_t getKey(char * hash, size_t len)
std::string removeSpaces(const std::string & orig)
void parseCmdLine(int argc, char ** argv, CommandLineArgs * cmd_args)
void printSystemConfig(const CommandLineArgs & cmd_args, const char * system_name)
uint64_t localTimeMilliS()
uint64_t zuluTimeMilliS()
bool demangle(const char * name, std::string & demangled_name)
int isValidNumber(const std::string & str)
void listFile(std::string initial_path, std::vector< ProcessInfo > * proc_id_list)
bool setCpuAffinity(pid_t pid, const std::vector< uint32_t > & cpu_list)
bool setIrqSmpAffinity(const std::string & irq_path, const std::string & param_name, const std::vector< uint32_t > & cpu_list)
std::vector< uint32_t > invertCpuList(const std::vector< uint32_t > & cpu_list)
bool isolateCpuListForProc(pid_t pid, const std::vector< uint32_t > & cpu_list)
bool isolateCpuListForIrq(const std::string & irq_path, const std::vector< uint32_t > & cpu_list)
std::vector< ProcessInfo > getProcessId(const std::vector< std::string > & proc_list)
bool bindProcList(const std::vector< uint32_t > & cpu_list, const std::vector< std::string > & proc_list)
bool bindIrqList(const std::vector< uint32_t > & cpu_list, const std::vector< uint32_t > & irq_list)
void isolateCpuList(const std::vector< uint32_t > & cpu_list)
void resetIsolateCpu()
std::vector< uint32_t > fromCpuSet(const cpu_set_t & cpuset)
cpu_set_t toCpuSet(const std::vector< uint32_t > & cpu_list)
std::vector< uint32_t > getAllCpu()
std::vector< uint32_t > getAvailableCpu()
std::vector< uint32_t > getIsolatedCpu()
bool reserveProcessMemory(size_t size_mb)
size_t getStackSize(pthread_attr_t & attr)
Returns actual stack size in bytes.
bool setStackSize(pthread_attr_t & attr, size_t size_bytes)
Sets new stack size.
bool prefaultThreadStack(pthread_attr_t & attr)
Pre-faults stack memory of the thread.
PageFaults getPageFaults(PageFaults * page_faults, int where =RUSAGE_THREAD)
Returns new page faults.
bool showPageFaults(PageFaults * page_faults, int where)
bool startLowLatency()
Starts low latency mode.
void stopLowLatency()
bool configureMallocBehavior(size_t size_mb)
Configures memory behavior for Real-time.
std::atomic< bool > sig_initialized(false )
std::atomic< bool > sig_terminated(false )
void signalCallbackHandler(int )
bool running()
bool setSwappiness(size_t swappiness)
bool setPrintkLevel(size_t level)
bool setCpuFreqPolicy(unsigned int cpu_id, const char * governor)
bool startRealTime(size_t size_mb)
bool startRealTime(const std::vector< uint32_t > & cpu_list, size_t size_mb =256)
Activates Real-time mode and isolates CPUs.
bool startRealTime(cmd_line::Realtime opt)
Activates Real-time mode and isolates CPUs.
bool startRealTime()
Activates Real-time mode and isolates CPUs.
void stopRealTime(cmd_line::Realtime opt)
Deactivate Real-time mode, removes CPUs' isolation.
void stopRealTime()
Deactivate Real-time mode, removes CPUs' isolation.
int schedSetAttr(pid_t pid, const SchedAttr * attr, unsigned int flags)
int schedGetAttr(pid_t pid, SchedAttr * attr, unsigned int size, unsigned int flags)
bool schedSelect(pid_t pid, SchedType sched_type, unsigned int dt_usec, int priority =0)
template <typename ElementType >
span< ElementType >
make_span(ElementType el)
template <typename ElementType >
span< ElementType >
make_span(ElementType * el, size_t s)
template <typename… Args>
auto
make_span(Args &&… args)
constexpr Timespec64 timespecToTimespec64(const struct timespec & t)
template <typename TIMESPEC >
constexpr uint64_t
timespecToNanoS(const TIMESPEC & time)
template <typename TIMESPEC >
constexpr uint64_t
timespecToMicroS(const TIMESPEC & time)
template <typename TIMESPEC >
constexpr uint64_t
timespecToMilliS(const TIMESPEC & time)
template <typename TIMESPEC >
constexpr double
timespecToS(const TIMESPEC & time)
template <typename TIMESPEC >
constexpr timespec
diff(const TIMESPEC & start, const TIMESPEC & end)
template <typename TIMESPEC >
constexpr void
correctNSec(TIMESPEC * time_n_sec)
template <typename TIMESPEC >
constexpr void
incTime(TIMESPEC * time, const TIMESPEC & duration)
template <typename TIMESPEC >
constexpr void
setTime(TIMESPEC * time, const TIMESPEC & value)
const char * version()
void constructor()
const char * tinyXMLErr2Str(int error)
std::string buildPath(std::initializer_list< std::string > str_list)
void ltrim(std::string & s)
std::string ltrimc(std::string s)
void rtrim(std::string & s)
std::string rtrimc(std::string s)
void trim(std::string & s)
std::string trimc(std::string s)

Attributes

Name
std::vector< uint32_t > cpu_isolated_list
int pm_qos_fd
constexpr uint64_t NSEC
constexpr uint64_t MSEC
constexpr uint64_t NSEC_MILISEC
constexpr uint64_t NSEC_MSEC

Types Documentation

enum SchedType

Enumerator Value Description
OTHER
DEADLINE
FIFO
RR

using SystemMode

using mcx::utils::SystemMode = typedef cmd_line::SystemMode;

using span

template <typename ElementType >
using mcx::utils::span = typedef tcb::span<ElementType>;

Functions Documentation

function singleBit

template <typename T >
constexpr T singleBit(
    unsigned int idx
)

function getBit

template <typename T >
constexpr bool getBit(
    T x,
    unsigned int idx
)

function setBit

template <typename T >
constexpr T setBit(
    T x,
    unsigned int idx
)

function clearBit

template <typename T >
constexpr T clearBit(
    T x,
    unsigned int idx
)

function setBitTo

template <typename T >
constexpr T setBitTo(
    T x,
    unsigned int idx,
    bool val
)

function getKey

static size_t getKey(
    char * hash,
    size_t len
)

function removeSpaces

static std::string removeSpaces(
    const std::string & orig
)

function parseCmdLine

void parseCmdLine(
    int argc,
    char ** argv,
    CommandLineArgs * cmd_args
)

function printSystemConfig

void printSystemConfig(
    const CommandLineArgs & cmd_args,
    const char * system_name
)

function localTimeMilliS

uint64_t localTimeMilliS()

function zuluTimeMilliS

uint64_t zuluTimeMilliS()

function demangle

bool demangle(
    const char * name,
    std::string & demangled_name
)

function isValidNumber

int isValidNumber(
    const std::string & str
)

function listFile

void listFile(
    std::string initial_path,
    std::vector< ProcessInfo > * proc_id_list
)

function setCpuAffinity

bool setCpuAffinity(
    pid_t pid,
    const std::vector< uint32_t > & cpu_list
)

function setIrqSmpAffinity

bool setIrqSmpAffinity(
    const std::string & irq_path,
    const std::string & param_name,
    const std::vector< uint32_t > & cpu_list
)

function invertCpuList

std::vector< uint32_t > invertCpuList(
    const std::vector< uint32_t > & cpu_list
)

function isolateCpuListForProc

bool isolateCpuListForProc(
    pid_t pid,
    const std::vector< uint32_t > & cpu_list
)

function isolateCpuListForIrq

bool isolateCpuListForIrq(
    const std::string & irq_path,
    const std::vector< uint32_t > & cpu_list
)

function getProcessId

std::vector< ProcessInfo > getProcessId(
    const std::vector< std::string > & proc_list
)

function bindProcList

bool bindProcList(
    const std::vector< uint32_t > & cpu_list,
    const std::vector< std::string > & proc_list
)

function bindIrqList

bool bindIrqList(
    const std::vector< uint32_t > & cpu_list,
    const std::vector< uint32_t > & irq_list
)

function isolateCpuList

void isolateCpuList(
    const std::vector< uint32_t > & cpu_list
)

function resetIsolateCpu

void resetIsolateCpu()

function fromCpuSet

std::vector< uint32_t > fromCpuSet(
    const cpu_set_t & cpuset
)

function toCpuSet

cpu_set_t toCpuSet(
    const std::vector< uint32_t > & cpu_list
)

function getAllCpu

std::vector< uint32_t > getAllCpu()

function getAvailableCpu

std::vector< uint32_t > getAvailableCpu()

function getIsolatedCpu

std::vector< uint32_t > getIsolatedCpu()

function reserveProcessMemory

bool reserveProcessMemory(
    size_t size_mb
)

function getStackSize

size_t getStackSize(
    pthread_attr_t & attr
)

Returns actual stack size in bytes.

Return: actual stack size on bytes

function setStackSize

bool setStackSize(
    pthread_attr_t & attr,
    size_t size_bytes
)

Sets new stack size.

Parameters:

  • size_bytes - new stack size in bytes

Return: true if new stack size is equal to the desired value

function prefaultThreadStack

bool prefaultThreadStack(
    pthread_attr_t & attr
)

Pre-faults stack memory of the thread.

Return: true on success.

Touches every byte of the stack to eliminate future page-faults

function getPageFaults

PageFaults getPageFaults(
    PageFaults * page_faults,
    int where =RUSAGE_THREAD
)

Returns new page faults.

Parameters:

  • page_faults - pointer to a total number of page faults.
  • where - where to measure page faults: RUSAGE_THREAD - current thread, RUSAGE_SELF - current process, RUSAGE_CHILDREN - all children processes.

Return: true on success.

Calculates difference between total page fault number and actual page faults.

function showPageFaults

bool showPageFaults(
    PageFaults * page_faults,
    int where
)

function startLowLatency

bool startLowLatency()

Starts low latency mode.

Return: true on success.

function stopLowLatency

void stopLowLatency()

Return: true on success.

Stops low latency mode.

function configureMallocBehavior

bool configureMallocBehavior(
    size_t size_mb
)

Configures memory behavior for Real-time.

Parameters:

  • size_mb - size of RAM to reserve in Megabytes.

Return: true on success.

Locks all current and future pages from preventing of being paged. Touches each page in this piece of memory to get it mapped into RAM.

function sig_initialized

static std::atomic< bool > sig_initialized(
    false 
)

function sig_terminated

static std::atomic< bool > sig_terminated(
    false 
)

function signalCallbackHandler

void signalCallbackHandler(
    int 
)

function running

bool running()

Return: true if no system terminate signals have been received.

Indicates that process is running.

function setSwappiness

bool setSwappiness(
    size_t swappiness
)

function setPrintkLevel

bool setPrintkLevel(
    size_t level
)

function setCpuFreqPolicy

bool setCpuFreqPolicy(
    unsigned int cpu_id,
    const char * governor
)

function startRealTime

bool startRealTime(
    size_t size_mb
)

function startRealTime

bool startRealTime(
    const std::vector< uint32_t > & cpu_list,
    size_t size_mb =256
)

Activates Real-time mode and isolates CPUs.

Parameters:

  • size_mb - size of RAM to reserve in Megabytes.

Return: true on success

@cpu_list - list of the CPUs to isolate.

function startRealTime

bool startRealTime(
    cmd_line::Realtime opt
)

Activates Real-time mode and isolates CPUs.

Return: true on success

@opt - struct with realtime options.

function startRealTime

bool startRealTime()

Activates Real-time mode and isolates CPUs.

Return: true on success

function stopRealTime

void stopRealTime(
    cmd_line::Realtime opt
)

Deactivate Real-time mode, removes CPUs' isolation.

@opt - struct with realtime options.

function stopRealTime

void stopRealTime()

Deactivate Real-time mode, removes CPUs' isolation.

function schedSetAttr

inline int schedSetAttr(
    pid_t pid,
    const SchedAttr * attr,
    unsigned int flags
)

function schedGetAttr

inline int schedGetAttr(
    pid_t pid,
    SchedAttr * attr,
    unsigned int size,
    unsigned int flags
)

function schedSelect

inline bool schedSelect(
    pid_t pid,
    SchedType sched_type,
    unsigned int dt_usec,
    int priority =0
)

function make_span

template <typename ElementType >
span< ElementType > make_span(
    ElementType el
)

function make_span

template <typename ElementType >
span< ElementType > make_span(
    ElementType * el,
    size_t s
)

function make_span

template <typename... Args>
auto make_span(
    Args &&... args
)

function timespecToTimespec64

constexpr Timespec64 timespecToTimespec64(
    const struct timespec & t
)

function timespecToNanoS

template <typename TIMESPEC >
constexpr uint64_t timespecToNanoS(
    const TIMESPEC & time
)

function timespecToMicroS

template <typename TIMESPEC >
constexpr uint64_t timespecToMicroS(
    const TIMESPEC & time
)

function timespecToMilliS

template <typename TIMESPEC >
constexpr uint64_t timespecToMilliS(
    const TIMESPEC & time
)

function timespecToS

template <typename TIMESPEC >
constexpr double timespecToS(
    const TIMESPEC & time
)

function diff

template <typename TIMESPEC >
constexpr timespec diff(
    const TIMESPEC & start,
    const TIMESPEC & end
)

function correctNSec

template <typename TIMESPEC >
constexpr void correctNSec(
    TIMESPEC * time_n_sec
)

function incTime

template <typename TIMESPEC >
constexpr void incTime(
    TIMESPEC * time,
    const TIMESPEC & duration
)

function setTime

template <typename TIMESPEC >
constexpr void setTime(
    TIMESPEC * time,
    const TIMESPEC & value
)

function version

const char * version()

function constructor

static void constructor()

function tinyXMLErr2Str

const char * tinyXMLErr2Str(
    int error
)

function buildPath

std::string buildPath(
    std::initializer_list< std::string > str_list
)

function ltrim

inline void ltrim(
    std::string & s
)

function ltrimc

inline std::string ltrimc(
    std::string s
)

function rtrim

inline void rtrim(
    std::string & s
)

function rtrimc

inline std::string rtrimc(
    std::string s
)

function trim

inline void trim(
    std::string & s
)

function trimc

inline std::string trimc(
    std::string s
)

Attributes Documentation

variable cpu_isolated_list

static std::vector< uint32_t > cpu_isolated_list = {};

variable pm_qos_fd

static int pm_qos_fd = -1;

variable NSEC

static constexpr uint64_t NSEC = 1000000000;

variable MSEC

static constexpr uint64_t MSEC = 1000000;

variable NSEC_MILISEC

static constexpr uint64_t NSEC_MILISEC = 1000000;

variable NSEC_MSEC

static constexpr uint64_t NSEC_MSEC = 1000;

Updated on 2022-04-05 at 16:21:27 +0200