24 #include <sys/types.h> 27 #include <linux/limits.h> 36 #define SYSFS_PATH "/sys/devices/system" 37 #define TEST_SYSFS_PATH "./cpu_test" 39 #define MAX_PROCESSOR_FILE "cpu/kernel_max" 40 #define POSS_PROCESSOR_FILE "cpu/possible" 41 #define AVAIL_PROCESSOR_FILE "cpu/present" 42 #define ONLN_PROCESSOR_FILE "cpu/online" 44 #define NUMA_FILE1 "cpu/cpu%u/node%u" 45 #define NUMA_FILE2 "node/node%u/cpu%u" 47 #define COREID_FILE "cpu/cpu%u/topology/core_id" 48 #define PHYSID_FILE "cpu/cpu%u/topology/physical_package_id" 50 #define L1SZ_FILE "cpu/cpu%u/cache/index0/size" 51 #define L2SZ_FILE1 "cpu/cpu%u/cache/index1/size" 52 #define L2SZ_FILE2 "cpu/cpu%u/cache/index2/size" 54 #define C0_LVL_FILE "cpu/cpu%u/cache/index0/level" 55 #define C1_LVL_FILE "cpu/cpu%u/cache/index1/level" 56 #define M0_LVL_FILE "cpu/cpu%u/cache/index2/level" 58 #define C0_SHMAP_FILE "cpu/cpu%u/cache/index0/shared_cpu_map" 59 #define C1_SHMAP_FILE "cpu/cpu%u/cache/index1/shared_cpu_map" 60 #define M0_SHMAP_FILE "cpu/cpu%u/cache/index2/shared_cpu_map" 98 uint64_t
cpu_masks[] = { 1, 3, 5, 13, 21, 43, 107, 219 };
161 for (
i = 0;
i <
map->b_nr;
i++) {
175 if (from_idx == to_idx)
176 ret = snprintf(pstr, sz,
"%u", from_idx);
178 ret = snprintf(pstr, sz,
"%u-%u",
214 char *map_file =
NULL;
253 fgets_rc = fgets(result,
BUF_SZ - 1,
fp);
257 rc = strncmp(result, expect, strlen(expect));
319 mixedid = physid << 16 | coreid;
322 pd->
pd_l2 == physid);
359 for (
i = 0;
i <
num;
i++) {
390 fprintf(
fp,
"%u\n",
num);
415 if (
sum->presentstr) {
435 for (
i = 0;
i < sz;
i++) {
438 sprintf(
filename,
"mkdir -p %s/cpu/cpu%u/topology",
442 sprintf(
filename,
"mkdir -p %s/cpu/cpu%u/cache/index0",
446 sprintf(
filename,
"mkdir -p %s/cpu/cpu%u/cache/index1",
450 sprintf(
filename,
"mkdir -p %s/cpu/cpu%u/cache/index2",
475 if (cpus[
i].c0szstr) {
481 if (cpus[
i].c1szstr) {
487 if (cpus[
i].m0szstr) {
493 if (cpus[
i].c0sharedmapstr) {
499 if (cpus[
i].c1sharedmapstr) {
505 if (cpus[
i].m0sharedmapstr) {
547 snprintf(str,
BUF_SZ,
"%u", (
unsigned)cpu_max - 1);
582 for (
i = 0;
i < map_avail->
b_nr; ++
i)
589 for (
i = 0;
i <
nr; ++
i) {
598 pi[
i].c0szstr =
"64K\n";
599 pi[
i].c1szstr =
"64K\n";
600 pi[
i].m0szstr =
"540K\n";
601 pi[
i].c0sharedmapstr =
"00000000,00000000,00000000," 602 "00000000,00000000,00000000,00000000,00000001\n";
603 pi[
i].c1sharedmapstr =
"00000000,00000000,00000000," 604 "00000000,00000000,00000000,00000000,00000001\n";
605 pi[
i].m0sharedmapstr =
"00000000,00000000,00000000," 606 "00000000,00000000,00000000,00000000,00000003\n";
615 pi[
i].c0szstr =
"64K\n";
616 pi[
i].c1szstr =
"64K\n";
617 pi[
i].m0szstr =
"540K\n";
618 pi[
i].c0sharedmapstr =
"00000000,00000000,00000000," 619 "00000000,00000000,00000000,00000000,00000001\n";
620 pi[
i].c1sharedmapstr =
"00000000,00000000,00000000," 621 "00000000,00000000,00000000,00000000,00000001\n";
622 pi[
i].m0sharedmapstr =
"00000000,00000000,00000000," 623 "00000000,00000000,00000000,00000000,00000003\n";
676 for (
i = 0;
i < cpu_max; ++
i) {
697 for (j = 0; j < map_onln.
b_nr; ++j) {
705 map_avail2 =
i % 2 == 0 ? &map_avail : &
map;
722 unsetenv(
"M0_PROCESSORS_INFO_DIR");
#define M0_PROCESSORS_INVALID_ID
const char * c0sharedmapstr
#define M0_ALLOC_ARR(arr, nr)
M0_INTERNAL int m0_bitmap_init(struct m0_bitmap *map, size_t nr)
static void ub_init3(int i)
static void clean_test_dataset(void)
M0_INTERNAL int struct dentry struct kstat * stat
M0_INTERNAL void m0_bitmap_fini(struct m0_bitmap *map)
static void ub_fini(void)
M0_INTERNAL void m0_processors_possible(struct m0_bitmap *map)
#define MAX_PROCESSOR_FILE
static uint32_t get_num_from_file(const char *file)
static void psummary_destroy(struct psummary *ps)
static void write_num_to_file(const char *file, uint32_t num)
M0_INTERNAL m0_processor_nr_t m0_processor_nr_max(void)
static void verify_id_get(void)
M0_INTERNAL void m0_processors_fini(void)
static void populate_cpu_summary(struct psummary *sum)
M0_INTERNAL size_t m0_bitmap_set_nr(const struct m0_bitmap *map)
#define ONLN_PROCESSOR_FILE
M0_INTERNAL m0_processor_nr_t m0_processor_id_get(void)
static void populate_cpus(struct pinfo cpus[], uint32_t sz)
const char * m0sharedmapstr
char * processor_info_dirp
const char * c1sharedmapstr
static int ub_init(const char *opts M0_UNUSED)
void test_processor(void)
#define POSS_PROCESSOR_FILE
uint32_t m0_processor_nr_t
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 void ub_init2(int i)
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)
M0_INTERNAL int m0_processors_init(void)
static void verify_max_processors()
struct m0_ub_set m0_processor_ub
void pinfo_destroy(struct pinfo *pi)
M0_INTERNAL void m0_processors_online(struct m0_bitmap *map)
static void ub_init1(int i)
struct m0_pdclust_instance pi
M0_INTERNAL void m0_bitmap_set(struct m0_bitmap *map, size_t idx, bool val)
static void maptostr(struct m0_bitmap *map, char *str, size_t sz)
static void verify_processors()
#define AVAIL_PROCESSOR_FILE
static void verify_a_processor(m0_processor_nr_t id, struct m0_processor_descr *pd)
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL int m0_processor_describe(m0_processor_nr_t id, struct m0_processor_descr *pd)
M0_INTERNAL bool m0_bitmap_get(const struct m0_bitmap *map, size_t idx)
static void verify_map(int mapid)
static void verify_all_params()
static void write_str_to_file(const char *file, const char *str)
M0_INTERNAL void m0_processors_available(struct m0_bitmap *map)