Skip to contentSkip to conversation

XOR template selection redo

PATCH New NeilBrown 1 participant 1 message Jun 24, 2004 1 message not in the archive MD RAID

lore
Share & tools
lore

NeilBrown

author
#1 lore raw

PATCH 1/1 XOR template selection redo

In reply to a message not in the archive

From: Josh Litherland <[email protected]>

The XOR routine selection process is often confusing as it often doesn't choose the routine that measures the fastest, as sometime one routine is known to have better cache performance.

This patch avoids the comparison when there is a known best choice, and makes the report more meaningful.

### Diffstat output

 ./drivers/md/xor.c |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)
drivers/md/xor.c renamed from drivers/md/xor.c~current~ +25 -14
diff ./drivers/md/xor.c~current~ ./drivers/md/xor.c
@@ -108,29 +108,40 @@ calibrate_xor_block(void)
 	}
 	b2 = b1 + 2*PAGE_SIZE + BENCH_SIZE;
 
-	printk(KERN_INFO "raid5: measuring checksumming speed\n");
+	/*
+	 * If this arch/cpu has a short-circuited selection, don't loop through all
+	 * the possible functions, just test the best one
+	 */
 
+	fastest = NULL;
+
+#ifdef XOR_SELECT_TEMPLATE
+		fastest = XOR_SELECT_TEMPLATE(fastest);
+#endif
+	
 #define xor_speed(templ)	do_xor_speed((templ), b1, b2)
 
-	XOR_TRY_TEMPLATES;
+	if (fastest) {
+		printk(KERN_INFO "raid5: automatically using best checksumming function: %s\n",
+			fastest->name);
+		xor_speed(fastest);
+	} else {
+		printk(KERN_INFO "raid5: measuring checksumming speed\n");
+		XOR_TRY_TEMPLATES;
+		fastest = template_list;
+		for (f = fastest; f; f = f->next) 
+			if (f->speed > fastest->speed)
+				fastest = f;
+	}
+
+	printk("raid5: using function: %s (%d.%03d MB/sec)\n",
+	       fastest->name, fastest->speed / 1000, fastest->speed % 1000);
 
 #undef xor_speed
 
 	free_pages((unsigned long)b1, 2);
 
-	fastest = template_list;
-	for (f = fastest; f; f = f->next)
-		if (f->speed > fastest->speed)
-			fastest = f;
-
-#ifdef XOR_SELECT_TEMPLATE
-	fastest = XOR_SELECT_TEMPLATE(fastest);
-#endif
-
 	active_template = fastest;
-	printk("raid5: using function: %s (%d.%03d MB/sec)\n",
-	       fastest->name, fastest->speed / 1000, fastest->speed % 1000);
-
 	return 0;
 }