Some experiments
This commit is contained in:
parent
edd435390c
commit
0639cbf43e
1 changed files with 19 additions and 6 deletions
|
@ -126,19 +126,26 @@ static int test_cachestat(const char *filename, bool write_random, bool create,
|
||||||
struct cachestat cs;
|
struct cachestat cs;
|
||||||
struct cachestat_range cs_range = { 0, filesize };
|
struct cachestat_range cs_range = { 0, filesize };
|
||||||
|
|
||||||
|
ksft_print_msg("Testing cachestat with:\n");
|
||||||
|
ksft_print_msg("pages [num_pages]: %d\n", num_pages);
|
||||||
|
ksft_print_msg("pagesize [PS]: %d\n", PS);
|
||||||
|
ksft_print_msg("file [filename]: %s\n", filename);
|
||||||
|
ksft_print_msg("filesize [filesize]: %d\n", filesize);
|
||||||
|
ksft_print_msg("[write_random]: %d\n", write_random);
|
||||||
|
|
||||||
|
ksft_print_msg("Opening %s\n", filename);
|
||||||
int fd = open(filename, open_flags, open_mode);
|
int fd = open(filename, open_flags, open_mode);
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
ksft_print_msg("Unable to create/open file.\n");
|
ksft_print_msg("Unable to create/open file: %m\n");
|
||||||
ret = KSFT_FAIL;
|
ret = KSFT_FAIL;
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
|
||||||
ksft_print_msg("Create/open %s\n", filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (write_random) {
|
if (write_random) {
|
||||||
if (!write_exactly(fd, filesize)) {
|
if (!write_exactly(fd, filesize)) {
|
||||||
ksft_print_msg("Unable to access urandom.\n");
|
ksft_print_msg("Unable to access urandom: \n");
|
||||||
ret = KSFT_FAIL;
|
ret = KSFT_FAIL;
|
||||||
goto out1;
|
goto out1;
|
||||||
}
|
}
|
||||||
|
@ -147,9 +154,10 @@ static int test_cachestat(const char *filename, bool write_random, bool create,
|
||||||
syscall_ret = syscall(__NR_cachestat, fd, &cs_range, &cs, 0);
|
syscall_ret = syscall(__NR_cachestat, fd, &cs_range, &cs, 0);
|
||||||
|
|
||||||
ksft_print_msg("Cachestat call returned %ld\n", syscall_ret);
|
ksft_print_msg("Cachestat call returned %ld\n", syscall_ret);
|
||||||
|
ksft_print_msg("Cachestat range is now: %d + %d\n", cs_range.off, cs_range.len);
|
||||||
|
|
||||||
if (syscall_ret) {
|
if (syscall_ret) {
|
||||||
ksft_print_msg("Cachestat returned non-zero.\n");
|
ksft_print_msg("Cachestat returned: %m\n");
|
||||||
ret = KSFT_FAIL;
|
ret = KSFT_FAIL;
|
||||||
goto out1;
|
goto out1;
|
||||||
|
|
||||||
|
@ -157,6 +165,11 @@ static int test_cachestat(const char *filename, bool write_random, bool create,
|
||||||
print_cachestat(&cs);
|
print_cachestat(&cs);
|
||||||
|
|
||||||
if (write_random) {
|
if (write_random) {
|
||||||
|
|
||||||
|
ksft_print_msg("nr_cache is now: %d\n", cs.nr_cache);
|
||||||
|
ksft_print_msg("nr_evicted is now: %d\n", cs.nr_evicted);
|
||||||
|
ksft_print_msg("num_pages is now: %d\n", num_pages);
|
||||||
|
|
||||||
if (cs.nr_cache + cs.nr_evicted != num_pages) {
|
if (cs.nr_cache + cs.nr_evicted != num_pages) {
|
||||||
ksft_print_msg(
|
ksft_print_msg(
|
||||||
"Total number of cached and evicted pages is off.\n");
|
"Total number of cached and evicted pages is off.\n");
|
||||||
|
|
Loading…
Reference in a new issue