[LTP] [PATCH v2 00/13]
v2 cover [LTP] [PATCH v2 00/13]
This patchset slowly untangles the mess called kernel/mem/lib/ library.
The library is split into several places, functions that are used by more than one group of tests are either reimplemented in the top level library or in the case of numa moved into numa_helper library in testcases/kerne/include/ and testcases/kernel/lib/.
The rest of the code is either moved into respective test directories or in the case of unused code removed.
This is not a coplete cleanup of the mem/ testcases as it mostly just moves code, but it's a nice first step that removes most of the unneeded dependencies and prepares for a possible refactoring later on.
v2:
- Rebased the patchset
- Fixed doc comments in headers
(decided to add short descriptions for functions after all)
- Fixed TST_MB in strings
- Fixed warnings introduced in ksm tests
Cyril Hrubis (13):
lib: tst_sys_conf: Add two functions
lib: Replace path_exist() with tst_path_exists()
lib: Add tst_mapping_in_range() testcases/kernel/mem: Move get_a_numa_node() testcases/kernel/mem: Move update_shm_size() testcases/kernel/mem: Move check_hugepage() + PATH_THP testcases/kernel/mem: Move NUMA bits to numa_helper.h testcases/kernel/mem: Move oom() fucntions to oom tests testcases/kernel/mem: Move KSM bits to ksm tests mem/swapping: Remove mem/lib refrence
mem/vma: Remove mem/lib dependency mem/hugetlb: Remove mem/lib depenency testcases/kernel/mem: Remove library
include/tst_fs.h | 10 + include/tst_memutils.h | 11 + include/tst_sys_conf.h | 32 + lib/tst_memutils.c | 31 + lib/tst_path_exists.c | 23 + lib/tst_sys_conf.c | 29 + testcases/kernel/include/numa_helper.h | 21 + testcases/kernel/lib/numa_cpuset.c | 64 ++ testcases/kernel/mem/cpuset/Makefile | 2 +- testcases/kernel/mem/cpuset/cpuset01.c | 4 +- testcases/kernel/mem/hugetlb/Makefile.inc | 3 - .../kernel/mem/hugetlb/hugemmap/hugemmap02.c | 4 +- .../kernel/mem/hugetlb/hugemmap/hugemmap05.c | 1 - .../kernel/mem/hugetlb/hugemmap/hugemmap13.c | 4 +- .../kernel/mem/hugetlb/hugemmap/hugemmap14.c | 6 +- .../mem/hugetlb/hugeshmat/hugeshmat04.c | 4 +- testcases/kernel/mem/hugetlb/lib/Makefile | 1 - testcases/kernel/mem/hugetlb/lib/hugetlb.c | 11 + testcases/kernel/mem/hugetlb/lib/hugetlb.h | 6 +- testcases/kernel/mem/include/libmem.mk | 43 -- testcases/kernel/mem/include/mem.h | 81 -- testcases/kernel/mem/ksm/Makefile | 2 +- testcases/kernel/mem/ksm/ksm01.c | 2 +- testcases/kernel/mem/ksm/ksm02.c | 4 +- testcases/kernel/mem/ksm/ksm03.c | 2 +- testcases/kernel/mem/ksm/ksm04.c | 4 +- testcases/kernel/mem/ksm/ksm05.c | 2 +- testcases/kernel/mem/ksm/ksm06.c | 4 +- testcases/kernel/mem/ksm/ksm07.c | 3 +- testcases/kernel/mem/ksm/ksm_common.h | 36 + testcases/kernel/mem/ksm/ksm_test.h | 302 ++++++++ testcases/kernel/mem/lib/Makefile | 27 - testcases/kernel/mem/lib/mem.c | 711 ------------------ testcases/kernel/mem/oom/Makefile | 7 +- testcases/kernel/mem/oom/oom.h | 231 ++++++ testcases/kernel/mem/oom/oom01.c | 13 +- testcases/kernel/mem/oom/oom02.c | 5 +- testcases/kernel/mem/oom/oom03.c | 11 +- testcases/kernel/mem/oom/oom04.c | 7 +- testcases/kernel/mem/oom/oom05.c | 11 +- testcases/kernel/mem/swapping/Makefile | 1 - testcases/kernel/mem/swapping/swapping01.c | 2 +- testcases/kernel/mem/thp/Makefile | 2 +- testcases/kernel/mem/thp/thp.h | 17 + testcases/kernel/mem/thp/thp01.c | 1 - testcases/kernel/mem/thp/thp02.c | 3 +- testcases/kernel/mem/thp/thp03.c | 5 +- testcases/kernel/mem/tunable/Makefile | 1 - testcases/kernel/mem/tunable/max_map_count.c | 17 +- .../kernel/mem/tunable/min_free_kbytes.c | 27 +- .../kernel/mem/tunable/overcommit_memory.c | 23 +- testcases/kernel/mem/vma/Makefile | 2 +- 52 files changed, 926 insertions(+), 950 deletions(-) create mode 100644 lib/tst_path_exists.c create mode 100644 testcases/kernel/lib/numa_cpuset.c delete mode 100644 testcases/kernel/mem/include/libmem.mk delete mode 100644 testcases/kernel/mem/include/mem.h create mode 100644 testcases/kernel/mem/ksm/ksm_test.h delete mode 100644 testcases/kernel/mem/lib/Makefile delete mode 100644 testcases/kernel/mem/lib/mem.c create mode 100644 testcases/kernel/mem/oom/oom.h create mode 100644 testcases/kernel/mem/thp/thp.h
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/13 lib: tst_sys_conf: Add two functions
Add two functions to read/write integer values from/to sysfs or procfs files.
With that we replace the get_sys_tune() and set_sys_tune() from testcases/kernel/mem/lib/mem.c with a better implementation.
We also remove the inclusion of the mem library from tunables, since it's no longer needed there.
--- include/tst_sys_conf.h | 32 +++++++++++++++++++ lib/tst_sys_conf.c | 29 +++++++++++++++++ .../mem/hugetlb/hugeshmat/hugeshmat04.c | 2 +- testcases/kernel/mem/include/mem.h | 2 -- testcases/kernel/mem/lib/mem.c | 29 ----------------- testcases/kernel/mem/oom/oom01.c | 10 +++--- testcases/kernel/mem/tunable/Makefile | 1 - testcases/kernel/mem/tunable/max_map_count.c | 17 ++++++---- .../kernel/mem/tunable/min_free_kbytes.c | 27 ++++++++-------- .../kernel/mem/tunable/overcommit_memory.c | 23 +++++++------ 10 files changed, 105 insertions(+), 67 deletions(-)
include/tst_sys_conf.h +32 -0
@@ -30,4 +30,36 @@ void tst_sys_conf_dump(void);int tst_read_bool_sys_param (const char *filename); +/** +* TST_SYS_CONF_LONG_SET() - Writes a long int into a sys or proc file. +* +* @path: A path to a sysfs or a procfs file. +* @val: A long int value to be written to the file. +* @check: If non-zero the library reads the file back and checks that the +* value is the one we have written there. If not the library calls +* tst_brk(TBROK, ...). +* +* Sets a sysfs or procfs file and optionally checks that it was set correctly. +*/ +#define TST_SYS_CONF_LONG_SET (path, val, check) \ + tst_sys_conf_long_set_(__FILE__, __LINE__, path, val, check) + +void tst_sys_conf_long_set_ (const char *file,const int lineno, +const char *path,long val,int check); + + +/** +* TST_SYS_CONF_LONG_GET() - Reads a long int from sys or proc file. +* +* @path: A path to a sysfs or a procfs file. +* return: A value read from the file converted into a long. +* +* Gets a sysfs or procfs file value and converts it to long. +*/ +#define TST_SYS_CONF_LONG_GET (path) \ + tst_sys_conf_long_get_(__FILE__, __LINE__, path) + +long tst_sys_conf_long_get_ (const char *file,const int lineno, +const char *path); +#endif
lib/tst_sys_conf.c +29 -0
@@ -180,3 +180,32 @@ int tst_read_bool_sys_param(const char *filename)/* Assume that any other value than 0 or N means the param is enabled */ return 1 ; } + +long tst_sys_conf_long_get_ (const char *file,const int lineno, +const char *path) +{ +long ret; + +safe_file_scanf (file, lineno,NULL , path,"%ld" , &ret); + +return ret; +} + +void tst_sys_conf_long_set_ (const char *file,const int lineno, +const char *path,long val,int check) +{ +tst_res_ (file, lineno,TINFO ,"Setting %s to %ld" , path, val); + +safe_file_printf (file, lineno,NULL , path,"%ld" , val); + +if (check) { +long read_val; + +safe_file_scanf (file, lineno,NULL , path,"%ld" , &read_val); + +if (val != read_val) +tst_brk_ (file, lineno,TBROK , +"Wrote %ld to %s but read back %ld" , + val, path, read_val); + } +}
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c +1 -1
@@ -82,7 +82,7 @@ static void setup(void)long hpage_size, orig_hugepages;unsigned long new_shmmax; - orig_hugepages =get_sys_tune ("nr_hugepages" ); + orig_hugepages =TST_SYS_CONF_LONG_GET ("/proc/sys/vm/nr_hugepages" );SAFE_FILE_SCANF (PATH_SHMMAX ,"%lu" , &new_shmmax);if (new_shmmax <SIZE )
testcases/kernel/mem/include/mem.h +0 -2
@@ -71,8 +71,6 @@ void write_cpusets(const struct tst_cg_group *cg, long nd);/* shared */ unsigned int get_a_numa_node (void );int path_exist (const char *path, ...); -void set_sys_tune (char *sys_file,long tune,int check); -long get_sys_tune (char *sys_file);void update_shm_size (size_t *shm_size);
testcases/kernel/mem/lib/mem.c +0 -29
@@ -638,35 +638,6 @@ int path_exist(const char *path, ...)return access (pathbuf,F_OK ) ==0 ; } -void set_sys_tune (char *sys_file,long tune,int check) -{ -long val; -char path[BUFSIZ ]; - -tst_res (TINFO ,"set %s to %ld" , sys_file, tune); - -snprintf (path,BUFSIZ ,PATH_SYSVM "%s" , sys_file); -SAFE_FILE_PRINTF (path,"%ld" , tune); - -if (check) { - val =get_sys_tune (sys_file); -if (val != tune) -tst_brk (TBROK ,"%s = %ld, but expect %ld" , - sys_file, val, tune); - } -} - -long get_sys_tune (char *sys_file) -{ -char path[BUFSIZ ]; -long tune; - -snprintf (path,BUFSIZ ,PATH_SYSVM "%s" , sys_file); -SAFE_FILE_SCANF (path,"%ld" , &tune); - -return tune; -} -void update_shm_size (size_t * shm_size) {size_t shmmax;
testcases/kernel/mem/oom/oom01.c +6 -4
@@ -18,18 +18,20 @@#include <unistd.h> #include "mem.h" +#define OVERCOMMIT_MEMORY "/proc/sys/vm/overcommit_memory" +static void verify_oom (void ) {/* we expect mmap to fail before OOM is hit */ -set_sys_tune ("overcommit_memory" ,2 ,1 ); +TST_SYS_CONF_LONG_SET (OVERCOMMIT_MEMORY ,2 ,1 );oom (NORMAL ,0 ,ENOMEM ,0 );/* with overcommit_memory set to 0 or 1 there's no * guarantee that mmap fails before OOM */ -set_sys_tune ("overcommit_memory" ,0 ,1 ); +TST_SYS_CONF_LONG_SET (OVERCOMMIT_MEMORY ,0 ,1 );oom (NORMAL ,0 ,ENOMEM ,1 ); -set_sys_tune ("overcommit_memory" ,1 ,1 ); +TST_SYS_CONF_LONG_SET (OVERCOMMIT_MEMORY ,1 ,1 );testoom (0 ,0 ,ENOMEM ,1 ); }
@@ -40,7 +42,7 @@ static struct tst_test test = { .test_all = verify_oom, .skip_in_compat = 1, .save_restore = (const struct tst_path_val []) { - {"/proc/sys/vm/overcommit_memory" ,NULL ,TST_SR_TBROK }, + {OVERCOMMIT_MEMORY ,NULL ,TST_SR_TBROK }, {} }, };
testcases/kernel/mem/tunable/Makefile +0 -1
@@ -4,5 +4,4 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/tunable/max_map_count.c +10 -7
@@ -48,10 +48,13 @@#include <stdio.h> #include <stdlib.h> #include <sys/utsname.h> -#include "mem.h" +#include "tst_test.h" #define MAP_COUNT_DEFAULT 1024 -#define MAX_MAP_COUNT 65536L +#define MAX_MAP_COUNT_MAX 65536L + +#define OVERCOMMIT_MEMORY "/proc/sys/vm/overcommit_memory" +#define MAX_MAP_COUNT "/proc/sys/vm/max_map_count"/* This is a filter to exclude map entries which aren't accounted * for in the vm_area_struct's map_count.
@@ -140,15 +143,15 @@ static void max_map_count_test(void) memfree =SAFE_READ_MEMINFO ("CommitLimit:" ) -SAFE_READ_MEMINFO ("Committed_AS:" );/* 64 used as a bias to make sure no overflow happen */ max_iters = memfree /sysconf (_SC_PAGESIZE) *1024 -64 ; -if (max_iters >MAX_MAP_COUNT ) - max_iters =MAX_MAP_COUNT ; +if (max_iters >MAX_MAP_COUNT_MAX ) + max_iters =MAX_MAP_COUNT_MAX ; max_maps =MAP_COUNT_DEFAULT ;if (max_iters < max_maps)tst_brk (TCONF ,"test requires more free memory" );while (max_maps <= max_iters) { -set_sys_tune ("max_map_count" , max_maps,1 ); +TST_SYS_CONF_LONG_SET (MAX_MAP_COUNT , max_maps,1 );switch (pid =SAFE_FORK ()) {case 0 :
@@ -192,8 +195,8 @@ static struct tst_test test = { .forks_child = 1, .test_all = max_map_count_test, .save_restore = (const struct tst_path_val []) { - {"/proc/sys/vm/overcommit_memory" ,"0" ,TST_SR_TBROK }, - {"/proc/sys/vm/max_map_count" ,NULL ,TST_SR_TBROK }, + {OVERCOMMIT_MEMORY ,"0" ,TST_SR_TBROK }, + {MAX_MAP_COUNT ,NULL ,TST_SR_TBROK }, {} }, };
testcases/kernel/mem/tunable/min_free_kbytes.c +14 -13
@@ -35,10 +35,14 @@#include <stdio.h> #include <stdlib.h> #include "lapi/abisize.h" -#include "mem.h" +#include "tst_test.h" #define MAP_SIZE (1UL<<20) +#define OVERCOMMIT_MEMORY "/proc/sys/vm/overcommit_memory" +#define MIN_FREE_KBYTES "/proc/sys/vm/min_free_kbytes" +#define PANIC_ON_OOM "/proc/sys/vm/panic_on_oom" +volatile int end;static long default_tune =-1 ;static unsigned long total_mem;
@@ -88,16 +92,13 @@ static void test_tune(unsigned long overcommit_policy)int ret, i;unsigned long tune, memfree, memtotal; -set_sys_tune ("overcommit_memory" , overcommit_policy,1 ); +TST_SYS_CONF_LONG_SET (OVERCOMMIT_MEMORY , overcommit_policy,1 );for (i =0 ; i <3 ; i++) { -/* case1 */ if (i ==0 ) -set_sys_tune ("min_free_kbytes" , default_tune,1 ); -/* case2 */ +TST_SYS_CONF_LONG_SET (MIN_FREE_KBYTES , default_tune,1 );else if (i ==1 ) { -set_sys_tune ("min_free_kbytes" ,2 * default_tune,1 ); -/* case3 */ +TST_SYS_CONF_LONG_SET (MIN_FREE_KBYTES ,2 * default_tune,1 ); }else { memfree =SAFE_READ_MEMINFO ("MemFree:" ); memtotal =SAFE_READ_MEMINFO ("MemTotal:" );
@@ -105,7 +106,7 @@ static void test_tune(unsigned long overcommit_policy)if (tune > (memtotal /50 )) tune = memtotal /50 ; -set_sys_tune ("min_free_kbytes" , tune,1 ); +TST_SYS_CONF_LONG_SET (MIN_FREE_KBYTES , tune,1 ); }fflush (stdout);
@@ -189,7 +190,7 @@ static void check_monitor(void)while (end) { memfree =SAFE_READ_MEMINFO ("MemFree:" ); - tune =get_sys_tune ("min_free_kbytes" ); + tune =TST_SYS_CONF_LONG_GET (MIN_FREE_KBYTES );if (memfree < tune) { tst_res(TINFO, "MemFree is %lu kB, "
@@ -208,14 +209,14 @@ static void sighandler(int signo LTP_ATTRIBUTE_UNUSED)static void setup (void ) { -if (get_sys_tune ("panic_on_oom" )) { +if (TST_SYS_CONF_LONG_GET (PANIC_ON_OOM )) {tst_brk (TCONF ,"panic_on_oom is set, disable it to run these testcases" ); } total_mem =SAFE_READ_MEMINFO ("MemTotal:" ) +SAFE_READ_MEMINFO ("SwapTotal:" ); - default_tune =get_sys_tune ("min_free_kbytes" ); + default_tune =TST_SYS_CONF_LONG_GET (MIN_FREE_KBYTES ); }static struct tst_test test = {
@@ -225,8 +226,8 @@ static struct tst_test test = { .setup = setup, .test_all = min_free_kbytes_test, .save_restore = (const struct tst_path_val []) { - {"/proc/sys/vm/overcommit_memory" ,NULL ,TST_SR_TBROK }, - {"/proc/sys/vm/min_free_kbytes" ,NULL ,TST_SR_TBROK }, + {OVERCOMMIT_MEMORY ,NULL ,TST_SR_TBROK }, + {MIN_FREE_KBYTES ,NULL ,TST_SR_TBROK }, {} }, };
testcases/kernel/mem/tunable/overcommit_memory.c +13 -10
@@ -62,12 +62,15 @@#include <stdio.h> #include <stdlib.h> #include <limits.h> -#include "mem.h" +#include "tst_test.h" #define DEFAULT_OVER_RATIO 50L#define EXPECT_PASS 0#define EXPECT_FAIL 1 +#define OVERCOMMIT_MEMORY "/proc/sys/vm/overcommit_memory" +#define OVERCOMMIT_RATIO "/proc/sys/vm/overcommit_ratio" +static char *R_opt;static long old_overcommit_ratio =-1 ;static long overcommit_ratio;
@@ -93,7 +96,7 @@ static void setup(void)else overcommit_ratio =DEFAULT_OVER_RATIO ; - old_overcommit_ratio =get_sys_tune ("overcommit_ratio" ); + old_overcommit_ratio =TST_SYS_CONF_LONG_GET (OVERCOMMIT_RATIO ); mem_total =SAFE_READ_MEMINFO ("MemTotal:" );tst_res (TINFO ,"MemTotal is %ld kB" , mem_total);
@@ -115,7 +118,7 @@ static void setup(void)SAFE_SETRLIMIT (RLIMIT_AS , &lim); } -set_sys_tune ("overcommit_ratio" , overcommit_ratio,1 ); +TST_SYS_CONF_LONG_SET (OVERCOMMIT_RATIO , overcommit_ratio,1 );calculate_total_batch_size ();tst_res (TINFO ,"TotalBatchSize is %ld kB" , total_batch_size);
@@ -124,7 +127,7 @@ static void setup(void)static void overcommit_memory_test (void ) {/* start to test overcommit_memory=2 */ -set_sys_tune ("overcommit_memory" ,2 ,1 ); +TST_SYS_CONF_LONG_SET (OVERCOMMIT_MEMORY ,2 ,1 );update_mem_commit ();alloc_and_check (commit_left *2 ,EXPECT_FAIL );
@@ -133,14 +136,14 @@ static void overcommit_memory_test(void)alloc_and_check (commit_left /2 ,EXPECT_PASS );/* start to test overcommit_memory=0 */ -set_sys_tune ("overcommit_memory" ,0 ,1 ); +TST_SYS_CONF_LONG_SET (OVERCOMMIT_MEMORY ,0 ,1 );update_mem ();alloc_and_check (free_total /2 ,EXPECT_PASS );alloc_and_check (sum_total *2 ,EXPECT_FAIL );/* start to test overcommit_memory=1 */ -set_sys_tune ("overcommit_memory" ,1 ,1 ); +TST_SYS_CONF_LONG_SET (OVERCOMMIT_MEMORY ,1 ,1 );alloc_and_check (sum_total /2 ,EXPECT_PASS );alloc_and_check (sum_total,EXPECT_PASS );
@@ -152,7 +155,7 @@ static int heavy_malloc(long size) {char *p; - p =malloc (size *KB ); + p =malloc (size *TST_KB );if (p !=NULL ) {tst_res (TINFO ,"malloc %ld kB successfully" , size);free (p);
@@ -240,7 +243,7 @@ static void calculate_total_batch_size(void)/* there are ncpu separate counters, that can all grow up to * batch_size. So the maximum error for __vm_enough_memory is * batch_size * ncpus. */ - total_batch_size = (batch_size * ncpus * pagesize) /KB ; + total_batch_size = (batch_size * ncpus * pagesize) /TST_KB ; }static struct tst_test test = {
@@ -253,8 +256,8 @@ static struct tst_test test = { .test_all = overcommit_memory_test, .skip_in_compat = 1, .save_restore = (const struct tst_path_val []) { - {"/proc/sys/vm/overcommit_memory" ,NULL ,TST_SR_TBROK }, - {"/proc/sys/vm/overcommit_ratio" ,NULL ,TST_SR_TBROK }, + {OVERCOMMIT_MEMORY ,NULL ,TST_SR_TBROK }, + {OVERCOMMIT_RATIO ,NULL ,TST_SR_TBROK }, {} }, };
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/13 lib: Replace path_exist() with tst_path_exists()
In reply to Cyril HrubisMove and rename the path_exist() function from testcases/kernel/mem/lib/ to the to level library.
This removes mem.h dependency from mem/cpuset/ test.
--- include/tst_fs.h | 10 ++++++++++ lib/tst_path_exists.c | 23 +++++++++++++++++++++++ testcases/kernel/mem/cpuset/Makefile | 2 +- testcases/kernel/mem/cpuset/cpuset01.c | 5 +++-- testcases/kernel/mem/include/mem.h | 1 - testcases/kernel/mem/lib/mem.c | 18 +++--------------- 6 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 lib/tst_path_exists.c
include/tst_fs.h +10 -0
@@ -145,6 +145,16 @@ int tst_dir_is_empty_(void (*cleanup)(void), const char *name, int verbose);*/ int tst_get_path (const char *prog_name,char *buf,size_t buf_len); +/** +* tst_path_exists() - checks if path exists +* +* @fmt: A printf-like format used to construct the path. +* @...: A printf-like parameter list. +* return: Non-zero if path exists, zero otherwise. +*/ +int tst_path_exists (const char *fmt, ...) + __attribute__ ((format (printf,1 ,2 ))); +/* * Fill a file with specified pattern * @fd: file descriptor
lib/tst_path_exists.c new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) Linux Test Project, 2011-2021 +* Copyright (c) Cyril Hrubis <[email protected]> 2024 +*/ + +#include <stdio.h> +#include <stdarg.h> +#include <unistd.h> +#include <limits.h> +#include "tst_fs.h" + +int tst_path_exists (const char *fmt, ...) +{ +va_list ap; +char pathbuf[PATH_MAX ]; + +va_start (ap, fmt); +vsnprintf (pathbuf,sizeof (pathbuf), fmt, ap); +va_end (ap); + +return access (pathbuf,F_OK ) ==0 ; +}
testcases/kernel/mem/cpuset/Makefile +1 -1
@@ -20,5 +20,5 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk +include $(top_srcdir)/testcases/kernel/include/lib.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/cpuset/cpuset01.c +3 -2
@@ -30,7 +30,8 @@#include <numaif.h> #endif -#include "mem.h" +#include "../include/mem.h" +#include "tst_test.h" #include "numa_helper.h" #ifdef HAVE_NUMA_V2
@@ -164,7 +165,7 @@ static long count_cpu(void) {int ncpus =0 ; -while (path_exist (PATH_SYS_SYSTEM "/cpu/cpu%d" , ncpus)) +while (tst_path_exists (PATH_SYS_SYSTEM "/cpu/cpu%d" , ncpus)) ncpus++;return ncpus;
testcases/kernel/mem/include/mem.h +0 -1
@@ -70,7 +70,6 @@ void write_cpusets(const struct tst_cg_group *cg, long nd);/* shared */ unsigned int get_a_numa_node (void ); -int path_exist (const char *path, ...);void update_shm_size (size_t *shm_size);
testcases/kernel/mem/lib/mem.c +3 -15
@@ -545,19 +545,19 @@ static void gather_node_cpus(char *cpus, long nd)char buf[BUFSIZ ];char path[BUFSIZ ], path1[BUFSIZ ]; -while (path_exist (PATH_SYS_SYSTEM "/cpu/cpu%d" , ncpus)) +while (tst_path_exists (PATH_SYS_SYSTEM "/cpu/cpu%d" , ncpus)) ncpus++;for (i =0 ; i < ncpus; i++) {snprintf (path,BUFSIZ ,PATH_SYS_SYSTEM "/node/node%ld/cpu%d" , nd, i); -if (path_exist (path)) { +if (tst_path_exists ("%s" , path)) {snprintf (path1,BUFSIZ ,"%s/online" , path);/* * if there is no online knob, then the cpu cannot * be taken offline */ -if (path_exist (path1)) { +if (tst_path_exists ("%s" , path1)) {SAFE_FILE_SCANF (path1,"%ld" , &online);if (online ==0 )continue ;
@@ -626,18 +626,6 @@ unsigned int get_a_numa_node(void)abort (); } -int path_exist (const char *path, ...) -{ -va_list ap; -char pathbuf[PATH_MAX ]; - -va_start (ap, path); -vsnprintf (pathbuf,sizeof (pathbuf), path, ap); -va_end (ap); - -return access (pathbuf,F_OK ) ==0 ; -} -void update_shm_size (size_t * shm_size) {size_t shmmax;
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 02/13] lib: Replace path_exist() with tst_path_exists()
Hi Cyril,
Quoted 10 lines · Cyril Hrubis
Move and rename the
path_exist()function from testcases/kernel/mem/lib/ to the to level library.This removes
mem.hdependency from mem/cpuset/ test.Signed-off-by Cyril Hrubis <[email protected]>Reviewed-by Petr Vorel <[email protected]>--- include/tst_fs.h | 10 ++++++++++ lib/tst_path_exists.c | 23 +++++++++++++++++++++++
The only thing I don't like is creating file for single functions. My long term plan was to have fewer files with more functions. I'm sorry I did not point this out in v1, thus feel free to ignore it.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 02/13] lib: Replace path_exist() with tst_path_exists()
Hi!
Quoted 11 lines
Quoted 10 lines
Move and rename the
path_exist()function from testcases/kernel/mem/lib/ to the to level library.This removes
mem.hdependency from mem/cpuset/ test.Signed-off-by Cyril Hrubis <[email protected]>Reviewed-by Petr Vorel <[email protected]>--- include/tst_fs.h | 10 ++++++++++ lib/tst_path_exists.c | 23 +++++++++++++++++++++++
Quoted 3 lines
The only thing I don't like is creating file for single functions. My long term plan was to have fewer files with more functions. I'm sorry I did not point this out in v1, thus feel free to ignore it.
Feel free to move this code to a file you find appropriate and merge the patchset.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 02/13] lib: Replace path_exist() with tst_path_exists()
Quoted 12 lines · Cyril Hrubis
Hi!
Quoted 11 lines
Quoted 10 lines
Move and rename the
path_exist()function from testcases/kernel/mem/lib/ to the to level library.This removes
mem.hdependency from mem/cpuset/ test.Signed-off-by Cyril Hrubis <[email protected]>Reviewed-by Petr Vorel <[email protected]>--- include/tst_fs.h | 10 ++++++++++ lib/tst_path_exists.c | 23 +++++++++++++++++++++++
Quoted 6 lines
Quoted 3 lines
The only thing I don't like is creating file for single functions. My long term plan was to have fewer files with more functions. I'm sorry I did not point this out in v1, thus feel free to ignore it.
Feel free to move this code to a file you find appropriate and merge the patchset.
Cyril, please merge it as is.
After that, I send a patch for
Moving into newly created tst_fs.c these new API sources: tst_ioctl.c, tst_fs_setup.c, tst_fill_fs.c, tst_fill_file.c, tst_path_exists.c, tst_supported_fs_types.c.
And moving into newly created tst_fs_old.c these old API sources:tst_fs_has_free.c (only dma_thread_diotest.c has not been converted into new API), tst_fs_type.c.
Having everything eventually in single tst_fs.c might be too much, but I'm not sure if it's worth to spent time to split tst_fs.h into separate headers (and then to corresponding c sources).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 02/13] lib: Replace path_exist() with tst_path_exists()
Hi!
I will wait till tomorrow so that other have chance to have a look and then push the patchset.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Li Wang
Reviewed-byRe: [LTP] [PATCH v2 02/13] lib: Replace path_exist() with tst_path_exists()
Quoted 4 lines · Cyril Hrubis
Hi!
I will wait till tomorrow so that other have chance to have a look and then push the patchset.
For the series:
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 02/13] lib: Replace path_exist() with tst_path_exists()
Hi!
Applied, thanks for the reviews.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 3/13 lib: Add tst_mapping_in_range()
In reply to Cyril HrubisThis moves the range_is_mapped() function from testcases/kernel/mem/lib/mem.c to a top level library and renames the function to a better fitting name.
--- include/tst_memutils.h | 11 +++++++ lib/tst_memutils.c | 31 ++++++++++++++++++ .../kernel/mem/hugetlb/hugemmap/hugemmap02.c | 4 +-- .../kernel/mem/hugetlb/hugemmap/hugemmap13.c | 4 +-- .../kernel/mem/hugetlb/hugemmap/hugemmap14.c | 6 ++-- .../mem/hugetlb/hugeshmat/hugeshmat04.c | 2 +- testcases/kernel/mem/include/mem.h | 2 -- testcases/kernel/mem/lib/mem.c | 32 ------------------- 8 files changed, 50 insertions(+), 42 deletions(-)
include/tst_memutils.h +11 -0
@@ -60,4 +60,15 @@ void tst_disable_oom_protection(pid_t pid);#define TST_PRINT_MEMINFO () safe_print_file(__FILE__, __LINE__, "/proc/meminfo") +/** +* tst_mapping_in_range() - Returns true if there is a mapping provided range. +* +* @low: A lower address inside of the processe address space. +* @high: A higher address inside of the processe address space. +* +* return: Returns true if there is a mapping between low and high addresses in +* the process address space. +*/ +int tst_mapping_in_range (unsigned long low,unsigned long high); +#endif /* TST_MEMUTILS_H__ */
lib/tst_memutils.c +31 -0
@@ -14,6 +14,7 @@#include "tst_test.h" #include "tst_memutils.h" #include "tst_capability.h" +#include "tst_safe_stdio.h" #include "lapi/syscalls.h" #define BLOCKSIZE (16 * 1024 * 1024)
@@ -184,3 +185,33 @@ void tst_disable_oom_protection(pid_t pid) {set_oom_score_adj (pid,0 ); } + +int tst_mapping_in_range (unsigned long low,unsigned long high) +{ +FILE *fp; + + fp =SAFE_FOPEN ("/proc/self/maps" ,"r" ); + +while (!feof (fp)) { +unsigned long start, end; +int ret; + + ret =fscanf (fp,"%lx-%lx %*[^\n]\n" , &start, &end); +if (ret !=2 ) { +fclose (fp); +tst_brk (TBROK |TERRNO ,"Couldn't parse /proc/self/maps line." ); + } + +if ((start >= low) && (start < high)) { +fclose (fp); +return 1 ; + } +if ((end >= low) && (end < high)) { +fclose (fp); +return 1 ; + } + } + +fclose (fp); +return 0 ; +}
testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +2 -2
@@ -62,7 +62,7 @@ static void test_hugemmap(void) addrlist[i] = addr; } -while (range_is_mapped (low_addr, low_addr + map_sz) ==1 ) { +while (tst_mapping_in_range (low_addr, low_addr + map_sz) ==1 ) { low_addr = low_addr +0x10000000 ;if (low_addr <LOW_ADDR )
@@ -74,7 +74,7 @@ static void test_hugemmap(void)if (addr ==MAP_FAILED )tst_brk (TBROK |TERRNO ,"mmap failed on nfildes" ); -while (range_is_mapped (low_addr2, low_addr2 + map_sz) ==1 ) { +while (tst_mapping_in_range (low_addr2, low_addr2 + map_sz) ==1 ) { low_addr2 = low_addr2 +0x10000000 ;if (low_addr2 <LOW_ADDR2 )
testcases/kernel/mem/hugetlb/hugemmap/hugemmap13.c +2 -2
@@ -45,7 +45,7 @@ static void run_test(void) below_start =FOURGB ; above_end =1024ULL *1024 *1024 *1024 ; -if (range_is_mapped (below_start, above_end) ==1 ) { +if (tst_mapping_in_range (below_start, above_end) ==1 ) {tst_res (TINFO |TERRNO ,"region 4G-IT is not free & " "mmap() failed expected" );tst_res (TPASS ,"Successful but inconclusive" );
@@ -70,7 +70,7 @@ static void run_test(void) below_start =FOURGB -MMAP_GRANULARITY ; above_end =FOURGB ; -if (range_is_mapped (below_start, above_end) ==1 ) { +if (tst_mapping_in_range (below_start, above_end) ==1 ) {tst_res (TINFO |TERRNO ,"region (4G-MMAP_GRANULARITY)-4G is not free & " "mmap() failed expected" );tst_res (TPASS ,"Successful but inconclusive" );
testcases/kernel/mem/hugetlb/hugemmap/hugemmap14.c +3 -3
@@ -50,7 +50,7 @@ static void run_test(void) below_start =FOURGB -256ULL *1024 *1024 ; above_end =FOURGB ; -if (range_is_mapped (below_start, above_end) ==1 ) { +if (tst_mapping_in_range (below_start, above_end) ==1 ) {tst_res (TINFO |TERRNO ,"region (4G-256M)-4G is not free & " "mmap() failed expected" );tst_res (TPASS ,"Successful but inconclusive" );
@@ -73,7 +73,7 @@ static void run_test(void) below_start =FOURGB ; above_end =FOURGB + page_size; -if (range_is_mapped (below_start, above_end) ==1 ) { +if (tst_mapping_in_range (below_start, above_end) ==1 ) {tst_res (TINFO |TERRNO ,"region 4G-(4G+page) is not free & " "mmap() failed expected" );tst_res (TPASS ,"Successful but inconclusive" );
@@ -101,7 +101,7 @@ static void run_test(void) below_start = highaddr; above_end = highaddr + page_size; -if (range_is_mapped (below_start, above_end) ==1 ) { +if (tst_mapping_in_range (below_start, above_end) ==1 ) {tst_res (TINFO |TERRNO ,"region haddr-(haddr+page) not free & " "mmap() failed unexpected" );tst_res (TPASS ,"Successful but inconclusive" );
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c +1 -1
@@ -55,7 +55,7 @@ static void shared_hugepage(void)tst_brk (TBROK |TERRNO ,"shmget" );while (boundary <=BOUNDARY_MAX - &&range_is_mapped (boundary, boundary+SIZE )) + &&tst_mapping_in_range (boundary, boundary+SIZE )) boundary +=128 *1024 *1024 ;if (boundary >BOUNDARY_MAX )tst_brk (TCONF ,"failed to find free unmapped range" );
testcases/kernel/mem/include/mem.h +0 -2
@@ -73,6 +73,4 @@ unsigned int get_a_numa_node(void);void update_shm_size (size_t *shm_size); -/* MMAP */ -int range_is_mapped (unsigned long low,unsigned long high);#endif
testcases/kernel/mem/lib/mem.c +0 -32
@@ -636,35 +636,3 @@ void update_shm_size(size_t * shm_size) *shm_size = shmmax; } } - -int range_is_mapped (unsigned long low,unsigned long high) -{ -FILE *fp; - - fp =fopen ("/proc/self/maps" ,"r" ); -if (fp ==NULL ) -tst_brk (TBROK |TERRNO ,"Failed to open /proc/self/maps." ); - -while (!feof (fp)) { -unsigned long start, end; -int ret; - - ret =fscanf (fp,"%lx-%lx %*[^\n]\n" , &start, &end); -if (ret !=2 ) { -fclose (fp); -tst_brk (TBROK |TERRNO ,"Couldn't parse /proc/self/maps line." ); - } - -if ((start >= low) && (start < high)) { -fclose (fp); -return 1 ; - } -if ((end >= low) && (end < high)) { -fclose (fp); -return 1 ; - } - } - -fclose (fp); -return 0 ; -}
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 4/13 testcases/kernel/mem: Move get_a_numa_node()
In reply to Cyril HrubisMove get_a_numa_node() from the library to the ksm_common.h since the function is used only by the ksm testcases.
--- testcases/kernel/mem/include/mem.h | 3 --- testcases/kernel/mem/ksm/ksm_common.h | 35 +++++++++++++++++++++++++++ testcases/kernel/mem/lib/mem.c | 33 ------------------------- 3 files changed, 35 insertions(+), 36 deletions(-)
testcases/kernel/mem/include/mem.h +0 -3
@@ -68,9 +68,6 @@ void write_memcg(void);/* cpuset/memcg - include/tst_cgroup.h */ void write_cpusets (const struct tst_cg_group *cg,long nd); -/* shared */ -unsigned int get_a_numa_node (void ); -void update_shm_size (size_t *shm_size);#endif
testcases/kernel/mem/ksm/ksm_common.h +35 -0
@@ -11,6 +11,7 @@#define KSM_COMMON_H__ #include "tst_test.h" +#include "numa_helper.h" #define DEFAULT_MEMSIZE 128
@@ -33,4 +34,38 @@ static inline void parse_ksm_options(char *str_size, int *size, tst_brk(TBROK, "the remainder of division of size by unit is not zero."); } +/* Warning: *DO NOT* use this function in child */ +static inline unsigned int get_a_numa_node (void ) +{ +unsigned int nd1, nd2; +int ret; + + ret =get_allowed_nodes (0 ,2 , &nd1, &nd2); +switch (ret) { +case 0 : +break ; +case -3 : +tst_brk (TCONF ,"requires a NUMA system." ); +default : +tst_brk (TBROK |TERRNO ,"1st get_allowed_nodes" ); + } + + ret =get_allowed_nodes (NH_MEMS |NH_CPUS ,1 , &nd1); +switch (ret) { +case 0 : +tst_res (TINFO ,"get node%u." , nd1); +return nd1; +case -3 : +tst_brk (TCONF ,"requires a NUMA system that has " +"at least one node with both memory and CPU " +"available." ); +default : +tst_brk (TBROK |TERRNO ,"2nd get_allowed_nodes" ); + } + +/* not reached */ +abort (); +} + +#endif /* KSM_COMMON_H__ */
testcases/kernel/mem/lib/mem.c +0 -33
@@ -593,39 +593,6 @@ void write_cpusets(const struct tst_cg_group *cg, long nd)/* shared */ -/* Warning: *DO NOT* use this function in child */ -unsigned int get_a_numa_node (void ) -{ -unsigned int nd1, nd2; -int ret; - - ret =get_allowed_nodes (0 ,2 , &nd1, &nd2); -switch (ret) { -case 0 : -break ; -case -3 : -tst_brk (TCONF ,"requires a NUMA system." ); -default : -tst_brk (TBROK |TERRNO ,"1st get_allowed_nodes" ); - } - - ret =get_allowed_nodes (NH_MEMS |NH_CPUS ,1 , &nd1); -switch (ret) { -case 0 : -tst_res (TINFO ,"get node%u." , nd1); -return nd1; -case -3 : -tst_brk (TCONF ,"requires a NUMA system that has " -"at least one node with both memory and CPU " -"available." ); -default : -tst_brk (TBROK |TERRNO ,"2nd get_allowed_nodes" ); - } - -/* not reached */ -abort (); -} -void update_shm_size (size_t * shm_size) {size_t shmmax;
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 5/13 testcases/kernel/mem: Move update_shm_size()
In reply to Cyril HrubisMove update_shm_size() from the lib to the libhugetlb.c since the function is used only by the hugetlb testcases.
--- testcases/kernel/mem/hugetlb/lib/hugetlb.c | 11 +++++++++++ testcases/kernel/mem/hugetlb/lib/hugetlb.h | 3 +++ testcases/kernel/mem/include/mem.h | 2 -- testcases/kernel/mem/lib/mem.c | 13 ------------- 4 files changed, 14 insertions(+), 15 deletions(-)
testcases/kernel/mem/hugetlb/lib/hugetlb.c +11 -0
@@ -130,3 +130,14 @@ int do_readback(void *p, size_t size, char *desc) }return 0 ; } + +void update_shm_size (size_t * shm_size) +{ +size_t shmmax; + +SAFE_FILE_SCANF (PATH_SHMMAX ,"%zu" , &shmmax); +if (*shm_size > shmmax) { +tst_res (TINFO ,"Set shm_size to shmmax: %zu" , shmmax); + *shm_size = shmmax; + } +}
testcases/kernel/mem/hugetlb/lib/hugetlb.h +3 -0
@@ -56,4 +56,7 @@ int getipckey(void);int getuserid (char *user);void rm_shm (int shm_id);int do_readback (void *p,size_t size,char *desc); + +void update_shm_size (size_t *shm_size); +#endif /* hugetlb.h */
testcases/kernel/mem/include/mem.h +0 -2
@@ -68,6 +68,4 @@ void write_memcg(void);/* cpuset/memcg - include/tst_cgroup.h */ void write_cpusets (const struct tst_cg_group *cg,long nd); -void update_shm_size (size_t *shm_size); -#endif
testcases/kernel/mem/lib/mem.c +0 -13
@@ -590,16 +590,3 @@ void write_cpusets(const struct tst_cg_group *cg, long nd)SAFE_CG_PRINT (cg,"cpuset.cpus" ,"0" ); } } - -/* shared */ - -void update_shm_size (size_t * shm_size) -{ -size_t shmmax; - -SAFE_FILE_SCANF (PATH_SHMMAX ,"%zu" , &shmmax); -if (*shm_size > shmmax) { -tst_res (TINFO ,"Set shm_size to shmmax: %zu" , shmmax); - *shm_size = shmmax; - } -}
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 6/13 testcases/kernel/mem: Move check_hugepage() + PATH_THP
In reply to Cyril HrubisThese were only used in thp testcases, also after this the mem library is no longer needed in thp tests so it's removed from the Makefile.
Also note that PATH_HUGEPAGES is defined in tst_hugepage.h which is included by tst_test.h so we can just remove this macro.
--- testcases/kernel/mem/include/mem.h | 7 ------- testcases/kernel/mem/lib/mem.c | 6 ------ testcases/kernel/mem/thp/Makefile | 2 +- testcases/kernel/mem/thp/thp.h | 17 +++++++++++++++++ testcases/kernel/mem/thp/thp01.c | 1 - testcases/kernel/mem/thp/thp02.c | 3 ++- testcases/kernel/mem/thp/thp03.c | 5 +++-- 7 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 testcases/kernel/mem/thp/thp.h
testcases/kernel/mem/include/mem.h +0 -7
@@ -52,17 +52,10 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages);void ksm_group_check (int run,int pg_shared,int pg_sharing,int pg_volatile,int pg_unshared,int sleep_msecs,int pages_to_scan); -/* THP */ - -#define PATH_THP "/sys/kernel/mm/transparent_hugepage/" -#define PATH_KHPD PATH_THP "khugepaged/" -/* HUGETLB */ -#define PATH_HUGEPAGES "/sys/kernel/mm/hugepages/"#define PATH_SHMMAX "/proc/sys/kernel/shmmax" -void check_hugepage (void );void write_memcg (void );/* cpuset/memcg - include/tst_cgroup.h */
testcases/kernel/mem/lib/mem.c +0 -6
@@ -324,12 +324,6 @@ static void verify(char **memory, char value, int proc,free (s); } -void check_hugepage (void ) -{ -if (access (PATH_HUGEPAGES ,F_OK )) -tst_brk (TCONF ,"Huge page is not supported." ); -} -struct ksm_merge_data {char data;unsigned int mergeable_size;
testcases/kernel/mem/thp/Makefile +1 -1
@@ -3,7 +3,7 @@ top_srcdir ?= ../../../.. thp04: LDLIBS += -lrt +thp04: CFLAGS += -pthread include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/thp/thp.h new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) Linux Test Project, 2011-2021 +* Copyright (c) Cyril Hrubis 2024 +*/ +#ifndef THP_H +#define THP_H + +#define PATH_THP "/sys/kernel/mm/transparent_hugepage/" + +static inline void check_hugepage (void ) +{ +if (access (PATH_HUGEPAGES ,F_OK )) +tst_brk (TCONF ,"Huge page is not supported." ); +} + +#endif /* THP_H */
testcases/kernel/mem/thp/thp01.c +0 -1
@@ -38,7 +38,6 @@#include <stdlib.h> #include <unistd.h> #include "tst_test.h" -#include "mem.h" #include "tst_minmax.h" #define ARGS_SZ (256 * 32)
testcases/kernel/mem/thp/thp02.c +2 -1
@@ -38,7 +38,8 @@#include <stdlib.h> #include <string.h> #include <unistd.h> -#include "mem.h" +#include "tst_test.h" +#include "thp.h" static int ps;static long hps, size;
testcases/kernel/mem/thp/thp03.c +3 -2
@@ -36,7 +36,8 @@#include <stdlib.h> #include <string.h> #include <errno.h> -#include "mem.h" +#include "tst_test.h" +#include "thp.h" #include "lapi/mmap.h" static void thp_test (void );
@@ -83,7 +84,7 @@ static void setup(void)check_hugepage (); - hugepage_size =SAFE_READ_MEMINFO ("Hugepagesize:" ) *KB ; + hugepage_size =SAFE_READ_MEMINFO ("Hugepagesize:" ) *TST_KB ; unaligned_size = hugepage_size *4 -1 ; page_size =SAFE_SYSCONF (_SC_PAGESIZE); }
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 7/13 testcases/kernel/mem: Move NUMA bits to numa_helper.h
In reply to Cyril HrubisTestcases that use these macros and functions include numa_helper.h anyways so there is no point in keeping numa related functions in mem.h.
Note that the unused clear_node() function was removed.
--- testcases/kernel/include/numa_helper.h | 21 +++++++++ testcases/kernel/lib/numa_cpuset.c | 64 ++++++++++++++++++++++++++ testcases/kernel/mem/cpuset/cpuset01.c | 1 - testcases/kernel/mem/include/mem.h | 24 ---------- testcases/kernel/mem/ksm/ksm02.c | 2 +- testcases/kernel/mem/ksm/ksm04.c | 2 +- testcases/kernel/mem/lib/mem.c | 57 ----------------------- testcases/kernel/mem/oom/oom04.c | 2 +- testcases/kernel/mem/oom/oom05.c | 2 +- 9 files changed, 89 insertions(+), 86 deletions(-) create mode 100644 testcases/kernel/lib/numa_cpuset.c
testcases/kernel/include/numa_helper.h +21 -0
@@ -27,13 +27,34 @@# include <numaif.h> #endif +struct tst_cg_group ; +#define NH_MEMS (1 << 0)#define NH_CPUS (1 << 1) +#if defined(__powerpc__) || defined(__powerpc64__) +# define MAXNODES 256 +#else +# define MAXNODES 512 +#endif + +#define TESTMEM (1UL<<30) + +#define BITS_PER_LONG (8 * sizeof(long)) + +#define PATH_SYS_SYSTEM "/sys/devices/system" + +static inline void set_node (unsigned long *array,unsigned int node) +{ + array[node /BITS_PER_LONG ] |=1UL << (node %BITS_PER_LONG ); +} +unsigned long get_max_node (void );int get_allowed_nodes_arr (int flag,int *num_nodes,int **nodes);int get_allowed_nodes (int flag,int count, ...);void nh_dump_nodes (void );int is_numa (void (*cleanup_fn)(void ),int flag,int min_nodes); +void write_node_cpusets (const struct tst_cg_group *cg,long nd); +#endif /* NUMA_HELPER_H */
testcases/kernel/lib/numa_cpuset.c new file +64 -0
64 lines not on this page · raw message
testcases/kernel/mem/cpuset/cpuset01.c +0 -1
@@ -30,7 +30,6 @@#include <numaif.h> #endif -#include "../include/mem.h" #include "tst_test.h" #include "numa_helper.h"
testcases/kernel/mem/include/mem.h +0 -24
@@ -9,35 +9,14 @@#include "ksm_helper.h" #include "tst_memutils.h" -#if defined(__powerpc__) || defined(__powerpc64__) -#define MAXNODES 256 -#else -#define MAXNODES 512 -#endif #define MB (1UL<<20)#define KB (1UL<<10) -#define PATH_SYS_SYSTEM "/sys/devices/system"#define PATH_SYSVM "/proc/sys/vm/"#define PATH_MEMINFO "/proc/meminfo" -#define BITS_PER_LONG (8 * sizeof(long)) - -static inline void set_node (unsigned long *array,unsigned int node) -{ - array[node /BITS_PER_LONG ] |=1UL << (node %BITS_PER_LONG ); -} - -static inline void clean_node (unsigned long *array) -{ -unsigned int i; - -for (i =0 ; i <MAXNODES /BITS_PER_LONG ; i++) - array[i] &=0UL ; -}/* OOM */ #define LENGTH (3UL<<30) -#define TESTMEM (1UL<<30)#define NORMAL 1#define MLOCK 2#define KSM 3
@@ -58,7 +37,4 @@ void ksm_group_check(int run, int pg_shared, int pg_sharing, int pg_volatile,void write_memcg (void ); -/* cpuset/memcg - include/tst_cgroup.h */ -void write_cpusets (const struct tst_cg_group *cg,long nd); -#endif
testcases/kernel/mem/ksm/ksm02.c +1 -1
@@ -76,7 +76,7 @@ static void verify_ksm(void) }create_same_memory (size, num, unit); -write_cpusets (tst_cg, node); +write_node_cpusets (tst_cg, node);SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());create_same_memory (size, num, unit);SAFE_CG_PRINTF (tst_cg_drain,"cgroup.procs" ,"%d" ,getpid ());
testcases/kernel/mem/ksm/ksm04.c +1 -1
@@ -63,7 +63,7 @@ static void verify_ksm(void) }create_same_memory (size, num, unit); -write_cpusets (tst_cg, node); +write_node_cpusets (tst_cg, node);create_same_memory (size, num, unit); }
testcases/kernel/mem/lib/mem.c +0 -57
60 lines not on this page · raw message
testcases/kernel/mem/oom/oom04.c +1 -1
@@ -60,7 +60,7 @@ static void setup(void)if (ret <0 )tst_brk (TBROK ,"Failed to get a memory node " "using get_allowed_nodes()" ); -write_cpusets (tst_cg, memnode); +write_node_cpusets (tst_cg, memnode);SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); }
testcases/kernel/mem/oom/oom05.c +1 -1
@@ -80,7 +80,7 @@ void setup(void)tst_brk (TBROK ,"Failed to get a memory node " "using get_allowed_nodes()" ); -write_cpusets (tst_cg, memnode); +write_node_cpusets (tst_cg, memnode);SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); }
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 8/13 testcases/kernel/mem: Move oom() fucntions to oom tests
In reply to Cyril HrubisFunctions that are used only by the oom testcases are moved into oom/oom.h.
--- testcases/kernel/mem/include/mem.h | 10 -- testcases/kernel/mem/lib/mem.c | 212 -------------------------- testcases/kernel/mem/oom/Makefile | 7 +- testcases/kernel/mem/oom/oom.h | 231 +++++++++++++++++++++++++++++ testcases/kernel/mem/oom/oom01.c | 3 +- testcases/kernel/mem/oom/oom02.c | 5 +- testcases/kernel/mem/oom/oom03.c | 11 +- testcases/kernel/mem/oom/oom04.c | 5 +- testcases/kernel/mem/oom/oom05.c | 9 +- 9 files changed, 256 insertions(+), 237 deletions(-) create mode 100644 testcases/kernel/mem/oom/oom.h
testcases/kernel/mem/include/mem.h +0 -10
@@ -14,16 +14,6 @@#define PATH_SYSVM "/proc/sys/vm/"#define PATH_MEMINFO "/proc/meminfo" -/* OOM */ - -#define LENGTH (3UL<<30) -#define NORMAL 1 -#define MLOCK 2 -#define KSM 3 - -void oom (int testcase,int lite,int retcode,int allow_sigkill); -void testoom (int mempolicy,int lite,int retcode,int allow_sigkill); -/* KSM */ void create_same_memory (int size,int num,int unit);
testcases/kernel/mem/lib/mem.c +0 -212
218 lines not on this page · raw message
testcases/kernel/mem/oom/Makefile +6 -1
@@ -19,5 +19,10 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk + +include $(top_srcdir)/testcases/kernel/include/lib.mk + +CFLAGS+=-pthread +LDFLAGS+=-pthread + include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/oom/oom.h new file +231 -0
231 lines not on this page · raw message
testcases/kernel/mem/oom/oom01.c +2 -1
@@ -16,7 +16,8 @@#include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include "mem.h" +#include "tst_test.h" +#include "oom.h" #define OVERCOMMIT_MEMORY "/proc/sys/vm/overcommit_memory"
testcases/kernel/mem/oom/oom02.c +3 -2
@@ -16,11 +16,12 @@#include <fcntl.h> #include <stdio.h> #if HAVE_NUMA_H -#include <numa.h> +# include <numa.h> #endif +#include "tst_test.h" #include "numa_helper.h" -#include "mem.h" +#include "oom.h" #ifdef HAVE_NUMA_V2
testcases/kernel/mem/oom/oom03.c +6 -5
@@ -16,11 +16,12 @@#include <fcntl.h> #include <stdio.h> #if HAVE_NUMA_H -#include <numa.h> +# include <numa.h> #endif +#include "tst_test.h" #include "numa_helper.h" -#include "mem.h" +#include "oom.h" #ifdef HAVE_NUMA_V2
@@ -38,12 +39,12 @@ static void verify_oom(void)* * To get more opportunities to reach the swap limitation, * let's scale down the value of 'memory.swap.max' to only -* 1MB for CGroup v2. +* 1TST_MB for CGroup v2. */ if (!TST_CG_VER_IS_V1 (tst_cg,"memory" )) -SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" ,MB ); +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" ,TST_MB );else -SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" ,TESTMEM +MB ); +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" ,TESTMEM +TST_MB );testoom (0 ,1 ,ENOMEM ,1 );
testcases/kernel/mem/oom/oom04.c +3 -2
@@ -16,11 +16,12 @@#include <fcntl.h> #include <stdio.h> #if HAVE_NUMA_H -#include <numa.h> +# include <numa.h> #endif +#include "tst_test.h" #include "numa_helper.h" -#include "mem.h" +#include "oom.h" #ifdef HAVE_NUMA_V2
testcases/kernel/mem/oom/oom05.c +5 -4
@@ -16,11 +16,12 @@#include <fcntl.h> #include <stdio.h> #if HAVE_NUMA_H -#include <numa.h> +# include <numa.h> #endif +#include "tst_test.h" #include "numa_helper.h" -#include "mem.h" +#include "oom.h" #ifdef HAVE_NUMA_V2
@@ -46,9 +47,9 @@ static void verify_oom(void)tst_res (TINFO ,"OOM on CPUSET & MEMCG with " "special memswap limitation:" );if (!TST_CG_VER_IS_V1 (tst_cg,"memory" )) -SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" ,MB ); +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" ,TST_MB );else -SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" ,TESTMEM +MB ); +SAFE_CG_PRINTF (tst_cg,"memory.swap.max" ,"%lu" ,TESTMEM +TST_MB );testoom (0 ,1 ,ENOMEM ,1 );
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 9/13 testcases/kernel/mem: Move KSM bits to ksm tests
In reply to Cyril HrubisMoves the ksm helpers into a ksm/ksm_test.h since these are not used by any other but ksm tests.
--- testcases/kernel/mem/include/mem.h | 5 - testcases/kernel/mem/ksm/Makefile | 2 +- testcases/kernel/mem/ksm/ksm01.c | 2 +- testcases/kernel/mem/ksm/ksm02.c | 2 +- testcases/kernel/mem/ksm/ksm03.c | 2 +- testcases/kernel/mem/ksm/ksm04.c | 2 +- testcases/kernel/mem/ksm/ksm05.c | 2 +- testcases/kernel/mem/ksm/ksm06.c | 4 +- testcases/kernel/mem/ksm/ksm07.c | 3 +- testcases/kernel/mem/ksm/ksm_common.h | 3 +- testcases/kernel/mem/ksm/ksm_test.h | 302 ++++++++++++++++++++++++++ testcases/kernel/mem/lib/mem.c | 287 ------------------------ 12 files changed, 315 insertions(+), 301 deletions(-) create mode 100644 testcases/kernel/mem/ksm/ksm_test.h
testcases/kernel/mem/include/mem.h +0 -5
@@ -16,11 +16,6 @@/* KSM */ -void create_same_memory (int size,int num,int unit); -void test_ksm_merge_across_nodes (unsigned long nr_pages); -void ksm_group_check (int run,int pg_shared,int pg_sharing,int pg_volatile, -int pg_unshared,int sleep_msecs,int pages_to_scan); -/* HUGETLB */ #define PATH_SHMMAX "/proc/sys/kernel/shmmax"
testcases/kernel/mem/ksm/Makefile +1 -1
@@ -7,5 +7,5 @@ LTPLIBS = numa ksm06: LTPLDLIBS = -lltpnuma include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk +include $(top_srcdir)/testcases/kernel/include/lib.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/ksm/ksm01.c +1 -1
@@ -56,7 +56,7 @@#include <stdlib.h> #include <string.h> #include <unistd.h> -#include "mem.h" +#include "tst_test.h" #include "ksm_common.h" static void verify_ksm (void )
testcases/kernel/mem/ksm/ksm02.c +1 -1
@@ -53,7 +53,7 @@#include <signal.h> #include <stdio.h> #include <unistd.h> -#include "mem.h" +#include "tst_test.h" #include "ksm_common.h" #ifdef HAVE_NUMA_V2
testcases/kernel/mem/ksm/ksm03.c +1 -1
@@ -56,7 +56,7 @@#include <stdlib.h> #include <string.h> #include <unistd.h> -#include "mem.h" +#include "tst_test.h" #include "ksm_common.h" static void verify_ksm (void )
testcases/kernel/mem/ksm/ksm04.c +1 -1
@@ -38,7 +38,7 @@#include <signal.h> #include <stdio.h> #include <unistd.h> -#include "mem.h" +#include "tst_test.h" #include "ksm_common.h" #ifdef HAVE_NUMA_V2
testcases/kernel/mem/ksm/ksm05.c +1 -1
@@ -39,7 +39,7 @@#include <stdlib.h> #include <errno.h> #include "tst_test.h" -#include "mem.h" +#include "ksm_helper.h" #ifdef HAVE_DECL_MADV_MERGEABLE
testcases/kernel/mem/ksm/ksm06.c +3 -1
@@ -33,8 +33,10 @@#include <unistd.h> #include <limits.h> -#include "mem.h" +#include "tst_test.h" #include "tst_numa.h" +#include "ksm_helper.h" +#include "ksm_test.h" #ifdef HAVE_NUMA_V2 # include <numa.h>
testcases/kernel/mem/ksm/ksm07.c +2 -1
@@ -23,7 +23,8 @@*/ #include <sys/wait.h> -#include "mem.h" +#include "tst_test.h" +#include "ksm_helper.h" /* This test allocates one page, fills the page with a's, captures the * full_scan and pages_skipped counters. Then it makes sure at least 3
testcases/kernel/mem/ksm/ksm_common.h +2 -1
@@ -11,7 +11,9 @@#define KSM_COMMON_H__ #include "tst_test.h" +#include "ksm_helper.h" #include "numa_helper.h" +#include "ksm_test.h" #define DEFAULT_MEMSIZE 128
@@ -67,5 +69,4 @@ static inline unsigned int get_a_numa_node(void) abort(); } -#endif /* KSM_COMMON_H__ */
testcases/kernel/mem/ksm/ksm_test.h new file +302 -0
302 lines not on this page · raw message
testcases/kernel/mem/lib/mem.c +0 -287
290 lines not on this page · raw message
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 09/13] testcases/kernel/mem: Move KSM bits to ksm tests
Hi Cyril,
LGTM.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 10/13 mem/swapping: Remove mem/lib refrence
In reply to Cyril HrubisThe test does not use the library at all!
--- testcases/kernel/mem/swapping/Makefile | 1 - testcases/kernel/mem/swapping/swapping01.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
testcases/kernel/mem/swapping/Makefile +0 -1
@@ -19,5 +19,4 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/swapping/swapping01.c +1 -1
@@ -40,8 +40,8 @@#include <stdlib.h> #include <string.h> #include <unistd.h> +#include "tst_test.h" #include "tst_safe_stdio.h" -#include "mem.h" /* allow swapping 1 * phy_mem in maximum */ #define COE_DELTA 1
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 11/13 mem/vma: Remove mem/lib dependency
In reply to Cyril HrubisThe test does just use the testcases/lib/ instead.
--- testcases/kernel/mem/vma/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/mem/vma/Makefile +1 -1
@@ -6,7 +6,7 @@ top_srcdir ?= ../../../.. vma05_vdso: CFLAGS+=-ggdb3 include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk +include $(top_srcdir)/testcases/kernel/include/lib.mk INSTALL_TARGETS := vma05.sh
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 12/13 mem/hugetlb: Remove mem/lib depenency
In reply to Cyril HrubisThe last bit used from the library PATH_SHMMAX macro.
--- testcases/kernel/mem/hugetlb/Makefile.inc | 3 --- testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c | 1 - testcases/kernel/mem/hugetlb/lib/Makefile | 1 - testcases/kernel/mem/hugetlb/lib/hugetlb.h | 3 ++- 4 files changed, 2 insertions(+), 6 deletions(-)
testcases/kernel/mem/hugetlb/Makefile.inc +0 -3
@@ -33,6 +33,3 @@ CPPFLAGS += -I$(abs_srcdir)/$(LIBIPCDIR) LDFLAGS += -L$(abs_builddir)/$(LIBIPCDIR) LDLIBS += -lhugetlb MAKE_DEPS += $(LIBIPC) - -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk -# vim: syntax=make
testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c +0 -1
@@ -34,7 +34,6 @@ static char path_sys_sz_huge[BUFSIZ];#define PATH_PROC_VM "/proc/sys/vm/"#define PATH_PROC_OVER PATH_PROC_VM "nr_overcommit_hugepages"#define PATH_PROC_HUGE PATH_PROC_VM "nr_hugepages" -#define PATH_SHMMAX "/proc/sys/kernel/shmmax"/* Only ia64 requires this */ #ifdef __ia64__
testcases/kernel/mem/hugetlb/lib/Makefile +0 -1
@@ -4,7 +4,6 @@ top_srcdir ?= ../../../../.. include $(top_srcdir)/include/mk/env_pre.mk -include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk INTERNAL_LIB := libhugetlb.a
testcases/kernel/mem/hugetlb/lib/hugetlb.h +2 -1
@@ -17,7 +17,6 @@#include <errno.h> #include <sys/wait.h> #include "tst_test.h" -#include "mem.h" #define PALIGN (p, a) ((void *)LTP_ALIGN((unsigned long)(p), (a)))
@@ -29,6 +28,8 @@#define SHM_HUGETLB 04000/* segment is mapped via hugetlb */ #endif +#define PATH_SHMMAX "/proc/sys/kernel/shmmax" +#ifndef barrier# ifdef mb/* Redefining the mb() */
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 13/13 testcases/kernel/mem: Remove library
In reply to Cyril HrubisNow that the last bits of the library are unused we can remove it safely.
--- testcases/kernel/mem/include/libmem.mk | 43 -------------------------- testcases/kernel/mem/include/mem.h | 25 --------------- testcases/kernel/mem/lib/Makefile | 27 ---------------- testcases/kernel/mem/lib/mem.c | 30 ------------------ 4 files changed, 125 deletions(-) delete mode 100644 testcases/kernel/mem/include/libmem.mk delete mode 100644 testcases/kernel/mem/include/mem.h delete mode 100644 testcases/kernel/mem/lib/Makefile delete mode 100644 testcases/kernel/mem/lib/mem.c
testcases/kernel/mem/include/libmem.mk deleted +0 -43
@@ -1,43 +0,0 @@ -# -# Copyright (C) 2012 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# - -MEM_SRCDIR := $(abs_top_srcdir)/testcases/kernel/mem -LIBMEM_SRCDIR := $(MEM_SRCDIR)/lib - -MEM_DIR := $(top_builddir)/testcases/kernel/mem -LIBMEM_DIR := $(MEM_DIR)/lib -LIBMEM := $(LIBMEM_DIR)/libmem.a -FILTER_OUT_DIRS := $(LIBMEM_DIR) -CFLAGS += -I$(MEM_SRCDIR)/include -pthread -LDLIBS += $(NUMA_LIBS) -lmem -lltp -LDFLAGS += -L$(LIBMEM_DIR) - -$(LIBMEM_DIR): - mkdir -p "$@" - -$(LIBMEM): $(LIBMEM_DIR) - $(MAKE) -C $^ -f "$(LIBMEM_SRCDIR)/Makefile" all - -MAKE_DEPS += $(LIBMEM) - -trunk-clean:: | lib-clean - -lib-clean:: $(LIBMEM_DIR) - $(MAKE) -C $^ -f "$(LIBMEM_SRCDIR)/Makefile" clean - -include $(top_srcdir)/testcases/kernel/include/lib.mk
testcases/kernel/mem/include/mem.h deleted +0 -25
@@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* Copyright (c) Linux Test Project, 2011-2021 -*/ -#ifndef _MEM_H -#define _MEM_H -#include "config.h" -#include "tst_test.h" -#include "ksm_helper.h" -#include "tst_memutils.h" - -#define MB (1UL<<20) -#define KB (1UL<<10) -#define PATH_SYSVM "/proc/sys/vm/" -#define PATH_MEMINFO "/proc/meminfo" - -/* KSM */ - -/* HUGETLB */ - -#define PATH_SHMMAX "/proc/sys/kernel/shmmax" - -void write_memcg (void ); - -#endif
testcases/kernel/mem/lib/Makefile deleted +0 -27
@@ -1,27 +0,0 @@ -# -# Copyright (C) 2010 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# - -top_srcdir ?= ../../../.. - -include $(top_srcdir)/include/mk/env_pre.mk - -CPPFLAGS += -I$(abs_srcdir)/../include -INTERNAL_LIB := libmem.a - -include $(top_srcdir)/testcases/kernel/include/lib.mk -include $(top_srcdir)/include/mk/lib.mk
testcases/kernel/mem/lib/mem.c deleted +0 -30
@@ -1,30 +0,0 @@ -#define TST_NO_DEFAULT_MAIN - -#include "config.h" -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/mount.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <sys/param.h> -#include <errno.h> -#include <fcntl.h> -#if HAVE_NUMA_H -#include <numa.h> -#endif -#if HAVE_NUMAIF_H -#include <numaif.h> -#endif -#include <pthread.h> -#include <stdarg.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -#include "mem.h" -#include "numa_helper.h" - - -/* KSM */ -
Signature · 5 lines
2.45.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 00/13] Get rid of testcases/kernel/mem/lib library
In reply to Cyril HrubisHi!
The CI run was started:
https://github.com/metan-ucw/ltp/actions/runs/13240065186
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 15 lines · Cyril Hrubis
This patchset slowly untangles the mess called
kernel/mem/lib/library.The library is split into several places, functions that are used by more than one group of tests are either reimplemented in the top level library or in the case of numa moved into
numa_helperlibrary in testcases/kerne/include/ and testcases/kernel/lib/.The rest of the code is either moved into respective test directories or in the case of unused code removed.
This is not a coplete cleanup of the mem/ testcases as it mostly just moves code, but it's a nice first step that removes most of the unneeded dependencies and prepares for a possible refactoring later on.
Quoted 6 lines
v2:
- Rebased the patchset
- Fixed doc comments in headers
(decided to add short descriptions for functions after all)
- FixedTST_MBin strings
- Fixed warnings introduced in ksm tests
big series, but all steps leading to end result look reasonable
Quoted 87 lines
Cyril Hrubis (13):
lib:tst_sys_conf: Add two functions
lib: Replacepath_exist()withtst_path_exists()
lib: Addtst_mapping_in_range()testcases/kernel/mem: Moveget_a_numa_node()testcases/kernel/mem: Moveupdate_shm_size()testcases/kernel/mem: Movecheck_hugepage()+PATH_THPtestcases/kernel/mem: Move NUMA bits tonuma_helper.htestcases/kernel/mem: Moveoom()fucntions to oom tests testcases/kernel/mem: Move KSM bits to ksm tests mem/swapping: Remove mem/lib refrence
mem/vma: Remove mem/lib dependency mem/hugetlb: Remove mem/lib depenency testcases/kernel/mem: Remove libraryinclude/tst_fs.h | 10 + include/tst_memutils.h | 11 + include/tst_sys_conf.h | 32 + lib/tst_memutils.c | 31 + lib/tst_path_exists.c | 23 + lib/tst_sys_conf.c | 29 + testcases/kernel/include/numa_helper.h | 21 + testcases/kernel/lib/numa_cpuset.c | 64 ++ testcases/kernel/mem/cpuset/Makefile | 2 +- testcases/kernel/mem/cpuset/cpuset01.c | 4 +- testcases/kernel/mem/hugetlb/Makefile.inc | 3 - .../kernel/mem/hugetlb/hugemmap/hugemmap02.c | 4 +- .../kernel/mem/hugetlb/hugemmap/hugemmap05.c | 1 - .../kernel/mem/hugetlb/hugemmap/hugemmap13.c | 4 +- .../kernel/mem/hugetlb/hugemmap/hugemmap14.c | 6 +- .../mem/hugetlb/hugeshmat/hugeshmat04.c | 4 +- testcases/kernel/mem/hugetlb/lib/Makefile | 1 - testcases/kernel/mem/hugetlb/lib/hugetlb.c | 11 + testcases/kernel/mem/hugetlb/lib/hugetlb.h | 6 +- testcases/kernel/mem/include/libmem.mk | 43 -- testcases/kernel/mem/include/mem.h | 81 -- testcases/kernel/mem/ksm/Makefile | 2 +- testcases/kernel/mem/ksm/ksm01.c | 2 +- testcases/kernel/mem/ksm/ksm02.c | 4 +- testcases/kernel/mem/ksm/ksm03.c | 2 +- testcases/kernel/mem/ksm/ksm04.c | 4 +- testcases/kernel/mem/ksm/ksm05.c | 2 +- testcases/kernel/mem/ksm/ksm06.c | 4 +- testcases/kernel/mem/ksm/ksm07.c | 3 +- testcases/kernel/mem/ksm/ksm_common.h | 36 + testcases/kernel/mem/ksm/ksm_test.h | 302 ++++++++ testcases/kernel/mem/lib/Makefile | 27 - testcases/kernel/mem/lib/mem.c | 711 ------------------ testcases/kernel/mem/oom/Makefile | 7 +- testcases/kernel/mem/oom/oom.h | 231 ++++++ testcases/kernel/mem/oom/oom01.c | 13 +- testcases/kernel/mem/oom/oom02.c | 5 +- testcases/kernel/mem/oom/oom03.c | 11 +- testcases/kernel/mem/oom/oom04.c | 7 +- testcases/kernel/mem/oom/oom05.c | 11 +- testcases/kernel/mem/swapping/Makefile | 1 - testcases/kernel/mem/swapping/swapping01.c | 2 +- testcases/kernel/mem/thp/Makefile | 2 +- testcases/kernel/mem/thp/thp.h | 17 + testcases/kernel/mem/thp/thp01.c | 1 - testcases/kernel/mem/thp/thp02.c | 3 +- testcases/kernel/mem/thp/thp03.c | 5 +- testcases/kernel/mem/tunable/Makefile | 1 - testcases/kernel/mem/tunable/max_map_count.c | 17 +- .../kernel/mem/tunable/min_free_kbytes.c | 27 +- .../kernel/mem/tunable/overcommit_memory.c | 23 +- testcases/kernel/mem/vma/Makefile | 2 +- 52 files changed, 926 insertions(+), 950 deletions(-) create mode 100644 lib/tst_path_exists.c create mode 100644 testcases/kernel/lib/numa_cpuset.c delete mode 100644 testcases/kernel/mem/include/libmem.mk delete mode 100644 testcases/kernel/mem/include/mem.h create mode 100644 testcases/kernel/mem/ksm/ksm_test.h delete mode 100644 testcases/kernel/mem/lib/Makefile delete mode 100644 testcases/kernel/mem/lib/mem.c create mode 100644 testcases/kernel/mem/oom/oom.h create mode 100644 testcases/kernel/mem/thp/thp.h--
2.45.3--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp