A question about synchronization scope

The section entitled “Using Automatic Synchronization” in the KMDF help says

To specify whether you want the framework to provide device-level synchronization,
queue-level synchronization, or no synchronization for your driver, you must specify
a synchronization scope for one or more of your driver’s objects.

A few lines later it says

The default synchronization scope for driver objects is WdfSynchronizationScopeNone.
The default synchronization scope for device and queue objects is
WdfSynchronizationScopeInheritFromParent.

I can see why I would need to specify something if I wanted device level or queue level
synchronisation, but if I don’t want any synchronisation, why must I specify
a synchronization scope explicitly (which is what the first paragraph says)? Surely the
default (of none) will do fine. What I’m saying is that the first paragraph above should
be altered to read

To specify whether you want the framework to provide device-level synchronization,
or queue-level synchronization for your driver, you must specify a synchronization
scope for one or more of your driver’s objects.

The reason I’m asking, is that I’m trying to figure out why the requests into my
driver are being serialised. It has a single default parallel queue. There is no mention
of synchronization scope anywhere in the driver - so I assume the default, of no scope, should
apply. I haven’t altered the default parentage, so my Driver (scope none) is the parent of my
device (scope inherit from parent) which is the parent of my queue (scope inherit from parent).

Despite that, I only get another request when I complete the first one. So what am I missing?

Don

What does !wdfdevice and !wdfdevicequeues say?
Pls use the wdfkd.dll that came with KMDF, not the one windbg

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Ward
Sent: Monday, June 12, 2006 1:39 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] A question about synchronization scope

The section entitled “Using Automatic Synchronization” in the KMDF help
says

To specify whether you want the framework to provide device-level
synchronization,
queue-level synchronization, or no synchronization for your driver,
you must specify
a synchronization scope for one or more of your driver’s objects.

A few lines later it says

The default synchronization scope for driver objects is
WdfSynchronizationScopeNone.
The default synchronization scope for device and queue objects is
WdfSynchronizationScopeInheritFromParent.

I can see why I would need to specify something if I wanted device
level or queue level
synchronisation, but if I don’t want any synchronisation, why must I
specify
a synchronization scope explicitly (which is what the first paragraph
says)? Surely the
default (of none) will do fine. What I’m saying is that the first
paragraph above should
be altered to read

To specify whether you want the framework to provide device-level
synchronization,
or queue-level synchronization for your driver, you must specify a
synchronization
scope for one or more of your driver’s objects.

The reason I’m asking, is that I’m trying to figure out why the requests
into my
driver are being serialised. It has a single default parallel queue.
There is no mention
of synchronization scope anywhere in the driver - so I assume the
default, of no scope, should
apply. I haven’t altered the default parentage, so my Driver (scope
none) is the parent of my
device (scope inherit from parent) which is the parent of my queue
(scope inherit from parent).

Despite that, I only get another request when I complete the first one.
So what am I missing?

Don


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> -----Original Message-----

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: 12 June 2006 21:55
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A question about synchronization scope

What does !wdfdevice and !wdfdevicequeues say?
> Pls use the wdfkd.dll that came with KMDF, not the one windbg
>

Just after device creation they say

-----------------------------------------------------------------
1: kd> !wdfdevice 0x7b105ec0

Dumping WDFDEVICE 0x7b105ec0
=================================

WDM PDEVICE_OBJECTs:self 8551b020, attached 86560910, pdo 86560910

Pnp state: 105 ( WdfDevStatePnpInit )
Power state: 300 ( WdfDevStatePowerObjectCreated )
Power Pol state: 500 ( WdfDevStatePwrPolObjectCreated )

Default WDFIOTARGET: 7b0eddd0

No pended pnp or power irps
Device is the power policy owner for the stack
1: kd> !wdfdevicequeues 0x7b105ec0

Dumping queues of WDFDEVICE 0x7b105ec0
=====================================
Number of queues: 1
----------------------------------
Queue: 1 (!wdfqueue 0x7b0dd1e8)
Parallel, Power-managed, PowerOff, Can accept, Can dispatch, ExecutionLevelDispatch, SynchronizationScopeNone
Number of driver owned requests: 0
Number of waiting requests: 0

