diff options
Diffstat (limited to 'mm/hwpoison-inject.c')
| -rw-r--r-- | mm/hwpoison-inject.c | 19 | 
1 files changed, 10 insertions, 9 deletions
diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c index 0948f1072d6..95487c71cad 100644 --- a/mm/hwpoison-inject.c +++ b/mm/hwpoison-inject.c @@ -1,4 +1,4 @@ -/* Inject a hwpoison memory failure on a arbitary pfn */ +/* Inject a hwpoison memory failure on a arbitrary pfn */  #include <linux/module.h>  #include <linux/debugfs.h>  #include <linux/kernel.h> @@ -20,8 +20,6 @@ static int hwpoison_inject(void *data, u64 val)  	if (!capable(CAP_SYS_ADMIN))  		return -EPERM; -	if (!hwpoison_filter_enable) -		goto inject;  	if (!pfn_valid(pfn))  		return -ENXIO; @@ -33,6 +31,9 @@ static int hwpoison_inject(void *data, u64 val)  	if (!get_page_unless_zero(hpage))  		return 0; +	if (!hwpoison_filter_enable) +		goto inject; +  	if (!PageLRU(p) && !PageHuge(p))  		shake_page(p, 0);  	/* @@ -45,7 +46,7 @@ static int hwpoison_inject(void *data, u64 val)  	 * do a racy check with elevated page count, to make sure PG_hwpoison  	 * will only be set for the targeted owner (or on a free page).  	 * We temporarily take page lock for try_get_mem_cgroup_from_page(). -	 * __memory_failure() will redo the check reliably inside page lock. +	 * memory_failure() will redo the check reliably inside page lock.  	 */  	lock_page(hpage);  	err = hwpoison_filter(hpage); @@ -54,8 +55,8 @@ static int hwpoison_inject(void *data, u64 val)  		return 0;  inject: -	printk(KERN_INFO "Injecting memory failure at pfn %lx\n", pfn); -	return __memory_failure(pfn, 18, MF_COUNT_INCREASED); +	pr_info("Injecting memory failure at pfn %#lx\n", pfn); +	return memory_failure(pfn, 18, MF_COUNT_INCREASED);  }  static int hwpoison_unpoison(void *data, u64 val) @@ -88,12 +89,12 @@ static int pfn_inject_init(void)  	 * hardware status change, hence do not require hardware support.  	 * They are mainly for testing hwpoison in software level.  	 */ -	dentry = debugfs_create_file("corrupt-pfn", 0600, hwpoison_dir, +	dentry = debugfs_create_file("corrupt-pfn", 0200, hwpoison_dir,  					  NULL, &hwpoison_fops);  	if (!dentry)  		goto fail; -	dentry = debugfs_create_file("unpoison-pfn", 0600, hwpoison_dir, +	dentry = debugfs_create_file("unpoison-pfn", 0200, hwpoison_dir,  				     NULL, &unpoison_fops);  	if (!dentry)  		goto fail; @@ -123,7 +124,7 @@ static int pfn_inject_init(void)  	if (!dentry)  		goto fail; -#ifdef	CONFIG_CGROUP_MEM_RES_CTLR_SWAP +#ifdef CONFIG_MEMCG_SWAP  	dentry = debugfs_create_u64("corrupt-filter-memcg", 0600,  				    hwpoison_dir, &hwpoison_filter_memcg);  	if (!dentry)  | 
