mcexec: memory policy control by environmental variable

Refs: #1470
Change-Id: I3d556cae90d31d81572b1c4e5c680e826577d428
This commit is contained in:
Masamichi Takagi
2020-12-15 14:17:32 +09:00
parent ed670c03af
commit 33dd2e60b1
21 changed files with 729 additions and 6 deletions

View File

@@ -0,0 +1,53 @@
#!/usr/bin/bash
# define WORKDIR
SCRIPT_PATH=$(readlink -m "${BASH_SOURCE[0]}")
SCRIPT_NAME="${SCRIPT_PATH##*/}"
TEST_NAME="${SCRIPT_NAME%.sh}"
AUTOTEST_HOME="${SCRIPT_PATH%/*/*/*}"
if [ -f ${AUTOTEST_HOME}/bin/config.sh ]; then
. ${AUTOTEST_HOME}/bin/config.sh
else
WORKDIR=$(pwd)
fi
declare -A mode
mode[interleave_local]="3"
mode[bind_local]="2"
mode[prefer_local]="1"
declare -A nodemask
nodemask[$(seq -s, 12 23)]="1"
nodemask[$(seq -s, 24 35)]="2"
nodemask[$(seq -s, 36 47)]="4"
nodemask[$(seq -s, 48 59)]="8"
nodemask[$(seq -s, 12 35)]="3"
nodemask[$(seq -s, 24 47)]="6"
nodemask[$(seq -s, 36 59)]="12"
nodemask[$(seq -s, 12 47)]="7"
nodemask[$(seq -s, 24 59)]="14"
nodemask[$(seq -s, 12 59)]="15"
@WITH_MCK@/sbin/mcstop+release.sh
@WITH_MCK@/sbin/mcreboot.sh -c 12-59 -m 1G@4,1G@5,1G@6,1G@7
for policy in interleave_local bind_local prefer_local; do
for cpuset in \
$(seq -s, 12 23) $(seq -s, 24 35) $(seq -s, 36 47) $(seq -s, 48 59) \
$(seq -s, 12 35) $(seq -s, 24 47) $(seq -s, 36 59) \
$(seq -s, 12 47) $(seq -s, 24 59) \
$(seq -s, 12 59); do
# check if policy is not set when not specified
if (( i++ == 0 )); then
FLIB_NUM_PROCESS_ON_NODE=1 FLIB_AFFINITY_ON_PROCESS=$cpuset @WITH_MCK@/bin/mcexec @CMAKE_INSTALL_PREFIX@/bin/check_mempolicy -m 0 || exit $?
fi
FLIB_NUM_PROCESS_ON_NODE=1 FLIB_AFFINITY_ON_PROCESS=$cpuset OMPI_MCA_plm_ple_memory_allocation_policy=$policy @WITH_MCK@/bin/mcexec @CMAKE_INSTALL_PREFIX@/bin/check_mempolicy -m ${mode[$policy]} -n ${nodemask[$cpuset]} || exit $?
done
done
@WITH_MCK@/sbin/mcstop+release.sh
exit 0

View File