EvtIoDeviceControl: (0xb6130680) Aspx3416!Aspx3416EvtIoDeviceControl
--------------------------------------------------------------------

There is a KMDF filter above the first driver (also no explicit synchronisation and a parallel queue)
For this filter driver, wdfdevice and wdfdevicequeues say

--------------------------------------------------------------------
1: kd> !wdfdevice 0x7b0dd978

Dumping WDFDEVICE 0x7b0dd978
=================================

WDM PDEVICE_OBJECTs:self 85bf47f8, attached 8551b020, pdo 86560910

Filter WDFDEVICE

Pnp state: 105 ( WdfDevStatePnpInit )
Power state: 300 ( WdfDevStatePowerObjectCreated )
Power Pol state: 500 ( WdfDevStatePwrPolObjectCreated )

Default WDFIOTARGET: 79ebb7d0

No pended pnp or power irps
1: kd> !wdfdevicequeues 0x7b0dd978

Dumping queues of WDFDEVICE 0x7b0dd978
=====================================
Number of queues: 2
----------------------------------
Queue: 1 (!wdfqueue 0x79f48fe8)
Manual, Not power-managed, PowerOn, Can accept, Can dispatch, ExecutionLevelDispatch, SynchronizationScopeNone
Number of driver owned requests: 0
Number of waiting requests: 0

This is WDF internal queue for create requests.
----------------------------------
Queue: 2 (!wdfqueue 0x7a8c5548)
Parallel, Not power-managed, PowerOn, Can accept, Can dispatch, ExecutionLevelDispatch, SynchronizationScopeNone
Number of driver owned requests: 0
Number of waiting requests: 0

EvtIoDeviceControl: (0xba4f53f0) AspxKiss!AspxKissEvtIoDeviceControl

Sorry, missed a flag. What does !wdfdevice 0xFFF say? That
will give the execution and sync levels associated with the device.

Thx
d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Ward
Sent: Monday, June 12, 2006 2:19 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A question about synchronization scope

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
> Sent: 12 June 2006 21:55
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] A question about synchronization scope
>
>
> What does !wdfdevice and !wdfdevicequeues say?
> Pls use the wdfkd.dll that came with KMDF, not the one windbg
>

Just after device creation they say

-----------------------------------------------------------------
1: kd> !wdfdevice 0x7b105ec0

Dumping WDFDEVICE 0x7b105ec0
=================================

WDM PDEVICE_OBJECTs:self 8551b020, attached 86560910, pdo 86560910

Pnp state: 105 ( WdfDevStatePnpInit )
Power state: 300 ( WdfDevStatePowerObjectCreated )
Power Pol state: 500 ( WdfDevStatePwrPolObjectCreated )

Default WDFIOTARGET: 7b0eddd0

No pended pnp or power irps
Device is the power policy owner for the stack
1: kd> !wdfdevicequeues 0x7b105ec0

Dumping queues of WDFDEVICE 0x7b105ec0
=====================================
Number of queues: 1
----------------------------------
Queue: 1 (!wdfqueue 0x7b0dd1e8)
Parallel, Power-managed, PowerOff, Can accept, Can dispatch,
ExecutionLevelDispatch, SynchronizationScopeNone
Number of driver owned requests: 0
Number of waiting requests: 0

EvtIoDeviceControl: (0xb6130680) Aspx3416!Aspx3416EvtIoDeviceControl
--------------------------------------------------------------------

There is a KMDF filter above the first driver (also no explicit
synchronisation and a parallel queue)
For this filter driver, wdfdevice and wdfdevicequeues say

--------------------------------------------------------------------
1: kd> !wdfdevice 0x7b0dd978

Dumping WDFDEVICE 0x7b0dd978
=================================

WDM PDEVICE_OBJECTs:self 85bf47f8, attached 8551b020, pdo 86560910

Filter WDFDEVICE

