From ace8577aeb438025ecf642f5eda3aa551d251951 Mon Sep 17 00:00:00 2001 From: Sergey Senozhatsky Date: Tue, 10 Jan 2012 02:43:59 +0300 Subject: block_dev: Suppress bdev_cache_init() kmemleak warninig Kmemleak reports the following warning in bdev_cache_init() [ 0.003738] kmemleak: Object 0xffff880153035200 (size 256): [ 0.003823] kmemleak: comm "swapper/0", pid 0, jiffies 4294667299 [ 0.003909] kmemleak: min_count = 1 [ 0.003988] kmemleak: count = 0 [ 0.004066] kmemleak: flags = 0x1 [ 0.004144] kmemleak: checksum = 0 [ 0.004224] kmemleak: backtrace: [ 0.004303] [] kmemleak_alloc+0x21/0x3e [ 0.004446] [] kmem_cache_alloc+0xca/0x1dc [ 0.004592] [] alloc_vfsmnt+0x1f/0x198 [ 0.004736] [] vfs_kern_mount+0x36/0xd2 [ 0.004879] [] kern_mount_data+0x18/0x32 [ 0.005025] [] bdev_cache_init+0x51/0x81 [ 0.005169] [] vfs_caches_init+0x101/0x10d [ 0.005313] [] start_kernel+0x344/0x383 [ 0.005456] [] x86_64_start_reservations+0xae/0xb2 [ 0.005602] [] x86_64_start_kernel+0x102/0x111 [ 0.005747] [] 0xffffffffffffffff [ 0.008653] kmemleak: Trying to color unknown object at 0xffff880153035220 as Grey [ 0.008754] Pid: 0, comm: swapper/0 Not tainted 3.3.0-rc0-dbg-04200-g8180888-dirty #888 [ 0.008856] Call Trace: [ 0.008934] [] ? find_and_get_object+0x44/0x118 [ 0.009023] [] paint_ptr+0x57/0x8f [ 0.009109] [] kmemleak_not_leak+0x23/0x42 [ 0.009195] [] bdev_cache_init+0x72/0x81 [ 0.009282] [] vfs_caches_init+0x101/0x10d [ 0.009368] [] start_kernel+0x344/0x383 [ 0.009466] [] x86_64_start_reservations+0xae/0xb2 [ 0.009555] [] ? early_idt_handlers+0x140/0x140 [ 0.009643] [] x86_64_start_kernel+0x102/0x111 due to attempt to mark pointer to `struct vfsmount' as a gray object, which is embedded into `struct mount' returned from alloc_vfsmnt(). Make `bd_mnt' static, avoiding need to tell kmemleak to mark it gray, as suggested by Al Viro. Signed-off-by: Sergey Senozhatsky Signed-off-by: Al Viro --- fs/block_dev.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 69a5b6fbee2..afe74dda632 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include "internal.h" @@ -521,7 +520,7 @@ static struct super_block *blockdev_superblock __read_mostly; void __init bdev_cache_init(void) { int err; - struct vfsmount *bd_mnt; + static struct vfsmount *bd_mnt; bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode), 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| @@ -533,12 +532,7 @@ void __init bdev_cache_init(void) bd_mnt = kern_mount(&bd_type); if (IS_ERR(bd_mnt)) panic("Cannot create bdev pseudo-fs"); - /* - * This vfsmount structure is only used to obtain the - * blockdev_superblock, so tell kmemleak not to report it. - */ - kmemleak_not_leak(bd_mnt); - blockdev_superblock = bd_mnt->mnt_sb; /* For writeback */ + blockdev_superblock = bd_mnt->mnt_sb; /* For writeback */ } /* -- cgit v1.2.3