Skip to contentSkip to conversation

nandbase performance

PATCH New Peter Grayson 1 participant 1 message Sep 23, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nandbase performance

Here is a patch against nand_base.c that improves partial page read performance. The patch simply replaces a byte-by-byte copy in a for-loop with a memcpy() call. Jffs2 does a lot of these partial page reads.

Pete

drivers/mtd/nand/nand_base.c +3 -2
diff -uNr mtd/drivers/mtd/nand/nand_base.c mtd-nandbase/drivers/mtd/nand/nand_base.c
@@ -1311,8 +1311,9 @@
 	readdata:
 		/* Partial page read, transfer data into fs buffer */
 		if (!aligned) { 
-			for (j = col; j < end && read < len; j++)
-				buf[read++] = data_poi[j];
+			int bytes_to_copy = min(end - col, (int)len - read);
+			memcpy(&buf[read], &data_poi[col], bytes_to_copy);
+			read += bytes_to_copy;
 			this->pagebuf = realpage;	
 		} else		
 			read += mtd->oobblock;