debugging question - long allocation in MmAllocatePagesForMdlEx

i’m looking at a dump where i have a bunch of thread spinning on a spin lock. the offending thread which owns the lock has spent 4.5 minutes in Mm trying to allocate memory:

nt!MiAllocateMostlyContiguous+0x3ab
nt!MiFindPagesForMdl+0x156
nt!MiAllocatePagesForMdl+0xaf
nt!MmAllocateNodePagesForMdlEx+0x75
nt!MmAllocatePagesForMdlEx+0x5b
mydriver!__AllocPagesForMdl+0x2f
mydriver!___AllocPages+0x2f

any idea why this might occurr? looks like I have plenty of memory:

2: kd>!memusage:

loading PFN database
loading (100% complete)
Compiling memory usage data (99% Complete).
Zeroed: 9969 ( 39876 kb)
Free: 2 ( 8 kb)
Standby: 21694504 (86778016 kb)
Modified: 17132 ( 68528 kb)
ModifiedNoWrite: 3 ( 12 kb)
Active/Valid: 42270547 (169082188 kb)
Transition: 38 ( 152 kb)
SLIST/Bad: 7705 ( 30820 kb)
Unknown: 0 ( 0 kb)
TOTAL: 63999900 (255999600 kb)

2: kd> !poolused 2

Sorting by NonPaged Pool Consumed

NonPaged Paged
Tag Allocs Used Allocs Used

EtwB 1900 298528800 225 42717184 Etw Buffer , Binary: nt!etw
AfdB 15334 126701072 0 0 Afd data buffer , Binary: afd.sys
TcDM 22973 93963072 0 0 TCP Delayed Delivery Memory Descriptor Lists , Binary: tcpip.sys
WfpL 2652493 84947472 0 0 WFP fast cache , Binary: netio.sys
Thre 29365 60583376 0 0 Thread objects , Binary: nt!ps
MmPb 2 21753856 0 0 Paging file bitmaps , Binary: nt!mm
Even 168523 21583168 0 0 Event objects
MmSd 131682 16855296 0 0 extended subsections used to map data files , Binary: nt!mm
File 49292 16530272 0 0 File objects
Nbuf 1851 15231152 0 0 NetIO Memory Descriptor List allocations , Binary: netio.sys

2: kd> !vm

*** Virtual Memory Usage ***
Physical Memory: 63999900 ( 255999600 Kb)
Page File: ??\C:\pagefile.sys
Current: 33564672 Kb Free Space: 32459440 Kb
Minimum: 33564672 Kb Maximum: 33564672 Kb
Page File: ??\Z:\pagefile.sys
Current: 16252928 Kb Free Space: 16239380 Kb
Minimum: 16252928 Kb Maximum: 314399612 Kb
Available Pages: 21704475 ( 86817900 Kb)
ResAvail Pages: 62607681 ( 250430724 Kb)
Locked IO Pages: 0 ( 0 Kb)
Free System PTEs: 4294385060 (17177540240 Kb)
Modified Pages: 16498 ( 65992 Kb)
Modified PF Pages: 14889 ( 59556 Kb)
NonPagedPool 0 Used: 652 ( 2608 Kb)
NonPagedPoolNx 0 Used:119831 ( 479324 Kb)
NonPagedPool 1 Used: 165 ( 660 Kb)
NonPagedPoolNx 1 Used: 45679 ( 182716 Kb)
NonPagedPool Usage: 1019 ( 4076 Kb)
NonPagedPoolNx Usage: 280686 ( 1122744 Kb)
NonPagedPool Max: 4294967296 (17179869184 Kb)
PagedPool 0 Usage: 111168 ( 444672 Kb)
PagedPool 1 Usage: 54583 ( 218332 Kb)
PagedPool 2 Usage: 38633 ( 154532 Kb)
PagedPool Usage: 204384 ( 817536 Kb)
PagedPool Maximum: 4160749568 (16642998272 Kb)
Session Commit: 5597 ( 22388 Kb)
Shared Commit: 72696 ( 290784 Kb)
Special Pool: 0 ( 0 Kb)
Shared Process: 79605 ( 318420 Kb)
Pages For MDLs: 1935 ( 7740 Kb)
PagedPool Commit: 204469 ( 817876 Kb)
Driver Commit: 7012 ( 28048 Kb)
Committed pages: 45373860 ( 181495440 Kb)
Commit limit: 76454300 ( 305817200 Kb)

What arguments are you passing to MmAllocatePagesForMdlEx?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, April 2, 2015 1:22 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] debugging question - long allocation in MmAllocatePagesForMdlEx

i’m looking at a dump where i have a bunch of thread spinning on a spin lock. the offending thread which owns the lock has spent 4.5 minutes in Mm trying to allocate memory:

nt!MiAllocateMostlyContiguous+0x3ab
nt!MiFindPagesForMdl+0x156
nt!MiAllocatePagesForMdl+0xaf
nt!MmAllocateNodePagesForMdlEx+0x75
nt!MmAllocatePagesForMdlEx+0x5b
mydriver!__AllocPagesForMdl+0x2f
mydriver!___AllocPages+0x2f

any idea why this might occurr? looks like I have plenty of memory:

2: kd>!memusage:

loading PFN database
loading (100% complete)
Compiling memory usage data (99% Complete).
Zeroed: 9969 ( 39876 kb)
Free: 2 ( 8 kb)
Standby: 21694504 (86778016 kb)
Modified: 17132 ( 68528 kb)
ModifiedNoWrite: 3 ( 12 kb)
Active/Valid: 42270547 (169082188 kb)
Transition: 38 ( 152 kb)
SLIST/Bad: 7705 ( 30820 kb)
Unknown: 0 ( 0 kb)
TOTAL: 63999900 (255999600 kb)