import mars-104.tgz

This commit is contained in:
Thomas Schoebel-Theuer 2011-05-06 11:25:52 +01:00
parent cabe994815
commit 9d1b483b97
7 changed files with 87 additions and 12 deletions

View File

@ -22,6 +22,7 @@
#define STRONG_MM
#define MEMLEAK // FIXME: remove this
//#define MEASURE_SYNC
///////////////////////// own type definitions ////////////////////////
@ -47,6 +48,8 @@ void _enqueue(struct aio_threadinfo *tinfo, struct aio_mref_aspect *mref_a, int
}
traced_unlock(&tinfo->lock, flags);
atomic_inc(&tinfo->total_enqueue_count);
}
static inline
@ -64,6 +67,7 @@ struct aio_mref_aspect *_dequeue(struct aio_threadinfo *tinfo, bool do_remove)
if (tmp != &tinfo->mref_list[prio]) {
if (do_remove) {
list_del_init(tmp);
atomic_inc(&tinfo->total_dequeue_count);
}
mref_a = container_of(tmp, struct aio_mref_aspect, io_head);
goto done;
@ -324,6 +328,7 @@ static int aio_submit_thread(void *data)
}
if ((long long)jiffies - mref_a->start_jiffies <= mref->ref_timeout) {
if (!_dequeue(tinfo, false)) {
atomic_inc(&output->total_msleep_count);
msleep(1000 * 4 / HZ);
}
_enqueue(tinfo, mref_a, MARS_PRIO_LOW, true);
@ -339,12 +344,13 @@ static int aio_submit_thread(void *data)
for (;;) {
if (mref->ref_rw != READ && output->brick->wait_during_fdsync) {
if (output->fdsync_active) {
long long delay = 60 * HZ;
atomic_inc(&output->total_fdsync_wait_count);
__wait_event_interruptible_timeout(
output->fdsync_event,
!output->fdsync_active || kthread_should_stop(),
delay);
}
wait_event_interruptible_timeout(
output->fdsync_event,
!output->fdsync_active || kthread_should_stop(),
60 * HZ);
}
@ -486,6 +492,9 @@ static int aio_sync_thread(void *data)
unsigned long flags;
int i;
int err;
#ifdef MEASURE_SYNC
long long old_jiffies;
#endif
output->fdsync_active = false;
@ -509,7 +518,19 @@ static int aio_sync_thread(void *data)
if (list_empty(&tmp_list))
continue;
if (output->fdsync_active) {
wake_up_interruptible(&output->fdsync_event);
}
atomic_inc(&output->total_fdsync_count);
#ifdef MEASURE_SYNC
old_jiffies = jiffies;
#endif
err = vfs_fsync(file, file->f_path.dentry, 1);
#ifdef MEASURE_SYNC
MARS_DBG("fdsync jiffies = %lld\n", jiffies - old_jiffies);
#endif
output->fdsync_active = false;
wake_up_interruptible(&output->fdsync_event);
if (err < 0) {
@ -556,9 +577,12 @@ char *aio_statistics(struct aio_brick *brick, int verbose)
// FIXME: check for allocation overflows
sprintf(res, "total reads = %d writes = %d allocs = %d delays = %d fdsync_waits = %d | flying reads = %d writes = %d allocs = %d \n",
atomic_read(&output->total_read_count), atomic_read(&output->total_write_count), atomic_read(&output->total_alloc_count), atomic_read(&output->total_delay_count), atomic_read(&output->total_fdsync_wait_count),
atomic_read(&output->read_count), atomic_read(&output->write_count), atomic_read(&output->alloc_count));
sprintf(res, "total reads = %d writes = %d allocs = %d delays = %d msleeps = %d fdsyncs = %d fdsync_waits = %d | flying reads = %d writes = %d allocs = %d q0 = %d/%d q1 = %d/%d q2 = %d/%d\n",
atomic_read(&output->total_read_count), atomic_read(&output->total_write_count), atomic_read(&output->total_alloc_count), atomic_read(&output->total_delay_count), atomic_read(&output->total_msleep_count), atomic_read(&output->total_fdsync_count), atomic_read(&output->total_fdsync_wait_count),
atomic_read(&output->read_count), atomic_read(&output->write_count), atomic_read(&output->alloc_count),
atomic_read(&output->tinfo[0].total_enqueue_count), atomic_read(&output->tinfo[0].total_dequeue_count),
atomic_read(&output->tinfo[1].total_enqueue_count), atomic_read(&output->tinfo[2].total_dequeue_count),
atomic_read(&output->tinfo[2].total_enqueue_count), atomic_read(&output->tinfo[2].total_dequeue_count));
return res;
}
@ -567,11 +591,19 @@ static noinline
void aio_reset_statistics(struct aio_brick *brick)
{
struct aio_output *output = brick->outputs[0];
int i;
atomic_set(&output->total_read_count, 0);
atomic_set(&output->total_write_count, 0);
atomic_set(&output->total_alloc_count, 0);
atomic_set(&output->total_delay_count, 0);
atomic_set(&output->total_msleep_count, 0);
atomic_set(&output->total_fdsync_count, 0);
atomic_set(&output->total_fdsync_wait_count, 0);
for (i = 0; i < 3; i++) {
struct aio_threadinfo *tinfo = &output->tinfo[i];
atomic_set(&tinfo->total_enqueue_count, 0);
atomic_set(&tinfo->total_dequeue_count, 0);
}
}

View File

@ -33,6 +33,8 @@ struct aio_threadinfo {
wait_queue_head_t event;
spinlock_t lock;
bool terminated;
atomic_t total_enqueue_count;
atomic_t total_dequeue_count;
};
struct aio_output {
@ -49,6 +51,8 @@ struct aio_output {
atomic_t total_write_count;
atomic_t total_alloc_count;
atomic_t total_delay_count;
atomic_t total_msleep_count;
atomic_t total_fdsync_count;
atomic_t total_fdsync_wait_count;
atomic_t read_count;
atomic_t write_count;

View File

@ -291,6 +291,18 @@ static void bio_ref_io(struct bio_output *output, struct mref_object *mref)
bio_get(bio);
rw = mref->ref_rw & 1;
if (brick->do_noidle) {
rw |= (1 << BIO_RW_NOIDLE);
}
if (!mref->ref_skip_sync) {
if (brick->do_sync) {
rw |= (1 << BIO_RW_SYNCIO);
}
if (brick->do_unplug) {
rw |= (1 << BIO_RW_UNPLUG);
}
}
MARS_IO("starting IO rw = %d fly = %d\n", rw, atomic_read(&brick->fly_count));
mars_trace(mref, "bio_submit");
@ -306,6 +318,7 @@ static void bio_ref_io(struct bio_output *output, struct mref_object *mref)
#ifdef FAKE_IO
bio->bi_end_io(bio, 0);
#else
bio->bi_rw = rw;
submit_bio(rw, bio);
#endif

View File

@ -21,6 +21,9 @@ struct bio_brick {
MARS_BRICK(bio);
// tunables
int ra_pages;
bool do_noidle;
bool do_sync;
bool do_unplug;
// readonly
loff_t total_size;
atomic_t fly_count;

View File

@ -449,10 +449,19 @@ static int if_release(struct gendisk *gd, fmode_t mode)
//static
void if_unplug(struct request_queue *q)
{
struct if_input *input = q->queuedata;
MARS_IO("UNPLUG\n");
int was_plugged = 1;
#if 1
spin_lock_irq(q->queue_lock);
was_plugged = blk_remove_plug(q);
spin_unlock_irq(q->queue_lock);
#else
queue_flag_clear_unlocked(QUEUE_FLAG_PLUGGED, q);
_if_unplug(input);
#endif
MARS_IO("UNPLUG %d\n", was_plugged);
if (true || was_plugged) {
struct if_input *input = q->queuedata;
_if_unplug(input);
}
}
//static

View File

@ -84,9 +84,14 @@ struct light_class {
#define IF_MAX_PLUGGED 10000
#define IF_READAHEAD 1
//#define IF_READAHEAD 0
#define BIO_READAHEAD 1
#define BIO_NOIDLE true
#define BIO_SYNC true
#define BIO_UNPLUG true
#define AIO_READAHEAD 1
#define AIO_WAIT_DURING_FDSYNC true
#define AIO_WAIT_DURING_FDSYNC false
static
void _set_trans_params(struct mars_brick *_brick, void *private)
@ -145,12 +150,14 @@ void _set_trans_params(struct mars_brick *_brick, void *private)
trans_brick->q_phase4.q_max_queued *= 2;
}
}
MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path);
}
static
void _set_client_params(struct mars_brick *_brick, void *private)
{
// currently no params
MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path);
}
static
@ -169,6 +176,7 @@ void _set_aio_params(struct mars_brick *_brick, void *private)
aio_brick->o_direct = false; // important!
aio_brick->o_fdsync = true;
aio_brick->wait_during_fdsync = AIO_WAIT_DURING_FDSYNC;
MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path);
}
static
@ -189,6 +197,10 @@ void _set_bio_params(struct mars_brick *_brick, void *private)
}
bio_brick = (void*)_brick;
bio_brick->ra_pages = BIO_READAHEAD;
bio_brick->do_noidle = BIO_NOIDLE;
bio_brick->do_sync = BIO_SYNC;
bio_brick->do_unplug = BIO_UNPLUG;
MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path);
}
@ -203,6 +215,7 @@ void _set_if_params(struct mars_brick *_brick, void *private)
if_brick->max_plugged = IF_MAX_PLUGGED;
if_brick->readahead = IF_READAHEAD;
if_brick->skip_sync = IF_SKIP_SYNC;
MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path);
}
///////////////////////////////////////////////////////////////////////
@ -1070,7 +1083,7 @@ int make_log_init(void *buf, struct mars_dent *parent)
aio_brick =
make_brick_all(global,
aio_dent,
NULL,
_set_aio_params,
NULL,
10 * HZ,
aio_path,

View File

@ -1860,6 +1860,7 @@ void trans_logger_log(struct trans_logger_output *output)
#ifdef CONFIG_DEBUG_KERNEL // debug override for catching long blocks
wait_timeout = 16 * HZ;
#endif
wait_timeout = 1;
if (brick->did_work) {
wait_timeout = 0; // start over immediately
} else if (brick->minimize_latency || (long long)jiffies - old_jiffies >= wait_timeout) {