mm/swapping01: new testcase

swapping01 - first time swap use results in heavy swapping

This case is used for testing upstream commit: 50a1598.

The upstream commit fixed a issue on s390/x platform that heavy
swapping might occur in some condition, however since the patch
was quite general, this testcase will be run on all supported
platforms to ensure no regression been introduced.

Details of the upstream fix:
On x86 a page without a mapper is by definition not referenced / old.
The s390 architecture keeps the reference bit in the storage key and
the current code will check the storage key for page without a mapper.
This leads to an interesting effect: the first time an s390 system
needs to write pages to swap it only finds referenced pages. This
causes a lot of pages to get added and written to the swap device.
To avoid this behaviour change page_referenced to query the storage
key only if there is a mapper of the page.

Test Strategy:
Try to allocate memory which size is slightly larger than current
available memory. After allocation done, continue loop for a while
and calculate the used swap size. The used swap size should be small
enough, else it indicates that heavy swapping is occured unexpectedly.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
mm: cleanup headers

This patch does some clean-ups under mem/ dir:

1) change #include "../include/mem.h" to #include "mem.h"
2) sort all headers properly

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
Tested-by: Caspar Zhang <caspar@casparzhang.com>
hugetlb/hugemmap04: check after hugepage allocated

This patch moves nr_hugepage check after hugepage allocated. Else the
test would never run due to init nr_hugepage == 0.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
expand gitignore coverage

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
sched_getparam: code cleanups

Cleanup the coding style.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
sched_getscheduler: code cleanups

Cleanup the code.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
sched_getparam:sched_getscheduler: fix 6-1 and 7-1

POSIX:
[EPERM]
    The requesting process does not have permission to obtain the
scheduling parameters of the specified process.

But Linux doesn't check the PERM.
And it's no definition that WHO hasn't permission to get
the param or scheduler of which process.

So, if the operation succeeds , return UNRESOLVED
but not FAIL.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
mmstress: make shared global variables volatile

Synchronization of threads depends on shared global variable.
With gcc version 4.6.2 this test spins forever on:
     while (wait_thread)
         sched_yield();

Make global shared variables volatile, so each thread
sees current value.

See also:
Bug 36081 - gcc optimizations and threads (pthread)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36081

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
hugetlb/hugeshmat: cleanup codes

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
hugetlb/hugeshmat: set nr_hugepages in tests

Like hugemmap tests, this patch enables nr_hugepages set/restore in each
test of hugeshmat, so that we don't need to set the values with external
commands.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
hugetlb/hugeshmctl: cleanup codes

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
hugetlb/hugeshmctl: set nr_hugepages in tests

This patch enables nr_hugepages set/restore in each test of hugeshmctl,
so that we don't need to set the values with external commands.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
hugetlb/hugeshmdt: cleanup codes

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
hugetlb/hugeshmdt: set nr_hugepages in tests

This patch enables nr_hugepages set/restore in each test of hugeshmdt,
so that we don't need to set the values with external commands.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
hugetlb/hugeshmget: cleanup codes

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
hugetlb/hugeshmget: set nr_hugepages in tests

This patch enables nr_hugepages set/restore in each test of hugeshmget,
so that we don't need to set the values with external commands.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
Acked-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
hugetlb/lib: cleanup codes

1) removed unnecessary header files in hugetlb/lib
2) removed unnecessary functions in hugetlb/lib
3) code clean-ups for Makefiles and libs

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
libltp: remove system_specific_hugepages_info

system_specific_hugepages_info is not well-implemented and has been
deprecated, all functions in it can be replaced with libmem. So removing
it.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
hugetlb/hugemmap03: fix broken test

hugemmap03 tries to do a hugemmap with only pagesize, which causes mmap
always fails with EINVAL. This patch fixes this behavior by changeing
map size to 1 hugepagesize and check whether errno is expected.

Also do some code clean-ups in the test.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
aio_read: code cleanups

Cleanup the code.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>