EXP rcuscale: Add crude tests for mem_dump_obj()
Hello Paul E. McKenney,
The patch b3a539cc4d37: "EXP rcuscale: Add crude tests for mem_dump_obj()" from Dec 7, 2020, leads to the following static checker warning:
kernel/rcu/rcutorture.c:1888 rcu_torture_stats()
warn: did you mean to pass the address of 'rhp'
kernel/rcu/rcutorture.c
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);
^^^^Hopefully the address of rhp doesn't change at all in this function 0_0!
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 }
regards,
dan carpenter
Paul E. McKenney
maintainerQuoted 19 lines · Dan Carpenter
Hello Paul E. McKenney,
The patch
b3a539cc4d37: "EXP rcuscale: Add crude tests formem_dump_obj()" from Dec 7, 2020, leads to the following static checker warning:
kernel/rcu/rcutorture.c:1888rcu_torture_stats()
warn: did you mean to pass the address of 'rhp'
kernel/rcu/rcutorture.c
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); ^^^^
Quoted 1 line
Hopefully the address of rhp doesn't change at all in this function 0_0!
One would hope!
The duplication makes it easier to check the output. Without it, it is necessary to get some information from the immediately preceding pr_alert() and others of it from the first pr_alert().
Thanx, Paul
Quoted 32 lines
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 }
regards,
dan carpenter