Skip to content

Commit

Permalink
Update hugepage poison test case in hwpoison
Browse files Browse the repository at this point in the history
1. get hugepage from /proc/meminfo. Don't support 1G hugepage yet
2. when vm.memory_failure_early_kill = 0, prctl command can toggle
   the kill policy correctly between early_kill and late_kill

Signed-off-by: Wen Jin <wenx.jin@intel.com>
Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
  • Loading branch information
Wen Jin authored and Andi Kleen committed Apr 11, 2016
1 parent 42399a0 commit ff05588
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cases/function/hwpoison/hugepage.h
Expand Up @@ -85,18 +85,20 @@ int hugetlbfs_root(char *dir)
return found;
}

/* Assume there is only one types of hugepage size for now. */
int gethugepagesize(void)
{
FILE *fp;
char *line = NULL;
size_t linelen = 0;
int hpagesize = 0;
struct dirent *dent;
DIR *dir;
dir = opendir("/sys/kernel/mm/hugepages");
if (!dir) err("open /sys/kernel/mm/hugepages");
while ((dent = readdir(dir)) != NULL)
if (sscanf(dent->d_name, "hugepages-%dkB", &hpagesize) >= 1)
if ((fp = fopen("/proc/meminfo", "r")) == NULL)
err("open /proc/meminfo");
while (getline(&line, &linelen, fp) > 0) {
if (sscanf(line, "Hugepagesize: %d kB", &hpagesize) >= 1)
break;
closedir(dir);
}
free(line);
fclose(fp);
return hpagesize * 1024;
}

Expand Down
3 changes: 3 additions & 0 deletions cases/function/hwpoison/run_hard.sh
Expand Up @@ -36,7 +36,10 @@ unmount_hugetlbfs

echo "------------------------------------------------------------------------"
echo "Running tprctl (hard offline test with various prctl settings)"
val=`sysctl -n vm.memory_failure_early_kill`
sysctl -w vm.memory_failure_early_kill=0
run_test ./tprctl success
sysctl -w vm.memory_failure_early_kill=$val

free_resources

Expand Down

0 comments on commit ff05588

Please sign in to comment.