From: Caspar Z. <su...@li...> - 2012-03-27 03:39:13
|
The branch, master, has been updated via 177a989c4a9ba022be074611e37b98ca41887c72 (commit) via bab395d9dd197996a0b71b7812f3797b6a3e2fba (commit) from 8b7cc630a58dca3f719380e6e140dda4440e692c (commit) - Log ----------------------------------------------------------------- commit 177a989c4a9ba022be074611e37b98ca41887c72 Author: Wanlong Gao <gao...@cn...> Date: Tue Mar 27 10:30:49 2012 +0800 hugeshmget02: limit the shm_size to shmmax If shm_size bigger than shmmax, shmget() will fail with EINTVAL. So, limit the value of shm_size. Below is the test result: [root@gaowanlong hugeshmget]# ./hugeshmget02 hugeshmget02 0 TINFO : set nr_hugepages to 128 hugeshmget02 1 TBROK : shmget #setup: errno=EINVAL(22): Invalid argument hugeshmget02 2 TBROK : Remaining cases broken hugeshmget02 0 TINFO : set nr_hugepages to 0 [root@gaowanlong hugeshmget]# cat /proc/sys/kernel/shmmax 33554432 After patched, [root@gaowanlong hugeshmget]# ./hugeshmget02 hugeshmget02 0 TINFO : set nr_hugepages to 128 hugeshmget02 1 TPASS : shmget failed as expected: TEST_ERRNO=EINVAL(22): Invalid argument hugeshmget02 2 TPASS : shmget failed as expected: TEST_ERRNO=EINVAL(22): Invalid argument hugeshmget02 3 TPASS : shmget failed as expected: TEST_ERRNO=EEXIST(17): File exists hugeshmget02 4 TPASS : shmget failed as expected: TEST_ERRNO=ENOENT(2): No such file or directory hugeshmget02 0 TINFO : set nr_hugepages to 0 [root@gaowanlong hugeshmget]# cat /proc/sys/kernel/shmall 2097152 [root@gaowanlong hugeshmget]# cat /proc/sys/kernel/shmmax 33554432 Signed-off-by: Wanlong Gao <gao...@cn...> Acked-by: Caspar Zhang <ca...@ca...> commit bab395d9dd197996a0b71b7812f3797b6a3e2fba Author: Jan Stancek <jst...@re...> Date: Mon Mar 26 16:21:05 2012 +0200 mremap: fix dependency on ipc subdir We need to use MAKE_DEPS to declare the ipc subdir depend otherwise attempting to do `make mremap01` without building in the ipc subdir will fail, and we can hit race conditions in the overall `make`. This is same change as in commit: commit 7103d3e8e0f9dc1804ba06ee66ee02753e8ce50e Author: Mike Frysinger <va...@ge...> Date: Fri Mar 23 12:27:13 2012 -0400 kill: fix dependency on ipc subdir Signed-off-by: Jan Stancek <jst...@re...> Reviewed-by: Caspar Zhang <ca...@ca...> ----------------------------------------------------------------------- Summary of changes: .../kernel/mem/hugetlb/hugeshmget/hugeshmget02.c | 8 ++++++++ testcases/kernel/syscalls/mremap/Makefile | 2 +- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c index 1ec786f..a971608 100644 --- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c +++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c @@ -58,6 +58,8 @@ char *TCID = "hugeshmget02"; int TST_TOTAL = 4; +#define PATH_SHMMAX "/proc/sys/kernel/shmmax" + static size_t shm_size; static int shm_id_1 = -1; static int shm_id_2 = -1; @@ -126,6 +128,8 @@ int main(int ac, char **av) void setup(void) { long hpage_size; + char buf[BUFSIZ]; + long shmmax; tst_require_root(NULL); tst_sig(NOFORK, DEF_HANDLER, cleanup); @@ -136,6 +140,10 @@ void setup(void) hpage_size = read_meminfo("Hugepagesize:") * 1024; shm_size = hpage_size * hugepages / 2; + read_file(PATH_SHMMAX, buf); + shmmax = SAFE_STRTOL(cleanup, buf, 0, LONG_MAX); + if (shm_size > shmmax) + shm_size = shmmax; shmkey = getipckey(); shmkey2 = shmkey + 1; shm_id_1 = shmget(shmkey, shm_size, IPC_CREAT|IPC_EXCL|SHM_RW); diff --git a/testcases/kernel/syscalls/mremap/Makefile b/testcases/kernel/syscalls/mremap/Makefile index 63e7485..102e473 100644 --- a/testcases/kernel/syscalls/mremap/Makefile +++ b/testcases/kernel/syscalls/mremap/Makefile @@ -32,7 +32,7 @@ $(LIBDIR): $(LIB): $(LIBDIR) $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" all -all: | $(LIB) +MAKE_DEPS := $(LIB) CPPFLAGS += -I$(abs_srcdir)/$(LIBDIR) hooks/post-receive -- ltp |