Skip to contentSkip to conversation

CFQ: delay getting cfq group at the very point we really need it

PATCH In review Gui Jianfeng 2 participants 2 messages Jul 15, 2010 – Jul 16, 2010 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CFQ: delay getting cfq group at the very point we really need it

Delay searching or allocating a cfq group at the very point that we really need it. This change would save some cycles every time we're getting a cfq queue.

---
 block/cfq-iosched.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
block/cfq-iosched.c +3 -2
index eb4086f..9b0cf13 100644
@@ -2820,10 +2820,8 @@ cfq_find_alloc_queue(struct cfq_data *cfqd, bool is_sync,
 {
 	struct cfq_queue *cfqq, *new_cfqq = NULL;
 	struct cfq_io_context *cic;
-	struct cfq_group *cfqg;
 
 retry:
-	cfqg = cfq_get_cfqg(cfqd, 1);
 	cic = cfq_cic_lookup(cfqd, ioc);
 	/* cic always exists here */
 	cfqq = cic_to_cfqq(cic, is_sync);
@@ -2852,6 +2850,9 @@ retry:
 		}
 
 		if (cfqq) {
+			struct cfq_group *cfqg;
+
+			cfqg = cfq_get_cfqg(cfqd, 1);
 			cfq_init_cfqq(cfqd, cfqq, current->pid, is_sync);
 			cfq_init_prio_data(cfqq, ioc);
 			cfq_link_cfqq_cfqg(cfqq, cfqg);

-- 1.5.4.rc3

Acked-by on v1 1/1
#1 lore raw
Quoted 25 lines · Gui Jianfeng

Delay searching or allocating a cfq group at the very point that we really need it. This change would save some cycles every time we're getting a cfq queue.

---
 block/cfq-iosched.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
block/cfq-iosched.c +0 -2
index eb4086f..9b0cf13 100644
@@ -2820,10 +2820,8 @@ cfq_find_alloc_queue(struct cfq_data *cfqd, bool is_sync,
 {
 	struct cfq_queue *cfqq, *new_cfqq = NULL;
 	struct cfq_io_context *cic;
-	struct cfq_group *cfqg;
 
 retry:
-	cfqg = cfq_get_cfqg(cfqd, 1);
 	cic = cfq_cic_lookup(cfqd, ioc);
 	/* cic always exists here */
 	cfqq = cic_to_cfqq(cic, is_sync);

block/cfq-iosched.c retry: · line 2856

Quoted 7 lines
block/cfq-iosched.c +3 -0
@@ -2852,6 +2850,9 @@ retry:
 		}
 
 		if (cfqq) {
+			struct cfq_group *cfqg;
+
+			cfqg = cfq_get_cfqg(cfqd, 1);
 			cfq_init_cfqq(cfqd, cfqq, current->pid, is_sync);

Gui, I noticed that once we have setup a cfqq and cfqg, for subequent requests we should not come into this function at all because in cfq_set_request(), cic will have pointer to cfqq.

So I am not sure in what call path there is substantial saving but anyway, it should not harm moving cfq_get_cfqg() call down and call it after cfqq has been allocated.

Thanks
Vivek