From 2e5c505a5059f42b081bf6b6d22377c1eb2ab963 Mon Sep 17 00:00:00 2001 From: Gilad Broner Date: Thu, 30 Oct 2014 17:28:55 +0200 Subject: [PATCH] block: test-iosched: remove test timeout timer When running a test, a timer was set to detect test timeout and to unblock the wait_event() function which is waiting for the test to finish. This is redundant as wait_event timeout variant gives the same functionality without the overhead of managing a timer for this purpose and improve code readability. Change-Id: Icbd3cb0f3fcb5854673f4506b102b0c80e97d6bb Signed-off-by: Gilad Broner --- block/test-iosched.c | 32 +++++++++++--------------------- include/linux/test-iosched.h | 3 --- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/block/test-iosched.c b/block/test-iosched.c index 80ffb134d480..cc7d28c1ba81 100644 --- a/block/test-iosched.c +++ b/block/test-iosched.c @@ -662,20 +662,6 @@ static int post_test(struct test_data *td) return ret; } -/* - * The timer verifies that the test will be completed even if we don't get - * the completion callback for all the requests. - */ -static void test_timeout_handler(unsigned long data) -{ - struct test_data *td = (struct test_data *)data; - - pr_info("%s: TIMEOUT timer expired", __func__); - td->test_state = TEST_COMPLETED; - wake_up(&td->wait_q); - return; -} - static unsigned int get_timeout_msec(struct test_data *td) { if (td->test_info.timeout_msec) @@ -754,8 +740,6 @@ int test_iosched_start_test(struct test_info *t_info) msleep(2000); timeout_msec = get_timeout_msec(ptd); - mod_timer(&ptd->timeout_timer, jiffies + - msecs_to_jiffies(timeout_msec)); if (ptd->test_info.get_test_case_str_fn) test_name = ptd->test_info.get_test_case_str_fn(ptd); @@ -779,8 +763,17 @@ int test_iosched_start_test(struct test_info *t_info) pr_info("%s: Waiting for the test completion", __func__); - wait_event(ptd->wait_q, ptd->test_state == TEST_COMPLETED); - del_timer_sync(&ptd->timeout_timer); + ret = wait_event_interruptible_timeout(ptd->wait_q, + (ptd->test_state == TEST_COMPLETED), + msecs_to_jiffies(timeout_msec)); + if (ret <= 0) { + ptd->test_state = TEST_COMPLETED; + if (!ret) + pr_info("%s: Test timeout\n", __func__); + else + pr_err("%s: Test error=%d\n", __func__, ret); + goto error; + } memcpy(t_info, &ptd->test_info, sizeof(struct test_info)); @@ -1144,9 +1137,6 @@ static int test_init_queue(struct request_queue *q, struct elevator_type *e) q->elevator = eq; spin_unlock_irq(q->queue_lock); - setup_timer(&ptd->timeout_timer, test_timeout_handler, - (unsigned long)ptd); - spin_lock_init(&ptd->lock); if (test_debugfs_init(ptd)) { diff --git a/include/linux/test-iosched.h b/include/linux/test-iosched.h index 691f7df176f6..717a3ad760e7 100644 --- a/include/linux/test-iosched.h +++ b/include/linux/test-iosched.h @@ -191,8 +191,6 @@ struct blk_dev_test_type { * new BIOs. * @start_sector: The address of the first sector that can * be accessed by the test - * @timeout_timer: A timer to verify test completion in - * case of non-completed requests * @wr_rd_next_req_id: A unique ID to identify WRITE/READ * request to ease the debugging of the * test cases @@ -225,7 +223,6 @@ struct test_data { struct request_queue *req_q; int num_of_write_bios; u32 start_sector; - struct timer_list timeout_timer; int wr_rd_next_req_id; int unique_next_req_id; spinlock_t lock;