Locking paged pool memory

Hello all,

Can following peace of code be legally used, or is it a “violation”
against the rules :

PVOID pMemory = ExAllocatePoolWithTag ( PagedPool ,
TEN_PROCENT_OF_TOTAL_PAGEDPOOL , MYTAG ) ;
PMDL pMDL = IoAllocateMdl ( pMemory , TEN_PROCENT_OF_TOTAL_PAGEDPOOL ,
FALSE , FALSE , NULL ) ;
MmProbeAndLockPages ( pMDL , KernelMode , IoModifyAccess )
;

Hi Christiaan,

It is fully leagal to use this snippet of code.

 

Good Luck,



From: “Christiaan Ghijselinck”

>Reply-To: “Windows System Software Devs Interest List”
>To: “Windows System Software Devs Interest List”
>Subject: [ntdev] Locking paged pool memory
>Date: Thu, 20 Nov 2003 16:13:38 -0500
>
>Hello all,
>
>Can following peace of code be legally used, or is it a “violation”
>against the rules :
>
>PVOID pMemory = ExAllocatePoolWithTag ( PagedPool ,
>TEN_PROCENT_OF_TOTAL_PAGEDPOOL , MYTAG ) ;
>PMDL pMDL = IoAllocateMdl ( pMemory , TEN_PROCENT_OF_TOTAL_PAGEDPOOL ,
>FALSE , FALSE , NULL ) ;
> MmProbeAndLockPages ( pMDL , KernelMode , IoModifyAccess )
>;
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


Contact brides & grooms FREE! Only on www.shaadi.com. Register now!

Thanks,

But do you know , or is there someone who knows, how locking of paged pool memory influences the whole memory management and swapping mechanism of the system. The problem I revealed is that USER programs ( not kernel drivers ) are really getting into trouble and cause the OS to malfunction (*) when they allocate a lot of memory after a driver has locked for example 32 MB ( total available ± 300 MB ) of paged pool memory at boot time. It seems to be that pageswapping is not working properly anymore. The problem manifest on W2k with Outlook Express when using the “find” text function within a huge mail folder.

(*) the whole system locks up : no response to mouse moves , keyboard input , etc… and no BSOD neither ! ? The only thing left to do is pushing the reset button :slight_smile:

----- Original Message -----
From: yatindra vaishnav
To: Windows System Software Devs Interest List
Sent: Friday, November 21, 2003 8:36 AM
Subject: [ntdev] Re: Locking paged pool memory

Hi Christiaan,

It is fully leagal to use this snippet of code.

Good Luck,



>From: “Christiaan Ghijselinck”
>Reply-To: “Windows System Software Devs Interest List”
>To: “Windows System Software Devs Interest List”
>Subject: [ntdev] Locking paged pool memory
>Date: Thu, 20 Nov 2003 16:13:38 -0500
>
>Hello all,
>
>Can following peace of code be legally used, or is it a “violation”
>against the rules :
>
>PVOID pMemory = ExAllocatePoolWithTag ( PagedPool ,
>TEN_PROCENT_OF_TOTAL_PAGEDPOOL , MYTAG ) ;
>PMDL pMDL = IoAllocateMdl ( pMemory , TEN_PROCENT_OF_TOTAL_PAGEDPOOL ,
>FALSE , FALSE , NULL ) ;
> MmProbeAndLockPages ( pMDL , KernelMode , IoModifyAccess )
>;
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com

------------------------------------------------------------------------------
Contact brides & grooms FREE! Only on www.shaadi.com. Register now! —
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compaqnet.be
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi Christiaan,

That is perfactly fine.that shud not be done the reason being is paged pool is used during allocation and all. and the schedular is goin to get in to trouble that is related to the normal work of pagging in and out, but this is perfactly fine and leagal snippet.

And i believe it is nthg to do with that, there is some thing else u r doin in the code which did this problem of freezing of the system.

Good Luck

From: “Christiaan Ghijselinck”

