[Devel] [PATCH RHEL7 COMMIT] ms/cfq-iosched: simplify control flow in cfq_get_queue()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Nov 23 07:30:36 PST 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.9.12
------>
commit dcd21871f74e0faa10982e8de34661671c126556
Author: Tejun Heo <tj at kernel.org>
Date:   Mon Nov 23 19:30:36 2015 +0400

    ms/cfq-iosched: simplify control flow in cfq_get_queue()
    
    cfq_get_queue()'s control flow looks like the following.
    
    	async_cfqq = NULL;
    	cfqq = NULL;
    
    	if (!is_sync) {
    		...
    		async_cfqq = ...;
    		cfqq = *async_cfqq;
    	}
    
    	if (!cfqq)
    		cfqq = ...;
    
    	if (!is_sync && !(*async_cfqq))
    		...;
    
    The only thing the local variable init, the second if, and the
    async_cfqq test in the third if achieves is to skip cfqq creation and
    installation if *async_cfqq was already non-NULL.  This is needlessly
    complicated with different tests examining the same condition.
    Simplify it to the following.
    
    	if (!is_sync) {
    		...
    		async_cfqq = ...;
    		cfqq = *async_cfqq;
    		if (cfqq)
    			goto out;
    	}
    
    	cfqq = ...;
    
    	if (!is_sync)
    		...;
     out:
    
    Signed-off-by: Tejun Heo <tj at kernel.org>
    Acked-by: Jeff Moyer <jmoyer at redhat.com>
    Cc: Vivek Goyal <vgoyal at redhat.com>
    Cc: Arianna Avanzini <avanzini.arianna at gmail.com>
    Signed-off-by: Jens Axboe <axboe at fb.com>
    
    https://jira.sw.ru/browse/PSBM-41334
    
    (cherry picked from commit 4ebc1c61d6185604c97fd0b0355ab668052044ab)
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 block/cfq-iosched.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 987c0f9..a4149c3 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3696,25 +3696,26 @@ cfq_get_queue(struct cfq_data *cfqd, bool is_sync, struct cfq_io_cq *cic,
 {
 	const int ioprio_class = IOPRIO_PRIO_CLASS(cic->ioprio);
 	const int ioprio = IOPRIO_PRIO_DATA(cic->ioprio);
-	struct cfq_queue **async_cfqq = NULL;
-	struct cfq_queue *cfqq = NULL;
+	struct cfq_queue **async_cfqq;
+	struct cfq_queue *cfqq;
 
 	if (!is_sync) {
 		async_cfqq = cfq_async_queue_prio(cfqd, ioprio_class, ioprio);
 		cfqq = *async_cfqq;
+		if (cfqq)
+			goto out;
 	}
 
-	if (!cfqq)
-		cfqq = cfq_find_alloc_queue(cfqd, is_sync, cic, bio);
+	cfqq = cfq_find_alloc_queue(cfqd, is_sync, cic, bio);
 
 	/*
 	 * pin the queue now that it's allocated, scheduler exit will prune it
 	 */
-	if (!is_sync && !(*async_cfqq)) {
+	if (!is_sync) {
 		cfqq->ref++;
 		*async_cfqq = cfqq;
 	}
-
+out:
 	cfqq->ref++;
 	return cfqq;
 }


More information about the Devel mailing list