aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2007-07-16 02:40:23 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:45 -0400
commit54114994f4de7e8076fc250e44501e55e19b75b5 (patch)
treeb0b0c2b5c3cf1c0daa7c6db7911c42dcf912f181
parent203a2935c734c054bfd4665fb5d8835498af50a8 (diff)
fault-injection: add min-order parameter to fail_page_alloc
Limiting smaller allocation failures by fault injection helps to find real possible bugs. Because higher order allocations are likely to fail and zero-order allocations are not likely to fail. This patch adds min-order parameter to fail_page_alloc. It specifies the minimum page allocation order to be injected failures. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/fault-injection/fault-injection.txt5
-rw-r--r--mm/page_alloc.c12
2 files changed, 16 insertions, 1 deletions
diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt
index b7ca560b9340..36ece095ff17 100644
--- a/Documentation/fault-injection/fault-injection.txt
+++ b/Documentation/fault-injection/fault-injection.txt
@@ -103,6 +103,11 @@ configuration of fault-injection capabilities.
103 default is 'N', setting it to 'Y' will inject failures 103 default is 'N', setting it to 'Y' will inject failures
104 only into non-sleep allocations (GFP_ATOMIC allocations). 104 only into non-sleep allocations (GFP_ATOMIC allocations).
105 105
106- /debug/fail_page_alloc/min-order:
107
108 specifies the minimum page allocation order to be injected
109 failures.
110
106o Boot option 111o Boot option
107 112
108In order to inject faults while debugfs is not available (early boot time), 113In order to inject faults while debugfs is not available (early boot time),
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 297efcf05ba4..f9e4e647d7e8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -900,11 +900,13 @@ static struct fail_page_alloc_attr {
900 900
901 u32 ignore_gfp_highmem; 901 u32 ignore_gfp_highmem;
902 u32 ignore_gfp_wait; 902 u32 ignore_gfp_wait;
903 u32 min_order;
903 904
904#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS 905#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
905 906
906 struct dentry *ignore_gfp_highmem_file; 907 struct dentry *ignore_gfp_highmem_file;
907 struct dentry *ignore_gfp_wait_file; 908 struct dentry *ignore_gfp_wait_file;
909 struct dentry *min_order_file;
908 910
909#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ 911#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
910 912
@@ -912,6 +914,7 @@ static struct fail_page_alloc_attr {
912 .attr = FAULT_ATTR_INITIALIZER, 914 .attr = FAULT_ATTR_INITIALIZER,
913 .ignore_gfp_wait = 1, 915 .ignore_gfp_wait = 1,
914 .ignore_gfp_highmem = 1, 916 .ignore_gfp_highmem = 1,
917 .min_order = 1,
915}; 918};
916 919
917static int __init setup_fail_page_alloc(char *str) 920static int __init setup_fail_page_alloc(char *str)
@@ -922,6 +925,8 @@ __setup("fail_page_alloc=", setup_fail_page_alloc);
922 925
923static int should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) 926static int should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
924{ 927{
928 if (order < fail_page_alloc.min_order)
929 return 0;
925 if (gfp_mask & __GFP_NOFAIL) 930 if (gfp_mask & __GFP_NOFAIL)
926 return 0; 931 return 0;
927 if (fail_page_alloc.ignore_gfp_highmem && (gfp_mask & __GFP_HIGHMEM)) 932 if (fail_page_alloc.ignore_gfp_highmem && (gfp_mask & __GFP_HIGHMEM))
@@ -953,12 +958,17 @@ static int __init fail_page_alloc_debugfs(void)
953 fail_page_alloc.ignore_gfp_highmem_file = 958 fail_page_alloc.ignore_gfp_highmem_file =
954 debugfs_create_bool("ignore-gfp-highmem", mode, dir, 959 debugfs_create_bool("ignore-gfp-highmem", mode, dir,
955 &fail_page_alloc.ignore_gfp_highmem); 960 &fail_page_alloc.ignore_gfp_highmem);
961 fail_page_alloc.min_order_file =
962 debugfs_create_u32("min-order", mode, dir,
963 &fail_page_alloc.min_order);
956 964
957 if (!fail_page_alloc.ignore_gfp_wait_file || 965 if (!fail_page_alloc.ignore_gfp_wait_file ||
958 !fail_page_alloc.ignore_gfp_highmem_file) { 966 !fail_page_alloc.ignore_gfp_highmem_file ||
967 !fail_page_alloc.min_order_file) {
959 err = -ENOMEM; 968 err = -ENOMEM;
960 debugfs_remove(fail_page_alloc.ignore_gfp_wait_file); 969 debugfs_remove(fail_page_alloc.ignore_gfp_wait_file);
961 debugfs_remove(fail_page_alloc.ignore_gfp_highmem_file); 970 debugfs_remove(fail_page_alloc.ignore_gfp_highmem_file);
971 debugfs_remove(fail_page_alloc.min_order_file);
962 cleanup_fault_attr_dentries(&fail_page_alloc.attr); 972 cleanup_fault_attr_dentries(&fail_page_alloc.attr);
963 } 973 }
964 974