Revision 15cf17d26e08ee95c2e392a3a71f55d32e99e971 authored by Konstantin Khlebnikov on 08 March 2013, 20:43:36 UTC, committed by Linus Torvalds on 08 March 2013, 23:05:34 UTC
Fix a warning from lockdep caused by calling cancel_work_sync() for
uninitialized struct work.  This path has been triggered by destructon
kmem-cache hierarchy via destroying its root kmem-cache.

  cache ffff88003c072d80
  obj ffff88003b410000 cache ffff88003c072d80
  obj ffff88003b924000 cache ffff88003c20bd40
  INFO: trying to register non-static key.
  the code is fine but needs lockdep annotation.
  turning off the locking correctness validator.
  Pid: 2825, comm: insmod Tainted: G           O 3.9.0-rc1-next-20130307+ #611
  Call Trace:
    __lock_acquire+0x16a2/0x1cb0
    lock_acquire+0x8a/0x120
    flush_work+0x38/0x2a0
    __cancel_work_timer+0x89/0xf0
    cancel_work_sync+0xb/0x10
    kmem_cache_destroy_memcg_children+0x81/0xb0
    kmem_cache_destroy+0xf/0xe0
    init_module+0xcb/0x1000 [kmem_test]
    do_one_initcall+0x11a/0x170
    load_module+0x19b0/0x2320
    SyS_init_module+0xc6/0xf0
    system_call_fastpath+0x16/0x1b

Example module to demonstrate:

  #include <linux/module.h>
  #include <linux/slab.h>
  #include <linux/mm.h>
  #include <linux/workqueue.h>

  int __init mod_init(void)
  {
  	int size = 256;
  	struct kmem_cache *cache;
  	void *obj;
  	struct page *page;

  	cache = kmem_cache_create("kmem_cache_test", size, size, 0, NULL);
  	if (!cache)
  		return -ENOMEM;

  	printk("cache %p\n", cache);

  	obj = kmem_cache_alloc(cache, GFP_KERNEL);
  	if (obj) {
  		page = virt_to_head_page(obj);
  		printk("obj %p cache %p\n", obj, page->slab_cache);
  		kmem_cache_free(cache, obj);
  	}

  	flush_scheduled_work();

  	obj = kmem_cache_alloc(cache, GFP_KERNEL);
  	if (obj) {
  		page = virt_to_head_page(obj);
  		printk("obj %p cache %p\n", obj, page->slab_cache);
  		kmem_cache_free(cache, obj);
  	}

  	kmem_cache_destroy(cache);

  	return -EBUSY;
  }

  module_init(mod_init);
  MODULE_LICENSE("GPL");

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Glauber Costa <glommer@parallels.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 755727b
History
File Mode Size
caching
configfs
nfs
pohmelfs
00-INDEX -rw-r--r-- 4.0 KB
9p.txt -rw-r--r-- 5.6 KB
Locking -rw-r--r-- 22.0 KB
Makefile -rw-r--r-- 217 bytes
adfs.txt -rw-r--r-- 2.6 KB
affs.txt -rw-r--r-- 8.0 KB
afs.txt -rw-r--r-- 7.8 KB
autofs4-mount-control.txt -rw-r--r-- 17.3 KB
automount-support.txt -rw-r--r-- 4.6 KB
befs.txt -rw-r--r-- 3.5 KB
bfs.txt -rw-r--r-- 2.1 KB
btrfs.txt -rw-r--r-- 2.8 KB
ceph.txt -rw-r--r-- 5.6 KB
cifs.txt -rw-r--r-- 2.3 KB
coda.txt -rw-r--r-- 48.6 KB
cramfs.txt -rw-r--r-- 2.5 KB
debugfs.txt -rw-r--r-- 8.1 KB
devpts.txt -rw-r--r-- 5.0 KB
directory-locking -rw-r--r-- 5.0 KB
dlmfs.txt -rw-r--r-- 4.2 KB
dnotify.txt -rw-r--r-- 2.9 KB
dnotify_test.c -rw-r--r-- 772 bytes
ecryptfs.txt -rw-r--r-- 2.3 KB
efivarfs.txt -rw-r--r-- 612 bytes
exofs.txt -rw-r--r-- 8.5 KB
ext2.txt -rw-r--r-- 17.9 KB
ext3.txt -rw-r--r-- 7.8 KB
ext4.txt -rw-r--r-- 25.8 KB
f2fs.txt -rw-r--r-- 18.8 KB
fiemap.txt -rw-r--r-- 9.4 KB
files.txt -rw-r--r-- 4.1 KB
fuse.txt -rw-r--r-- 15.8 KB
gfs2-glocks.txt -rw-r--r-- 10.5 KB
gfs2-uevents.txt -rw-r--r-- 3.7 KB
gfs2.txt -rw-r--r-- 1.8 KB
hfs.txt -rw-r--r-- 2.9 KB
hfsplus.txt -rw-r--r-- 1.7 KB
hpfs.txt -rw-r--r-- 14.8 KB
inotify.txt -rw-r--r-- 10.7 KB
isofs.txt -rw-r--r-- 2.5 KB
jfs.txt -rw-r--r-- 2.3 KB
locks.txt -rw-r--r-- 2.7 KB
logfs.txt -rw-r--r-- 9.6 KB
mandatory-locking.txt -rw-r--r-- 8.0 KB
ncpfs.txt -rw-r--r-- 574 bytes
nilfs2.txt -rw-r--r-- 8.1 KB
ntfs.txt -rw-r--r-- 31.3 KB
ocfs2.txt -rw-r--r-- 4.3 KB
omfs.txt -rw-r--r-- 4.0 KB
path-lookup.txt -rw-r--r-- 18.4 KB
porting -rw-r--r-- 16.0 KB
proc.txt -rw-r--r-- 78.9 KB
qnx6.txt -rw-r--r-- 7.1 KB
quota.txt -rw-r--r-- 3.1 KB
ramfs-rootfs-initramfs.txt -rw-r--r-- 15.8 KB
relay.txt -rw-r--r-- 21.1 KB
romfs.txt -rw-r--r-- 8.3 KB
seq_file.txt -rw-r--r-- 12.0 KB
sharedsubtree.txt -rw-r--r-- 29.0 KB
spufs.txt -rw-r--r-- 20.3 KB
squashfs.txt -rw-r--r-- 10.4 KB
sysfs-pci.txt -rw-r--r-- 5.2 KB
sysfs-tagging.txt -rw-r--r-- 1.8 KB
sysfs.txt -rw-r--r-- 11.6 KB
sysv-fs.txt -rw-r--r-- 7.4 KB
tmpfs.txt -rw-r--r-- 6.5 KB
ubifs.txt -rw-r--r-- 5.1 KB
udf.txt -rw-r--r-- 3.4 KB
ufs.txt -rw-r--r-- 1.2 KB
vfat.txt -rw-r--r-- 14.2 KB
vfs.txt -rw-r--r-- 48.4 KB
xfs-delayed-logging-design.txt -rw-r--r-- 40.5 KB
xfs.txt -rw-r--r-- 10.4 KB
xip.txt -rw-r--r-- 3.0 KB

back to top