How big memory the system be able to lock down ?

I have a DLL that requests Data Transfer from my drivers.

DeviceIoCtl( hDriver,
IOCTL_DATA_TRANSFER,
InParams,
sizeof(InParams),
pBuffer,
BufferSize,
&BytesRead,
&Overlapped );

The IOCTL_DATA_TRANSFER is defined as METHOD_OUT_DIRECT

When the buffer is too big, the system can not lock down the buffer and I
receive the error ERROR_NO_SYSTEM_RESOURCES. That is OK.
Once I receive this error, I would like to break my big buffer to many
smaller buffers ( that the system be able to lock it down ) and repeat
this request many time with samller buffers.

My question is:

How big my buffer should be to make sure that the system be able to lock
it down ?
I do not want to break my big buffer to too many 4K chunks.

Is there a API or series of APIs that I can call to get this information ?

Thank for your help

QUANG

There is no a-priori way to determine how many physical pages will be
available to lock down your buffer at the time the system will attempt
to do so. There are hard limits on the size of an MDL, but it’s good
practice never to even approach those limits. Probably 256k is a good
chunk size.

Quang Vu wrote:

I have a DLL that requests Data Transfer from my drivers.

DeviceIoCtl( hDriver,
IOCTL_DATA_TRANSFER,
InParams,
sizeof(InParams),
pBuffer,
BufferSize,
&BytesRead,
&Overlapped );

The IOCTL_DATA_TRANSFER is defined as METHOD_OUT_DIRECT

When the buffer is too big, the system can not lock down the buffer and I
receive the error ERROR_NO_SYSTEM_RESOURCES. That is OK.
Once I receive this error, I would like to break my big buffer to many
smaller buffers ( that the system be able to lock it down ) and repeat
this request many time with samller buffers.

My question is:

How big my buffer should be to make sure that the system be able to lock
it down ?
I do not want to break my big buffer to too many 4K chunks.

Is there a API or series of APIs that I can call to get this information ?

Thank for your help

QUANG


Nick Ryan (MVP for DDK)

> to do so. There are hard limits on the size of an MDL, but it’s good

practice never to even approach those limits. Probably 256k is a good
chunk size.

When I was trying to allocate large blocks I discovered that The Mdl
limitation was the biggest problem. I could not get a large enough MDL
from IoAllocateMdl(). Creating the MDL by hand as follows (minus
details) worked fine:

mdlSize = MmSizeOfMdl(BufferStruct->Buffer, BufferStruct->Size);
Mdl = (PMDL) ExAllocatePool(NonPagedPool, mdlSize);
MmInitializeMdl(Mdl, Buffer, Size);
MmProbeAndLockPages(Mdl, UserMode, IoModifyAccess);

Rob
xxxxx@telusplanet.net

Interesting… someone from Microsoft want to chime in on the validity
of this technique? If it is, then why the arbitrary size restriction for
IoAllocateMdl?

Robert Newton wrote:

>to do so. There are hard limits on the size of an MDL, but it’s good
>practice never to even approach those limits. Probably 256k is a good
>chunk size.

When I was trying to allocate large blocks I discovered that The Mdl
limitation was the biggest problem. I could not get a large enough MDL
from IoAllocateMdl(). Creating the MDL by hand as follows (minus
details) worked fine:

mdlSize = MmSizeOfMdl(BufferStruct->Buffer, BufferStruct->Size);
Mdl = (PMDL) ExAllocatePool(NonPagedPool, mdlSize);
MmInitializeMdl(Mdl, Buffer, Size);
MmProbeAndLockPages(Mdl, UserMode, IoModifyAccess);

Rob
xxxxx@telusplanet.net


Nick Ryan (MVP for DDK)

No APIs known to me, but 64MB is the absolute limit due to using USHORT
16bit field to describe the MDL tail length. This means 64KB per MDL tail, or
16K page entries in the MDL, or 64MB of memory described by the single MDL.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Quang Vu”
To: “Windows System Software Devs Interest List”
Sent: Monday, November 17, 2003 7:16 PM
Subject: [ntdev] How big memory the system be able to lock down ?

> I have a DLL that requests Data Transfer from my drivers.
>
>
> DeviceIoCtl( hDriver,
> IOCTL_DATA_TRANSFER,
> InParams,
> sizeof(InParams),
> pBuffer,
> BufferSize,
> &BytesRead,
> &Overlapped );
>
>
>
> The IOCTL_DATA_TRANSFER is defined as METHOD_OUT_DIRECT
>
> When the buffer is too big, the system can not lock down the buffer and I
> receive the error ERROR_NO_SYSTEM_RESOURCES. That is OK.
> Once I receive this error, I would like to break my big buffer to many
> smaller buffers ( that the system be able to lock it down ) and repeat
> this request many time with samller buffers.
>
>
> My question is:
>
> How big my buffer should be to make sure that the system be able to lock
> it down ?
> I do not want to break my big buffer to too many 4K chunks.
>
> Is there a API or series of APIs that I can call to get this information ?
>
> Thank for your help
>
> QUANG
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

In my ignorance, I’ve used mdl which describes 75707220 bytes and
had no problems. Anyone offering explanation?

ned

“Maxim S. Shatskih” wrote:

No APIs known to me, but 64MB is the absolute limit due to using USHORT
16bit field to describe the MDL tail length. This means 64KB per MDL tail, or
16K page entries in the MDL, or 64MB of memory described by the single MDL.