"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core-thrash.c" between
stress-ng-0.13.04.tar.xz and stress-ng-0.13.05.tar.xz

About: stress-ng will stress test a computer system in various selectable ways. It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces.

core-thrash.c  (stress-ng-0.13.04.tar.xz):core-thrash.c  (stress-ng-0.13.05.tar.xz)
skipping to change at line 154 skipping to change at line 154
mode[0] = '0' + (stress_mwc8() & 7); mode[0] = '0' + (stress_mwc8() & 7);
mode[1] = '\0'; mode[1] = '\0';
ret = system_write("/proc/sys/vm/zone_reclaim_mode", mode, 1); ret = system_write("/proc/sys/vm/zone_reclaim_mode", mode, 1);
(void)ret; (void)ret;
#endif #endif
} }
/* /*
* stress_slab_shrink()
* shrink slabs to help release some memory
*/
static inline void stress_slab_shrink(void)
{
DIR *dir;
struct dirent *d;
static const char slabpath[] = "/sys/kernel/slab";
int ret;
/*
* older shrink interface, may fail
*/
ret = system_write("/sys/kernel/slab/cache/shrink", "1", 1);
(void)ret;
dir = opendir(slabpath);
if (!dir)
return;
/*
* shrink all slabs
*/
while ((d = readdir(dir)) != NULL) {
if (isalpha((int)d->d_name[0])) {
char path[PATH_MAX];
(void)snprintf(path, sizeof(path), "%s/%s", slabpath, d->
d_name);
ret = system_write(path, "1", 1);
(void)ret;
}
}
(void)closedir(dir);
}
/*
* stress_drop_caches() * stress_drop_caches()
* drop caches * drop caches
*/ */
static inline void stress_drop_caches(void) static inline void stress_drop_caches(void)
{ {
#if defined(__linux__) #if defined(__linux__)
static int method = 0; static int method = 0;
char str[3]; char str[3];
int ret; int ret;
skipping to change at line 262 skipping to change at line 298
int ret; int ret;
ret = stress_set_sched(getpid(), SCHED_RR, 10, true); ret = stress_set_sched(getpid(), SCHED_RR, 10, true);
(void)ret; (void)ret;
#endif #endif
stress_set_proc_name("stress-ng-thrash"); stress_set_proc_name("stress-ng-thrash");
if (stress_sighandler("main", SIGALRM, stress_thrash_handler, NUL L) < 0) if (stress_sighandler("main", SIGALRM, stress_thrash_handler, NUL L) < 0)
_exit(0); _exit(0);
while (thrash_run) { while (thrash_run) {
if ((stress_mwc8() & 0x3) == 0) if ((stress_mwc8() & 0x3) == 0) {
stress_slab_shrink();
stress_pagein_all_procs(); stress_pagein_all_procs();
}
if ((stress_mwc8() & 0x7) == 0) if ((stress_mwc8() & 0x7) == 0)
stress_drop_caches(); stress_drop_caches();
stress_compact_memory(); stress_compact_memory();
stress_merge_memory(); stress_merge_memory();
stress_zone_reclaim(); stress_zone_reclaim();
(void)sleep(1); (void)sleep(1);
} }
thrash_run = false; thrash_run = false;
_exit(0); _exit(0);
} }
 End of changes. 3 change blocks. 
1 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)