@@ -0,0 +1,48 @@
#!/usr/bin/bash
# define WORKDIR
SCRIPT_PATH=$(readlink -m "${BASH_SOURCE[0]}")
SCRIPT_NAME="${SCRIPT_PATH##*/}"
TEST_NAME="${SCRIPT_NAME%.sh}"
AUTOTEST_HOME="${SCRIPT_PATH%/*/*/*}"
if [ -f ${AUTOTEST_HOME}/bin/config.sh ]; then
. ${AUTOTEST_HOME}/bin/config.sh
else
WORKDIR=$(pwd)
fi
declare -A mode
mode[interleave_nonlocal]="3"
mode[bind_nonlocal]="2"
mode[prefer_nonlocal]="1"
declare -A nodemask
nodemask[$(seq -s, 12 23)]="14"
nodemask[$(seq -s, 24 35)]="13"
nodemask[$(seq -s, 36 47)]="11"
nodemask[$(seq -s, 48 59)]="7"
nodemask[$(seq -s, 12 35)]="12"
nodemask[$(seq -s, 24 47)]="9"
nodemask[$(seq -s, 36 59)]="3"
nodemask[$(seq -s, 12 47)]="8"
nodemask[$(seq -s, 24 59)]="1"
nodemask[$(seq -s, 12 59)]="0"
@WITH_MCK@/sbin/mcstop+release.sh
@WITH_MCK@/sbin/mcreboot.sh -c 12-59 -m 1G@4,1G@5,1G@6,1G@7
for policy in interleave_nonlocal bind_nonlocal prefer_nonlocal; do
for cpuset in \
$(seq -s, 12 23) $(seq -s, 24 35) $(seq -s, 36 47) $(seq -s, 48 59) \
$(seq -s, 12 35) $(seq -s, 24 47) $(seq -s, 36 59) \
$(seq -s, 12 47) $(seq -s, 24 59) \
$(seq -s, 12 59); do
FLIB_NUM_PROCESS_ON_NODE=1 FLIB_AFFINITY_ON_PROCESS=$cpuset OMPI_MCA_plm_ple_memory_allocation_policy=$policy @WITH_MCK@/bin/mcexec @CMAKE_INSTALL_PREFIX@/bin/check_mempolicy -m ${mode[$policy]} -n ${nodemask[$cpuset]} || exit $?
done
done
@WITH_MCK@/sbin/mcstop+release.sh
exit 0

View File

@@ -0,0 +1,34 @@
#!/usr/bin/bash
# define WORKDIR
SCRIPT_PATH=$(readlink -m "${BASH_SOURCE[0]}")
SCRIPT_NAME="${SCRIPT_PATH##*/}"
TEST_NAME="${SCRIPT_NAME%.sh}"
AUTOTEST_HOME="${SCRIPT_PATH%/*/*/*}"
if [ -f ${AUTOTEST_HOME}/bin/config.sh ]; then
. ${AUTOTEST_HOME}/bin/config.sh
else
WORKDIR=$(pwd)
fi
declare -A mode
mode[interleave_all]="3"
mode[bind_all]="2"
@WITH_MCK@/sbin/mcstop+release.sh
@WITH_MCK@/sbin/mcreboot.sh -c 12-59 -m 1G@4,1G@5,1G@6,1G@7
for policy in interleave_all bind_all; do
for cpuset in \
$(seq -s, 12 23) $(seq -s, 24 35) $(seq -s, 36 47) $(seq -s, 48 59) \
$(seq -s, 12 35) $(seq -s, 24 47) $(seq -s, 36 59) \
$(seq -s, 12 47) $(seq -s, 24 59) \
$(seq -s, 12 59); do
FLIB_NUM_PROCESS_ON_NODE=1 FLIB_AFFINITY_ON_PROCESS=$cpuset OMPI_MCA_plm_ple_memory_allocation_policy=$policy @WITH_MCK@/bin/mcexec @CMAKE_INSTALL_PREFIX@/bin/check_mempolicy -m ${mode[$policy]} -n 15 || exit $?
done
done
@WITH_MCK@/sbin/mcstop+release.sh
exit 0

View File

@@ -0,0 +1,30 @@
#!/usr/bin/bash
# define WORKDIR
SCRIPT_PATH=$(readlink -m "${BASH_SOURCE[0]}")
SCRIPT_NAME="${SCRIPT_PATH##*/}"
TEST_NAME="${SCRIPT_NAME%.sh}"
AUTOTEST_HOME="${SCRIPT_PATH%/*/*/*}"
if [ -f ${AUTOTEST_HOME}/bin/config.sh ]; then
. ${AUTOTEST_HOME}/bin/config.sh
else
WORKDIR=$(pwd)
fi
@WITH_MCK@/sbin/mcstop+release.sh
@WITH_MCK@/sbin/mcreboot.sh -c 12-59 -m 1G@4,1G@5,1G@6,1G@7
for policy in localalloc; do
for cpuset in \
$(seq -s, 12 23) $(seq -s, 24 35) $(seq -s, 36 47) $(seq -s, 48 59) \
$(seq -s, 12 35) $(seq -s, 24 47) $(seq -s, 36 59) \
$(seq -s, 12 47) $(seq -s, 24 59) \
$(seq -s, 12 59); do
FLIB_NUM_PROCESS_ON_NODE=1 FLIB_AFFINITY_ON_PROCESS=$cpuset OMPI_MCA_plm_ple_memory_allocation_policy=$policy @WITH_MCK@/bin/mcexec @CMAKE_INSTALL_PREFIX@/bin/check_mempolicy -m 0 || exit $?
done
done
@WITH_MCK@/sbin/mcstop+release.sh
exit 0

