Esempio n. 1
0
/**
 * @brief Prints information about cache allocation settings in the system
 *
 * @param sock_count number of detected CPU sockets
 * @param sockets arrays with detected CPU socket id's
 * @param cpu_info cpu information structure
 */
static void
print_allocation_config(const struct pqos_capability *cap_l3ca,
                        const unsigned sock_count,
                        const unsigned *sockets,
                        const struct pqos_cpuinfo *cpu_info)
{
	int ret;
	unsigned i;

	if (cap_l3ca == NULL)
                return;

        for (i = 0; i < sock_count; i++) {
                struct pqos_l3ca tab[PQOS_MAX_L3CA_COS];
                unsigned num = 0;

                ret = pqos_l3ca_get(sockets[i], PQOS_MAX_L3CA_COS,
                                    &num, tab);
                if (ret == PQOS_RETVAL_OK) {
                        unsigned n = 0;

                        printf("L3CA COS definitions for Socket %u:\n",
                               sockets[i]);
                        for (n = 0; n < num; n++) {
                                printf("   L3CA COS%u => MASK 0x%llx\n",
                                       tab[n].class_id,
                                       (unsigned long long)tab[n].u.ways_mask);
                        }
                }
        }

	for (i = 0; i < sock_count; i++) {
		unsigned *lcores = NULL;
		unsigned lcount = 0, n = 0;

		lcores = pqos_cpu_get_cores(cpu_info, sockets[i], &lcount);
		if (lcores == NULL || lcount == 0) {
			printf("Error retrieving core information!\n");
                        free(lcores);
			return;
		}
		printf("Core information for socket %u:\n",
                       sockets[i]);
		for (n = 0; n < lcount; n++) {
			unsigned class_id = 0;
			int ret1 = PQOS_RETVAL_OK;

			if (cap_l3ca != NULL)
				ret1 = pqos_alloc_assoc_get(lcores[n],
                                                            &class_id);
			if (ret1 == PQOS_RETVAL_OK)
				printf("    Core %u => COS%u\n",
                                       lcores[n], class_id);
			else
				printf("    Core %u => ERROR\n",
                                       lcores[n]);
		}
                free(lcores);
	}
}
Esempio n. 2
0
/**
 * @brief Prints information about cache allocation settings in the system
 */
static void
print_allocation_config(void)
{
	int ret;
	unsigned i;
	unsigned sock_count, *sockets = NULL;
	const struct pqos_cpuinfo *p_cpu = NULL;
	const struct pqos_cap *p_cap = NULL;

	/* Get CMT capability and CPU info pointer */
	ret = pqos_cap_get(&p_cap, &p_cpu);
	if (ret != PQOS_RETVAL_OK) {
		printf("Error retrieving PQoS capabilities!\n");
		return;
	}
	/* Get CPU socket information to set COS */
	sockets = pqos_cpu_get_sockets(p_cpu, &sock_count);
	if (sockets == NULL) {
		printf("Error retrieving CPU socket information!\n");
		return;
	}
	for (i = 0; i < sock_count; i++) {
		unsigned *lcores = NULL;
		unsigned lcount = 0, n = 0;

		lcores = pqos_cpu_get_cores(p_cpu, sockets[i], &lcount);
		if (lcores == NULL || lcount == 0) {
			printf("Error retrieving core information!\n");
                        free(sockets);
			return;
		}
		printf("Core information for socket %u:\n",
				sockets[i]);
		for (n = 0; n < lcount; n++) {
			unsigned class_id = 0;

			ret = pqos_alloc_assoc_get(lcores[n], &class_id);
			if (ret == PQOS_RETVAL_OK)
				printf("    Core %u => COS%u\n",
                                       lcores[n], class_id);
			else
				printf("    Core %u => ERROR\n",
                                       lcores[n]);
		}
                free(lcores);
	}
        free(sockets);
}
Esempio n. 3
0
void alloc_print_config(const struct pqos_capability *cap_mon,
                        const struct pqos_capability *cap_l3ca,
                        const struct pqos_capability *cap_l2ca,
                        const unsigned sock_count,
                        const unsigned *sockets,
                        const struct pqos_cpuinfo *cpu_info)
{
        int ret;
        unsigned i;

        for (i = 0; (i < sock_count) && (cap_l3ca != NULL); i++) {
                struct pqos_l3ca tab[PQOS_MAX_L3CA_COS];
                unsigned num = 0;
                unsigned n = 0;

                ret = pqos_l3ca_get(sockets[i], PQOS_MAX_L3CA_COS,
                                    &num, tab);
                if (ret != PQOS_RETVAL_OK)
                        continue;

                printf("L3CA COS definitions for Socket %u:\n",
                       sockets[i]);
                for (n = 0; n < num; n++) {
                        if (tab[n].cdp) {
                                printf("    L3CA COS%u => DATA 0x%llx,"
                                       "CODE 0x%llx\n",
                                       tab[n].class_id,
                                       (unsigned long long)tab[n].u.s.data_mask,
                                       (unsigned long long)
                                       tab[n].u.s.code_mask);
                        } else {
                                printf("    L3CA COS%u => MASK 0x%llx\n",
                                       tab[n].class_id,
                                       (unsigned long long)tab[n].u.ways_mask);
                        }
                }
        }

        for (i = 0; (i < sock_count) && (cap_l2ca != NULL); i++) {
                struct pqos_l2ca tab[PQOS_MAX_L2CA_COS];
                unsigned num = 0;
                unsigned n = 0;

                ret = pqos_l2ca_get(sockets[i], PQOS_MAX_L2CA_COS,
                                    &num, tab);
                if (ret != PQOS_RETVAL_OK)
                        continue;

                printf("L2CA COS definitions for Socket %u:\n",
                       sockets[i]);
                for (n = 0; n < num; n++)
                        printf("    L2CA COS%u => MASK 0x%llx\n",
                               tab[n].class_id,
                               (unsigned long long)tab[n].ways_mask);
        }

        for (i = 0; i < sock_count; i++) {
                unsigned *lcores = NULL;
                unsigned lcount = 0, n = 0;

                lcores = pqos_cpu_get_cores(cpu_info, sockets[i], &lcount);
                if (lcores == NULL) {
                        printf("Error retrieving core information!\n");
                        return;
                }
                printf("Core information for socket %u:\n",
                       sockets[i]);
                for (n = 0; n < lcount; n++) {
                        unsigned class_id = 0;
                        pqos_rmid_t rmid = 0;
                        int ret = PQOS_RETVAL_OK;
                        const int is_mon = (cap_mon != NULL);
                        const int is_alloc = (cap_l3ca != NULL) ||
                                (cap_l2ca != NULL);

			if (is_alloc)
				ret = pqos_alloc_assoc_get(lcores[n],
                                                           &class_id);
			if (is_mon && ret == PQOS_RETVAL_OK)
				ret = pqos_mon_assoc_get(lcores[n], &rmid);

                        if (ret != PQOS_RETVAL_OK) {
                                printf("    Core %u => ERROR\n", lcores[n]);
                                continue;
                        }

                        if (is_alloc && is_mon)
                                printf("    Core %u => COS%u, RMID%u\n",
                                       lcores[n], class_id, (unsigned)rmid);
                        if (is_alloc && !is_mon)
                                printf("    Core %u => COS%u\n", lcores[n],
                                       class_id);
                        if (!is_alloc && is_mon)
                                printf("    Core %u => RMID%u\n", lcores[n],
                                       (unsigned)rmid);
                }
                free(lcores);
        }
}