Introduction ------------ nandsim_prof.c is NAND memory emulator based on nandsim.c. I added following features. + Counts and checks partial page programming operation cycles. + Counts and checks page reads cycles. + Read counters in detail, all erase blocks, and program pages. + msleep() or schedule() at write page and erase block. + Slightly more faster at programming page. I changed following features. + Read status from nodes under /sys/class/mtd/mtdN node, instead of debugfs nodes. + Fix kernel panic when using cache_file (backing store file). Down Load and Links ------------------- Down load: http://www.ftechworks.mydns.jp/blog/ubifs/nandsim_prof_patch_to_v3.18.25.tar.gz Patch to linux kernel --------------------- To patch linux kernel, type following commands. Where ${work_dir} is working directory to extract files from nandsim_prof_patch_to_v3.18.25.tar.gz file. ${down_loaded_directory} is the directory holding down loaded nandsim_prof_patch_to_v3.18.25.tar.gz file. ${git_work_dir} is the linux kernel source directory controled revision by git. % mkdir ${work_dir} % cd ${work_dir} % tar zxvf ${down_loaded_directory}/nandsim_prof_patch_to_v3.18.25.tar.gz % cd ${git_work_dir} % git checkout -b v3.18.25 v3.18.25 % git apply ${work_dir}/nandsim_prof_patch_to_v3.18.25/nandsim_prof_patch_to_v3.18.25.diff Module Parameters ----------------- The following module parameters are added to nandsim_prof.c. * programm_msleep Unit: milli seconds. Specify sleep time when program a page. The following values are assigned to special feature. <0 : Do not msleep(). 0 : Do schedule(). * erase_msleep Unit: milli seconds. Specify sleep time when erase a block. The following values are assigned to special feature. <0 : Do not msleep(). 0 : Do schedule(). * page_prog_max Unit: times. Specify max times of partial page programming. When the times of programming specific page more than or equal to this value, driver prints out to kernel log. See "partial write" in NAND memory data sheet. * page_read_max Unit: times. Specify max times of page reading. When the times of reading specific page more than or equal to this value, driver prints out to kernel log. To see anti "read disturb" operation are working. * block_erase_max Unit: times. Specify max times of block erasing. When the times of erasing specific block more than or equal to this value, driver prints out to kernel log. * partial_write_check Unit: integer. Check partial write data pattern. The following lines shows node values and functions. 0: Do not check. 1: Check write 0 over 0. Note: It's safe that writing zero to cell which already turned into zero. The other module parameters are same as nandsim.c. Device statistics directory --------------------------- Device statistics are shown in /sys/class/mtd/mtdN directory. Where N is the next partition to the last partition in partition table (parts module parameter). Note: We assume mount sysfs on /sys mount point. The parts module parameter determinates N. Some cases in following lines show parts module parameter and N relations. * Case 1: "no parts module parameter." If you didn't specify parts module parameter, partitions are arranged as follows. mtd0 Partition contains whole NAND memory areas. mtd1 This partition also contains whole NAND memory areas and shows NAND memory statistics. You can read statistics from nodes under /sys/class/mtd/mtd1 directory. Note: This case may be most typical case, when you insert nandsim_prof module into kernel with less or no module parameters. * Case 2: "Completely specified partition, no remaining areas." If you specify partition(s) completely, the last partition contains the last NAND page. mtd0 .. mtdN-1 Partitions specified by parts module parameter. mtdN-1 contains the last NAND page. mtdN This partition contains whole NAND memory areas. So this partition overlaps with mtd0 to mtdN-1. This partition shows NAND statistics. You can read statistics from nodes under /sys/class/mtd/mtdN directory. * Case 3: "Specified partitions with remaining areas." If you specify partition(s) with remaining areas, the last partition specified parts module parameter doesn't contains the last NAND page. mtd0 .. mtdN-2 Partitions specified by parts module parameter. mtdN-1 The Partition added by nandsim_prof driver. This partition is "remaining" partition which contains pages from the page adjacent mtdN-2 to the last NAND page. mtdN This partition contains whole NAND memory areas. So this partition overlaps with mtd0 to mtdN-1. This partition shows NAND statistics. You can read statistics from nodes under /sys/class/mtd/mtdN directory. Added and modified statistics ----------------------------- Here, The following macro names are represents NAND memory geometry. The first_id_byte, second_id_byte, third_id_byte, and fourth_id_byte module parameters determin NAND memory geometry. NAND_PAGES The number of pages. "page" is the programming unit at an operation. NAND_BLOCKS The number of erase blocks, "erase block" is consisted from some pages. The following nodes in /sys/class/mtd/mtdN are added to nandsim_prof driver. These show NAND memory statistics. Binaries are read as host byte order. * progs_report format: Text R/W: 0444 progs_report shows summary of page_progs binary statistics. The following text is an example of progs_report. Number of pages: 262144 Number of pages allocated: 117061 Maximum number of programs: 2 Minimum number of programs: 0 Number of pages with program counts from 0 to 0: 145083 Number of pages with program counts from 1 to 1: 112926 Number of pages with program counts from 2 to 2: 4135 "Number of pages" shows NAND memory pages, it is constant. "Number of pages allocated" shows the number of allocated NAND memory pages from the kernel memory (kmem_cache) or cache file (backing store file). Allocated pages emulates NAND memory cell which contains programmed data. This number matches to pages programmed one or more times. Take a look the above example, this value is 117061, and equal to 112926 + 4135. "Maximum number of programs" shows the maximum number of program times since erased for all pages. "Minimum number of programs" shows the minimum number of program times since erased for all pages. "Number of pages with program counts from i to j" shows the number of pages which programmed from i to j times since erased. If i and j equal to zero, the number shows pages those are erased. * page_reads format: uint32_t page_reads[NAND_PAGES]; R/W: 0644 page_reads[i] is the number of times page i read since erased. * page_progs format: uint8_t page_progs[NAND_PAGES]; page_progs[i] is the number of times page i programed since erased. * block_erases format uint32_t block_erases[NAND_BLOCKS]; block_erases[i] is the number of times block i erased. * wear_report format: Text same as nandsim R/W: 0444 wear_report node is slightly modified from nandsim. Added "Total numbers of erases" number. This number almostly same to "Total wear". If "Total numbers of erases" is not same to "Total wear", Some element of block_erases[] were overflowed. I modified "Number of ebs with erase counts from i to j" number. First rank of this line's "i" starts from "Minimum number of erases". The following lines shows wear_report example. Total wear: 836885 Total numbers of erases: 836885 Number of erase blocks: 8192 Average number of erases: 102 Maximum number of erases: 233 Minimum number of erases: 1 Number of ebs with erase counts from 1 to 24: 1323 Number of ebs with erase counts from 25 to 47: 1350 Number of ebs with erase counts from 48 to 71: 834 Number of ebs with erase counts from 72 to 94: 1047 Number of ebs with erase counts from 95 to 117: 650 Number of ebs with erase counts from 118 to 140: 321 Number of ebs with erase counts from 141 to 163: 615 Number of ebs with erase counts from 164 to 187: 564 Number of ebs with erase counts from 188 to 210: 600 Number of ebs with erase counts from 211 to 233: 888