Hi, Observed memory leak while accessing /proc/fs/fscache/stats Kernel Version : 3.9.0-rc8 (Kmemleak enabled) Platform : ATCA board(X86) Steps to reproduce the memory leak 1. Build a Kmemleak enabled kernel 2. mount -t debugfs nodev /sys/kernel/debug/ 3. cat /proc/fs/fscache/stats 4. echo scan > /sys/kernel/debug/kmemleak 5. cat /sys/kernel/debug/kmemleak Its independent of the hardware. Can be reproduced on PC as well Step 5 will give the following memory leak information cat /sys/kernel/debug/kmemleak unreferenced object 0xecd04320 (size 32): comm "cat", pid 2457, jiffies 103889 (age 17.664s) hex dump (first 32 bytes): 70 09 23 c1 d0 09 23 c1 b0 09 23 c1 90 13 f4 f8 p.#...#...#..... 00 00 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ................ backtrace: [<c11ec610>] create_object+0x100/0x400 [<c16150f3>] kmemleak_alloc+0x73/0x120 [<c11e42ec>] kmem_cache_alloc+0x1bc/0x310 [<c1232633>] single_open+0x33/0xf0 [<f8f4137f>] fscache_stats_open+0x1f/0x30 [fscache] [<c128c491>] proc_reg_open+0xe1/0x230 [<c11efef6>] do_dentry_open+0x446/0x550 [<c11f01c4>] finish_open+0x34/0x80 [<c120dab1>] do_last+0x8e1/0x1a90 [<c120ed66>] path_openat+0x106/0x7c0 [<c12102ca>] do_filp_open+0x3a/0xd0 [<c11f24c3>] do_sys_open+0x1a3/0x370 [<c11f26c1>] sys_open+0x31/0x50 [<c164a086>] sysenter_do_call+0x12/0x28 [<ffffffff>] 0xffffffff Shyju
The kernel memory leak observed is when the proc file /proc/fs/fscache/stats is read. The reason is that in fscache_stats_open, single_open is called and respective release function is not called during release. Hence fix with correct release function - single_release. The patch is as below diff -uprN -X linux-3.9-rc8-vanilla/Documentation/dontdiff linux-3.9-rc8-vanilla/fs/fscache/stats.c linux-3.9-rc8.mod/fs/fscache/stats.c --- linux-3.9-rc8-vanilla/fs/fscache/stats.c 2013-04-22 03:08:45.000000000 +0530 +++ linux-3.9-rc8.mod/fs/fscache/stats.c 2013-04-24 23:03:31.531296160 +0530 @@ -287,5 +287,5 @@ const struct file_operations fscache_sta .open = fscache_stats_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = single_release, }; --Anurup M
The mail with the patch has been send to LKML --Anurup M
The issue is fixed and merged to mainline. please see git commit: ec686c92 @shyju, Please valdiate and close the bug..
It has been done. Merged in kernel stable trees by Greg