Skip to contentSkip to conversation

task containersv11 kernel BUG at include/linux/dcache.h:323

PATCH Paul Jackson 2 participants 5 messages Sep 16, 2007 – Sep 18, 2007 VFS

lore
Share & tools
lore
#0 lore raw

Paul Menage,

When I run a cpuset creation/destruction stress test I have against the 2.6.23-rc4-mm1 kernel with the task-containersv11-* patches, I get an BUG or similar within a couple of seconds, apparently over some fs lock or count confusions.

When I add Andrew Morton's (Thanks, Andrew!) very recent patch:

fs/dcache.c 2007-09-15 09:48:40.306230196 -0700 renamed from fs/dcache.c 2007-09-14 21:30:19.504902465 -0700 +1 -0
@@ -176,6 +176,7 @@ void dput(struct dentry *dentry)
        if (!dentry)
                return;
 
+       WARN_ON_ONCE(!atomic_read(&dentry->d_count));
 repeat:
        if (atomic_read(&dentry->d_count) == 1)
                might_sleep();

... then I get a warning first from the above line, resulting in the following messages, showing the warning and then the subsequent BUG:

Sep 15 21:41:45 margin kernel: WARNING: at fs/dcache.c:179 dput()
Sep 15 21:41:45 margin kernel:
Sep 15 21:41:45 margin kernel: Call Trace:
Sep 15 21:41:45 margin kernel:  [<a0000001000139c0>] show_stack+0x40/0xa0
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fbd0 bsp=e00000b050038e20
Sep 15 21:41:45 margin kernel:  [<a000000100013a50>] dump_stack+0x30/0x60
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fda0 bsp=e00000b050038e08
Sep 15 21:41:45 margin kernel:  [<a0000001001a60c0>] dput+0xa0/0x420
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fda0 bsp=e00000b050038dd8
Sep 15 21:41:45 margin kernel:  [<a000000100193f00>] do_rmdir+0x160/0x200
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fda0 bsp=e00000b050038da0
Sep 15 21:41:45 margin kernel:  [<a000000100194070>] sys_rmdir+0x30/0x60
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fe30 bsp=e00000b050038d48
Sep 15 21:41:45 margin kernel:  [<a00000010000af80>] ia64_ret_from_syscall+0x0/0x20
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fe30 bsp=e00000b050038d48
Sep 15 21:41:45 margin kernel:  [<a000000000010620>] __kernel_syscall_via_break+0x0/0x20
Sep 15 21:41:45 margin kernel:                                 sp=e00000b050040000 bsp=e00000b050038d48
Sep 15 21:41:46 margin kernel: kernel BUG at include/linux/dcache.h:323!
Sep 15 21:41:46 margin kernel: cpuset_creation[5590]: bugcheck! 0 [1]
Sep 15 21:41:46 margin kernel: Modules linked in:
Sep 15 21:41:46 margin kernel:
Sep 15 21:41:46 margin kernel: Pid: 5590, CPU 0, comm:      cpuset_creation
Sep 15 21:41:46 margin kernel: psr : 00001010085a6010 ifs : 800000000000048c ip  : [<a000000100193280>]    Not tainted
Sep 15 21:41:46 margin kernel: ip is at do_path_lookup+0x480/0x540
Sep 15 21:41:46 margin kernel: unat: 0000000000000000 pfs : 000000000000048c rsc : 0000000000000003
Sep 15 21:41:46 margin kernel: rnat: 0000000000000000 bsps: 0000000000000000 pr  : 000000000055a959
Sep 15 21:41:46 margin kernel: ldrs: 0000000000000000 ccv : 0000000000000000 fpsr: 0009804c0270033f
Sep 15 21:41:46 margin kernel: csd : 0000000000000000 ssd : 0000000000000000
Sep 15 21:41:46 margin kernel: b0  : a000000100193280 b6  : a000000100093960 b7  : a00000010000f0b0
Sep 15 21:41:46 margin kernel: f6  : 1003e0000000000000000 f7  : 000000000000000000000
Sep 15 21:41:46 margin kernel: f8  : 000000000000000000000 f9  : 1003e000000000001c000
Sep 15 21:41:46 margin kernel: f10 : 1003e0000000000000070 f11 : 1003e0000000000000400
Sep 15 21:41:46 margin kernel: r1  : a000000101074460 r2  : e000003016fa0ce0 r3  : 0000000000000002
Sep 15 21:41:46 margin kernel: r8  : 000000000000002d r9  : 0000000000004000 r10 : e000003003105619
Sep 15 21:41:46 margin kernel: r11 : e000003003110000 r12 : e000003016fa7d80 r13 : e000003016fa0000
Sep 15 21:41:46 margin kernel: r14 : 0000000000000000 r15 : e000003016fa0cf0 r16 : e000003016fa0d08
Sep 15 21:41:46 margin kernel: r17 : e00001b008397e18 r18 : 0000000000000001 r19 : e00000300310561b
Sep 15 21:41:46 margin kernel: r20 : 0000000000004000 r21 : 0000000000004000 r22 : e000003003110000
Sep 15 21:41:46 margin kernel: r23 : ffffffffffff0428 r24 : 0000018110000380 r25 : 0000018000000000
Sep 15 21:41:46 margin kernel: r26 : e000003016fa0cf0 r27 : e000003016fa0ce0 r28 : e000003016fa0d08
Sep 15 21:41:46 margin kernel: r29 : 0000000000000001 r30 : 0000000000000002 r31 : 0000000000001060
Sep 15 21:41:46 margin kernel:
Sep 15 21:41:46 margin kernel: Call Trace:
Sep 15 21:41:46 margin kernel:  [<a0000001000139c0>] show_stack+0x40/0xa0
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7950 bsp=e000003016fa10d0
Sep 15 21:41:47 margin kernel:  [<a0000001000142c0>] show_regs+0x840/0x880
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7b20 bsp=e000003016fa1078
Sep 15 21:41:47 margin kernel:  [<a0000001000362a0>] die+0x220/0x300
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7b20 bsp=e000003016fa1030
Sep 15 21:41:47 margin kernel:  [<a0000001000363d0>] die_if_kernel+0x50/0x80
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7b20 bsp=e000003016fa1000
Sep 15 21:41:47 margin kernel:  [<a000000100037af0>] ia64_bad_break+0x230/0x480
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7b20 bsp=e000003016fa0fd0
Sep 15 21:41:47 margin kernel:  [<a00000010000b120>] ia64_leave_kernel+0x0/0x280
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7bb0 bsp=e000003016fa0fd0
Sep 15 21:41:47 margin kernel:  [<a000000100193280>] do_path_lookup+0x480/0x540
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7d80 bsp=e000003016fa0f70
Sep 15 21:41:47 margin kernel:  [<a000000100194ac0>] __path_lookup_intent_open+0x80/0x120
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7d90 bsp=e000003016fa0f18
Sep 15 21:41:47 margin kernel:  [<a000000100194c60>] path_lookup_open+0x40/0x60
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7d90 bsp=e000003016fa0ed8
Sep 15 21:41:47 margin kernel:  [<a000000100194f30>] open_namei+0xb0/0xf80
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7d90 bsp=e000003016fa0e70
Sep 15 21:41:47 margin kernel:  [<a000000100177a10>] do_filp_open+0x50/0xc0
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7da0 bsp=e000003016fa0e38
Sep 15 21:41:47 margin kernel:  [<a000000100177b00>] do_sys_open+0x80/0x1c0
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7e30 bsp=e000003016fa0de0
Sep 15 21:41:47 margin kernel:  [<a000000100177d10>] sys_open+0x50/0x80
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7e30 bsp=e000003016fa0d88
Sep 15 21:41:47 margin kernel:  [<a00000010000af80>] ia64_ret_from_syscall+0x0/0x20
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7e30 bsp=e000003016fa0d88
Sep 15 21:41:47 margin kernel:  [<a000000000010620>] __kernel_syscall_via_break+0x0/0x20
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa8000 bsp=e000003016fa0d88
Sep 15 21:41:47 margin kernel: note: cpuset_creation[5590] exited with preempt_count 1

