Motr  M0
processor.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/limits.h>
#include "ut/ut.h"
#include "lib/ub.h"
#include "lib/assert.h"
#include "lib/memory.h"
#include "lib/processor.h"
#include "lib/string.h"
Include dependency graph for processor.c:

Go to the source code of this file.

Data Structures

struct  psummary
 
struct  pinfo
 

Macros

#define SYSFS_PATH   "/sys/devices/system"
 
#define TEST_SYSFS_PATH   "./cpu_test"
 
#define MAX_PROCESSOR_FILE   "cpu/kernel_max"
 
#define POSS_PROCESSOR_FILE   "cpu/possible"
 
#define AVAIL_PROCESSOR_FILE   "cpu/present"
 
#define ONLN_PROCESSOR_FILE   "cpu/online"
 
#define NUMA_FILE1   "cpu/cpu%u/node%u"
 
#define NUMA_FILE2   "node/node%u/cpu%u"
 
#define COREID_FILE   "cpu/cpu%u/topology/core_id"
 
#define PHYSID_FILE   "cpu/cpu%u/topology/physical_package_id"
 
#define L1SZ_FILE   "cpu/cpu%u/cache/index0/size"
 
#define L2SZ_FILE1   "cpu/cpu%u/cache/index1/size"
 
#define L2SZ_FILE2   "cpu/cpu%u/cache/index2/size"
 
#define C0_LVL_FILE   "cpu/cpu%u/cache/index0/level"
 
#define C1_LVL_FILE   "cpu/cpu%u/cache/index1/level"
 
#define M0_LVL_FILE   "cpu/cpu%u/cache/index2/level"
 
#define C0_SHMAP_FILE   "cpu/cpu%u/cache/index0/shared_cpu_map"
 
#define C1_SHMAP_FILE   "cpu/cpu%u/cache/index1/shared_cpu_map"
 
#define M0_SHMAP_FILE   "cpu/cpu%u/cache/index2/shared_cpu_map"
 
#define BUF_SZ   512
 

Enumerations

enum  { UB_ITER = 100000 }
 
enum  { POSS_MAP = 1, AVAIL_MAP = 2, ONLN_MAP = 3 }
 

Functions

static int ub_init (const char *opts M0_UNUSED)
 
static void ub_fini (void)
 
static void ub_init1 (int i)
 
static void ub_init2 (int i)
 
static void ub_init3 (int i)
 
static uint32_t get_num_from_file (const char *file)
 
static void maptostr (struct m0_bitmap *map, char *str, size_t sz)
 
static void verify_id_get (void)
 
static void verify_map (int mapid)
 
static void verify_max_processors ()
 
static void verify_a_processor (m0_processor_nr_t id, struct m0_processor_descr *pd)
 
static void verify_processors ()
 
static void write_str_to_file (const char *file, const char *str)
 
static void write_num_to_file (const char *file, uint32_t num)
 
static void populate_cpu_summary (struct psummary *sum)
 
static void populate_cpus (struct pinfo cpus[], uint32_t sz)
 
static void clean_test_dataset (void)
 
static void verify_all_params ()
 
static struct psummarypsummary_new (m0_processor_nr_t cpu_max, struct m0_bitmap *map_poss, struct m0_bitmap *map_avail, struct m0_bitmap *map_onln)
 
static void psummary_destroy (struct psummary *ps)
 
static struct pinfopinfo_new (m0_processor_nr_t cpu_max, struct m0_bitmap *map_poss, struct m0_bitmap *map_avail, struct m0_bitmap *map_onln, size_t *nr_out)
 
void pinfo_destroy (struct pinfo *pi)
 
void test_processor (void)
 

Variables

char * processor_info_dirp
 
uint64_t cpu_masks [] = { 1, 3, 5, 13, 21, 43, 107, 219 }
 
struct m0_ub_set m0_processor_ub
 

Macro Definition Documentation

◆ AVAIL_PROCESSOR_FILE

#define AVAIL_PROCESSOR_FILE   "cpu/present"

Definition at line 41 of file processor.c.

◆ BUF_SZ

#define BUF_SZ   512

Definition at line 62 of file processor.c.

◆ C0_LVL_FILE

#define C0_LVL_FILE   "cpu/cpu%u/cache/index0/level"

Definition at line 54 of file processor.c.

◆ C0_SHMAP_FILE

#define C0_SHMAP_FILE   "cpu/cpu%u/cache/index0/shared_cpu_map"

Definition at line 58 of file processor.c.

◆ C1_LVL_FILE

#define C1_LVL_FILE   "cpu/cpu%u/cache/index1/level"

Definition at line 55 of file processor.c.

◆ C1_SHMAP_FILE

#define C1_SHMAP_FILE   "cpu/cpu%u/cache/index1/shared_cpu_map"

Definition at line 59 of file processor.c.

◆ COREID_FILE

#define COREID_FILE   "cpu/cpu%u/topology/core_id"

Definition at line 47 of file processor.c.

◆ L1SZ_FILE

#define L1SZ_FILE   "cpu/cpu%u/cache/index0/size"

Definition at line 50 of file processor.c.

◆ L2SZ_FILE1

#define L2SZ_FILE1   "cpu/cpu%u/cache/index1/size"

Definition at line 51 of file processor.c.

◆ L2SZ_FILE2

#define L2SZ_FILE2   "cpu/cpu%u/cache/index2/size"

Definition at line 52 of file processor.c.

◆ M0_LVL_FILE

#define M0_LVL_FILE   "cpu/cpu%u/cache/index2/level"

Definition at line 56 of file processor.c.

◆ M0_SHMAP_FILE

#define M0_SHMAP_FILE   "cpu/cpu%u/cache/index2/shared_cpu_map"

