From afc0ed3d1fde99ebf122d247ce50635557e1624f Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Mon, 21 Apr 2014 16:05:14 -0400 Subject: [PATCH] move away from syscall counts towards operation counts mostly just shm renaming: previous_count -> previous_op_count child_syscall_count -> child_op_count --- Documentation/TODO | 1 - child.c | 10 +++++----- include/shm.h | 6 ++++-- log.c | 2 +- main.c | 2 +- shm.c | 2 +- syscall.c | 2 +- watchdog.c | 10 +++++----- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Documentation/TODO b/Documentation/TODO index e96b1ee..e9382a0 100644 --- a/Documentation/TODO +++ b/Documentation/TODO @@ -1,5 +1,4 @@ * Flesh out the child ops some more - - move away from 'syscall counts' towards 'iteration count' - Add more things that a real program would do. - add all the ops things like fsx do. - do file ops on a bunch of trinity test files diff --git a/child.c b/child.c index 2e5e000..199e398 100644 --- a/child.c +++ b/child.c @@ -150,7 +150,7 @@ void init_child(int childno) sched_setaffinity(pid, sizeof(set), &set); } - shm->child_syscall_count[childno] = 0; + shm->child_op_count[childno] = 0; memset(childname, 0, sizeof(childname)); sprintf(childname, "trinity-c%d", childno); @@ -212,13 +212,13 @@ static void check_parent_pid(void) // Skip over 'boring' entries. if ((shm->pids[i] == EMPTY_PIDSLOT) && (shm->previous[i].nr == 0) && - (shm->child_syscall_count[i] == 0)) + (shm->child_op_count[i] == 0)) continue; output(0, "[%d] pid:%d call:%s callno:%d\n", i, shm->pids[i], print_syscall_name(shm->previous[i].nr, shm->previous[i].do32bit), - shm->child_syscall_count[i]); + shm->child_op_count[i]); } shm->exit_reason = EXIT_REPARENT_PROBLEM; exit(EXIT_FAILURE); @@ -245,12 +245,12 @@ static unsigned int handle_sigreturn(int childno) output(2, "\n"); /* Flush out the previous syscall output. */ /* Check if we're making any progress at all. */ - if (shm->child_syscall_count[childno] == last) { + if (shm->child_op_count[childno] == last) { count++; //output(1, "no progress for %d tries.\n", count); } else { count = 0; - last = shm->child_syscall_count[childno]; + last = shm->child_op_count[childno]; } if (count == 3) { output(1, "no progress for 3 tries, exiting child.\n"); diff --git a/include/shm.h b/include/shm.h index 26327e2..70165fe 100644 --- a/include/shm.h +++ b/include/shm.h @@ -31,10 +31,12 @@ struct shm_s { unsigned long total_syscalls_done; unsigned long successes; unsigned long failures; - unsigned long previous_count; - unsigned long *child_syscall_count; + unsigned long previous_op_count; /* combined total of all children */ + unsigned long *child_op_count; /* these are per-child so we can see if + a child is making progress or not. */ unsigned long regenerate; + unsigned int seed; unsigned int *seeds; diff --git a/log.c b/log.c index d52f093..62bc942 100644 --- a/log.c +++ b/log.c @@ -395,7 +395,7 @@ static void output_syscall_prefix_to_fd(const unsigned int childno, const pid_t entry = syscalls[syscallnr].entry; - fprintf(fd, "[child%u:%u] [%lu] %s", childno, pid, shm->child_syscall_count[childno], + fprintf(fd, "[child%u:%u] [%lu] %s", childno, pid, shm->child_op_count[childno], (shm->syscall[childno].do32bit == TRUE) ? "[32BIT] " : ""); if (syscallnr > max_nr_syscalls) diff --git a/main.c b/main.c index 6e10178..98039ee 100644 --- a/main.c +++ b/main.c @@ -165,7 +165,7 @@ static void handle_child(pid_t childpid, int childstatus) dump_pid_slots(); } } else { - debugf("Child %d exited after %ld syscalls.\n", childpid, shm->child_syscall_count[slot]); + debugf("Child %d exited after %ld operations.\n", childpid, shm->child_op_count[slot]); reap_child(childpid); } break; diff --git a/shm.c b/shm.c index c88a4e0..7248b55 100644 --- a/shm.c +++ b/shm.c @@ -43,7 +43,7 @@ void create_shm(void) void create_shm_arrays(void) { - shm->child_syscall_count = alloc_shared(max_children * sizeof(unsigned long)); + shm->child_op_count = alloc_shared(max_children * sizeof(unsigned long)); shm->pids = alloc_shared(max_children * sizeof(pid_t)); diff --git a/syscall.c b/syscall.c index f23ec05..2608df4 100644 --- a/syscall.c +++ b/syscall.c @@ -90,7 +90,7 @@ static unsigned long do_syscall(int childno, int *errno_saved) a6 = shm->syscall[childno].a6; shm->total_syscalls_done++; - shm->child_syscall_count[childno]++; + shm->child_op_count[childno]++; (void)gettimeofday(&shm->tv[childno], NULL); if (syscalls[nr].entry->flags & NEED_ALARM) diff --git a/watchdog.c b/watchdog.c index 1115676..79de757 100644 --- a/watchdog.c +++ b/watchdog.c @@ -51,12 +51,12 @@ static int check_shm_sanity(void) // FIXME: The '500000' is magic, and should be dynamically calculated. // On startup, we should figure out how many getpid()'s per second we can do, // and use that. - if (shm->total_syscalls_done - shm->previous_count > 500000) { + if (shm->total_syscalls_done - shm->previous_op_count > 500000) { output(0, "Execcount increased dramatically! (old:%ld new:%ld):\n", - shm->previous_count, shm->total_syscalls_done); + shm->previous_op_count, shm->total_syscalls_done); shm->exit_reason = EXIT_SHM_CORRUPTION; } - shm->previous_count = shm->total_syscalls_done; + shm->previous_op_count = shm->total_syscalls_done; return SHM_OK; } @@ -361,8 +361,8 @@ static void watchdog(void) synclogs(); for_each_pidslot(i) { - if (shm->child_syscall_count[i] > hiscore) - hiscore = shm->child_syscall_count[i]; + if (shm->child_op_count[i] > hiscore) + hiscore = shm->child_op_count[i]; } if (shm->total_syscalls_done > 1) { -- 2.11.4.GIT