Pnp state: 105 ( WdfDevStatePnpInit )
Power state: 300 ( WdfDevStatePowerObjectCreated )
Power Pol state: 500 ( WdfDevStatePwrPolObjectCreated )

Default WDFIOTARGET: 79ebb7d0

No pended pnp or power irps
1: kd> !wdfdevicequeues 0x7b0dd978

Dumping queues of WDFDEVICE 0x7b0dd978
=====================================
Number of queues: 2
----------------------------------
Queue: 1 (!wdfqueue 0x79f48fe8)
Manual, Not power-managed, PowerOn, Can accept, Can dispatch,
ExecutionLevelDispatch, SynchronizationScopeNone
Number of driver owned requests: 0
Number of waiting requests: 0

This is WDF internal queue for create requests.
----------------------------------
Queue: 2 (!wdfqueue 0x7a8c5548)
Parallel, Not power-managed, PowerOn, Can accept, Can dispatch,
ExecutionLevelDispatch, SynchronizationScopeNone
Number of driver owned requests: 0
Number of waiting requests: 0

EvtIoDeviceControl: (0xba4f53f0) AspxKiss!AspxKissEvtIoDeviceControl


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> Sorry, missed a flag. What does !wdfdevice 0xFFF
> say? That
> will give the execution and sync levels associated with the device.
>
> Thx
> d

Breakpoint 0 hit
Aspx3416!Aspx3416EvtDeviceAdd+0x4a3:
b61305f3 8b45b4 mov eax,[ebp-0x4c]
1: kd> !wdfdevice 0x7b105ec0 0xfff

Dumping WDFDEVICE 0x7b105ec0
=================================

WDM PDEVICE_OBJECTs:self 85bf47f8, attached 86560910, pdo 86560910

Pnp state: 105 ( WdfDevStatePnpInit )
Power state: 300 ( WdfDevStatePowerObjectCreated )
Power Pol state: 500 ( WdfDevStatePwrPolObjectCreated )

Default WDFIOTARGET: 79ebb7d0

No pended pnp or power irps
Device is the power policy owner for the stack

Pnp state history:
[0] WdfDevStatePnpObjectCreated (0x100)
[1] WdfDevStatePnpInit (0x105)

Power state history:
[0] WdfDevStatePowerObjectCreated (0x300)

Power policy state history:
[0] WdfDevStatePwrPolObjectCreated (0x500)

EvtDeviceD0Entry: Aspx3416!Aspx3416EvtDeviceD0Entry (b6126e00)
EvtDevicePrepareHardware: Aspx3416!Aspx3416EvtDevicePrepareHardware (b61263a0)
EvtDeviceReleaseHardware: Aspx3416!Aspx3416EvtDeviceReleaseHardware (b6126a00)

WDFCHILDLIST Handles:
!WDFCHILDLIST 0x7a4b9348 (static PDO list)

SyncronizationScope is WdfSynchronizationScopeNone
ExecutionLevel is WdfExecutionLevelDispatch
1: kd> g
AspxKissEvtDeviceAdd called
Breakpoint 1 hit
AspxKiss!AspxKissEvtDeviceAdd+0x21a:
b636d35a 8b45b8 mov eax,[ebp-0x48]
1: kd> !wdfdevice 0x7b0dd978 0xfff

Dumping WDFDEVICE 0x7b0dd978
=================================

WDM PDEVICE_OBJECTs:self 8551b020, attached 85bf47f8, pdo 86560910

Filter WDFDEVICE

Pnp state: 105 ( WdfDevStatePnpInit )
Power state: 300 ( WdfDevStatePowerObjectCreated )
Power Pol state: 500 ( WdfDevStatePwrPolObjectCreated )

Default WDFIOTARGET: 7b0eddd0

No pended pnp or power irps

Pnp state history:
[0] WdfDevStatePnpObjectCreated (0x100)
[1] WdfDevStatePnpInit (0x105)

Power state history:
[0] WdfDevStatePowerObjectCreated (0x300)

