rcutorture: Handle failure of memory allocation functions
This commit adds warnings for allocation failure during the mem_dump_obj() tests. It also terminates these tests upon such failure. Signed-off-by: Li Qiong <liqiong@nfschina.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
parent
3002153a91
commit
1a5ca5e098
@ -1991,7 +1991,13 @@ static void rcu_torture_mem_dump_obj(void)
|
||||
static int z;
|
||||
|
||||
kcp = kmem_cache_create("rcuscale", 136, 8, SLAB_STORE_USER, NULL);
|
||||
if (WARN_ON_ONCE(!kcp))
|
||||
return;
|
||||
rhp = kmem_cache_alloc(kcp, GFP_KERNEL);
|
||||
if (WARN_ON_ONCE(!rhp)) {
|
||||
kmem_cache_destroy(kcp);
|
||||
return;
|
||||
}
|
||||
pr_alert("mem_dump_obj() slab test: rcu_torture_stats = %px, &rhp = %px, rhp = %px, &z = %px\n", stats_task, &rhp, rhp, &z);
|
||||
pr_alert("mem_dump_obj(ZERO_SIZE_PTR):");
|
||||
mem_dump_obj(ZERO_SIZE_PTR);
|
||||
@ -2008,6 +2014,8 @@ static void rcu_torture_mem_dump_obj(void)
|
||||
kmem_cache_free(kcp, rhp);
|
||||
kmem_cache_destroy(kcp);
|
||||
rhp = kmalloc(sizeof(*rhp), GFP_KERNEL);
|
||||
if (WARN_ON_ONCE(!rhp))
|
||||
return;
|
||||
pr_alert("mem_dump_obj() kmalloc test: rcu_torture_stats = %px, &rhp = %px, rhp = %px\n", stats_task, &rhp, rhp);
|
||||
pr_alert("mem_dump_obj(kmalloc %px):", rhp);
|
||||
mem_dump_obj(rhp);
|
||||
@ -2015,6 +2023,8 @@ static void rcu_torture_mem_dump_obj(void)
|
||||
mem_dump_obj(&rhp->func);
|
||||
kfree(rhp);
|
||||
rhp = vmalloc(4096);
|
||||
if (WARN_ON_ONCE(!rhp))
|
||||
return;
|
||||
pr_alert("mem_dump_obj() vmalloc test: rcu_torture_stats = %px, &rhp = %px, rhp = %px\n", stats_task, &rhp, rhp);
|
||||
pr_alert("mem_dump_obj(vmalloc %px):", rhp);
|
||||
mem_dump_obj(rhp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user