>Reply-To: “Windows System Software Devs Interest List”
>To: “Windows System Software Devs Interest List”
>Subject: [ntdev] Re: Locking paged pool memory
>Date: Fri, 21 Nov 2003 09:34:13 +0100
>
>
>
>Thanks,
>
>But do you know , or is there someone who knows, how locking of paged pool memory influences the whole memory management and swapping mechanism of the system. The problem I revealed is that USER programs ( not kernel drivers ) are really getting into trouble and cause the OS to malfunction () when they allocate a lot of memory after a driver has locked for example 32 MB ( total available ± 300 MB ) of paged pool memory at boot time. It seems to be that pageswapping is not working properly anymore. The problem manifest on W2k with Outlook Express when using the “find” text function within a huge mail folder.
>
>(
) the whole system locks up : no response to mouse moves , keyboard input , etc… and no BSOD neither ! ? The only thing left to do is pushing the reset button :slight_smile:
>
> ----- Original Message -----
> From: yatindra vaishnav
> To: Windows System Software Devs Interest List
> Sent: Friday, November 21, 2003 8:36 AM
> Subject: [ntdev] Re: Locking paged pool memory
>
>
> Hi Christiaan,
>
> It is fully leagal to use this snippet of code.
>
>
>
> Good Luck,
>
>
>
>
>
> >From: “Christiaan Ghijselinck”
> >Reply-To: “Windows System Software Devs Interest List”
> >To: “Windows System Software Devs Interest List”
> >Subject: [ntdev] Locking paged pool memory
> >Date: Thu, 20 Nov 2003 16:13:38 -0500
> >
> >Hello all,
> >
> >Can following peace of code be legally used, or is it a “violation”
> >against the rules :
> >
> >PVOID pMemory = ExAllocatePoolWithTag ( PagedPool ,
> >TEN_PROCENT_OF_TOTAL_PAGEDPOOL , MYTAG ) ;
> >PMDL pMDL = IoAllocateMdl ( pMemory , TEN_PROCENT_OF_TOTAL_PAGEDPOOL ,
> >FALSE , FALSE , NULL ) ;
> > MmProbeAndLockPages ( pMDL , KernelMode , IoModifyAccess )
> >;
> >
> >
> >
> >—
> >Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
> >
> >You are currently subscribed to ntdev as: xxxxx@hotmail.com
> >To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>------------------------------------------------------------------------------
> Contact brides & grooms FREE! Only on www.shaadi.com. Register now! —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>—
>Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


The Great MSN Sale. Get shopping discounts. Win exciting prizes!

Well obviously it reduces the amount of pageable memory left in the system.
In addition, if you are calling MmGetSystemAddressForMdl, your are consuming
a lot of system PTEs. Also you are obviously reducing the amount of physical
memory available for other purposes. In your example below however, locking
down 32MB should not be a problem, assuming that you have somewhere around
300MB of ram. Does your driver do anything besides lock down memory? Have
you tried using windbg to break into the system and analyze what is going
on?

=====================
Mark Roddy


From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
Sent: Friday, November 21, 2003 3:34 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Locking paged pool memory

Thanks,

But do you know , or is there someone who knows, how locking of paged pool
memory influences the whole memory management and swapping mechanism of the
system. The problem I revealed is that USER programs ( not kernel drivers )
are really getting into trouble and cause the OS to malfunction (*) when
they allocate a lot of memory after a driver has locked for example 32 MB (
total available ± 300 MB ) of paged pool memory at boot time. It seems to
be that pageswapping is not working properly anymore. The problem manifest
on W2k with Outlook Express when using the “find” text function within a
huge mail folder.

(*) the whole system locks up : no response to mouse moves , keyboard input
, etc… and no BSOD neither ! ? The only thing left to do is pushing the
reset button :slight_smile:

----- Original Message -----
From: yatindra mailto:xxxxx vaishnav
To: Windows System Software Devs Interest mailto:xxxxx List

Sent: Friday, November 21, 2003 8:36 AM
Subject: [ntdev] Re: Locking paged pool memory

Hi Christiaan,

It is fully leagal to use this snippet of code.

Good Luck,



>From: “Christiaan Ghijselinck”
>Reply-To: “Windows System Software Devs Interest List”
>To: “Windows System Software Devs Interest List”
>Subject: [ntdev] Locking paged pool memory
>Date: Thu, 20 Nov 2003 16:13:38 -0500
>
>Hello all,
>
>Can following peace of code be legally used, or is it a “violation”
>against the rules :
>
>PVOID pMemory = ExAllocatePoolWithTag ( PagedPool ,
>TEN_PROCENT_OF_TOTAL_PAGEDPOOL , MYTAG ) ;
>PMDL pMDL = IoAllocateMdl ( pMemory , TEN_PROCENT_OF_TOTAL_PAGEDPOOL ,
>FALSE , FALSE , NULL ) ;
> MmProbeAndLockPages ( pMDL , KernelMode , IoModifyAccess )
>;
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com

_____

Contact brides & grooms FREE! Only on www.shaadi.com. Register now!
http:
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@compaqnet.be
To unsubscribe send a blank email to xxxxx@lists.osr.com


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

You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com</http:></mailto:xxxxx></mailto:xxxxx>

Thank you Mark and Yatindra for your responses.

In the mean time, I did some other investigations about that behaveour on W2k-sp1. My system has 1.25 GB of total memory.
But first some facts :

The amount of total memory that I can allocate are :
a. using ExAllocatePoolWithTag ( NonPagedPool , … , ) = 224 MB ( furtheron referred as “paged + locked” )
b. using ExAllocatePoolWithTag ( PagedPool , … , … ) + “Lock” = 352 MB ( furtheron “non-paged” )
c. using MmAllocateNonCachedMemory ( ) = 256 MB ( furtheron “non-cached” )

