Example #1
0
/*
 * get the number of the nodes including offline nodes
 */
int get_nmems(void)
{
	struct bitmask *bmp = NULL;
	int n = 0;

	/* get the bitmask's len */
	if (mems_nbits <= 0) {
		mems_nbits = cpuset_mems_nbits();
		if (mems_nbits <= 0)
			return -1;
	}

	/* allocate the space for bitmask */
	bmp = bitmask_alloc(mems_nbits);
	if (bmp == NULL)
		return -1;

	if (present_memmask(bmp)) {
		bitmask_free(bmp);
		return -1;
	}

	/* Numbwe of highest set bit +1 is the number of the nodes */
	if (bitmask_weight(bmp) <= 0) {
		bitmask_free(bmp);
		return -1;
	}

	n = bitmask_last(bmp) + 1;
	bitmask_free(bmp);

	return n;
}
Example #2
0
/**
 * @brief
 *	Add a memory node to the memory mask that is constructed while reading
 *	vnode definitions files.
 *
 * @param[in] memnum - memory board node id
 *
 * @return    int
 * @retval    0     Success
 * @retval   -1     Failure
 *
 */
static int
memmask_add(unsigned int memnum)
{
	if (mem_mask == NULL) {
		if (mems_nbits == 0)
			mems_nbits = cpuset_mems_nbits();
		mem_mask = bitmask_alloc(mems_nbits);
		if (mem_mask == NULL) {
			log_err(PBSE_SYSTEM, __func__, "bitmask_alloc failed");
			return (-1);
		} else
			bitmask_clearall(mem_mask);
	}
	assert(memnum < bitmask_nbits(mem_mask));
	(void) bitmask_setbit(mem_mask, memnum);

	return (0);
}