summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
authoraw148015 <Andrew.W.Wilson@sun.com>2009-04-13 08:55:44 -0700
committeraw148015 <Andrew.W.Wilson@sun.com>2009-04-13 08:55:44 -0700
commit57c911815cf9a6ce6df110cc669f6df3517813af (patch)
treea09230d91e13f7e1fcf3824bbcf22fab96a73796 /usr/src/cmd
parentea2f5b9e5bf4966630882d6d681a94768aea1d75 (diff)
downloadillumos-gate-57c911815cf9a6ce6df110cc669f6df3517813af.tar.gz
6543078 A ',' in the description field of a profile file breaks in a confusing manner
6573651 Have an option to not collect utilization data from /proc 6697106 filebench needs a way to remove cruft after run
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/filebench/common/fb_localfs.c17
-rw-r--r--usr/src/cmd/filebench/common/filebench.h2
-rw-r--r--usr/src/cmd/filebench/common/fileset.c82
-rw-r--r--usr/src/cmd/filebench/common/fileset.h1
-rw-r--r--usr/src/cmd/filebench/common/flowop.c91
-rw-r--r--usr/src/cmd/filebench/common/fsplug.h4
-rw-r--r--usr/src/cmd/filebench/common/ipc.h7
-rw-r--r--usr/src/cmd/filebench/common/parser_gram.y24
-rw-r--r--usr/src/cmd/filebench/common/parser_lex.l1
-rw-r--r--usr/src/cmd/filebench/common/stats.c105
-rwxr-xr-xusr/src/cmd/filebench/fbscript/filebench.pl78
11 files changed, 296 insertions, 116 deletions
diff --git a/usr/src/cmd/filebench/common/fb_localfs.c b/usr/src/cmd/filebench/common/fb_localfs.c
index df5ebad7cd..b1958073c5 100644
--- a/usr/src/cmd/filebench/common/fb_localfs.c
+++ b/usr/src/cmd/filebench/common/fb_localfs.c
@@ -96,6 +96,7 @@ static int fb_lfs_fsync(fb_fdesc_t *);
static int fb_lfs_stat(char *, struct stat64 *);
static int fb_lfs_fstat(fb_fdesc_t *, struct stat64 *);
static int fb_lfs_access(const char *, int);
+static void fb_lfs_recur_rm(char *);
static fsplug_func_t fb_lfs_funcs =
{
@@ -122,7 +123,8 @@ static fsplug_func_t fb_lfs_funcs =
fb_lfs_fsync, /* fsync */
fb_lfs_stat, /* stat */
fb_lfs_fstat, /* fstat */
- fb_lfs_access /* access */
+ fb_lfs_access, /* access */
+ fb_lfs_recur_rm /* recursive rm */
};
#ifdef HAVE_AIO
@@ -577,6 +579,19 @@ fb_lfs_rmdir(char *path)
}
/*
+ * does a recursive rm to remove an entire directory tree (i.e. a fileset).
+ * Supplied with the path to the root of the tree.
+ */
+static void
+fb_lfs_recur_rm(char *path)
+{
+ char cmd[MAXPATHLEN];
+
+ (void) snprintf(cmd, sizeof (cmd), "rm -rf %s", path);
+ (void) system(cmd);
+}
+
+/*
* Does a posix opendir(), Returns a directory handle on success,
* NULL on failure.
*/
diff --git a/usr/src/cmd/filebench/common/filebench.h b/usr/src/cmd/filebench/common/filebench.h
index bc98afed36..f174f8e548 100644
--- a/usr/src/cmd/filebench/common/filebench.h
+++ b/usr/src/cmd/filebench/common/filebench.h
@@ -118,7 +118,7 @@ void filebench_plugin_funcvecinit(void);
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
-#define FILEBENCH_VERSION "1.4.5"
+#define FILEBENCH_VERSION "1.4.6"
#define FILEBENCHDIR "/usr/benchmarks/filebench"
#define FILEBENCH_PROMPT "filebench> "
#define MAX_LINE_LEN 1024
diff --git a/usr/src/cmd/filebench/common/fileset.c b/usr/src/cmd/filebench/common/fileset.c
index 03184162ec..38a075be42 100644
--- a/usr/src/cmd/filebench/common/fileset.c
+++ b/usr/src/cmd/filebench/common/fileset.c
@@ -1029,11 +1029,8 @@ fileset_create(fileset_t *fileset)
}
if (!reusing) {
- char cmd[MAXPATHLEN];
-
/* Remove existing */
- (void) snprintf(cmd, sizeof (cmd), "rm -rf %s", path);
- (void) system(cmd);
+ FB_RECUR_RM(path);
filebench_log(LOG_VERBOSE,
"Removed any existing %s %s in %llu seconds",
fileset_entity_name(fileset), fileset_name,
@@ -1169,6 +1166,83 @@ exit:
}
/*
+ * Removes all files and directories associated with a fileset
+ * from the storage subsystem.
+ */
+static void
+fileset_delete_storage(fileset_t *fileset)
+{
+ char path[MAXPATHLEN];
+ char *fileset_path;
+ char *fileset_name;
+
+ if ((fileset_path = avd_get_str(fileset->fs_path)) == NULL)
+ return;
+
+ if ((fileset_name = avd_get_str(fileset->fs_name)) == NULL)
+ return;
+
+#ifdef HAVE_RAW_SUPPORT
+ /* treat raw device as special case */
+ if (fileset->fs_attrs & FILESET_IS_RAW_DEV)
+ return;
+#endif /* HAVE_RAW_SUPPORT */
+
+ /* set up path to file */
+ (void) fb_strlcpy(path, fileset_path, MAXPATHLEN);
+ (void) fb_strlcat(path, "/", MAXPATHLEN);
+ (void) fb_strlcat(path, fileset_name, MAXPATHLEN);
+
+ /* now delete any files and directories on the disk */
+ FB_RECUR_RM(path);
+}
+
+/*
+ * Removes the fileset entity and all of its filesetentry entities.
+ */
+static void
+fileset_delete_fileset(fileset_t *fileset)
+{
+ filesetentry_t *entry, *next_entry;
+
+ /* run down the file list, removing and freeing each filesetentry */
+ for (entry = fileset->fs_filelist; entry; entry = next_entry) {
+
+ /* free the entry */
+ next_entry = entry->fse_next;
+
+ /* return it to the pool */
+ switch (entry->fse_flags & FSE_TYPE_MASK) {
+ case FSE_TYPE_FILE:
+ case FSE_TYPE_LEAFDIR:
+ case FSE_TYPE_DIR:
+ ipc_free(FILEBENCH_FILESETENTRY, (void *)entry);
+ break;
+ default:
+ filebench_log(LOG_ERROR,
+ "Unallocated filesetentry found on list");
+ break;
+ }
+ }
+
+ ipc_free(FILEBENCH_FILESET, (void *)fileset);
+}
+
+void
+fileset_delete_all_filesets(void)
+{
+ fileset_t *fileset, *next_fileset;
+
+ for (fileset = filebench_shm->shm_filesetlist;
+ fileset; fileset = next_fileset) {
+ next_fileset = fileset->fs_next;
+ fileset_delete_storage(fileset);
+ fileset_delete_fileset(fileset);
+ }
+
+ filebench_shm->shm_filesetlist = NULL;
+}
+/*
* Adds an entry to the fileset's file list. Single threaded so
* no locking needed.
*/
diff --git a/usr/src/cmd/filebench/common/fileset.h b/usr/src/cmd/filebench/common/fileset.h
index 2abe1d41a2..95e697cbd8 100644
--- a/usr/src/cmd/filebench/common/fileset.h
+++ b/usr/src/cmd/filebench/common/fileset.h
@@ -176,6 +176,7 @@ typedef struct fileset {
} fileset_t;
int fileset_createset(fileset_t *);
+void fileset_delete_all_filesets(void);
int fileset_openfile(fb_fdesc_t *fd, fileset_t *fileset,
filesetentry_t *entry, int flag, int mode, int attrs);
fileset_t *fileset_define(avd_t);
diff --git a/usr/src/cmd/filebench/common/flowop.c b/usr/src/cmd/filebench/common/flowop.c
index a36c296721..4a527e2a44 100644
--- a/usr/src/cmd/filebench/common/flowop.c
+++ b/usr/src/cmd/filebench/common/flowop.c
@@ -144,29 +144,32 @@ void
flowop_beginop(threadflow_t *threadflow, flowop_t *flowop)
{
#ifdef HAVE_PROCFS
- if ((noproc == 0) && (threadflow->tf_lwpusagefd == 0)) {
- char procname[128];
+ if ((filebench_shm->shm_mmode & FILEBENCH_MODE_NOUSAGE) == 0) {
+ if ((noproc == 0) && (threadflow->tf_lwpusagefd == 0)) {
+ char procname[128];
- (void) snprintf(procname, sizeof (procname),
- "/proc/%d/lwp/%d/lwpusage", my_pid, _lwp_self());
- threadflow->tf_lwpusagefd = open(procname, O_RDONLY);
- }
+ (void) snprintf(procname, sizeof (procname),
+ "/proc/%d/lwp/%d/lwpusage", my_pid, _lwp_self());
+ threadflow->tf_lwpusagefd = open(procname, O_RDONLY);
+ }
- (void) pread(threadflow->tf_lwpusagefd,
- &threadflow->tf_susage,
- sizeof (struct prusage), 0);
-
- /* Compute overhead time in this thread around op */
- if (threadflow->tf_eusage.pr_stime.tv_nsec) {
- flowop->fo_stats.fs_mstate[FLOW_MSTATE_OHEAD] +=
- TIMESPEC_TO_HRTIME(threadflow->tf_eusage.pr_utime,
- threadflow->tf_susage.pr_utime) +
- TIMESPEC_TO_HRTIME(threadflow->tf_eusage.pr_ttime,
- threadflow->tf_susage.pr_ttime) +
- TIMESPEC_TO_HRTIME(threadflow->tf_eusage.pr_stime,
- threadflow->tf_susage.pr_stime);
+ (void) pread(threadflow->tf_lwpusagefd,
+ &threadflow->tf_susage,
+ sizeof (struct prusage), 0);
+
+ /* Compute overhead time in this thread around op */
+ if (threadflow->tf_eusage.pr_stime.tv_nsec) {
+ flowop->fo_stats.fs_mstate[FLOW_MSTATE_OHEAD] +=
+ TIMESPEC_TO_HRTIME(threadflow->tf_eusage.pr_utime,
+ threadflow->tf_susage.pr_utime) +
+ TIMESPEC_TO_HRTIME(threadflow->tf_eusage.pr_ttime,
+ threadflow->tf_susage.pr_ttime) +
+ TIMESPEC_TO_HRTIME(threadflow->tf_eusage.pr_stime,
+ threadflow->tf_susage.pr_stime);
+ }
}
#endif
+
/* Start of op for this thread */
threadflow->tf_stime = gethrtime();
}
@@ -190,30 +193,32 @@ flowop_endop(threadflow_t *threadflow, flowop_t *flowop, int64_t bytes)
flowop->fo_stats.fs_mstate[FLOW_MSTATE_LAT] +=
(gethrtime() - threadflow->tf_stime);
#ifdef HAVE_PROCFS
- if ((pread(threadflow->tf_lwpusagefd, &threadflow->tf_eusage,
- sizeof (struct prusage), 0)) != sizeof (struct prusage))
- filebench_log(LOG_ERROR, "cannot read /proc");
-
- t =
- TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_utime,
- threadflow->tf_eusage.pr_utime) +
- TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_ttime,
- threadflow->tf_eusage.pr_ttime) +
- TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_stime,
- threadflow->tf_eusage.pr_stime);
- flowop->fo_stats.fs_mstate[FLOW_MSTATE_CPU] += t;
-
- flowop->fo_stats.fs_mstate[FLOW_MSTATE_WAIT] +=
- TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_tftime,
- threadflow->tf_eusage.pr_tftime) +
- TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_dftime,
- threadflow->tf_eusage.pr_dftime) +
- TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_kftime,
- threadflow->tf_eusage.pr_kftime) +
- TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_kftime,
- threadflow->tf_eusage.pr_kftime) +
- TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_slptime,
- threadflow->tf_eusage.pr_slptime);
+ if ((filebench_shm->shm_mmode & FILEBENCH_MODE_NOUSAGE) == 0) {
+ if ((pread(threadflow->tf_lwpusagefd, &threadflow->tf_eusage,
+ sizeof (struct prusage), 0)) != sizeof (struct prusage))
+ filebench_log(LOG_ERROR, "cannot read /proc");
+
+ t =
+ TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_utime,
+ threadflow->tf_eusage.pr_utime) +
+ TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_ttime,
+ threadflow->tf_eusage.pr_ttime) +
+ TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_stime,
+ threadflow->tf_eusage.pr_stime);
+ flowop->fo_stats.fs_mstate[FLOW_MSTATE_CPU] += t;
+
+ flowop->fo_stats.fs_mstate[FLOW_MSTATE_WAIT] +=
+ TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_tftime,
+ threadflow->tf_eusage.pr_tftime) +
+ TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_dftime,
+ threadflow->tf_eusage.pr_dftime) +
+ TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_kftime,
+ threadflow->tf_eusage.pr_kftime) +
+ TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_kftime,
+ threadflow->tf_eusage.pr_kftime) +
+ TIMESPEC_TO_HRTIME(threadflow->tf_susage.pr_slptime,
+ threadflow->tf_eusage.pr_slptime);
+ }
#endif
flowop->fo_stats.fs_count++;
diff --git a/usr/src/cmd/filebench/common/fsplug.h b/usr/src/cmd/filebench/common/fsplug.h
index 4158f9f33a..61f3e1ddfa 100644
--- a/usr/src/cmd/filebench/common/fsplug.h
+++ b/usr/src/cmd/filebench/common/fsplug.h
@@ -76,6 +76,7 @@ typedef struct fsplug_func_s {
int (*fsp_stat)(char *, struct stat64 *);
int (*fsp_fstat)(fb_fdesc_t *, struct stat64 *);
int (*fsp_access)(const char *, int);
+ void (*fsp_recur_rm)(char *);
} fsplug_func_t;
extern fsplug_func_t *fs_functions_vec;
@@ -126,6 +127,9 @@ extern fsplug_func_t *fs_functions_vec;
#define FB_FSYNC(fdesc) \
(*fs_functions_vec->fsp_fsync)(fdesc)
+#define FB_RECUR_RM(path) \
+ (*fs_functions_vec->fsp_recur_rm)(path)
+
#define FB_STAT(path, statp) \
(*fs_functions_vec->fsp_stat)(path, statp)
diff --git a/usr/src/cmd/filebench/common/ipc.h b/usr/src/cmd/filebench/common/ipc.h
index 1ed54a5fe2..bee1b72810 100644
--- a/usr/src/cmd/filebench/common/ipc.h
+++ b/usr/src/cmd/filebench/common/ipc.h
@@ -82,10 +82,14 @@ extern "C" {
#define FILEBENCH_ABORT_RSRC 3
#define FILEBENCH_ABORT_FINI 4
+ /* run modes */
#define FILEBENCH_MODE_TIMEOUT 0x0
#define FILEBENCH_MODE_Q1STDONE 0x1
#define FILEBENCH_MODE_QALLDONE 0x2
+ /* misc. modes */
+#define FILEBENCH_MODE_NOUSAGE 0x01
+
typedef struct filebench_shm {
/*
* All state down to shm_marker are set to zero during filebench
@@ -165,7 +169,8 @@ typedef struct filebench_shm {
*/
char shm_fscriptname[1024];
int shm_id;
- int shm_rmode;
+ int shm_rmode; /* run mode settings */
+ int shm_mmode; /* misc. mode settings */
int shm_1st_err;
pthread_mutex_t shm_threadflow_lock;
pthread_mutex_t shm_msg_lock;
diff --git a/usr/src/cmd/filebench/common/parser_gram.y b/usr/src/cmd/filebench/common/parser_gram.y
index a52f147d70..33a45d179e 100644
--- a/usr/src/cmd/filebench/common/parser_gram.y
+++ b/usr/src/cmd/filebench/common/parser_gram.y
@@ -172,7 +172,7 @@ static void parser_version(cmd_t *cmd);
%token FSC_LIST FSC_DEFINE FSC_EXEC FSC_QUIT FSC_DEBUG FSC_CREATE
%token FSC_SLEEP FSC_STATS FSC_FOREACH FSC_SET FSC_SHUTDOWN FSC_LOG
%token FSC_SYSTEM FSC_FLOWOP FSC_EVENTGEN FSC_ECHO FSC_LOAD FSC_RUN
-%token FSC_WARMUP
+%token FSC_WARMUP FSC_NOUSESTATS
%token FSC_USAGE FSC_HELP FSC_VARS FSC_VERSION FSC_ENABLE FSC_DOMULTISYNC
%token FSV_STRING FSV_VAL_INT FSV_VAL_BOOLEAN FSV_VARIABLE FSV_WHITESTRING
%token FSV_RANDUNI FSV_RANDTAB FSV_RANDVAR FSV_URAND FSV_RAND48
@@ -829,6 +829,13 @@ set_command: FSC_SET FSV_VARIABLE FSK_ASSIGN FSV_VAL_INT
if (($$ = alloc_cmd()) == NULL)
YYERROR;
$$->cmd = NULL;
+} | FSC_SET FSE_MODE FSC_NOUSESTATS
+{
+ filebench_shm->shm_mmode |= FILEBENCH_MODE_NOUSAGE;
+ filebench_log(LOG_INFO, "disabling CPU usage statistics");
+ if (($$ = alloc_cmd()) == NULL)
+ YYERROR;
+ $$->cmd = NULL;
}| FSC_SET FSV_RANDVAR FSS_TYPE FSK_ASSIGN randvar_attr_typop
{
if (($$ = alloc_cmd()) == NULL)
@@ -1051,6 +1058,10 @@ shutdown_command: FSC_SHUTDOWN entity
case FSE_PROC:
$$->cmd = &parser_proc_shutdown;
break;
+ case FSE_FILE:
+ case FSE_FILESET:
+ $$->cmd = &parser_fileset_shutdown;
+ break;
default:
filebench_log(LOG_ERROR, "unknown entity", $2);
YYERROR;
@@ -2918,6 +2929,17 @@ parser_fileset_create(cmd_t *cmd)
}
/*
+ * Deletes the files and directories that represent files and filesets on the
+ * storage medium.
+ */
+static void
+parser_fileset_shutdown(cmd_t *cmd)
+{
+ filebench_log(LOG_INFO, "Shutting down filesets");
+ fileset_delete_all_filesets();
+}
+
+/*
* Shuts down all processes and their associated threads. When finished
* it deletes interprocess shared memory and resets the event generator.
* It does not exit the filebench program though.
diff --git a/usr/src/cmd/filebench/common/parser_lex.l b/usr/src/cmd/filebench/common/parser_lex.l
index cbefc28ca1..ba022ad9b1 100644
--- a/usr/src/cmd/filebench/common/parser_lex.l
+++ b/usr/src/cmd/filebench/common/parser_lex.l
@@ -76,6 +76,7 @@ help { return FSC_HELP; }
list { return FSC_LIST; }
load { return FSC_LOAD; }
log { return FSC_LOG; }
+nousestats { return FSC_NOUSESTATS; }
run { return FSC_RUN; }
set { return FSC_SET; }
shutdown { return FSC_SHUTDOWN; }
diff --git a/usr/src/cmd/filebench/common/stats.c b/usr/src/cmd/filebench/common/stats.c
index 42236d3bcc..a3dc562125 100644
--- a/usr/src/cmd/filebench/common/stats.c
+++ b/usr/src/cmd/filebench/common/stats.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -58,68 +58,99 @@ static hrtime_t stats_cputime = 0;
#ifdef HAVE_LIBKSTAT
static kstat_ctl_t *kstatp = NULL;
static kstat_t *sysinfo_ksp = NULL;
+static kstat_t **cpu_kstat_list = NULL;
+static int kstat_ncpus = 0;
-/*
- * Uses the kstat library or, if it is not available, the /proc/stat file
- * to obtain cpu statistics. Collects statistics for each cpu, initializes
- * a local pointer to the sysinfo kstat, and returns the sum of user and
- * kernel time for all the cpus.
- */
-static fbint_t
-kstats_read_cpu(void)
+static int
+stats_build_kstat_list(void)
{
- int ncpus;
- kstat_t **cpu_stat_list = NULL;
- ulong_t cputime_states[CPU_STATES];
- hrtime_t cputime;
- int i;
-
kstat_t *ksp;
- if (kstatp == NULL) {
- if ((kstatp = kstat_open()) == (kstat_ctl_t *)NULL) {
- filebench_log(LOG_ERROR, "Cannot read kstats");
- return (-1);
- }
- }
-
- /*
- * Per-CPU statistics
- */
-
- ncpus = 0;
+ kstat_ncpus = 0;
for (ksp = kstatp->kc_chain; ksp; ksp = ksp->ks_next)
if (strncmp(ksp->ks_name, "cpu_stat", 8) == 0)
- ncpus++;
+ kstat_ncpus++;
- if ((cpu_stat_list =
- (kstat_t **)malloc(ncpus * sizeof (kstat_t *))) == NULL) {
+ if ((cpu_kstat_list = (kstat_t **)
+ malloc(kstat_ncpus * sizeof (kstat_t *))) == NULL) {
filebench_log(LOG_ERROR, "malloc failed");
- return (-1);
+ return (FILEBENCH_ERROR);
}
- ncpus = 0;
+ kstat_ncpus = 0;
for (ksp = kstatp->kc_chain; ksp; ksp = ksp->ks_next)
if (strncmp(ksp->ks_name, "cpu_stat", 8) == 0 &&
kstat_read(kstatp, ksp, NULL) != -1)
- cpu_stat_list[ncpus++] = ksp;
+ cpu_kstat_list[kstat_ncpus++] = ksp;
- if (ncpus == 0) {
+ if (kstat_ncpus == 0) {
filebench_log(LOG_ERROR,
"kstats can't find any cpu statistics");
- return (0);
+ return (FILEBENCH_ERROR);
+ }
+
+ return (FILEBENCH_OK);
+}
+
+static int
+stats_kstat_update(void)
+{
+ if (kstatp == NULL) {
+ if ((kstatp = kstat_open()) == (kstat_ctl_t *)NULL) {
+ filebench_log(LOG_ERROR, "Cannot read kstats");
+ return (FILEBENCH_ERROR);
+ }
}
+ /* get the sysinfo kstat */
if (sysinfo_ksp == NULL)
sysinfo_ksp = kstat_lookup(kstatp, "unix", 0, "sysinfo");
+ /* get per cpu kstats, if necessary */
+ if (cpu_kstat_list == NULL) {
+
+ /* Initialize the array of cpu kstat pointers */
+ if (stats_build_kstat_list() == FILEBENCH_ERROR)
+ return (FILEBENCH_ERROR);
+
+ } else if (kstat_chain_update(kstatp) != 0) {
+
+ /* free up current array of kstat ptrs and get new one */
+ free((void *)cpu_kstat_list);
+ if (stats_build_kstat_list() == FILEBENCH_ERROR)
+ return (FILEBENCH_ERROR);
+ }
+
+ return (FILEBENCH_OK);
+}
+
+/*
+ * Uses the kstat library or, if it is not available, the /proc/stat file
+ * to obtain cpu statistics. Collects statistics for each cpu, initializes
+ * a local pointer to the sysinfo kstat, and returns the sum of user and
+ * kernel time for all the cpus.
+ */
+static fbint_t
+kstats_read_cpu(void)
+{
+ ulong_t cputime_states[CPU_STATES];
+ hrtime_t cputime;
+ int i;
+
+ /*
+ * Per-CPU statistics
+ */
+
+ if (stats_kstat_update() == FILEBENCH_ERROR)
+ return (0);
+
/* Sum across all CPUs */
(void) memset(&cputime_states, 0, sizeof (cputime_states));
- for (i = 0; i < ncpus; i++) {
+ for (i = 0; i < kstat_ncpus; i++) {
cpu_stat_t cpu_stats;
int j;
- (void) kstat_read(kstatp, cpu_stat_list[i],
+ (void) kstat_read(kstatp, cpu_kstat_list[i],
(void *) &cpu_stats);
for (j = 0; j < CPU_STATES; j++)
cputime_states[j] += cpu_stats.cpu_sysinfo.cpu[j];
diff --git a/usr/src/cmd/filebench/fbscript/filebench.pl b/usr/src/cmd/filebench/fbscript/filebench.pl
index 228774e162..ef1db221f2 100755
--- a/usr/src/cmd/filebench/fbscript/filebench.pl
+++ b/usr/src/cmd/filebench/fbscript/filebench.pl
@@ -48,6 +48,7 @@ my %MULTIDATA = ();
my %DEFDATA = ();
my %CONFDATA = ();
my %STATSHASH = ();
+my $OPTIONFLAGS = "cleanupstorage";
@ext_stats=();
@file_stats=();
@arg_stats=();
@@ -195,6 +196,11 @@ sub op_quit {
# Shutdown the appropriate processes
print FSCRIPT "shutdown processes\n";
+ # remove filesets, if requested
+ if (conf_exists("cleanupstorage") == 1) {
+ printf FSCRIPT "shutdown filesets\n";
+ }
+
# Quit filebench
print FSCRIPT "quit\n";
close(FSCRIPT);
@@ -449,7 +455,9 @@ sub op_load_defaults {
}
}
- op_set($var, $val);
+ if ($val ne "") {
+ op_set($var, $val);
+ }
}
}
}
@@ -500,22 +508,29 @@ sub parse_profile {
push(@{ $MULTIDATA{$opt} }, $val);
}
} elsif($default_section) {
- $line =~ /(.+) = (.+);/;
- my $opt = $1;
- my $val = $2;
- chomp($opt);
- chomp($val);
- my @vals = ();
- # Check to see if this needs to be a list
- if($val =~ /,/) {
- push(@vals, $+) while $val =~
- m{"([^\"\\]*(?:\\.[^\"\\]*)*)",? | ([^,]+),? | , }gx;
- push(@vals, undef) if substr($val, -1,1) eq ',';
- @{ $DEFDATA{$opt} } = @vals;
+ if ($line =~ /(.+) = (.+);/) {
+ my $opt = $1;
+ my $val = $2;
+ chomp($opt);
+ chomp($val);
+ my @vals = ();
+ # Check to see if this needs to be a list
+ if(($val =~ /,/) && ($val !~ /"/)) {
+ push(@vals, $+) while $val =~
+ m{"([^\"\\]*(?:\\.[^\"\\]*)*)",? | ([^,]+),? | , }gx;
+ push(@vals, undef) if substr($val, -1,1) eq ',';
+ @{ $DEFDATA{$opt} } = @vals;
+ } else {
+ @{DEFDATA{$opt}} = ();
+ push(@{ $DEFDATA{$opt} }, $val);
+ }
} else {
- @{CONFDATA{$opt}} = ();
- push(@{ $DEFDATA{$opt} }, $val);
- }
+ $line =~ /($OPTIONFLAGS);/;
+ my $opt = $1;
+ chomp($opt);
+ @{DEFDATA{$opt}} = ();
+ push(@{ $DEFDATA{$opt} }, "");
+ }
} else {
if($line =~ /^CONFIG /) {
my $config = $line;
@@ -567,21 +582,28 @@ sub parse_config {
next if ($line =~ /^#/ or $line eq "");
- $line =~ /(.+) = (.+);/;
- my $opt = $1;
- my $val = $2;
- chomp($opt);
- chomp($val);
- my @vals = ();
- # Check to see if this needs to be a list
- if($val =~ /,/) {
- push(@vals, $+) while $val =~
- m{"([^\"\\]*(?:\\.[^\"\\]*)*)",? | ([^,]+),? | , }gx;
- push(@vals, undef) if substr($val, -1,1) eq ',';
+ if ($line =~ /(.+) = (.+);/) {
+ my $opt = $1;
+ my $val = $2;
+ chomp($opt);
+ chomp($val);
+ my @vals = ();
+ # Check to see if this needs to be a list
+ if(($val =~ /,/) && ($val !~ /"/)) {
+ push(@vals, $+) while $val =~
+ m{"([^\"\\]*(?:\\.[^\"\\]*)*)",? | ([^,]+),? | , }gx;
+ push(@vals, undef) if substr($val, -1,1) eq ',';
@{ $CONFDATA{$opt} } = @vals;
+ } else {
+ @{CONFDATA{$opt}} = ();
+ push(@{ $CONFDATA{$opt} }, $val);
+ }
} else {
+ $line =~ /($OPTIONFLAGS);/;
+ my $opt = $1;
+ chomp($opt);
@{CONFDATA{$opt}} = ();
- push(@{ $CONFDATA{$opt} }, $val);
+ push(@{ $CONFDATA{$opt} }, "");
}
}