===

Can you figure out where this is coming from? It is not in code that I understand all that well, so I am hoping that I don't have to spend hours poking around in it to make sense of the problem.

Signature · 3 lines
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <[email protected]> 1.650.933.1373
#1 lore raw

This is already fixed in -mm - see

task-containersv11-basic-task-container-framework-containers-fix-refcount-bug.patch task-containersv11-add-container_clone-interface-containers-fix-refcount-bug.patch

Paul

Quoted 111 lines · Paul Jackson

Paul Menage,

When I run a cpuset creation/destruction stress test I have against the 2.6.23-rc4-mm1 kernel with the task-containersv11-* patches, I get an BUG or similar within a couple of seconds, apparently over some fs lock or count confusions.

When I add Andrew Morton's (Thanks, Andrew!) very recent patch:

fs/dcache.c 2007-09-15 09:48:40.306230196 -0700 renamed from fs/dcache.c 2007-09-14 21:30:19.504902465 -0700 +1 -0
@@ -176,6 +176,7 @@ void dput(struct dentry *dentry)
        if (!dentry)
                return;
 
+       WARN_ON_ONCE(!atomic_read(&dentry->d_count));
 repeat:
        if (atomic_read(&dentry->d_count) == 1)
                might_sleep();

... then I get a warning first from the above line, resulting in the following messages, showing the warning and then the subsequent BUG:

Sep 15 21:41:45 margin kernel: WARNING: at fs/dcache.c:179 dput()
Sep 15 21:41:45 margin kernel:
Sep 15 21:41:45 margin kernel: Call Trace:
Sep 15 21:41:45 margin kernel:  [<a0000001000139c0>] show_stack+0x40/0xa0
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fbd0 bsp=e00000b050038e20
Sep 15 21:41:45 margin kernel:  [<a000000100013a50>] dump_stack+0x30/0x60
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fda0 bsp=e00000b050038e08
Sep 15 21:41:45 margin kernel:  [<a0000001001a60c0>] dput+0xa0/0x420
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fda0 bsp=e00000b050038dd8
Sep 15 21:41:45 margin kernel:  [<a000000100193f00>] do_rmdir+0x160/0x200
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fda0 bsp=e00000b050038da0
Sep 15 21:41:45 margin kernel:  [<a000000100194070>] sys_rmdir+0x30/0x60
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fe30 bsp=e00000b050038d48
Sep 15 21:41:45 margin kernel:  [<a00000010000af80>] ia64_ret_from_syscall+0x0/0x20
Sep 15 21:41:45 margin kernel:                                 sp=e00000b05003fe30 bsp=e00000b050038d48
Sep 15 21:41:45 margin kernel:  [<a000000000010620>] __kernel_syscall_via_break+0x0/0x20
Sep 15 21:41:45 margin kernel:                                 sp=e00000b050040000 bsp=e00000b050038d48
Sep 15 21:41:46 margin kernel: kernel BUG at include/linux/dcache.h:323!
Sep 15 21:41:46 margin kernel: cpuset_creation[5590]: bugcheck! 0 [1]
Sep 15 21:41:46 margin kernel: Modules linked in:
Sep 15 21:41:46 margin kernel:
Sep 15 21:41:46 margin kernel: Pid: 5590, CPU 0, comm:      cpuset_creation
Sep 15 21:41:46 margin kernel: psr : 00001010085a6010 ifs : 800000000000048c ip  : [<a000000100193280>]    Not tainted
Sep 15 21:41:46 margin kernel: ip is at do_path_lookup+0x480/0x540
Sep 15 21:41:46 margin kernel: unat: 0000000000000000 pfs : 000000000000048c rsc : 0000000000000003
Sep 15 21:41:46 margin kernel: rnat: 0000000000000000 bsps: 0000000000000000 pr  : 000000000055a959
Sep 15 21:41:46 margin kernel: ldrs: 0000000000000000 ccv : 0000000000000000 fpsr: 0009804c0270033f
Sep 15 21:41:46 margin kernel: csd : 0000000000000000 ssd : 0000000000000000
Sep 15 21:41:46 margin kernel: b0  : a000000100193280 b6  : a000000100093960 b7  : a00000010000f0b0
Sep 15 21:41:46 margin kernel: f6  : 1003e0000000000000000 f7  : 000000000000000000000
Sep 15 21:41:46 margin kernel: f8  : 000000000000000000000 f9  : 1003e000000000001c000
Sep 15 21:41:46 margin kernel: f10 : 1003e0000000000000070 f11 : 1003e0000000000000400
Sep 15 21:41:46 margin kernel: r1  : a000000101074460 r2  : e000003016fa0ce0 r3  : 0000000000000002
Sep 15 21:41:46 margin kernel: r8  : 000000000000002d r9  : 0000000000004000 r10 : e000003003105619
Sep 15 21:41:46 margin kernel: r11 : e000003003110000 r12 : e000003016fa7d80 r13 : e000003016fa0000
Sep 15 21:41:46 margin kernel: r14 : 0000000000000000 r15 : e000003016fa0cf0 r16 : e000003016fa0d08
Sep 15 21:41:46 margin kernel: r17 : e00001b008397e18 r18 : 0000000000000001 r19 : e00000300310561b
Sep 15 21:41:46 margin kernel: r20 : 0000000000004000 r21 : 0000000000004000 r22 : e000003003110000
Sep 15 21:41:46 margin kernel: r23 : ffffffffffff0428 r24 : 0000018110000380 r25 : 0000018000000000
Sep 15 21:41:46 margin kernel: r26 : e000003016fa0cf0 r27 : e000003016fa0ce0 r28 : e000003016fa0d08
Sep 15 21:41:46 margin kernel: r29 : 0000000000000001 r30 : 0000000000000002 r31 : 0000000000001060
Sep 15 21:41:46 margin kernel:
Sep 15 21:41:46 margin kernel: Call Trace:
Sep 15 21:41:46 margin kernel:  [<a0000001000139c0>] show_stack+0x40/0xa0
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7950 bsp=e000003016fa10d0
Sep 15 21:41:47 margin kernel:  [<a0000001000142c0>] show_regs+0x840/0x880
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7b20 bsp=e000003016fa1078
Sep 15 21:41:47 margin kernel:  [<a0000001000362a0>] die+0x220/0x300
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7b20 bsp=e000003016fa1030
Sep 15 21:41:47 margin kernel:  [<a0000001000363d0>] die_if_kernel+0x50/0x80
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7b20 bsp=e000003016fa1000
Sep 15 21:41:47 margin kernel:  [<a000000100037af0>] ia64_bad_break+0x230/0x480
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7b20 bsp=e000003016fa0fd0
Sep 15 21:41:47 margin kernel:  [<a00000010000b120>] ia64_leave_kernel+0x0/0x280
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7bb0 bsp=e000003016fa0fd0
Sep 15 21:41:47 margin kernel:  [<a000000100193280>] do_path_lookup+0x480/0x540
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7d80 bsp=e000003016fa0f70
Sep 15 21:41:47 margin kernel:  [<a000000100194ac0>] __path_lookup_intent_open+0x80/0x120
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7d90 bsp=e000003016fa0f18
Sep 15 21:41:47 margin kernel:  [<a000000100194c60>] path_lookup_open+0x40/0x60
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7d90 bsp=e000003016fa0ed8
Sep 15 21:41:47 margin kernel:  [<a000000100194f30>] open_namei+0xb0/0xf80
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7d90 bsp=e000003016fa0e70
Sep 15 21:41:47 margin kernel:  [<a000000100177a10>] do_filp_open+0x50/0xc0
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7da0 bsp=e000003016fa0e38
Sep 15 21:41:47 margin kernel:  [<a000000100177b00>] do_sys_open+0x80/0x1c0
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7e30 bsp=e000003016fa0de0
Sep 15 21:41:47 margin kernel:  [<a000000100177d10>] sys_open+0x50/0x80
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7e30 bsp=e000003016fa0d88
Sep 15 21:41:47 margin kernel:  [<a00000010000af80>] ia64_ret_from_syscall+0x0/0x20
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa7e30 bsp=e000003016fa0d88
Sep 15 21:41:47 margin kernel:  [<a000000000010620>] __kernel_syscall_via_break+0x0/0x20
Sep 15 21:41:47 margin kernel:                                 sp=e000003016fa8000 bsp=e000003016fa0d88
Sep 15 21:41:47 margin kernel: note: cpuset_creation[5590] exited with preempt_count 1