Power policy state history:
[0] WdfDevStatePwrPolObjectCreated (0x500)

No state machine callbacks assigned.

WDFCHILDLIST Handles:
!WDFCHILDLIST 0x7a84d8a0 (static PDO list)

SyncronizationScope is WdfSynchronizationScopeNone
ExecutionLevel is WdfExecutionLevelDispatch

I looked at the output as did Eliyas and we can’t see any reason why you
are only seeing one request at a time. Just to verify, is your
application opening up the device as OVERLAPPED and sending multiple
I/Os? Also, if you don’t suspect the application, you can run !wdfqueue
on your default queue at runtime and it will show all
outstanding and pending WDFREQUESTs. Run the command at a point where
you think multiple requests should be in the driver at once and see what
it says

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Ward
Sent: Monday, June 12, 2006 3:03 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A question about synchronization scope

> Sorry, missed a flag. What does !wdfdevice 0xFFF
> say? That
> will give the execution and sync levels associated with the device.
>
> Thx
> d

Breakpoint 0 hit
Aspx3416!Aspx3416EvtDeviceAdd+0x4a3:
b61305f3 8b45b4 mov eax,[ebp-0x4c]
1: kd> !wdfdevice 0x7b105ec0 0xfff

Dumping WDFDEVICE 0x7b105ec0
=================================

WDM PDEVICE_OBJECTs:self 85bf47f8, attached 86560910, pdo 86560910

Pnp state: 105 ( WdfDevStatePnpInit )
Power state: 300 ( WdfDevStatePowerObjectCreated )
Power Pol state: 500 ( WdfDevStatePwrPolObjectCreated )

Default WDFIOTARGET: 79ebb7d0

No pended pnp or power irps
Device is the power policy owner for the stack

Pnp state history:
[0] WdfDevStatePnpObjectCreated (0x100)
[1] WdfDevStatePnpInit (0x105)

Power state history:
[0] WdfDevStatePowerObjectCreated (0x300)

Power policy state history:
[0] WdfDevStatePwrPolObjectCreated (0x500)

EvtDeviceD0Entry: Aspx3416!Aspx3416EvtDeviceD0Entry (b6126e00)
EvtDevicePrepareHardware: Aspx3416!Aspx3416EvtDevicePrepareHardware
(b61263a0)
EvtDeviceReleaseHardware: Aspx3416!Aspx3416EvtDeviceReleaseHardware
(b6126a00)

WDFCHILDLIST Handles:
!WDFCHILDLIST 0x7a4b9348 (static PDO list)

SyncronizationScope is WdfSynchronizationScopeNone
ExecutionLevel is WdfExecutionLevelDispatch
1: kd> g
AspxKissEvtDeviceAdd called
Breakpoint 1 hit
AspxKiss!AspxKissEvtDeviceAdd+0x21a:
b636d35a 8b45b8 mov eax,[ebp-0x48]
1: kd> !wdfdevice 0x7b0dd978 0xfff

Dumping WDFDEVICE 0x7b0dd978
=================================

WDM PDEVICE_OBJECTs:self 8551b020, attached 85bf47f8, pdo 86560910

Filter WDFDEVICE

Pnp state: 105 ( WdfDevStatePnpInit )
Power state: 300 ( WdfDevStatePowerObjectCreated )
Power Pol state: 500 ( WdfDevStatePwrPolObjectCreated )

Default WDFIOTARGET: 7b0eddd0

No pended pnp or power irps

Pnp state history:
[0] WdfDevStatePnpObjectCreated (0x100)
[1] WdfDevStatePnpInit (0x105)

Power state history:
[0] WdfDevStatePowerObjectCreated (0x300)

Power policy state history:
[0] WdfDevStatePwrPolObjectCreated (0x500)

No state machine callbacks assigned.

WDFCHILDLIST Handles:
!WDFCHILDLIST 0x7a84d8a0 (static PDO list)

SyncronizationScope is WdfSynchronizationScopeNone
ExecutionLevel is WdfExecutionLevelDispatch


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> -----Original Message-----

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: 12 June 2006 23:53
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A question about synchronization scope

