Minor kmemleak report via bdev_cache_init
Hi Denis,
With the commit c2acf7b908217 (fs/block_dev.c: __read_mostly improvement and sb_is_blkdev_sb utilization), the bd_mnt is only local and kmemleak reports the corresponding vfsmnt structure as unreferenced (together with the duplicated name) since it can no longer track a valid pointer to it:
unreferenced object 0xdf813848 (size 128):
comm "swapper", pid 0, jiffies 4294937384
backtrace:
[<c00872c0>] kmemleak_alloc+0x144/0x27c
[<c00848c8>] kmem_cache_alloc+0x108/0x13c
[<c009fc00>] alloc_vfsmnt+0x20/0x144
[<c008bc34>] vfs_kern_mount+0x30/0xac
[<c008bccc>] kern_mount_data+0x1c/0x20
[<c00104a8>] bdev_cache_init+0x54/0x90
[<c000fd7c>] vfs_caches_init+0xfc/0x128
[<c0008984>] start_kernel+0x1f8/0x254
unreferenced object 0xdf8033d0 (size 32):
comm "swapper", pid 0, jiffies 4294937384
backtrace:
[<c00872c0>] kmemleak_alloc+0x144/0x27c
[<c0085e10>] __kmalloc_track_caller+0x15c/0x194
[<c0071704>] kstrdup+0x3c/0x58
[<c009fc5c>] alloc_vfsmnt+0x7c/0x144
[<c008bc34>] vfs_kern_mount+0x30/0xac
[<c008bccc>] kern_mount_data+0x1c/0x20
[<c00104a8>] bdev_cache_init+0x54/0x90
[<c000fd7c>] vfs_caches_init+0xfc/0x128
[<c0008984>] start_kernel+0x1f8/0x254 Can this object be freed (as below) or should I just tell kmemleak to ignore it (or is it referenced and that's a kmemleak false positive)?
fs/block_dev.c +1 -0
@@ -344,6 +344,7 @@ void __init bdev_cache_init(void)if (IS_ERR (bd_mnt))panic ("Cannot create bdev pseudo-fs" ); blockdev_superblock = bd_mnt->mnt_sb;/* For writeback */ +free_vfsmnt (bd_mnt); }/*
Thanks.
Signature · 1 line
Catalin
Quoted 41 lines · On Tue, 06 Jan 2009 18:25:34 +0000 Catalin Marinas <[email protected]>…
Hi Denis,
With the commit
c2acf7b908217(fs/block_dev.c:__read_mostlyimprovement andsb_is_blkdev_sbutilization), thebd_mntis only local and kmemleak reports the corresponding vfsmnt structure as unreferenced (together with the duplicated name) since it can no longer track a valid pointer to it:unreferenced object
0xdf813848(size 128):
comm "swapper", pid 0, jiffies 4294937384
backtrace:[<c00872c0>] kmemleak_alloc+0x144/0x27c [<c00848c8>] kmem_cache_alloc+0x108/0x13c [<c009fc00>] alloc_vfsmnt+0x20/0x144 [<c008bc34>] vfs_kern_mount+0x30/0xac [<c008bccc>] kern_mount_data+0x1c/0x20 [<c00104a8>] bdev_cache_init+0x54/0x90 [<c000fd7c>] vfs_caches_init+0xfc/0x128 [<c0008984>] start_kernel+0x1f8/0x254 unreferenced object 0xdf8033d0 (size 32): comm "swapper", pid 0, jiffies 4294937384 backtrace: [<c00872c0>] kmemleak_alloc+0x144/0x27c [<c0085e10>] __kmalloc_track_caller+0x15c/0x194 [<c0071704>] kstrdup+0x3c/0x58 [<c009fc5c>] alloc_vfsmnt+0x7c/0x144 [<c008bc34>] vfs_kern_mount+0x30/0xac [<c008bccc>] kern_mount_data+0x1c/0x20 [<c00104a8>] bdev_cache_init+0x54/0x90 [<c000fd7c>] vfs_caches_init+0xfc/0x128 [<c0008984>] start_kernel+0x1f8/0x254Can this object be freed (as below) or should I just tell kmemleak to ignore it (or is it referenced and that's a kmemleak false positive)?
fs/block_dev.c +0
-0
fs/block_dev.c void __init bdev_cache_init(void) · line 349
Quoted 6 lines
fs/block_dev.c +1
-0@@ -344,6 +344,7 @@ void __init bdev_cache_init(void)if (IS_ERR (bd_mnt))panic ("Cannot create bdev pseudo-fs" ); blockdev_superblock = bd_mnt->mnt_sb;/* For writeback */ +free_vfsmnt (bd_mnt); }
hm, yes, well, we might be able to get away with that - the kernel holds onto bd_mnt->mnt_sb for internal use for all time, but we don't directly use that vfsmount for anything after we've constructed blockdev_superblock.
However there might well be things under blockdev_superblock which point back at this vfsmount - dunno, I didn't check.
Cheng Renquan
Acked-byQuoted 59 lines · Andrew Morton
Quoted 41 lines · On Tue, 06 Jan 2009 18:25:34 +0000 Catalin Marinas <[email protected]>…
Hi Denis,
With the commit
c2acf7b908217(fs/block_dev.c:__read_mostlyimprovement andsb_is_blkdev_sbutilization), thebd_mntis only local and kmemleak reports the corresponding vfsmnt structure as unreferenced (together with the duplicated name) since it can no longer track a valid pointer to it:unreferenced object
0xdf813848(size 128):
comm "swapper", pid 0, jiffies 4294937384
backtrace:[<c00872c0>] kmemleak_alloc+0x144/0x27c [<c00848c8>] kmem_cache_alloc+0x108/0x13c [<c009fc00>] alloc_vfsmnt+0x20/0x144 [<c008bc34>] vfs_kern_mount+0x30/0xac [<c008bccc>] kern_mount_data+0x1c/0x20 [<c00104a8>] bdev_cache_init+0x54/0x90 [<c000fd7c>] vfs_caches_init+0xfc/0x128 [<c0008984>] start_kernel+0x1f8/0x254 unreferenced object 0xdf8033d0 (size 32): comm "swapper", pid 0, jiffies 4294937384 backtrace: [<c00872c0>] kmemleak_alloc+0x144/0x27c [<c0085e10>] __kmalloc_track_caller+0x15c/0x194 [<c0071704>] kstrdup+0x3c/0x58 [<c009fc5c>] alloc_vfsmnt+0x7c/0x144 [<c008bc34>] vfs_kern_mount+0x30/0xac [<c008bccc>] kern_mount_data+0x1c/0x20 [<c00104a8>] bdev_cache_init+0x54/0x90 [<c000fd7c>] vfs_caches_init+0xfc/0x128 [<c0008984>] start_kernel+0x1f8/0x254Can this object be freed (as below) or should I just tell kmemleak to ignore it (or is it referenced and that's a kmemleak false positive)?
fs/block_dev.c +0
-0fs/block_dev.c void __init bdev_cache_init(void) · line 348
Quoted 5 lines
fs/block_dev.c +1
-0@@ -344,6 +344,7 @@ void __init bdev_cache_init(void)if (IS_ERR (bd_mnt))panic ("Cannot create bdev pseudo-fs" ); blockdev_superblock = bd_mnt->mnt_sb;/* For writeback */ +free_vfsmnt (bd_mnt); }hm, yes, well, we might be able to get away with that - the kernel holds onto
bd_mnt->mnt_sbfor internal use for all time, but we don't directly use that vfsmount for anything after we've constructedblockdev_superblock.
Quoted 2 lines
However there might well be things under
blockdev_superblockwhich point back at this vfsmount - dunno, I didn't check.
I've checked that, the blockdev_superblock doesn't have a back pointer to vfsmount indeed, and can never use vfsmount anymore, although generally it needs more testing.
To Al Viro: by this checking I found more vfsmount's not used, too, in some other kern_mount'ed vfsmount, such as pipefs, sockfs, ipc mqueue, selinux, smackfs, besides bdevfs, in such situations also only superblock is used, the vfsmount only used as kern_mount and never used anymore.
So maybe we can do some more cleanup. Patches will be sent later.
Signature · 3 lines
Denis, Cheng Renquan (程任全), Shenzhen, China Bob Hope - "I grew up with six brothers. That's how I learned to dance - waiting for the bathroom."