LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-20-2021, 10:59 PM   #1
laurent01_
LQ Newbie
 
Registered: Jan 2021
Posts: 3

Rep: Reputation: Disabled
Question subclass and name_version of lockdep


I'm new to lockdep and there is something which I cannot understand exactly. I want to figure out subclass and name_version. It seems that since lockdep use name_version to track the each instance of the lock class. And subclass represents for nested lock.

Then Here my questions comes.

There are two SSD each /dev/sda /dev/sdb and each SSD has two partitions so /dev/sda1 /dev/sda2 /dev/sdb1 /dev/sdb2 Then for each disk and partition, how the lock name is determined? I think that /dev/sda -> lock#1 /dev/sda1-> lock#1/1 /dev/sda2 -> lock#?/1 How the /dev/sda2's lock name is determined? It seems that the order of lock_acquire() might influence the name_version but let assume /dev/sda1's lock is pre-acquired than /dev/sda2's one.

Is there anyone who can clarify the each lock's name for possible case?
 
Old 01-24-2021, 08:10 PM   #2
laurent01_
LQ Newbie
 
Registered: Jan 2021
Posts: 3

Original Poster
Rep: Reputation: Disabled
I think I have figure out what these are. Here is the thing that I get so far.
Basically, lockdep distinguish lock by class, not instance. In other words, lock thinks all spinlocks to be same, unless you set the key explicitly by lockdep_set* function.(Hereafter, assume all the spinlock is initialized by the same function)
Actually, when a spinlock is intialized, key argument which is static is always passed to the lockdep_map member of the spinlock. That's the reason why lockdep recognize all spinlocks to be same.
However, this is not useful when you debug deadlock or possible deadlock situation. So lockdep provides lockdep_set* function so that you can register each lock to be considered different by the lockdep. When the name passed to lockdep_set* is overlapped, lockdep distinguish registered lock by the name_version which is printed as # followed by number. Subclass has same principle. It is used for nested lock. With subclass argument existing, lockdep register newly so that it differentiate it. Otherwise, lockdep warns you that there is an possible deadlock situation.

Let me explain again with an example.
there is a directory contains three subdirectory which contains three files.
Top_Dir
|_Sub_Dir_1
|__File1, File2, File3
|_Sub_Dir_2
|__File4, File5, File6
|_Sub_Dir_3
|__File7, File8, File9
In this situation, if you use spinlocks for all directory and file and does not set the key explicitly, lockdep will recognizes all the lock to be same.
But if you set the key explicitly with same name, you can see such that dir_lock, dir_lock#2, dir_lock#3, ...
Moreover, when you use subclass argument with *Nested function, you can see such that dir_lock/1, dir_lock#2/1, ....

To conclude, you can annotate name_version and subclass for helping you to debug deadlock situation easily.

Last edited by laurent01_; 01-25-2021 at 09:14 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to disable lockdep? guanx Linux - Kernel 0 02-11-2013 04:44 AM
How to "subclass" a suffix rule in a makefile? RileyTheWiley Programming 1 05-17-2012 08:51 AM
Traffic Shaping not queuing to correct subclass SiegeX Linux - Networking 3 12-12-2007 08:35 PM
java; how do I make a subclass extend a library function? fatblueduck Programming 2 04-28-2006 02:40 PM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 11:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration