2005-10-15 07:04:29

by li nux

[permalink] [raw]
Subject: lock_kernel twice possible ?

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/


2005-10-15 07:33:11

by Coywolf Qi Hunt

[permalink] [raw]
Subject: Re: lock_kernel twice possible ?

On 10/15/05, li nux <[email protected]> wrote:
> 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/

2005-10-15 07:38:05

by li nux

[permalink] [raw]
Subject: Re: lock_kernel twice possible ?

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

--- Coywolf Qi Hunt <[email protected]> wrote:

> On 10/15/05, li nux <[email protected]> wrote:
> > 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/
>




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

2005-10-15 07:46:36

by Mitchell Blank Jr

[permalink] [raw]
Subject: Re: lock_kernel twice possible ?

li nux wrote:
> 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

2005-10-15 07:47:31

by Coywolf Qi Hunt

[permalink] [raw]
Subject: Re: lock_kernel twice possible ?

On 10/15/05, li nux <[email protected]> wrote:
> 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
--
Coywolf Qi Hunt
http://sosdg.org/~coywolf/

2005-10-19 21:28:28

by Bill Davidsen

[permalink] [raw]
Subject: Re: lock_kernel twice possible ?

Coywolf Qi Hunt wrote:
> On 10/15/05, li nux <[email protected]> wrote:
>
>>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

--
-bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me

2005-10-20 07:00:52

by Steven Rostedt

[permalink] [raw]
Subject: Re: lock_kernel twice possible ?


On Wed, 19 Oct 2005, Bill Davidsen wrote:

>
> ~~~~~~~
>
> 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
>

A4: top-posting is for pointy haired managers.

Sorry! ;)

-- Steve