From: Jens Axboe Date: Wed, 31 May 2006 08:16:18 +0000 (+0200) Subject: Merge branch 'master' of ssh://router/data/git/fio X-Git-Tag: fio-1.4~11 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=a4e167ee3ba40cb0587cf27dca2a9f8b947e568a;hp=1bb6b2a5c9b79af8ca03e8e29ad2a2eb3e6d83e7 Merge branch 'master' of ssh://router/data/git/fio --- diff --git a/README b/README index bc2574e7..8b84a08a 100644 --- a/README +++ b/README @@ -92,7 +92,9 @@ The format is as follows: rw, offset, length where with rw=0/1 for read/write, and the offset and length entries being in bytes. - + lockmem=x Lock down x amount of memory on the machine, to + simulate a machine with less memory available. x can + include k/m/g suffix. Examples using a job file ------------------------- diff --git a/fio-ini.c b/fio-ini.c index eeef3052..9b9262c9 100644 --- a/fio-ini.c +++ b/fio-ini.c @@ -50,6 +50,7 @@ int rate_quit = 0; int write_lat_log = 0; int write_bw_log = 0; int exitall_on_terminate = 0; +unsigned long long mlock_size = 0; static int setup_rate(struct thread_data *td) { @@ -807,6 +808,10 @@ int parse_jobs_ini(char *file) fgetpos(f, &off); continue; } + if (!check_strcnv(p, "lockmem", &mlock_size)) { + fgetpos(f, &off); + continue; + } if (!check_strstore(p, "directory", td->directory)) { fgetpos(f, &off); continue; diff --git a/fio.c b/fio.c index 3c35039a..09f40afe 100644 --- a/fio.c +++ b/fio.c @@ -57,6 +57,8 @@ static void update_io_ticks(void); static void disk_util_timer_arm(void); static void print_thread_status(void); +extern unsigned long long mlock_size; + /* * thread life cycle */ @@ -2234,8 +2236,23 @@ static void run_threads(void) struct thread_data *td; unsigned long spent; int i, todo, nr_running, m_rate, t_rate, nr_started; + void *mlocked_mem = NULL; printf("Starting %d thread%s\n", thread_number, thread_number > 1 ? "s" : ""); + + if (mlock_size) { + mlocked_mem = malloc(mlock_size); + if (!mlocked_mem) { + perror("malloc locked mem"); + return; + } + if (mlock(mlocked_mem, mlock_size) < 0) { + free(mlocked_mem); + perror("mlock"); + return; + } + } + fflush(stdout); signal(SIGINT, sig_handler); @@ -2347,6 +2364,12 @@ static void run_threads(void) } update_io_ticks(); + + if (mlocked_mem) { + if (munlock(mlocked_mem, mlock_size) < 0) + perror("munlock"); + free(mlocked_mem); + } } static void show_group_stats(struct group_run_stats *rs, int id)