I am blocking the IRP_MJ_READ when (Irp->Flags & (IRP_NOCACHE |
IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO),
Sometime i got the deadlock as following:
kd> !locks
**** DUMP OF ALL RESOURCE OBJECTS ****
KD: Scanning for held locks…
Resource @ 0x823cb514 Exclusively owned
Contention Count = 78
NumberOfSharedWaiters = 8
Threads: 821fe370-02<*> 82035da8-01 8215c968-01 820414f0-01
82079be8-01 82311da8-01 822166f0-01 8214bbf0-01
820c5518-01
KD: Scanning for held locks.
Resource @ 0x823caae0 Exclusively owned
Contention Count = 4
Threads: 821fe370-01<*>
KD: Scanning for held
locks…
Resource @ 0x823cc5b0 Shared 1 owning threads
Threads: 823c5643-01<*> *** Actual Thread 823c5640
KD: Scanning for held locks…
Resource @ 0x820ab190 Shared 1 owning threads
Contention Count = 1
NumberOfExclusiveWaiters = 1
Threads: 820e9bc8-01<*>
Threads Waiting On Exclusive Access:
821fe370
KD: Scanning for held locks.
Resource @ 0x820ffe28 Shared 1 owning threads
Threads: 823c5643-01<*> *** Actual Thread 823c5640
2724 total locks, 5 locks currently held
kd> dt eresource 0x823cb514
MyFilter!ERESOURCE
+0x000 SystemResourcesList : _LIST_ENTRY [0x823cb54c - 0x823d888c]
+0x008 OwnerTable : 0x822b5398 _OWNER_ENTRY
+0x00c ActiveCount : 1
+0x00e Flag : 0x80
+0x010 SharedWaiters : 0x823ea148 _KSEMAPHORE
+0x014 ExclusiveWaiters : 0x823d3048 _KEVENT
+0x018 OwnerThreads : [2] _OWNER_ENTRY
+0x028 ContentionCount : 0x4e
+0x02c NumberOfSharedWaiters : 8
+0x02e NumberOfExclusiveWaiters : 0
+0x030 Address : (null)
+0x030 CreatorBackTraceIndex : 0
+0x034 SpinLock : 0
kd> dt eresource 0x820ab190
MyFilter!ERESOURCE
+0x000 SystemResourcesList : _LIST_ENTRY [0x8220b788 - 0x820ab128]
+0x008 OwnerTable : (null)
+0x00c ActiveCount : 1
+0x00e Flag : 0
+0x010 SharedWaiters : (null)
+0x014 ExclusiveWaiters : 0x8224f4e0 _KEVENT
+0x018 OwnerThreads : [2] _OWNER_ENTRY
+0x028 ContentionCount : 1
+0x02c NumberOfSharedWaiters : 0
+0x02e NumberOfExclusiveWaiters : 1
+0x030 Address : (null)
+0x030 CreatorBackTraceIndex : 0
+0x034 SpinLock : 0
The thread 820e9bc8 is the one i am blocking, which is waiting for the event
from my another user thread 8215c968, It is holding the resource 0x820ab190.
My user thread 8215c968 is checking the file exist, it is waitting for the
resource 0x823cb514 which was blocking by thread 821fe370.
The thread 821fe370 is wmiprvse.exe service which is exclusively holding
the resource 0x823cb514, and exclusively waiting for another resource
0x820ab190
which was holding by the thread 820e9bc8.
How can I know what resource is blocking, because i didn’t hold any resource
in filter driver. Can i release the resource which was holding by my
pagingIo thread?
And what other resources will be held by pagingIo read request?
Thanks
Ben
>The thread 820e9bc8 is the one i am blocking, which is waiting for the event
from my another user thread 8215c968, It is holding the resource 0x820ab190.
and, at the same time,
… i didn’t hold any resource in filter driver
How can you explain this???
The thread 820e9bc8 is the one i am blocking, which is waiting for the event
from my another user thread 8215c968, It is holding the resource 0x820ab190.
Who is holding the resource 0x820ab190??? Is it thread 820e9bc8 or thread 8215c968??? In any case, where is this resource being held - after all, you claim that you don’t hold any resources
in your driver???
it is waitting for the resource 0x823cb514 which was blocking by thread 821fe370.
The above statement is just undecypherable…
Do you mean that thread 821fe370 holds the resource 0x823cb514???
If we assume that this is the case, and that it is thread 820e9bc8 and not thread 8215c968 who holds the resource 0x820ab190, then everything starts making a perfect sense - thread 820e9bc8
enters the waiting state on event while holding the resource 0x820ab190; the event can get signalled only by the thread 8215c968 and it can happen only after thread 8215c968 obtains the resource 0x823cb514 which is exclusively owned by the thread 821fe370; thread 821fe370 can release the resource 0x823cb514 after having completed the target operation; thread 821fe370 cannot start the target operation, because, in order to start it, it needs the resource 0x820ab190 that is being held by the thread 820e9bc8. At this point everything starts making sense - the vicious circle has been formed, and there is no way to break it. However, what becomes unclear at this point is what you are asking about - it looks like you have explained the situation yourself, so that you know why you deadlock.
Could you please formulate your question properly - it is hard to understand what you mean…
Anton Bassov
I didn’t read thoroughly your explanation about mutual locks, but I think
that there is a flaw in your design.
As I understand, before allowing the read operation to proceed ( this is an
operation generated by the page fault handler ),
your filter driver waits for response from another thread which generates
requests to a file system ( create requests in this case ).
It might be disappointed, but this design is wrong because you create a
dependence which is not considered as normal by
FSDs’ developers - the paging IRP_MJ_READ operation depend on IRP_MJ_CREATE
operation ( doesn’t matter for the same file or not ).
If you don’t change the design you will always strugle with sporadic dead
locks. Do not create additional dependences.
And now answers to your questions:
How can I know what resource is blocking, because i didn’t hold any
resource
in filter driver.
There is no any way except scanning all synchronization objects in the
system. The only thing you can do is to check for the so called thread’s Top
Level Irp( which is usually not an Irp ) and if it is not NULL you know that
some resources have been acquired.
Can i release the resource which was holding by my
pagingIo thread?
I don’t understand this question, especially about “my pagingIo thread”.
If the resource has been acquired by your filter you definitely can release
it if this doesn’t contradict with a synchronization scheme,
if this resource has not been acquired by your filter then you can’t release
it.
–
Slava Imameyev, xxxxx@hotmail.com
wrote in message news:xxxxx@ntfsd…
>I am blocking the IRP_MJ_READ when (Irp->Flags & (IRP_NOCACHE |
> IRP_PAGING_IO | IRP_SYNCHRONOUS_PAGING_IO),
>
> Sometime i got the deadlock as following:
>
> kd> !locks
> DUMP OF ALL RESOURCE OBJECTS
> KD: Scanning for held locks…
>
> Resource @ 0x823cb514 Exclusively owned
> Contention Count = 78
> NumberOfSharedWaiters = 8
> Threads: 821fe370-02<> 82035da8-01 8215c968-01 820414f0-01
> 82079be8-01 82311da8-01 822166f0-01 8214bbf0-01
> 820c5518-01
> KD: Scanning for held locks.
>
> Resource @ 0x823caae0 Exclusively owned
> Contention Count = 4
> Threads: 821fe370-01<>
> KD: Scanning for held
> locks…
>
> Resource @ 0x823cc5b0 Shared 1 owning threads
> Threads: 823c5643-01<> Actual Thread 823c5640
> KD: Scanning for held locks…
>
> Resource @ 0x820ab190 Shared 1 owning threads
> Contention Count = 1
> NumberOfExclusiveWaiters = 1
> Threads: 820e9bc8-01<>
> Threads Waiting On Exclusive Access:
> 821fe370
>
> KD: Scanning for held locks.
>
> Resource @ 0x820ffe28 Shared 1 owning threads
> Threads: 823c5643-01<>* Actual Thread 823c5640
> 2724 total locks, 5 locks currently held
> kd> dt eresource 0x823cb514
> MyFilter!ERESOURCE
> +0x000 SystemResourcesList : _LIST_ENTRY [0x823cb54c - 0x823d888c]
> +0x008 OwnerTable : 0x822b5398 _OWNER_ENTRY
> +0x00c ActiveCount : 1
> +0x00e Flag : 0x80
> +0x010 SharedWaiters : 0x823ea148 _KSEMAPHORE
> +0x014 ExclusiveWaiters : 0x823d3048 _KEVENT
> +0x018 OwnerThreads : [2] _OWNER_ENTRY
> +0x028 ContentionCount : 0x4e
> +0x02c NumberOfSharedWaiters : 8
> +0x02e NumberOfExclusiveWaiters : 0
> +0x030 Address : (null)
> +0x030 CreatorBackTraceIndex : 0
> +0x034 SpinLock : 0
> kd> dt eresource 0x820ab190
> MyFilter!ERESOURCE
> +0x000 SystemResourcesList : _LIST_ENTRY [0x8220b788 - 0x820ab128]
> +0x008 OwnerTable : (null)
> +0x00c ActiveCount : 1
> +0x00e Flag : 0
> +0x010 SharedWaiters : (null)
> +0x014 ExclusiveWaiters : 0x8224f4e0 _KEVENT
> +0x018 OwnerThreads : [2] _OWNER_ENTRY
> +0x028 ContentionCount : 1
> +0x02c NumberOfSharedWaiters : 0
> +0x02e NumberOfExclusiveWaiters : 1
> +0x030 Address : (null)
> +0x030 CreatorBackTraceIndex : 0
> +0x034 SpinLock : 0
>
> The thread 820e9bc8 is the one i am blocking, which is waiting for the
> event
> from my another user thread 8215c968, It is holding the resource
> 0x820ab190.
> My user thread 8215c968 is checking the file exist, it is waitting for the
> resource 0x823cb514 which was blocking by thread 821fe370.
> The thread 821fe370 is wmiprvse.exe service which is exclusively holding
> the resource 0x823cb514, and exclusively waiting for another resource
> 0x820ab190
> which was holding by the thread 820e9bc8.
>
> How can I know what resource is blocking, because i didn’t hold any
> resource
> in filter driver. Can i release the resource which was holding by my
> pagingIo thread?
>
> And what other resources will be held by pagingIo read request?
>
>
> Thanks
>
> Ben
>
>
>
>
>