src/dpdk/lib/librte_eal/linux/eal_hugepage_info.c
int
eal_hugepage_info_init(void)
{
	struct hugepage_info *hpi, *tmp_hpi;
	unsigned int i;
	struct internal_config *internal_conf =
		eal_get_internal_configuration();

	if (hugepage_info_init() < 0)
		return -1;

	/* for no shared files mode, we're done */
	if (internal_conf->no_shconf)
		return 0;

	hpi = &internal_conf->hugepage_info[0];

	tmp_hpi = create_shared_memory(eal_hugepage_info_path(),
			sizeof(internal_conf->hugepage_info));
	if (tmp_hpi == NULL) {
		RTE_LOG(ERR, EAL, "Failed to create shared memory!\n");
		return -1;
	}

	memcpy(tmp_hpi, hpi, sizeof(internal_conf->hugepage_info));

	/* we've copied file descriptors along with everything else, but they
	 * will be invalid in secondary process, so overwrite them
	 */
	for (i = 0; i < RTE_DIM(internal_conf->hugepage_info); i++) {
		struct hugepage_info *tmp = &tmp_hpi[i];
		tmp->lock_descriptor = -1;
	}

	if (munmap(tmp_hpi, sizeof(internal_conf->hugepage_info)) < 0) {
		RTE_LOG(ERR, EAL, "Failed to unmap shared memory!\n");
		return -1;
	}
	return 0;
}
/*
 * when we initialize the hugepage info, everything goes
 * to socket 0 by default. it will later get sorted by memory
 * initialization procedure.
 */
when we initialize the hugepage info, everything goes
to socket 0 by default. it will later get sorted by memory
initialization procedure.
when we initialize the hugepage info everything goes to socket 0 by default . it will later get sorted by memory initialization procedure .
int
eal_hugepage_info_init(void)
{
	struct hugepage_info *hpi, *tmp_hpi;
	unsigned int i;
	struct internal_config *internal_conf =
		eal_get_internal_configuration();
	if (hugepage_info_init() < 0)
		return -1;
	if (internal_conf->no_shconf)
		return 0;
	hpi = &internal_conf->hugepage_info[0];
	tmp_hpi = create_shared_memory(eal_hugepage_info_path(),
			sizeof(internal_conf->hugepage_info));
	if (tmp_hpi == NULL) {
		RTE_LOG(ERR, EAL, "Failed to create shared memory!\n");
		return -1;
	}
	memcpy(tmp_hpi, hpi, sizeof(internal_conf->hugepage_info));
	for (i = 0; i < RTE_DIM(internal_conf->hugepage_info); i++) {
		struct hugepage_info *tmp = &tmp_hpi[i];
		tmp->lock_descriptor = -1;
	}
	if (munmap(tmp_hpi, sizeof(internal_conf->hugepage_info)) < 0) {
		RTE_LOG(ERR, EAL, "Failed to unmap shared memory!\n");
		return -1;
	}
	return 0;
}
int eal_hugepage_info_init ( void ) { struct hugepage_info * hpi , * tmp_hpi ; unsigned int i ; struct internal_config * internal_conf = eal_get_internal_configuration ( ) ; if ( hugepage_info_init ( ) < 0 ) return -1 ; if ( internal_conf -> no_shconf ) return 0 ; hpi = & internal_conf -> hugepage_info [ 0 ] ; tmp_hpi = create_shared_memory ( eal_hugepage_info_path ( ) , sizeof ( internal_conf -> hugepage_info ) ) ; if ( tmp_hpi == NULL ) { RTE_LOG ( ERR , EAL , " \n " ) ; return -1 ; } memcpy ( tmp_hpi , hpi , sizeof ( internal_conf -> hugepage_info ) ) ; for ( i = 0 ; i < RTE_DIM ( internal_conf -> hugepage_info ) ; i ++ ) { struct hugepage_info * tmp = & tmp_hpi [ i ] ; tmp -> lock_descriptor = -1 ; } if ( munmap ( tmp_hpi , sizeof ( internal_conf -> hugepage_info ) ) < 0 ) { RTE_LOG ( ERR , EAL , " \n " ) ; return -1 ; } return 0 ; }
when we initialize the hugepage info, everything goes
 to socket 0 by default.
when we initialize the hugepage info everything goes to socket 0 by default .
/* for no shared files mode, we're done */ /* we've copied file descriptors along with everything else, but they
	 * will be invalid in secondary process, so overwrite them
	 */