View File

@@ -0,0 +1,44 @@
#!/usr/bin/bash
# define WORKDIR
SCRIPT_PATH=$(readlink -m "${BASH_SOURCE[0]}")
SCRIPT_NAME="${SCRIPT_PATH##*/}"
TEST_NAME="${SCRIPT_NAME%.sh}"
AUTOTEST_HOME="${SCRIPT_PATH%/*/*/*}"
if [ -f ${AUTOTEST_HOME}/bin/config.sh ]; then
. ${AUTOTEST_HOME}/bin/config.sh
else
WORKDIR=$(pwd)
fi
declare -A mode
mode[interleave_local]="3"
mode[bind_local]="2"
mode[prefer_local]="1"
declare -A nodemask
nodemask[$(seq -s, 12 23)]="2"
nodemask[$(seq -s, 24 35)]="4"
nodemask[$(seq -s, 36 47)]="8"
nodemask[$(seq -s, 12 35)]="6"
nodemask[$(seq -s, 24 47)]="12"
nodemask[$(seq -s, 12 47)]="14"
# reserve the last 36 cpus
@WITH_MCK@/sbin/mcreboot.sh -c 24-59 -m 1G@4,1G@5,1G@6,1G@7
for policy in interleave_local bind_local prefer_local; do
for cpuset in \
$(seq -s, 12 23) $(seq -s, 24 35) $(seq -s, 36 47) \
$(seq -s, 12 35) $(seq -s, 24 47) \
$(seq -s, 12 47); do
# check nodemask when last 36 cpus are reserved
FLIB_NUM_PROCESS_ON_NODE=1 FLIB_AFFINITY_ON_PROCESS=$cpuset OMPI_MCA_plm_ple_memory_allocation_policy=$policy @WITH_MCK@/bin/mcexec @CMAKE_INSTALL_PREFIX@/bin/check_mempolicy -m ${mode[$policy]} -n ${nodemask[$cpuset]} || exit $?
done
done
@WITH_MCK@/sbin/mcstop+release.sh
exit 0

View File

@@ -0,0 +1,44 @@
#!/usr/bin/bash
# define WORKDIR
SCRIPT_PATH=$(readlink -m "${BASH_SOURCE[0]}")
SCRIPT_NAME="${SCRIPT_PATH##*/}"
TEST_NAME="${SCRIPT_NAME%.sh}"
AUTOTEST_HOME="${SCRIPT_PATH%/*/*/*}"
if [ -f ${AUTOTEST_HOME}/bin/config.sh ]; then
. ${AUTOTEST_HOME}/bin/config.sh
else
WORKDIR=$(pwd)
fi
declare -A mode
mode[interleave_nonlocal]="3"
mode[bind_nonlocal]="2"
mode[prefer_nonlocal]="1"
declare -A nodemask
nodemask[$(seq -s, 12 23)]="13"
nodemask[$(seq -s, 24 35)]="11"
nodemask[$(seq -s, 36 47)]="7"
nodemask[$(seq -s, 12 35)]="9"
nodemask[$(seq -s, 24 47)]="3"
nodemask[$(seq -s, 12 47)]="1"
# reserve the last 36 cpus
@WITH_MCK@/sbin/mcreboot.sh -c 24-59 -m 1G@4,1G@5,1G@6,1G@7
for policy in interleave_nonlocal bind_nonlocal prefer_nonlocal; do
for cpuset in \
$(seq -s, 12 23) $(seq -s, 24 35) $(seq -s, 36 47) \
$(seq -s, 12 35) $(seq -s, 24 47) \
$(seq -s, 12 47); do
# check nodemask when last 36 cpus are reserved
FLIB_NUM_PROCESS_ON_NODE=1 FLIB_AFFINITY_ON_PROCESS=$cpuset OMPI_MCA_plm_ple_memory_allocation_policy=$policy @WITH_MCK@/bin/mcexec @CMAKE_INSTALL_PREFIX@/bin/check_mempolicy -m ${mode[$policy]} -n ${nodemask[$cpuset]} || exit $?
done
done
@WITH_MCK@/sbin/mcstop+release.sh
exit 0