===

Can you figure out where this is coming from? It is not in code that I understand all that well, so I am hoping that I don't have to spend hours poking around in it to make sense of the problem.

--
I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <[email protected]> 1.650.933.1373

#2 lore raw
Quoted 1 line · Paul M

This is already fixed in -mm

I'm missing a clue ... the latest *-mm below

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/

I see is:

2.6.23-rc4/2.6.23-rc4-mm1/

dated two weeks ago, without this fix.

I also don't see any mention of this fix in any recent lkml or linux-mm mailing list messages.

What am I missing? Where is this patch?

Signature · 3 lines
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <[email protected]> 1.925.600.0401
#3 lore raw
Quoted 9 lines · Paul Jackson
Quoted 1 line · Paul M

This is already fixed in -mm

I'm missing a clue ... the latest *-mm below

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/

I see is:

Quoted 8 lines

2.6.23-rc4/2.6.23-rc4-mm1/

dated two weeks ago, without this fix.

I also don't see any mention of this fix in any recent lkml or linux-mm mailing list messages.

What am I missing? Where is this patch?

It was just last week - it went to the containers list and not the entire lkml. I've attached the patch.

Paul

Fix a reference counting bug in containerfs

As part of the extraction of cpusetfs to containerfs, a call to cpuset_get_dentry() was lost (justified by the fact that the dentry in question was now being passed down by the caller). Since cpuset_get_dentry() called lookup_one_len(), this resulted in a reference count being missed from the directory dentry.

