Re: Memory fragmentation issue in kernel mode




"killme" <killme@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:553CE535-CD8D-4D53-8F5B-84BF514BF713@xxxxxxxxxxxxxxxx
Hi All,

I am having one peculiar problem in Windows XP SP2 (with all patches
applied). I have my driver that uses direct IO to perform data transfer
(the
data transfer will be in 256 KB buffers). I have one third party test
application which will be accessing my device to test the driver. When I
run
this application for around 1 million passes, then
MmGetSystemAddressForMdlSafe() fails in my driver. When I ran the ioctl
sample provided in DDK with different buffer sizes, it succeeded for 512
bytes and 4KB but failed for 64KB and afterwards indicating some memory
fragmentation. One more thing is that I never allocate any memory in the
driver during the process other than using MmGetSystemAddressxxx().

I have following questions:
1. In such scenario, what should a driver writer do? He can simply fail
the request and continue or try to access the MDL in a scatter/gather
manner
and continue based upon the importance of the device?

Well, if your driver can use this workaround, I would try that.

2. Will the system ever recover after such memory fragmentation?
3. Is it application's or system's responsibility to prevent memory
fragmentation? i.e. Is it an application bug or OS problem?

Well, a user level application can do very little with this kind of
fragmentation, which is actually fragmentation of the system virtual address
space. A user level application doesn't allocate and even access the system
virtual address space. A driver does (by allocating memory or mapping memory
from the process address space to system address space with
MmGetSystemAddress). But even in a driver, this is one the usual way to
dispatch IRPs. So strictly speaking, i think it's more of an OS problem.

....having said that, it seems quite weird that your machine's memory gets so
fragmented that the OS cannot map 64k of memory into system address space.
This operation is done literally thousands of times by the OS for every
communication between kernel mode and user mode. Are your direct io requests
synchronous or asynchronous? If asynch, how many concurrent IO requests (and
related mappings of MDLs to system address space) do you think you might
have?

Have a nice day
GV





.



Relevant Pages

  • Re: Memory fragmentation issue in kernel mode
    ... Also, on the Performance tab, watch the Kernel Memory section. ... fragmentation, which is actually fragmentation of the system virtual ... A user level application doesn't allocate and even access the ... I have my driver that uses direct IO to perform data transfer ...
    (microsoft.public.development.device.drivers)
  • Re: Memory fragmentation issue in kernel mode
    ... My direct I/O requests are asynchronous ones with 4 parallel ... Memory usage of the applications were looking normal. ... fragmentation, which is actually fragmentation of the system virtual ... application which will be accessing my device to test the driver. ...
    (microsoft.public.development.device.drivers)
  • [PATCH] Integrating SEP Driver with RAR Driver
    ... RAR stands for Restricted Access Region; this is memory ... This is upstream revision 4 of the SEP driver. ... +This functions maps and allocates the shared area on the external ...
    (Linux-Kernel)
  • Re: Memory fragmentation issue in kernel mode
    ... fragmentation, which is actually fragmentation of the system virtual ... A user level application doesn't allocate and even access the ... non-paged memory leaks - it can do quite a lot, ... application which will be accessing my device to test the driver. ...
    (microsoft.public.development.device.drivers)
  • PROBLEM: Memory leak in -test9?
    ... There seems to be a memory leak in 2.6.0-test9. ... 0cf8-0cff: PCI conf1 ... 16 nodes reported by PnP BIOS; 16 recorded by driver ... ide0 at 0x1f0-0x1f7,0x3f6 on irq 14 ...
    (Linux-Kernel)