Spinlocks

If I have a code like this in my CREATE Dispatch routine. And if my Link
List can be of 100 elements or more.

Acquire Spin Lock
If Create Link List has elements
{
If this filename found in Create Link List
{
Release Spin lock
Return SpyPassthrough
}
}
Release Spin lock

Is there a need to do this operation using spin locks ? Will this lead
to unexpected behavior or performance loss for my driver.

Any comments ??
Regards,
Anurag

  1. if there is chance that some other thread can execute the list modification code path (like delete, insert , empty operations), the u DEFINITELY need to take a spin lock.

2 Also it seems that u are worried about the cost of the search operation in the link list in create dispatch.
In that case u should use faster search data structures like a SPLAY tree (available in kernel by IFS kit)
or a hash table. (based on the search key characteristics)

Regards,
Vikramaditya.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Anurag Sarin
Sent: Monday, September 13, 2004 9:26 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Spinlocks

If I have a code like this in my CREATE Dispatch routine. And if my Link List can be of 100 elements or more.

Acquire Spin Lock
If Create Link List has elements
{
If this filename found in Create Link List
{
Release Spin lock
Return SpyPassthrough
}
}
Release Spin lock

Is there a need to do this operation using spin locks ? Will this lead to unexpected behavior or performance loss for my driver.

Any comments ??
Regards,
Anurag


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Anurag Sarin wrote:

If I have a code like this in my CREATE Dispatch routine. And if my Link

PLEASE don’t cross-post your messages. Choose a list and post it there.
Spinlocks, I’d personally post to the NTDEV list.

Thanks,

Peter
OSR

OSR is touchy today.

-----Original Message-----
From: PeterGV [mailto:xxxxx@osr.com]
Sent: Monday, September 13, 2004 2:58 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Spinlocks

Anurag Sarin wrote:

If I have a code like this in my CREATE Dispatch routine. And if my Link

PLEASE don’t cross-post your messages. Choose a list and post it there.
Spinlocks, I’d personally post to the NTDEV list.

Thanks,

Peter
OSR


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@stecs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Chris Atkinson wrote:

OSR is touchy today.

Well, you know… It gives us something to do.

At least we don’t let Hector post to these lists. Last time we did
that, we got complaints about his behavior.

Be thankful for small favors,

Peter
OSR

More analysis of my BSOD.

analyse -v Result
MULTIPLE_IRP_COMPLETE_REQUESTS(44)


Debugging details.

Arg1: ff9c4008, Address of the IRP
Arg2: 00000cca
Arg3: 00000000
Arg4: 00000000

Debugging Details:

IRP_ADDRESS: ff9c4008

DEFAULT_BUCKET_ID: DRIVER_FAULT

BUGCHECK_STR: 0x44

LAST_CONTROL_TRANSFER: from 8042bcb9 to 80452e70

STACK_TEXT:
b79346ec 8042bcb9 00000003 b7934734 ff9c4008
nt!RtlpBreakWithStatusInstruction
b793471c 8042c068 00000003 814fe148 ff9c4008
nt!KiBugCheckDebugBreak+0x31
b7934aa4 8041f68a 00000000 ff9c4008 00000cca nt!KeBugCheckEx+0x37b
b7934ad8 b7d0bf13 8162b208 81629d48 00000000 nt!IopfCompleteRequest+0x32
b7934af0 b7d0d732 ff9c4002 c0000241 00000000
tcpip!TCPDataRequestComplete+0xbc
b7934b00 b7d08f08 ff9c4008 c0000241 00000000
tcpip!TCPRequestComplete+0xf
b7934b2c b7d08cdf c0000241 b7934b00 81629d48 tcpip!CloseTCB+0x14f
b7934b40 b7d09214 81629d48 00000040 b7934b00 tcpip!TryToCloseTCB+0x4b
b7934b68 b7d09335 b7934b90 00000000 00000002 tcpip!TdiDisconnect+0xa6
b7934bb0 b7d0c0b7 816c0b48 00000000 8178d650 tcpip!TCPDisconnect+0xfb
b7934bc4 8041f54b 8178d650 816c0b48 00000000
tcpip!TCPDispatchInternalDeviceControl+0x108
b7934bd8 b7a1e375 ffb4d188 ffa90a28 800653e0 nt!IopfCallDriver+0x35
b7934bf8 b7a1d434 ffb4d18c 816e79b0 ff9c58a8 afd!AfdBeginAbort+0x18d
b7934c1c b7a18349 ff9c58a8 ff9c5900 816e79b0 afd!AfdCleanup+0x283
b7934c30 8041f54b 816e79b0 ff9c58a8 81489228 afd!AfdDispatch+0x42
b7934c44 804bc9e4 80064f90 818903a0 00000001 nt!IopfCallDriver+0x35
b7934c78 8049ce45 81645d60 816e79b0 001f01ff nt!IopCloseFile+0x275
b7934ca4 8044c642 81645d60 81489214 81489228
nt!ObpDecrementHandleCount+0x13c
b7934d58 80461691 00000174 00000000 00000000 nt!NtClose+0x1f0
b7934d58 77f88583 00000174 00000000 00000000 nt!KiSystemService+0xc4
0012f948 74fd38cb 00000174 0000000b 00143360 ntdll!NtClose+0xb
0012f9cc 750332db 00000174 0012f9e8 0000000b msafd!WSPCloseSocket+0x280
0012f9ec 004018df 00000174 0012ff3c 00000000 WS2_32!closesocket+0x5e
WARNING: Stack unwind information not available. Following frames may be
wrong.
0012fb90 00401567 00132530 00405823 1500000a teekids+0x18df
0012ff4c 004022b5 00400000 00000000 00132530 teekids+0x1567
0012ff6c 00401236 00000001 00138218 00135020 teekids+0x22b5
0012ffc0 77e87903 00f2e948 00f2eb2c 7ffdf000 teekids+0x1236
75030000 00000003 00000004 0000ffff 000000b8
KERNEL32!BaseProcessStart+0x3d