This patch removes container_get_dentry() and replaces it with direct calls to lookup_one_len(); the initialization of containerfs dentry ops is done now in container_create_file() at dentry creation time.

---
 kernel/container.c |   26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)
kernel/container.c +8 -18
Index: container-2.6.23-rc4-mm1/kernel/container.c
===================================================================
@@ -604,19 +604,6 @@ static void container_diput(struct dentr
 	iput(inode);
 }
 
-static struct dentry *container_get_dentry(struct dentry *parent,
-					   const char *name)
-{
-	struct dentry *d = lookup_one_len(name, parent, strlen(name));
-	static struct dentry_operations container_dops = {
-		.d_iput = container_diput,
-	};
-
-	if (!IS_ERR(d))
-		d->d_op = &container_dops;
-	return d;
-}
-
 static void remove_dir(struct dentry *d)
 {
 	struct dentry *parent = dget(d->d_parent);
@@ -1507,6 +1494,10 @@ static struct inode_operations container
 static int container_create_file(struct dentry *dentry, int mode,
 				struct super_block *sb)
 {
+	static struct dentry_operations container_dops = {
+		.d_iput = container_diput,
+	};
+
 	struct inode *inode;
 
 	if (!dentry)
@@ -1532,7 +1523,7 @@ static int container_create_file(struct 
 		inode->i_size = 0;
 		inode->i_fop = &container_file_operations;
 	}
-
+	dentry->d_op = &container_dops;
 	d_instantiate(dentry, inode);
 	dget(dentry);	/* Extra count - pin the dentry in core */
 	return 0;
@@ -1553,13 +1544,12 @@ static int container_create_dir(struct c
 	int error = 0;
 
 	parent = cont->parent->dentry;
-	if (IS_ERR(dentry))
-		return PTR_ERR(dentry);
 	error = container_create_file(dentry, S_IFDIR | mode, cont->root->sb);
 	if (!error) {
 		dentry->d_fsdata = cont;
 		inc_nlink(parent->d_inode);
 		cont->dentry = dentry;
+		dget(dentry);
 	}
 	dput(dentry);
 
@@ -1581,7 +1571,7 @@ int container_add_file(struct container 
 	}
 	strcat(name, cft->name);
 	BUG_ON(!mutex_is_locked(&dir->d_inode->i_mutex));
-	dentry = container_get_dentry(dir, name);
+	dentry = lookup_one_len(name, dir, strlen(name));
 	if (!IS_ERR(dentry)) {
 		error = container_create_file(dentry, 0644 | S_IFREG,
 						cont->root->sb);
@@ -2587,7 +2577,7 @@ int container_clone(struct task_struct *
 	/* Hold the parent directory mutex across this operation to
 	 * stop anyone else deleting the new container */
 	mutex_lock(&inode->i_mutex);
-	dentry = container_get_dentry(parent->dentry, nodename);
+	dentry = lookup_one_len(nodename, parent->dentry, strlen(nodename));
 	if (IS_ERR(dentry)) {
 		printk(KERN_INFO
 		       "Couldn't allocate dentry for %s: %ld\n", nodename,
#4 lore raw
Quoted 1 line · Paul Menage

Fix a reference counting bug in containerfs

Tested using my cpuset creation/destruction stress test.

That fixed it - thank!

Signature · 3 lines
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <[email protected]> 1.925.600.0401