static __inline__ void free_lcores(lcore_t *lc) { if (lc) { free_lcores(lc->next); free(lc); } }
static void print_core_map(lcore_t *lcores, unsigned mode, unsigned balanced) { unsigned s, c; /* * For unpaired mode print HT0 on each physical core. * * For paired mode print lcore for HT1 as well, * except for physical core 0. This is because * the main thread runs on core 0, HT 0. * * For paired mode, add HT1 on physical core 0:socket 0 * last, in case the user wants to use all logical cores * in the system. * */ if (balanced) { /* * Balanced map. Print cores in the following order: * Core 0 one socket 0, core 0 on socket 1 etc. */ for (c = 0; c < cnt(lcores, get_core_id); c++) { for (s = 0; s < cnt(lcores,get_socket_id); s++) { print_matching_lcores(lcores, s, c, 0); if (mode == 0 && (c != 0 || s != 0)) print_matching_lcores(lcores, s, c, 1); } } } else { /* * Unbalanced map. Print cores in the following order: * Core 0 one socket 0, core 1 on socket 0... */ for (s = 0; s < cnt(lcores, get_socket_id); s++) { for (c = 0; c < cnt(lcores, get_core_id); c++) { print_matching_lcores(lcores, s, c, 0); if (mode == 0 && (c != 0 || s != 0)) print_matching_lcores(lcores, s, c, 1); } } } if (mode == 0) print_matching_lcores(lcores, 0, 0, 1); free_lcores(lcores); printf("\n"); }