FOLLOWUP_IP:
tcpip!TCPDataRequestComplete+bc
b7d0bf13 5f pop edi

SYMBOL_STACK_INDEX: 4

FOLLOWUP_NAME: MachineOwner

SYMBOL_NAME: tcpip!TCPDataRequestComplete+bc

MODULE_NAME: tcpip

IMAGE_NAME: tcpip.sys

DEBUG_FLR_IMAGE_TIMESTAMP: 38437f02

STACK_COMMAND: kb

BUCKET_ID: 0x44_tcpip!TCPDataRequestComplete+bc

Followup: MachineOwner

-----Original Message-----
From: PeterGV [mailto:xxxxx@osr.com]
Sent: Tuesday, September 14, 2004 7:13 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Spinlocks

Chris Atkinson wrote:

OSR is touchy today.

Well, you know… It gives us something to do.

At least we don’t let Hector post to these lists. Last time we did
that, we got complaints about his behavior.

Be thankful for small favors,

Peter
OSR


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@divassoftware.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Anurag,

They only time you need to use spinlocks is if you might access your list at DPC level. For example if you need to access your list from a completion routine.

If your list is never accessed at DPC level then I would recommend you use a different lock; I would recommend a FastMutex or an EResource. The difference between these two is that an EResource will give you shared/exclusive access (acquire the list shared to search, acquire exclusive to modify it) whereas a FastMutex only gives you exclusive access.

The goal should always be to hold a spinlock for as little time as possible. If the list gets to big (to me 100 or more elements is the beginning of that “too big” range) and you need to use a spinlock you should follow Vikramaditya’s suggestion and find a better way to organize your data.

Excessive use of spinlocks will really starts showing up on MP machines with 4 or more processors.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no rights


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Vikram Gupta
Sent: Monday, September 13, 2004 7:27 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Spinlocks

  1. if there is chance that some other thread can execute the list modification code path (like delete, insert , empty operations), the u DEFINITELY need to take a spin lock.
    ?
    2 Also it seems that u are worried about the cost of the search operation in the link list in create dispatch.
    In that case u should use faster search data structures like a SPLAY tree (available in kernel by IFS kit)
    or a hash table. (based on the search key characteristics)
    ?
    Regards,
    Vikramaditya.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Anurag Sarin
Sent: Monday, September 13, 2004 9:26 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Spinlocks
If I have a code like this in my CREATE Dispatch routine. And if my Link List can be of 100 elements or more.

Acquire Spin Lock
If Create Link List has elements
{
??? ??? ??? If this filename found in Create Link List
??? ? {
??? ??? ??? ??? Release Spin lock
??? ??? ??? ??? Return SpyPassthrough
??? ??? }
}
Release Spin lock

Is there a need to do this operation using spin locks ? Will this lead to unexpected behavior or performance loss for my driver.
Any comments ??
Regards,
Anurag?

Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com