Motr  M0
processor.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #include <linux/limits.h>
28 
29 #include "ut/ut.h"
30 #include "lib/ub.h"
31 #include "lib/assert.h"
32 #include "lib/memory.h"
33 #include "lib/processor.h"
34 #include "lib/string.h"
35 
36 #define SYSFS_PATH "/sys/devices/system"
37 #define TEST_SYSFS_PATH "./cpu_test"
38 
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"
43 
44 #define NUMA_FILE1 "cpu/cpu%u/node%u"
45 #define NUMA_FILE2 "node/node%u/cpu%u"
46 
47 #define COREID_FILE "cpu/cpu%u/topology/core_id"
48 #define PHYSID_FILE "cpu/cpu%u/topology/physical_package_id"
49 
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"
53 
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"
57 
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"
61 
62 #define BUF_SZ 512
63 
64 struct psummary {
65  char *kmaxstr;
66  char *possstr;
67  char *presentstr;
68  char *onlnstr;
69 };
70 
71 struct pinfo {
72  uint32_t numaid;
73  uint32_t physid;
74  uint32_t coreid;
75  uint32_t c0lvl;
76  uint32_t c1lvl;
77  uint32_t m0lvl;
78  const char *c0szstr;
79  const char *c1szstr;
80  const char *m0szstr;
81  const char *c0sharedmapstr;
82  const char *c1sharedmapstr;
83  const char *m0sharedmapstr;
84 };
85 
86 enum {
87  UB_ITER = 100000
88 };
89 
90 enum {
91  POSS_MAP = 1,
92  AVAIL_MAP = 2,
94 };
95 
97 
98 uint64_t cpu_masks[] = { 1, 3, 5, 13, 21, 43, 107, 219 };
99 
100 static int ub_init(const char *opts M0_UNUSED)
101 {
102  return 0;
103 }
104 
105 static void ub_fini(void)
106 {
107 }
108 
109 static void ub_init1(int i)
110 {
111 }
112 
113 static void ub_init2(int i)
114 {
115  int rc;
116 
119  M0_UT_ASSERT(rc == 0);
120 }
121 
122 static void ub_init3(int i)
123 {
124  int rc;
125 
128  M0_UT_ASSERT(rc == 0);
129 }
130 
131 static uint32_t get_num_from_file(const char *file)
132 {
133  uint32_t num = 0;
134  int rc;
135  FILE *fp;
136 
137  fp = fopen(file, "r");
138  if (fp == NULL)
139  return num;
140  rc = fscanf(fp, "%u", &num);
141  M0_UT_ASSERT(rc != EOF);
142  fclose(fp);
143 
144  return num;
145 }
146 
147 static void maptostr(struct m0_bitmap *map, char *str, size_t sz)
148 {
149  uint32_t i;
150  uint32_t from_idx;
151  uint32_t to_idx;
152  char *pstr;
153  bool val;
154  int ret;
155 
156  M0_UT_ASSERT(map != NULL && str != NULL);
157  M0_UT_ASSERT(sz > 0);
158  *str = '\0';
159  pstr = str;
160 
161  for (i = 0; i < map->b_nr; i++) {
162  val = m0_bitmap_get(map, i);
163  if (val == true) {
164  if (*str != '\0') {
165  M0_UT_ASSERT(sz > 1);
166  strcat(str, ",");
167  ++pstr;
168  --sz;
169  M0_UT_ASSERT(*pstr == '\0');
170  }
171  from_idx = i;
172  for (; i < map->b_nr && m0_bitmap_get(map, i); ++i)
173  ;
174  to_idx = i - 1;
175  if (from_idx == to_idx)
176  ret = snprintf(pstr, sz, "%u", from_idx);
177  else
178  ret = snprintf(pstr, sz, "%u-%u",
179  from_idx, to_idx);
180  M0_UT_ASSERT(ret >= 0);
181  M0_UT_ASSERT((size_t)ret < sz);
182  pstr += ret;
183  sz -= ret;
184  }
185  }
186 }
187 
188 static void verify_id_get(void)
189 {
190  struct m0_bitmap map;
193  int rc;
194 
196  M0_UT_ASSERT(rc == 0);
197 
200 
202 
203  id = m0_processor_id_get();
204  if (id != M0_PROCESSORS_INVALID_ID)
206 
209 }
210 
211 static void verify_map(int mapid)
212 {
213  char *expect;
214  char *map_file = NULL;
215  char *fgets_rc;
216  char buf[BUF_SZ];
217  char result[BUF_SZ];
218  char filename[PATH_MAX];
219  int rc;
220  FILE *fp;
221  struct m0_bitmap map;
223 
225  M0_UT_ASSERT(rc == 0);
226 
229 
230  switch (mapid) {
231  case POSS_MAP:
232  map_file = POSS_PROCESSOR_FILE;
234  break;
235  case AVAIL_MAP:
236  map_file = AVAIL_PROCESSOR_FILE;
238  break;
239  case ONLN_MAP:
240  map_file = ONLN_PROCESSOR_FILE;
242  break;
243  default:
244  M0_UT_ASSERT(0);
245  break;
246  };
247 
248  expect = &buf[0];
249  maptostr(&map, expect, BUF_SZ);
250 
251  sprintf(filename, "%s/%s", processor_info_dirp, map_file);
252  fp = fopen(filename, "r");
253  fgets_rc = fgets(result, BUF_SZ - 1, fp);
254  M0_UT_ASSERT(fgets_rc != NULL);
255  fclose(fp);
256 
257  rc = strncmp(result, expect, strlen(expect));
258  M0_UT_ASSERT(rc == 0);
259 
262 }
263 
265 {
266  char filename[PATH_MAX];
267  int rc;
269  m0_processor_nr_t result;
270 
272  M0_UT_ASSERT(rc == 0);
273 
274  sprintf(filename, "%s/%s", processor_info_dirp, MAX_PROCESSOR_FILE);
276  /* Convert "maximum index" to "maximum number". */
277  ++result;
278 
280  M0_UT_ASSERT(num == result);
281 
283 }
284 
286  struct m0_processor_descr *pd)
287 {
288  int rc1=0;
289  int rc2=0;
290  char filename[PATH_MAX];
291  uint32_t coreid;
292  uint32_t physid;
293  uint32_t mixedid;
294  uint32_t l1_sz;
295  uint32_t lvl;
296  uint32_t l2_sz;
297  struct stat statbuf;
298 
299  M0_UT_ASSERT(pd->pd_id == id);
300  M0_UT_ASSERT(pd->pd_pipeline == id);
301 
302  sprintf(filename, "%s/" NUMA_FILE1, processor_info_dirp,
303  id, pd->pd_numa_node);
304  rc1 = stat(filename, &statbuf);
305  if (rc1 != 0) {
306  sprintf(filename, "%s/" NUMA_FILE2, processor_info_dirp,
307  pd->pd_numa_node, id);
308  rc2 = stat(filename, &statbuf);
309  M0_UT_ASSERT(rc2 == 0);
310  }
311  M0_UT_ASSERT(rc1 == 0 || rc2 == 0 || pd->pd_numa_node == 0);
312 
313  sprintf(filename, "%s/" COREID_FILE, processor_info_dirp, id);
314  coreid = get_num_from_file(filename);
315 
316  sprintf(filename, "%s/" PHYSID_FILE, processor_info_dirp, id);
317  physid = get_num_from_file(filename);
318 
319  mixedid = physid << 16 | coreid;
320  M0_UT_ASSERT(pd->pd_l1 == id || pd->pd_l1 == mixedid);
321  M0_UT_ASSERT(pd->pd_l2 == id || pd->pd_l2 == mixedid ||
322  pd->pd_l2 == physid);
323 
324  sprintf(filename, "%s/" L1SZ_FILE, processor_info_dirp, id);
325  l1_sz = get_num_from_file(filename);
326 
327  l1_sz *= 1024;
328  M0_UT_ASSERT(pd->pd_l1_sz == l1_sz);
329 
330  sprintf(filename, "%s/" C1_LVL_FILE, processor_info_dirp, id);
332  if (lvl == 1)
333  sprintf(filename, "%s/" L2SZ_FILE2, processor_info_dirp, id);
334  else
335  sprintf(filename, "%s/" L2SZ_FILE1, processor_info_dirp, id);
336 
337  l2_sz = get_num_from_file(filename);
338 
339  l2_sz *= 1024;
340  M0_UT_ASSERT(pd->pd_l2_sz == l2_sz);
341 }
342 
343 static void verify_processors()
344 {
347  struct m0_bitmap onln_map;
348  struct m0_processor_descr pd;
349  bool val;
350  int rc;
351 
353  M0_UT_ASSERT(rc == 0);
354 
356  m0_bitmap_init(&onln_map, num);
357  m0_processors_online(&onln_map);
358 
359  for (i = 0; i < num; i++) {
360  val = m0_bitmap_get(&onln_map, i);
361  if (val == true) {
362  rc = m0_processor_describe(i, &pd);
363  if (rc == 0)
364  verify_a_processor(i, &pd);
365  }
366  }
367 
368  m0_bitmap_fini(&onln_map);
370 }
371 
372 static void write_str_to_file(const char *file, const char *str)
373 {
374  FILE *fp;
375 
376  fp = fopen(file, "w");
377  if (fp == NULL)
378  return;
379  fputs(str, fp);
380  fclose(fp);
381 }
382 
383 static void write_num_to_file(const char *file, uint32_t num)
384 {
385  FILE *fp;
386 
387  fp = fopen(file, "w");
388  if (fp == NULL)
389  return;
390  fprintf(fp, "%u\n", num);
391  fclose(fp);
392 }
393 
394 static void populate_cpu_summary(struct psummary *sum)
395 {
396  int rc;
397  char filename[PATH_MAX];
398 
399  sprintf(filename, "mkdir -p %s/cpu", processor_info_dirp);
400  rc = system(filename);
401  M0_UT_ASSERT(rc != -1);
402 
403  if (sum->kmaxstr) {
404  sprintf(filename, "%s/" MAX_PROCESSOR_FILE,
406  write_str_to_file(filename, sum->kmaxstr);
407  }
408 
409  if (sum->possstr) {
410  sprintf(filename, "%s/" POSS_PROCESSOR_FILE,
412  write_str_to_file(filename, sum->possstr);
413  }
414 
415  if (sum->presentstr) {
416  sprintf(filename, "%s/" AVAIL_PROCESSOR_FILE,
418  write_str_to_file(filename, sum->presentstr);
419  }
420 
421  if (sum->onlnstr) {
422  sprintf(filename, "%s/" ONLN_PROCESSOR_FILE,
424  write_str_to_file(filename, sum->onlnstr);
425  }
426 }
427 
428 static void populate_cpus(struct pinfo cpus[], uint32_t sz)
429 {
430  char filename[PATH_MAX];
431  FILE *fp;
432  uint32_t i;
433  int rc;
434 
435  for (i = 0; i < sz; i++) {
436  if (cpus[i].numaid == M0_PROCESSORS_INVALID_ID)
437  continue;
438  sprintf(filename, "mkdir -p %s/cpu/cpu%u/topology",
440  rc = system(filename);
441  M0_UT_ASSERT(rc != -1);
442  sprintf(filename, "mkdir -p %s/cpu/cpu%u/cache/index0",
444  rc = system(filename);
445  M0_UT_ASSERT(rc != -1);
446  sprintf(filename, "mkdir -p %s/cpu/cpu%u/cache/index1",
448  rc = system(filename);
449  M0_UT_ASSERT(rc != -1);
450  sprintf(filename, "mkdir -p %s/cpu/cpu%u/cache/index2",
452  rc = system(filename);
453  M0_UT_ASSERT(rc != -1);
454 
455  sprintf(filename, "%s/" NUMA_FILE1, processor_info_dirp, i,
456  cpus[i].numaid);
457  fp = fopen(filename, "w");
458  fclose(fp);
459 
460  sprintf(filename, "%s/" COREID_FILE, processor_info_dirp, i);
461  write_num_to_file(filename, cpus[i].coreid);
462 
463  sprintf(filename, "%s/" PHYSID_FILE, processor_info_dirp, i);
464  write_num_to_file(filename, cpus[i].physid);
465 
466  sprintf(filename, "%s/" C0_LVL_FILE, processor_info_dirp, i);
467  write_num_to_file(filename, cpus[i].c0lvl);
468 
469  sprintf(filename, "%s/" C1_LVL_FILE, processor_info_dirp, i);
470  write_num_to_file(filename, cpus[i].c1lvl);
471 
472  sprintf(filename, "%s/" M0_LVL_FILE, processor_info_dirp, i);
473  write_num_to_file(filename, cpus[i].m0lvl);
474 
475  if (cpus[i].c0szstr) {
476  sprintf(filename, "%s/" L1SZ_FILE,
478  write_str_to_file(filename, cpus[i].c0szstr);
479  }
480 
481  if (cpus[i].c1szstr) {
482  sprintf(filename, "%s/" L2SZ_FILE1,
484  write_str_to_file(filename, cpus[i].c1szstr);
485  }
486 
487  if (cpus[i].m0szstr) {
488  sprintf(filename, "%s/" L2SZ_FILE2,
490  write_str_to_file(filename, cpus[i].m0szstr);
491  }
492 
493  if (cpus[i].c0sharedmapstr) {
494  sprintf(filename, "%s/" C0_SHMAP_FILE,
496  write_str_to_file(filename, cpus[i].c0sharedmapstr);
497  }
498 
499  if (cpus[i].c1sharedmapstr) {
500  sprintf(filename, "%s/" C1_SHMAP_FILE,
502  write_str_to_file(filename, cpus[i].c1sharedmapstr);
503  }
504 
505  if (cpus[i].m0sharedmapstr) {
506  sprintf(filename, "%s/" M0_SHMAP_FILE,
508  write_str_to_file(filename, cpus[i].m0sharedmapstr);
509  }
510 
511  } /* for - populate test data for all CPUs */
512 }
513 
514 static void clean_test_dataset(void)
515 {
516  char cmd[PATH_MAX];
517  int rc;
518 
519  sprintf(cmd, "rm -rf %s", processor_info_dirp);
520  rc = system(cmd);
521  M0_UT_ASSERT(rc != -1);
522 }
523 
524 static void verify_all_params()
525 {
531  if (strcmp(processor_info_dirp, SYSFS_PATH) == 0)
532  verify_id_get();
533 }
534 
535 static struct psummary *psummary_new(m0_processor_nr_t cpu_max,
536  struct m0_bitmap *map_poss,
537  struct m0_bitmap *map_avail,
538  struct m0_bitmap *map_onln)
539 {
540  struct psummary *ps;
541  char buf[BUF_SZ];
542  char *str = &buf[0];
543 
544  M0_ALLOC_PTR(ps);
545  M0_UT_ASSERT(ps != NULL);
546  /* kmaxstr contains maximum index which starts from 0. */
547  snprintf(str, BUF_SZ, "%u", (unsigned)cpu_max - 1);
548  ps->kmaxstr = m0_strdup(str);
549  M0_UT_ASSERT(ps->kmaxstr != NULL);
550  maptostr(map_poss, str, BUF_SZ);
551  ps->possstr = m0_strdup(str);
552  M0_UT_ASSERT(ps->possstr != NULL);
553  maptostr(map_avail, str, BUF_SZ);
554  ps->presentstr = m0_strdup(str);
555  M0_UT_ASSERT(ps->presentstr != NULL);
556  maptostr(map_onln, str, BUF_SZ);
557  ps->onlnstr = m0_strdup(str);
558  M0_UT_ASSERT(ps->onlnstr != NULL);
559 
560  return ps;
561 }
562 
563 static void psummary_destroy(struct psummary *ps)
564 {
565  m0_free(ps->kmaxstr);
566  m0_free(ps->possstr);
567  m0_free(ps->presentstr);
568  m0_free(ps->onlnstr);
569  m0_free(ps);
570 }
571 
572 static struct pinfo *pinfo_new(m0_processor_nr_t cpu_max,
573  struct m0_bitmap *map_poss,
574  struct m0_bitmap *map_avail,
575  struct m0_bitmap *map_onln,
576  size_t *nr_out)
577 {
578  struct pinfo *pi;
579  size_t nr = 0;
580  size_t i;
581 
582  for (i = 0; i < map_avail->b_nr; ++i)
583  if (m0_bitmap_get(map_avail, i))
584  nr = i + 1;
585  M0_UT_ASSERT(nr > 0);
586  M0_ALLOC_ARR(pi, nr);
587  M0_UT_ASSERT(pi != NULL);
588 
589  for (i = 0; i < nr; ++i) {
590  if (m0_bitmap_get(map_onln, i)) {
591  /* online */
592  pi[i].numaid = 1;
593  pi[i].physid = 0;
594  pi[i].coreid = 0;
595  pi[i].c0lvl = 1;
596  pi[i].c1lvl = 1;
597  pi[i].m0lvl = 2;
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";
607  } else if (m0_bitmap_get(map_avail, i)) {
608  /* present */
609  pi[i].numaid = 1;
610  pi[i].physid = 0;
611  pi[i].coreid = 0;
612  pi[i].c0lvl = 1;
613  pi[i].c1lvl = 1;
614  pi[i].m0lvl = 2;
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";
624  } else {
625  /* not present */
626  pi[i].numaid = M0_PROCESSORS_INVALID_ID;
627  }
628  }
629 
630  *nr_out = nr;
631  return pi;
632 }
633 
634 void pinfo_destroy(struct pinfo *pi)
635 {
636  m0_free(pi);
637 }
638 
639 void test_processor(void)
640 {
641  struct m0_bitmap map_poss = {};
642  struct m0_bitmap map_avail = {};
643  struct m0_bitmap map_onln = {};
644  struct m0_bitmap map = {};
645  struct m0_bitmap *map_avail2;
646  struct psummary *ps;
647  struct pinfo *pi;
649  m0_processor_nr_t cpu_poss;
650  m0_processor_nr_t cpu_avail;
651  m0_processor_nr_t cpu_onln;
653  uint64_t rmask;
654  size_t nr;
655  size_t j;
656  int rc;
657 
658  rc = m0_bitmap_init(&map_poss, cpu_max);
659  M0_UT_ASSERT(rc == 0);
660  rc = m0_bitmap_init(&map_avail, cpu_max);
661  M0_UT_ASSERT(rc == 0);
662  rc = m0_bitmap_init(&map_onln, cpu_max);
663  M0_UT_ASSERT(rc == 0);
664  rc = m0_bitmap_init(&map, cpu_max);
665  M0_UT_ASSERT(rc == 0);
666  m0_processors_possible(&map_poss);
667  cpu_poss = m0_bitmap_set_nr(&map_poss);
668  m0_processors_available(&map_avail);
669  cpu_avail = m0_bitmap_set_nr(&map_avail);
670  m0_processors_online(&map_onln);
671  cpu_onln = m0_bitmap_set_nr(&map_onln);
672 
673  M0_UT_ASSERT(cpu_poss <= cpu_max);
674  M0_UT_ASSERT(cpu_avail <= cpu_poss);
675  M0_UT_ASSERT(cpu_onln <= cpu_avail);
676  for (i = 0; i < cpu_max; ++i) {
677  M0_UT_ASSERT(ergo(m0_bitmap_get(&map_onln, i),
678  m0_bitmap_get(&map_avail, i)));
679  M0_UT_ASSERT(ergo(m0_bitmap_get(&map_avail, i),
680  m0_bitmap_get(&map_poss, i)));
681  }
682 
683  m0_processors_fini(); /* clean normal data so we can load test data */
684 
687 
689  setenv("M0_PROCESSORS_INFO_DIR", TEST_SYSFS_PATH, 1);
690 
691  for (i = 0; i < cpu_onln && i < ARRAY_SIZE(cpu_masks); ++i) {
692  /*
693  * apply a mask to real online cpu map in order to create
694  * test data.
695  */
696  rmask = cpu_masks[i];
697  for (j = 0; j < map_onln.b_nr; ++j) {
698  if (m0_bitmap_get(&map_onln, j)) {
699  m0_bitmap_set(&map, j, rmask % 2 == 1);
700  rmask /= 2;
701  } else
702  m0_bitmap_set(&map, j, false);
703  }
704  /* map of present CPUs equals to online's every 2nd step */
705  map_avail2 = i % 2 == 0 ? &map_avail : &map;
706 
707  ps = psummary_new(cpu_max, &map_poss, map_avail2, &map);
708  pi = pinfo_new(cpu_max, &map_poss, map_avail2, &map, &nr);
710  populate_cpus(pi, nr);
713  pinfo_destroy(pi);
714  psummary_destroy(ps);
715  }
716 
717  m0_bitmap_fini(&map_poss);
718  m0_bitmap_fini(&map_avail);
719  m0_bitmap_fini(&map_onln);
721 
722  unsetenv("M0_PROCESSORS_INFO_DIR");
723  /* restore normal data */
725  M0_UT_ASSERT(rc == 0);
726 }
727 
729  .us_name = "processor-ub",
730  .us_init = ub_init,
731  .us_fini = ub_fini,
732  .us_run = {
733  {.ub_name = "Init1",
734  .ub_iter = UB_ITER,
735  .ub_round = ub_init1},
736  {.ub_name = "Init2",
737  .ub_iter = UB_ITER,
738  .ub_round = ub_init2},
739  {.ub_name = "Init3",
740  .ub_iter = UB_ITER,
741  .ub_round = ub_init3},
742  {.ub_name = NULL}
743  }
744 };
745 
746 /*
747  * Local variables:
748  * c-indentation-style: "K&R"
749  * c-basic-offset: 8
750  * tab-width: 8
751  * fill-column: 80
752  * scroll-step: 1
753  * End:
754  */
uint64_t id
Definition: cob.h:2380
#define NUMA_FILE2
Definition: processor.c:45
static size_t nr
Definition: dump.c:1505
#define M0_PROCESSORS_INVALID_ID
Definition: processor.h:59
uint32_t c0lvl
Definition: processor.c:75
const char * c0sharedmapstr
Definition: processor.c:81
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
M0_INTERNAL int m0_bitmap_init(struct m0_bitmap *map, size_t nr)
Definition: bitmap.c:86
static void ub_init3(int i)
Definition: processor.c:122
static void clean_test_dataset(void)
Definition: processor.c:514
#define m0_strdup(s)
Definition: string.h:43
M0_INTERNAL int struct dentry struct kstat * stat
Definition: dir.c:1433
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_bitmap_fini(struct m0_bitmap *map)
Definition: bitmap.c:97
map
Definition: processor.c:112
static void ub_fini(void)
Definition: processor.c:105
Definition: idx_mock.c:52
#define ergo(a, b)
Definition: misc.h:293
M0_INTERNAL void m0_processors_possible(struct m0_bitmap *map)
Definition: processor.c:1099
const char * c1szstr
Definition: processor.c:79
#define MAX_PROCESSOR_FILE
Definition: processor.c:39
static uint32_t get_num_from_file(const char *file)
Definition: processor.c:131
struct m0_file file
Definition: di.c:36
static void psummary_destroy(struct psummary *ps)
Definition: processor.c:563
static void write_num_to_file(const char *file, uint32_t num)
Definition: processor.c:383
#define L2SZ_FILE2
Definition: processor.c:52
M0_INTERNAL m0_processor_nr_t m0_processor_nr_max(void)
Definition: processor.c:1093
uint32_t physid
Definition: processor.c:73
static void verify_id_get(void)
Definition: processor.c:188
uint32_t numaid
Definition: processor.c:72
#define M0_LVL_FILE
Definition: processor.c:56
uint32_t m0lvl
Definition: processor.c:77
static int sum
Definition: rwlock.c:53
M0_INTERNAL void m0_processors_fini(void)
Definition: processor.c:1084
uint32_t pd_pipeline
Definition: processor.h:186
static void populate_cpu_summary(struct psummary *sum)
Definition: processor.c:394
M0_INTERNAL size_t m0_bitmap_set_nr(const struct m0_bitmap *map)
Definition: bitmap.c:172
#define L1SZ_FILE
Definition: processor.c:50
#define ONLN_PROCESSOR_FILE
Definition: processor.c:42
M0_INTERNAL m0_processor_nr_t m0_processor_id_get(void)
Definition: processor.c:1139
#define C0_LVL_FILE
Definition: processor.c:54
static void populate_cpus(struct pinfo cpus[], uint32_t sz)
Definition: processor.c:428
const char * m0sharedmapstr
Definition: processor.c:83
const char * c0szstr
Definition: processor.c:78
#define TEST_SYSFS_PATH
Definition: processor.c:37
Definition: sock.c:887
uint32_t pd_numa_node
Definition: processor.h:173
char * processor_info_dirp
Definition: processor.c:96
const char * c1sharedmapstr
Definition: processor.c:82
static int ub_init(const char *opts M0_UNUSED)
Definition: processor.c:100
int i
Definition: dir.c:1033
void test_processor(void)
Definition: processor.c:639
char * onlnstr
Definition: processor.c:68
#define POSS_PROCESSOR_FILE
Definition: processor.c:40
#define C1_LVL_FILE
Definition: processor.c:55
uint32_t m0_processor_nr_t
Definition: processor.h:62
m0_processor_nr_t pd_id
Definition: processor.h:171
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)
Definition: processor.c:535
static void ub_init2(int i)
Definition: processor.c:113
const char * us_name
Definition: ub.h:76
#define COREID_FILE
Definition: processor.c:47
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)
Definition: processor.c:572
M0_INTERNAL int m0_processors_init(void)
Definition: processor.c:1062
char * presentstr
Definition: processor.c:67
static void verify_max_processors()
Definition: processor.c:264
struct m0_ub_set m0_processor_ub
Definition: processor.c:728
uint32_t coreid
Definition: processor.c:74
void pinfo_destroy(struct pinfo *pi)
Definition: processor.c:634
M0_INTERNAL void m0_processors_online(struct m0_bitmap *map)
Definition: processor.c:1113
static void ub_init1(int i)
Definition: processor.c:109
struct m0_pdclust_instance pi
Definition: fd.c:107
M0_INTERNAL void m0_bitmap_set(struct m0_bitmap *map, size_t idx, bool val)
Definition: bitmap.c:139
static void maptostr(struct m0_bitmap *map, char *str, size_t sz)
Definition: processor.c:147
#define M0_SHMAP_FILE
Definition: processor.c:60
#define NUMA_FILE1
Definition: processor.c:44
char * possstr
Definition: processor.c:66
#define BUF_SZ
Definition: processor.c:62
uint64_t cpu_masks[]
Definition: processor.c:98
static void verify_processors()
Definition: processor.c:343
#define L2SZ_FILE1
Definition: processor.c:51
#define AVAIL_PROCESSOR_FILE
Definition: processor.c:41
static void verify_a_processor(m0_processor_nr_t id, struct m0_processor_descr *pd)
Definition: processor.c:285
uint32_t c1lvl
Definition: processor.c:76
#define C1_SHMAP_FILE
Definition: processor.c:59
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL int m0_processor_describe(m0_processor_nr_t id, struct m0_processor_descr *pd)
Definition: processor.c:1120
M0_INTERNAL bool m0_bitmap_get(const struct m0_bitmap *map, size_t idx)
Definition: bitmap.c:105
static void verify_map(int mapid)
Definition: processor.c:211
#define SYSFS_PATH
Definition: processor.c:36
#define C0_SHMAP_FILE
Definition: processor.c:58
char * kmaxstr
Definition: processor.c:65
Definition: rcv_session.c:58
static void verify_all_params()
Definition: processor.c:524
size_t b_nr
Definition: bitmap.h:44
int num
Definition: bulk_if.c:54
static void write_str_to_file(const char *file, const char *str)
Definition: processor.c:372
void m0_free(void *data)
Definition: memory.c:146
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
Definition: ub.h:74
#define M0_UT_ASSERT(a)
Definition: ut.h:46
M0_INTERNAL void m0_processors_available(struct m0_bitmap *map)
Definition: processor.c:1106
#define PHYSID_FILE
Definition: processor.c:48
const char * m0szstr
Definition: processor.c:80
#define M0_UNUSED
Definition: misc.h:380