All this memory can be allocated at the same time, thus, I do not release memory before allocating some other !
The total paged memory lies in fact around 350 MB instead of the 300 MB I mentioned before.

The memory is allocated in batches of 32 MB.

And now the tests :

First let me tell me that I use only a simple “toy” driver that practically contains only a DriverEntry routine were the memory is allocated. Once allocated, it returns STATUS_SUCCESS. I did not even provide an unload function.

The cases I can differentiate are :

a. When I allocate NO “non-cached-memory” I am able to allocate and lock about 50 % of the “paged + locked” memory. This seems to be a kind of “watermark” sometimes the system lock occcurs with Outlook Express , sometimes not. Once above the 50 %, my system locks up every time I start up the “find” function in Outlook Express. If I allocate and lock for example only 32 MB, there is no problem.

b. When I DO allocate 128 MB of “non-cached-memory” , and at the same time, I allocate 32 MB of “paged + locked”, the system ALWAYS locks up !

c. If I allocate ALL available “non-cached” memory, but NO “paged+locked” memory, my system NEVER locks up !

d. All situations described above DO NOT depend on the amount of “non-paged” memory that I allocate at the same time. It seems to be that allocating of “non-paged” memory has no effect on this behaveour.

The first bad thing about this that there is even no error message from the program that gets in trouble ( Outlook Express ). There is no BSOD neither, which lets me expect that lack of PTE’s is not the cause. The worst thing about all, is according my opinion, that this error situation DOES NOT appear on WinXP ( I did not made tests on Server 2003 yet ). This makes Win2000 at least totally “unreliable” , just because everything looks fine after reboot and problems occur just depending on the program you run. I also got sometimes error C0000142 ( DLL initialization failed ) for other programs.

Christiaan

----- Original Message -----
From: Roddy, Mark
To: Windows System Software Devs Interest List
Sent: Friday, November 21, 2003 3:27 PM
Subject: [ntdev] Re: Locking paged pool memory

Well obviously it reduces the amount of pageable memory left in the system. In addition, if you are calling MmGetSystemAddressForMdl, your are consuming a lot of system PTEs. Also you are obviously reducing the amount of physical memory available for other purposes. In your example below however, locking down 32MB should not be a problem, assuming that you have somewhere around 300MB of ram. Does your driver do anything besides lock down memory? Have you tried using windbg to break into the system and analyze what is going on?

=====================
Mark Roddy


From: Christiaan Ghijselinck [mailto:xxxxx@CompaqNet.be]
Sent: Friday, November 21, 2003 3:34 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: Locking paged pool memory

Thanks,

But do you know , or is there someone who knows, how locking of paged pool memory influences the whole memory management and swapping mechanism of the system. The problem I revealed is that USER programs ( not kernel drivers ) are really getting into trouble and cause the OS to malfunction (*) when they allocate a lot of memory after a driver has locked for example 32 MB ( total available ± 300 MB ) of paged pool memory at boot time. It seems to be that pageswapping is not working properly anymore. The problem manifest on W2k with Outlook Express when using the “find” text function within a huge mail folder.

(*) the whole system locks up : no response to mouse moves , keyboard input , etc… and no BSOD neither ! ? The only thing left to do is pushing the reset button :slight_smile:

----- Original Message -----
From: yatindra vaishnav
To: Windows System Software Devs Interest List
Sent: Friday, November 21, 2003 8:36 AM
Subject: [ntdev] Re: Locking paged pool memory

Hi Christiaan,

It is fully leagal to use this snippet of code.

Good Luck,



>From: “Christiaan Ghijselinck”
>Reply-To: “Windows System Software Devs Interest List”
>To: “Windows System Software Devs Interest List”
>Subject: [ntdev] Locking paged pool memory
>Date: Thu, 20 Nov 2003 16:13:38 -0500
>
>Hello all,
>
>Can following peace of code be legally used, or is it a “violation”
>against the rules :
>
>PVOID pMemory = ExAllocatePoolWithTag ( PagedPool ,
>TEN_PROCENT_OF_TOTAL_PAGEDPOOL , MYTAG ) ;
>PMDL pMDL = IoAllocateMdl ( pMemory , TEN_PROCENT_OF_TOTAL_PAGEDPOOL ,
>FALSE , FALSE , NULL ) ;
> MmProbeAndLockPages ( pMDL , KernelMode , IoModifyAccess )
>;
>
>
>
>—
>Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com

--------------------------------------------------------------------------
Contact brides & grooms FREE! Only on www.shaadi.com. Register now! —
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compaqnet.be
To unsubscribe send a blank email to xxxxx@lists.osr.com

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

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

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

You are currently subscribed to ntdev as: xxxxx@compaqnet.be
To unsubscribe send a blank email to xxxxx@lists.osr.com