I looked at the output as did Eliyas and we can’t see any
reason why you
are only seeing one request at a time. Just to verify, is your
application opening up the device as OVERLAPPED and sending multiple
I/Os? Also, if you don’t suspect the application, you can
run !wdfqueue
on your default queue at runtime and it will show all
> outstanding and pending WDFREQUESTs. Run the command at a point where
> you think multiple requests should be in the driver at once
> and see what
> it says
>
> d

I’ll try your suggestions. The App isn’t sending overlapped requests (although
it could I suppose). Instead, there are 20 threads making non overlapped
requests in parallel.

But to return to my original question: why does the help say you must (my emphasis)
specify

I am working on the doc issue…are your 20 threads sending I/O on the
same handle? If so, then it doesn’t matter how many threads are sending
i/o on the handle, they will all be serialized if the handle not opened
as OVERLAPPED. If each thread is opening its own handle, then you
should see a lot of concurrent i/o.

A non OVERLAPPED handle serializes *all* i/o to the handle from *all*
threads, it does not serialize i/o based on the particular thread.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Ward
Sent: Monday, June 12, 2006 4:04 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A question about synchronization scope

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: 12 June 2006 23:53
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] A question about synchronization scope

I looked at the output as did Eliyas and we can’t see any
reason why you
are only seeing one request at a time. Just to verify, is your
application opening up the device as OVERLAPPED and sending multiple
I/Os? Also, if you don’t suspect the application, you can
run !wdfqueue
on your default queue at runtime and it will show all
> outstanding and pending WDFREQUESTs. Run the command at a point where
> you think multiple requests should be in the driver at once
> and see what
> it says
>
> d

I’ll try your suggestions. The App isn’t sending overlapped requests
(although
it could I suppose). Instead, there are 20 threads making non overlapped
requests in parallel.

But to return to my original question: why does the help say you must
(my emphasis)
specify


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Sorry for incomplete post; must have pressed send by mistake.

I looked at the output as did Eliyas and we can’t see any
reason why you
are only seeing one request at a time. Just to verify, is your
application opening up the device as OVERLAPPED and sending multiple
I/Os? Also, if you don’t suspect the application, you can
run !wdfqueue
on your default queue at runtime and it will show all
> outstanding and pending WDFREQUESTs. Run the command at a point where
> you think multiple requests should be in the driver at once
> and see what
> it says
>
> d

Thanks for your suggestions (which I’ll try) and the confirmation that, as far
as you can see, I should be getting multiple requests.

The App isn’t sending overlapped requests (although it could I suppose).
Instead, there are 20 threads making non overlapped requests in parallel.
One explanation might be that the transfers are too small to pile up in the driver
because it’s managing to turn them round too quickly. I’ll try giving it some more
serious work to do. If that doesn’t work, I’ll use overlapped requests.

When it seemed as if the requests were being serialised, my first thought
was that I’d missed out a vital part of the magic spell.

But to return to my original question: why does the help say you must (my emphasis)
specify synchronization scope if you wish to have no synchronisation? Why does it say

To specify whether you want the framework to provide device-level synchronization,
queue-level synchronization, or no synchronization for your driver, you must specify
a synchronization scope for one or more of your driver’s objects.

instead of

To specify whether you want the framework to provide device-level synchronization,
or queue-level synchronization for your driver, you must specify a synchronization
scope for one or more of your driver’s objects.

Don

> I am working on the doc issue…are your 20 threads sending I/O on the

same handle? If so, then it doesn’t matter how many threads
are sending
i/o on the handle, they will all be serialized if the handle
not opened
as OVERLAPPED. If each thread is opening its own handle, then you
should see a lot of concurrent i/o.

A non OVERLAPPED handle serializes *all* i/o to the handle from *all*
threads, it does not serialize i/o based on the particular thread.

Thank you. They are all using the same (non overlapped) handle. They also
have access to another, non overlapped handle, which I shall try tomorrow
(it being rather late here, local time, to be altering code).

Don