Definition at line 60 of file processor.c.

◆ MAX_PROCESSOR_FILE

#define MAX_PROCESSOR_FILE   "cpu/kernel_max"

Definition at line 39 of file processor.c.

◆ NUMA_FILE1

#define NUMA_FILE1   "cpu/cpu%u/node%u"

Definition at line 44 of file processor.c.

◆ NUMA_FILE2

#define NUMA_FILE2   "node/node%u/cpu%u"

Definition at line 45 of file processor.c.

◆ ONLN_PROCESSOR_FILE

#define ONLN_PROCESSOR_FILE   "cpu/online"

Definition at line 42 of file processor.c.

◆ PHYSID_FILE

#define PHYSID_FILE   "cpu/cpu%u/topology/physical_package_id"

Definition at line 48 of file processor.c.

◆ POSS_PROCESSOR_FILE

#define POSS_PROCESSOR_FILE   "cpu/possible"

Definition at line 40 of file processor.c.

◆ SYSFS_PATH

#define SYSFS_PATH   "/sys/devices/system"

Definition at line 36 of file processor.c.

◆ TEST_SYSFS_PATH

#define TEST_SYSFS_PATH   "./cpu_test"

Definition at line 37 of file processor.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UB_ITER 

Definition at line 86 of file processor.c.

◆ anonymous enum

anonymous enum
Enumerator
POSS_MAP 
AVAIL_MAP 
ONLN_MAP 

Definition at line 90 of file processor.c.

Function Documentation

◆ clean_test_dataset()

static void clean_test_dataset ( void  )
static

Definition at line 514 of file processor.c.

Here is the caller graph for this function:

◆ get_num_from_file()

static uint32_t get_num_from_file ( const char *  file)
static

Definition at line 131 of file processor.c.

Here is the caller graph for this function:

◆ maptostr()

static void maptostr ( struct m0_bitmap map,
char *  str,
size_t  sz 
)
static

Definition at line 147 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pinfo_destroy()

void pinfo_destroy ( struct pinfo pi)

Definition at line 634 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pinfo_new()

static struct pinfo* pinfo_new ( m0_processor_nr_t  cpu_max,
struct m0_bitmap map_poss,
struct m0_bitmap map_avail,
struct m0_bitmap map_onln,
size_t *  nr_out 
)
static

Definition at line 572 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ populate_cpu_summary()

static void populate_cpu_summary ( struct psummary sum)
static

Definition at line 394 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ populate_cpus()

static void populate_cpus ( struct pinfo  cpus[],
uint32_t  sz 
)
static

Definition at line 428 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ psummary_destroy()

static void psummary_destroy ( struct psummary ps)
static

Definition at line 563 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ psummary_new()

static struct psummary* psummary_new ( m0_processor_nr_t  cpu_max,
struct m0_bitmap map_poss,
struct m0_bitmap map_avail,
struct m0_bitmap map_onln 
)
static

Definition at line 535 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_processor()

void test_processor ( void  )

Definition at line 639 of file processor.c.

Here is the call graph for this function:

◆ ub_fini()

static void ub_fini ( void  )
static

Definition at line 105 of file processor.c.

◆ ub_init()

static int ub_init ( const char *opts  M0_UNUSED)
static

Definition at line 100 of file processor.c.

◆ ub_init1()

static void ub_init1 ( int  i)
static

Definition at line 109 of file processor.c.

◆ ub_init2()

static void ub_init2 ( int  i)
static

Definition at line 113 of file processor.c.

Here is the call graph for this function:

◆ ub_init3()

static void ub_init3 ( int  i)
static

Definition at line 122 of file processor.c.

Here is the call graph for this function:

◆ verify_a_processor()

static void verify_a_processor ( m0_processor_nr_t  id,
struct m0_processor_descr pd 
)
static

Definition at line 285 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_all_params()

static void verify_all_params ( )
static

Definition at line 524 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_id_get()

static void verify_id_get ( void  )
static

Definition at line 188 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_map()

static void verify_map ( int  mapid)
static

Definition at line 211 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_max_processors()

static void verify_max_processors ( )
static

Definition at line 264 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_processors()

static void verify_processors ( )
static

Definition at line 343 of file processor.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_num_to_file()

static void write_num_to_file ( const char *  file,
uint32_t  num 
)
static

Definition at line 383 of file processor.c.

Here is the caller graph for this function:

◆ write_str_to_file()

static void write_str_to_file ( const char *  file,
const char *  str 
)
static

Definition at line 372 of file processor.c.

Here is the caller graph for this function:

Variable Documentation

◆ cpu_masks

uint64_t cpu_masks[] = { 1, 3, 5, 13, 21, 43, 107, 219 }

Definition at line 98 of file processor.c.

◆ m0_processor_ub

struct m0_ub_set m0_processor_ub
Initial value:
= {
.us_name = "processor-ub",
.us_init = ub_init,
.us_fini = ub_fini,
.us_run = {
{.ub_name = "Init1",
.ub_iter = UB_ITER,
.ub_round = ub_init1},
{.ub_name = "Init2",
.ub_iter = UB_ITER,
.ub_round = ub_init2},
{.ub_name = "Init3",
.ub_iter = UB_ITER,
.ub_round = ub_init3},
{.ub_name = NULL}
}
}
static void ub_init3(int i)
Definition: processor.c:122
#define NULL
Definition: misc.h:38
static void ub_fini(void)
Definition: processor.c:105
static int ub_init(const char *opts M0_UNUSED)
Definition: processor.c:100
static void ub_init2(int i)
Definition: processor.c:113
static void ub_init1(int i)
Definition: processor.c:109

Definition at line 728 of file processor.c.

◆ processor_info_dirp

char* processor_info_dirp

Definition at line 96 of file processor.c.