View File

@@ -0,0 +1,34 @@
#!/usr/bin/bash
# define WORKDIR
SCRIPT_PATH=$(readlink -m "${BASH_SOURCE[0]}")
SCRIPT_NAME="${SCRIPT_PATH##*/}"
TEST_NAME="${SCRIPT_NAME%.sh}"
AUTOTEST_HOME="${SCRIPT_PATH%/*/*/*}"
if [ -f ${AUTOTEST_HOME}/bin/config.sh ]; then
. ${AUTOTEST_HOME}/bin/config.sh
else
WORKDIR=$(pwd)
fi
declare -A mode
mode[interleave_all]="3"
mode[bind_all]="2"
# reserve the last 36 cpus
@WITH_MCK@/sbin/mcreboot.sh -c 24-59 -m 1G@4,1G@5,1G@6,1G@7
for policy in interleave_all bind_all; do
for cpuset in \
$(seq -s, 12 23) $(seq -s, 24 35) $(seq -s, 36 47) \
$(seq -s, 12 35) $(seq -s, 24 47) \
$(seq -s, 12 47); do
# check nodemask when last 36 cpus are reserved
FLIB_NUM_PROCESS_ON_NODE=1 FLIB_AFFINITY_ON_PROCESS=$cpuset OMPI_MCA_plm_ple_memory_allocation_policy=$policy @WITH_MCK@/bin/mcexec @CMAKE_INSTALL_PREFIX@/bin/check_mempolicy -m ${mode[$policy]} -n 15 || exit $?
done
done
@WITH_MCK@/sbin/mcstop+release.sh
exit 0

View File

@@ -0,0 +1,54 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <numaif.h>
#include <okng.h>
#define PLD_PROCESS_NUMA_MASK_BITS 256
int main(int argc, char **argv)
{
long ret;
int mode;
unsigned long nodemask[PLD_PROCESS_NUMA_MASK_BITS /
(sizeof(unsigned long) * 8)] = { 0 };
int mode_expected = -1;
unsigned long nodemask_expected[PLD_PROCESS_NUMA_MASK_BITS /
(sizeof(unsigned long) * 8)] = { 0 };
int opt;
while ((opt = getopt(argc, argv, "m:n:")) != -1) {
switch (opt) {
case 'm':
mode_expected = atol(optarg);
break;
case 'n':
nodemask_expected[0] = atoi(optarg);
break;
default: /* '?' */
INTERR(1, "unknown option %c\n", optopt);
}
}
INTERR(mode_expected == -1, "specify -m <mode>\n");
ret = get_mempolicy(&mode, nodemask, PLD_PROCESS_NUMA_MASK_BITS,
NULL, 0);
INTERR(ret, "get_mempolicy failed with %ld\n", ret);
OKNG(mode == mode_expected, "mode: actual (%d), expected (%d)\n",
mode, mode_expected);
/* nodemask is "don't care" when mode is MPOL_DEFAULT */
if (mode_expected != 0) {
OKNG(nodemask[0] == nodemask_expected[0],
"nodemask: actual (%ld), expected (%ld)\n",
nodemask[0],
nodemask_expected[0]);
}
ret = 0;
out:
return ret;
}

View File

@@ -0,0 +1,9 @@
BEGIN { id = -1; }
/Node .*, zone\s*(Normal|DMA32)/ { id = substr($2, 1, length($2) - 1); }
{
if ($0 ~ keyword && id != -1) {
printf("id: %d, nr_free_pages: %ld\n", id, $2);
id = -1;
}
}

View File

@@ -0,0 +1,13 @@
{
id = substr($2, 1, length($2) - 1);
size = $4;
sizes[id] += size;
}
END {
for (i = 0; i <= id; i++) {
if (sizes[i] * page_size > 2 * 1024 * 1024 * 1024) {
print i;
}
}
}