History

rcutorture: Add crude tests for mem_dump_obj()

This commit adds a few crude tests for mem_dump_obj() to rcutorture runs. Just to prevent bitrot, you understand!

Paul E. McKenney committed 5 years ago

Commit 0d3dd2c1 parent 5bb1bb33 files · +42 −0Browse files

Unified · Split

3 files
  1. kernel/rcu/rcutorture.c +39 −0
  2. mm/slab_common.c +2 −0
  3. mm/util.c +1 −0
kernel/rcu/rcutorture.c+39−0
@@ -1861,6 +1861,45 @@ rcu_torture_stats(void *arg) · 1860 unmodified lines
1861 torture_shutdown_absorb("rcu_torture_stats");1861 torture_shutdown_absorb("rcu_torture_stats");
1862 } while (!torture_must_stop());1862 } while (!torture_must_stop());
1863 torture_kthread_stopping("rcu_torture_stats");1863 torture_kthread_stopping("rcu_torture_stats");
1864
1865 {
1866 struct rcu_head *rhp;
1867 struct kmem_cache *kcp;
1868 static int z;
1869
1870 kcp = kmem_cache_create("rcuscale", 136, 8, SLAB_STORE_USER, NULL);
1871 rhp = kmem_cache_alloc(kcp, GFP_KERNEL);
1872 pr_alert("mem_dump_obj() slab test: rcu_torture_stats = %px, &rhp = %px, rhp = %px, &z = %px\n", stats_task, &rhp, rhp, &z);
1873 pr_alert("mem_dump_obj(ZERO_SIZE_PTR):");
1874 mem_dump_obj(ZERO_SIZE_PTR);
1875 pr_alert("mem_dump_obj(NULL):");
1876 mem_dump_obj(NULL);
1877 pr_alert("mem_dump_obj(%px):", &rhp);
1878 mem_dump_obj(&rhp);
1879 pr_alert("mem_dump_obj(%px):", rhp);
1880 mem_dump_obj(rhp);
1881 pr_alert("mem_dump_obj(%px):", &rhp->func);
1882 mem_dump_obj(&rhp->func);
1883 pr_alert("mem_dump_obj(%px):", &z);
1884 mem_dump_obj(&z);
1885 kmem_cache_free(kcp, rhp);
1886 kmem_cache_destroy(kcp);
1887 rhp = kmalloc(sizeof(*rhp), GFP_KERNEL);
1888 pr_alert("mem_dump_obj() kmalloc test: rcu_torture_stats = %px, &rhp = %px, rhp = %px\n", stats_task, &rhp, rhp);
1889 pr_alert("mem_dump_obj(kmalloc %px):", rhp);
1890 mem_dump_obj(rhp);
1891 pr_alert("mem_dump_obj(kmalloc %px):", &rhp->func);
1892 mem_dump_obj(&rhp->func);
1893 kfree(rhp);
1894 rhp = vmalloc(4096);
1895 pr_alert("mem_dump_obj() vmalloc test: rcu_torture_stats = %px, &rhp = %px, rhp = %px\n", stats_task, &rhp, rhp);
1896 pr_alert("mem_dump_obj(vmalloc %px):", rhp);
1897 mem_dump_obj(rhp);
1898 pr_alert("mem_dump_obj(vmalloc %px):", &rhp->func);
1899 mem_dump_obj(&rhp->func);
1900 vfree(rhp);
1901 }
1902
1864 return 0;1903 return 0;
1865}1904}
1866 1905
mm/slab_common.c+2−0
@@ -545,6 +545,7 @@ bool kmem_valid_obj(void *object) · 544 unmodified lines
545 page = virt_to_head_page(object);545 page = virt_to_head_page(object);
546 return PageSlab(page);546 return PageSlab(page);
547}547}
548EXPORT_SYMBOL_GPL(kmem_valid_obj);
548 549
549/**550/**
550 * kmem_dump_obj - Print available slab provenance information551 * kmem_dump_obj - Print available slab provenance information
@@ -601,6 +602,7 @@ void kmem_dump_obj(void *object) · 50 unmodified lines
601 pr_info(" %pS\n", kp.kp_stack[i]);602 pr_info(" %pS\n", kp.kp_stack[i]);
602 }603 }
603}604}
605EXPORT_SYMBOL_GPL(kmem_dump_obj);
604#endif606#endif
605 607
606#ifndef CONFIG_SLOB608#ifndef CONFIG_SLOB
mm/util.c+1−0
@@ -1014,4 +1014,5 @@ void mem_dump_obj(void *object) · 1013 unmodified lines
1014 }1014 }
1015 pr_cont(" non-slab/vmalloc memory.\n");1015 pr_cont(" non-slab/vmalloc memory.\n");
1016}1016}
1017EXPORT_SYMBOL_GPL(mem_dump_obj);
1017#endif1018#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t