Revert "shmobj: Support large page"

This reverts commit 9a60997ea0.

Change-Id: Id60959b4e03451987239faa0bbc2e780b72fafaa
This commit is contained in:
Masamichi Takagi
2020-07-18 17:48:26 +09:00
committed by Masamichi Takagi
parent 40f8091fab
commit d7cf39883f
32 changed files with 75 additions and 2212 deletions

View File

@@ -1,106 +0,0 @@
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/mman.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define PAGES 3
#define MAP_HUGE_SHIFT 26
static unsigned long ps, hps;
void *test_mmap(unsigned long size, int pgshift)
{
int lp_flags = 0;
if (pgshift != 0) {
lp_flags = MAP_HUGETLB | (pgshift << MAP_HUGE_SHIFT);
}
return mmap(NULL, size, PROT_WRITE | PROT_READ,
MAP_ANONYMOUS | MAP_SHARED |
lp_flags,
-1, 0);
}
int main(int argc, char **argv)
{
void *addr;
int i, pgshift, err, ret = 0;
size_t size;
if (argc < 2) {
printf("error: too few arguments\n");
ret = -1;
goto out;
}
pgshift = atoi(argv[1]);
hps = (1 << pgshift);
ps = getpagesize();
printf("** Case 1: specified MAP_HUGETLB\n");
size = hps * PAGES;
addr = test_mmap(size, pgshift);
if (addr == MAP_FAILED) {
perror("mmap fail: ");
ret = -1;
}
memset(addr, 'a', size);
errno = 0;
err = munmap(addr + size - ps, ps);
if (err == -1 && errno == EINVAL) {
printf("[OK] munmap returned %d and errno: EINVAL\n", err);
}
else {
printf("[NG] munamp succceeded\n");
ret = -1;
// goto out;
}
printf("** Case 2: size is aligned on large page\n");
size = hps * PAGES;
addr = test_mmap(size, 0);
if (addr == MAP_FAILED) {
perror("mmap fail: ");
ret = -1;
}
memset(addr, 'a', size);
errno = 0;
err = munmap(addr + size - ps, ps);
if (err == -1 && errno == EINVAL) {
printf("[OK] munmap returned %d and errno: EINVAL\n", err);
}
else {
printf("[NG] munamp succceeded\n");
ret = -1;
// goto out;
}
printf("** Case 3: size is NOT aligned on large page\n");
size = hps * PAGES - ps;
addr = test_mmap(size, 0);
if (addr == MAP_FAILED) {
perror("mmap fail: ");
ret = -1;
}
memset(addr, 'a', size);
errno = 0;
err = munmap(addr + size - ps, ps);
if (err == 0 && errno == 0) {
printf("[OK] munamp succceeded\n");
}
else {
printf("[NG] munmap returned %d and errno: EINVAL\n", err);
ret = -1;
// goto out;
}
out:
return ret;
}