Skip to contentSkip to conversation

lock_kernel twice possible ?

DISCUSSION li nux 5 participants 7 messages Oct 15, 2005 – Oct 20, 2005

lore
Share & tools
lore

li nux

author
#0 lore raw

Hi,

I was going thru the NFS v3 code for SMP kernel 2.6.11 to see how an inode gets revalidated. I found that there is a possibility that there may be an attempt to do lock_kernel() twice.

Is this possible ? If yes then how this deadlock condition is/can be avoided.

-lnxluv

Below is the code flow (please see ** for
lock_kernel):

nfs_revalidate_inode
- __nfs_revalidate_inode
- ** lock_kernel() **
- nfs_wait_on_inode
- Call getattr() (which is nfs3_proc_getattr()) to get the attributes from the server and refresh the inode with the new values
- IF the cached data is invalid for the inode
- Writeback (If dirty) and sync the inode, call nfs_wb_all
- nfs_wb_all
- nfs_sync_inode
- call nfs_wait_on_requests to wait for the requests associated with the pages to get complete
- nfs_flush_inode
- nfs_scan_dirty
- nfs_flush_list
- nfs_flush_one
- nfs_write_rpcsetup
- nfs3_proc_write_setup
- rpc_init_task
- rpc_call_setup
- nfs_execute_write
- ** lock_kernel() **
- rpc_execute
- ** unlock_kernel() **
- ** unlock_kernel() **

__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

#1 lore raw
Quoted 9 lines · li nux

Hi,

I was going thru the NFS v3 code for SMP kernel 2.6.11 to see how an inode gets revalidated. I found that there is a possibility that there may be an attempt to do lock_kernel() twice.

Is this possible ? If yes then how this deadlock condition is/can be avoided.

The BKL is recursive!
--
Coywolf Qi Hunt
http://sosdg.org/~coywolf/

author
#2 lore raw

Sorry, couldn't get what you want to say.
Can you please elaborate.

Quoted 10 lines · --- Coywolf Qi Hunt
Quoted 3 lines · li nux

Hi,

I was going thru the NFS v3 code for SMP kernel

2.6.11

Quoted 2 lines

to see how an inode gets revalidated. I found that there is a possibility that there may be an

attempt to

Quoted 2 lines

do lock_kernel() twice.

Quoted 8 lines
Quoted 2 lines

Is this possible ? If yes then how this deadlock
condition is/can be avoided.

The BKL is recursive!
--
Coywolf Qi Hunt
http://sosdg.org/~coywolf/

__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

#3 lore raw
Quoted 2 lines · li nux

Sorry, couldn't get what you want to say.
Can you please elaborate.

A "recursive lock" is one that can be taken multiple times by the same owner. So:

	lock_kernel();
	lock_kernel();
	unlock_kernel();
	unlock_kernel();

is perfectly ok. The lock_kernel() code detects that the calling thread already owns the lock and just increments current->lock_depth.

Under linux locks are non-recursive EXCEPT for lock_kernel() (aka the BLK or "big kernel lock")

See lib/kernel_lock.c for more details.

-Mitch

#5 lore raw
Quoted 8 lines · Coywolf Qi Hunt
Quoted 2 lines · li nux

Sorry, couldn't get what you want to say.
Can you please elaborate.

http://www.zipworld.com.au/~akpm/linux/patches/stuff/top-posting.txt
http://www.catb.org/~esr/jargon/html/T/top-post.html

The whole post fit on one screen and he was not continuing the conversation, he was commenting on your post as a whole. I think you're being a bit pedantic here.

I don't think his reply failed your criteria, it wasn't overlong, it didn't break a flowing discussion, and no backward reading was required.

~~~~~~~

Q: Why is top-posting evil?

A1: Because top-posters tend to leave the entirety of the email to which
they are replying intact, so the email gets too long.

A2: Because we prefer to use bottom-posting, and it is *extremely* hard to
maintain a coherently flowing email conversation when some of the participants are bottom-posting and some are top-posting.

A3: backwards read don't humans because

Signature · 3 lines
   -bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me
#6 lore raw
Quoted 5 lines · Bill Davidsen

~~~~~~~

Q: Why is top-posting evil?

Quoted 9 lines

A1: Because top-posters tend to leave the entirety of the email to which
they are replying intact, so the email gets too long.

A2: Because we prefer to use bottom-posting, and it is *extremely* hard to
maintain a coherently flowing email conversation when some of the participants are bottom-posting and some are top-posting.

A3: backwards read don't humans because

A4: top-posting is for pointy haired managers.

Sorry! ;)

-- Steve