RE: [NTDev] Proper order of tearing down an MDL ...

Sara,

I remember your similar response when I was having that problem; but
I think the empirical evidence is against you. Both Gary and I were
able to run unlimited amounts of sequential I/O, with large buffers
mapped for each I/O, without explicitly unmapping the MDLs upon
completion. I don’t see how this would work if the PTEs weren’t
being recycled. It’s parallelism or giant buffers, that cause the
PTEs to be exhausted all at once, that causes the crash.

You speak of freeing the MDL, but for ‘direct’ IRPs, the OS provides
and seemingly frees the primary data MDL. The driver doesn’t explicitly
free it. Perhaps the difference between your experience and ours is
that you were dealing with additional private MDLs, allocating and
freeing them yourself?

Now that you’ve got me thinking about it again…

Have a look in a debugger at the actual disassembly of MmUnlockPages().
The first thing it does is test byte 6 of the MDL (MdlFlags) for bit 0x01
(MDL_MAPPED_TO_SYSTEM_VA), then conditionally calls MmUnmapLockedPages().

So, though IoFreeMdl() doesn’t unmap unless MDL_PARTIAL_HAS_BEEN_MAPPED
is set, ‘direct’ I/O MDLs are going to be unmapped by virtue of being
unlocked.


Dave Cox
Hewlett-Packard Co.
NSSO/SANS/SMSO (Santa Barbara)
https://ecardfile.com/id/Dave+Cox

-----Original Message-----
From: Sara Abraham [mailto:xxxxx@veritas.com]
Sent: Wednesday, December 20, 2000 12:39 PM
To: NT Developers Interest List
Subject: [ntdev] RE: [NTDev] Proper order of tearing down an MDL …

>
> > Hmmm, since it’s IoAllocateMdl links it to
> > IRP->MdlAddress->Next, do I need
> > to call IoFreeMdl, or will that happen when IoCompleteRequest
> > tears down the
> >
> > IRP?
>
> I’ve never paid much attention to chaining MDLs with the
Next ptr, but
> it sounds like the system is cleaning up the portion you
append; this
> is how it is able to unmap your data buffers from system
space currently.
> If it did not, a few large I/Os would exhaust your PTEs immediately,
> overlapped or not.
>

It’s true that the Io completion routines will go through the
list of MDLs
and free them, however, it won’t unlock and unmap them.
From my NT4 experience, the unlock and unmap was issued only
if MdlFlags was
MDL_PARTIAL (which happens if the MDL is allocated with
IoBuildPartialMdl).
Are you running a free build ? If this is your problem and
you’ll run a
check build, you should hit an ASSERT when trying to free a
mapped MDL.

Sara


You are currently subscribed to ntdev as: david_cox2@hp.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com