OSHMEM: integrate review comments from open-mpi/ompi-release#7
Этот коммит содержится в:
родитель
8da6c14e06
Коммит
5ce2f10067
@ -264,7 +264,9 @@ segment_attach(map_segment_t *ds_buf, sshmem_mkey_t *mkey)
|
|||||||
ds_buf->seg_size,
|
ds_buf->seg_size,
|
||||||
PROT_READ | PROT_WRITE,
|
PROT_READ | PROT_WRITE,
|
||||||
MAP_SHARED |
|
MAP_SHARED |
|
||||||
|
#if defined(MAP_ANONYMOUS)
|
||||||
MAP_ANONYMOUS |
|
MAP_ANONYMOUS |
|
||||||
|
#endif
|
||||||
MAP_FIXED,
|
MAP_FIXED,
|
||||||
-1,
|
-1,
|
||||||
0);
|
0);
|
||||||
|
@ -38,36 +38,8 @@ typedef struct mca_sshmem_sysv_module_t {
|
|||||||
} mca_sshmem_sysv_module_t;
|
} mca_sshmem_sysv_module_t;
|
||||||
extern mca_sshmem_sysv_module_t mca_sshmem_sysv_module;
|
extern mca_sshmem_sysv_module_t mca_sshmem_sysv_module;
|
||||||
|
|
||||||
/*
|
OSHMEM_MODULE_DECLSPEC extern size_t sshmem_sysv_gethugepagesize(void);
|
||||||
* Get current huge page size
|
|
||||||
*/
|
|
||||||
static size_t oshmem_gethugepagesize(void)
|
|
||||||
{
|
|
||||||
static size_t huge_page_size = 0;
|
|
||||||
char buf[256];
|
|
||||||
int size_kb;
|
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
/* Cache the huge page size value */
|
|
||||||
if (huge_page_size == 0) {
|
|
||||||
f = fopen("/proc/meminfo", "r");
|
|
||||||
if (f != NULL) {
|
|
||||||
while (fgets(buf, sizeof(buf), f)) {
|
|
||||||
if (sscanf(buf, "Hugepagesize: %d kB", &size_kb) == 1) {
|
|
||||||
huge_page_size = size_kb * 1024L;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (huge_page_size == 0) {
|
|
||||||
huge_page_size = 2 * 1024L *1024L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return huge_page_size;
|
|
||||||
}
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
#endif /* MCA_SSHMEM_SYSV_EXPORT_H */
|
#endif /* MCA_SSHMEM_SYSV_EXPORT_H */
|
||||||
|
@ -104,6 +104,9 @@ sysv_runtime_query(mca_base_module_t **module,
|
|||||||
char *addr = NULL;
|
char *addr = NULL;
|
||||||
struct shmid_ds tmp_buff;
|
struct shmid_ds tmp_buff;
|
||||||
int flags;
|
int flags;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = OSHMEM_SUCCESS;
|
||||||
|
|
||||||
*priority = 0;
|
*priority = 0;
|
||||||
*module = NULL;
|
*module = NULL;
|
||||||
@ -111,11 +114,12 @@ sysv_runtime_query(mca_base_module_t **module,
|
|||||||
/* if we are here, then let the run-time test games begin */
|
/* if we are here, then let the run-time test games begin */
|
||||||
|
|
||||||
#if defined (SHM_HUGETLB)
|
#if defined (SHM_HUGETLB)
|
||||||
if (mca_sshmem_sysv_component.use_hp > 0) {
|
if (mca_sshmem_sysv_component.use_hp != 0) {
|
||||||
flags = IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR | SHM_HUGETLB;
|
flags = IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR | SHM_HUGETLB;
|
||||||
if (-1 == (shmid = shmget(IPC_PRIVATE, oshmem_gethugepagesize(), flags))) {
|
if (-1 == (shmid = shmget(IPC_PRIVATE, sshmem_sysv_gethugepagesize(), flags))) {
|
||||||
if (mca_sshmem_sysv_component.use_hp == 1) {
|
if (mca_sshmem_sysv_component.use_hp == 1) {
|
||||||
mca_sshmem_sysv_component.use_hp = 0;
|
mca_sshmem_sysv_component.use_hp = 0;
|
||||||
|
ret = OSHMEM_ERR_NOT_AVAILABLE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
mca_sshmem_sysv_component.use_hp = 0;
|
mca_sshmem_sysv_component.use_hp = 0;
|
||||||
@ -124,6 +128,7 @@ sysv_runtime_query(mca_base_module_t **module,
|
|||||||
shmctl(shmid, IPC_RMID, NULL);
|
shmctl(shmid, IPC_RMID, NULL);
|
||||||
if (mca_sshmem_sysv_component.use_hp == 1) {
|
if (mca_sshmem_sysv_component.use_hp == 1) {
|
||||||
mca_sshmem_sysv_component.use_hp = 0;
|
mca_sshmem_sysv_component.use_hp = 0;
|
||||||
|
ret = OSHMEM_ERR_NOT_AVAILABLE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
mca_sshmem_sysv_component.use_hp = 0;
|
mca_sshmem_sysv_component.use_hp = 0;
|
||||||
@ -132,6 +137,7 @@ sysv_runtime_query(mca_base_module_t **module,
|
|||||||
#else
|
#else
|
||||||
if (mca_sshmem_sysv_component.use_hp == 1) {
|
if (mca_sshmem_sysv_component.use_hp == 1) {
|
||||||
mca_sshmem_sysv_component.use_hp = 0;
|
mca_sshmem_sysv_component.use_hp = 0;
|
||||||
|
ret = OSHMEM_ERR_NOT_AVAILABLE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
mca_sshmem_sysv_component.use_hp = 0;
|
mca_sshmem_sysv_component.use_hp = 0;
|
||||||
@ -140,10 +146,12 @@ sysv_runtime_query(mca_base_module_t **module,
|
|||||||
if (0 == mca_sshmem_sysv_component.use_hp) {
|
if (0 == mca_sshmem_sysv_component.use_hp) {
|
||||||
flags = IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR;
|
flags = IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR;
|
||||||
if (-1 == (shmid = shmget(IPC_PRIVATE, (size_t)(opal_getpagesize()), flags))) {
|
if (-1 == (shmid = shmget(IPC_PRIVATE, (size_t)(opal_getpagesize()), flags))) {
|
||||||
|
ret = OSHMEM_ERR_NOT_AVAILABLE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
else if ((void *)-1 == (addr = shmat(shmid, NULL, 0))) {
|
else if ((void *)-1 == (addr = shmat(shmid, NULL, 0))) {
|
||||||
shmctl(shmid, IPC_RMID, NULL);
|
shmctl(shmid, IPC_RMID, NULL);
|
||||||
|
ret = OSHMEM_ERR_NOT_AVAILABLE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,7 +176,7 @@ sysv_runtime_query(mca_base_module_t **module,
|
|||||||
if ((char *)-1 != addr) {
|
if ((char *)-1 != addr) {
|
||||||
shmdt(addr);
|
shmdt(addr);
|
||||||
}
|
}
|
||||||
return OSHMEM_SUCCESS;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ////////////////////////////////////////////////////////////////////////// */
|
/* ////////////////////////////////////////////////////////////////////////// */
|
||||||
@ -186,12 +194,12 @@ sysv_register(void)
|
|||||||
MCA_BASE_VAR_SCOPE_ALL_EQ,
|
MCA_BASE_VAR_SCOPE_ALL_EQ,
|
||||||
&mca_sshmem_sysv_component.priority);
|
&mca_sshmem_sysv_component.priority);
|
||||||
|
|
||||||
mca_sshmem_sysv_component.use_hp = 2;
|
mca_sshmem_sysv_component.use_hp = -1;
|
||||||
mca_base_component_var_register (&mca_sshmem_sysv_component.super.base_version,
|
mca_base_component_var_register (&mca_sshmem_sysv_component.super.base_version,
|
||||||
"use_hp", "Huge pages usage "
|
"use_hp", "Huge pages usage "
|
||||||
"[0 - off, 1 - on, 2 - auto] (default: 2)", MCA_BASE_VAR_TYPE_INT,
|
"[0 - off, 1 - on, -1 - auto] (default: -1)", MCA_BASE_VAR_TYPE_INT,
|
||||||
NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
|
NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
|
||||||
OPAL_INFO_LVL_3,
|
OPAL_INFO_LVL_4,
|
||||||
MCA_BASE_VAR_SCOPE_ALL_EQ,
|
MCA_BASE_VAR_SCOPE_ALL_EQ,
|
||||||
&mca_sshmem_sysv_component.use_hp);
|
&mca_sshmem_sysv_component.use_hp);
|
||||||
|
|
||||||
|
@ -188,8 +188,8 @@ segment_create(map_segment_t *ds_buf,
|
|||||||
*/
|
*/
|
||||||
flags = IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR;
|
flags = IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR;
|
||||||
#if defined (SHM_HUGETLB)
|
#if defined (SHM_HUGETLB)
|
||||||
flags |= (mca_sshmem_sysv_component.use_hp ? SHM_HUGETLB : 0);
|
flags |= ((0 != mca_sshmem_sysv_component.use_hp) ? SHM_HUGETLB : 0);
|
||||||
size = ((size + oshmem_gethugepagesize() - 1) / oshmem_gethugepagesize()) * oshmem_gethugepagesize();
|
size = ((size + sshmem_sysv_gethugepagesize() - 1) / sshmem_sysv_gethugepagesize()) * sshmem_sysv_gethugepagesize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Create a new shared memory segment and save the shmid. */
|
/* Create a new shared memory segment and save the shmid. */
|
||||||
@ -295,7 +295,7 @@ segment_detach(map_segment_t *ds_buf, sshmem_mkey_t *mkey)
|
|||||||
shmctl(ds_buf->seg_id, IPC_RMID, NULL );
|
shmctl(ds_buf->seg_id, IPC_RMID, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mca_sshmem_sysv_component.use_hp > 0) {
|
if (mca_sshmem_sysv_component.use_hp != 0) {
|
||||||
/**
|
/**
|
||||||
* Workaround kernel panic when detaching huge pages from user space simultanously from several processes
|
* Workaround kernel panic when detaching huge pages from user space simultanously from several processes
|
||||||
* dont detach here instead let kernel do it during process cleanup
|
* dont detach here instead let kernel do it during process cleanup
|
||||||
@ -337,3 +337,36 @@ segment_unlink(map_segment_t *ds_buf)
|
|||||||
return OSHMEM_SUCCESS;
|
return OSHMEM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get current huge page size
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
size_t sshmem_sysv_gethugepagesize(void)
|
||||||
|
{
|
||||||
|
static size_t huge_page_size = 0;
|
||||||
|
char buf[256];
|
||||||
|
int size_kb;
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
/* Cache the huge page size value */
|
||||||
|
if (huge_page_size == 0) {
|
||||||
|
f = fopen("/proc/meminfo", "r");
|
||||||
|
if (f != NULL) {
|
||||||
|
while (fgets(buf, sizeof(buf), f)) {
|
||||||
|
if (sscanf(buf, "Hugepagesize: %d kB", &size_kb) == 1) {
|
||||||
|
huge_page_size = size_kb * 1024L;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (huge_page_size == 0) {
|
||||||
|
huge_page_size = 2 * 1024L *1024L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return huge_page_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,12 +312,12 @@ verbs_register(void)
|
|||||||
MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
|
MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
mca_sshmem_verbs_component.has_shared_mr = 2;
|
mca_sshmem_verbs_component.has_shared_mr = -1;
|
||||||
index = mca_base_component_var_register (&mca_sshmem_verbs_component.super.base_version,
|
index = mca_base_component_var_register (&mca_sshmem_verbs_component.super.base_version,
|
||||||
"shared_mr", "Shared memory region usage "
|
"shared_mr", "Shared memory region usage "
|
||||||
"[0 - off, 1 - on, 2 - auto] (default: 2)", MCA_BASE_VAR_TYPE_INT,
|
"[0 - off, 1 - on, -1 - auto] (default: -1)", MCA_BASE_VAR_TYPE_INT,
|
||||||
NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
|
NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
|
||||||
OPAL_INFO_LVL_3,
|
OPAL_INFO_LVL_4,
|
||||||
MCA_BASE_VAR_SCOPE_ALL_EQ,
|
MCA_BASE_VAR_SCOPE_ALL_EQ,
|
||||||
&mca_sshmem_verbs_component.has_shared_mr);
|
&mca_sshmem_verbs_component.has_shared_mr);
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user