Pinning Interface and MDL Interface

I am a green hand in kernel. I can’t understand the difference between the
Pinning Interface and MDL Interface for cache manage.I hope get some
information about this.thanks to all of you.(I am sorry ,i am poor in my
english).

There are two important issues in managing things in cache:

Fixing a mapping of the VIRTUAL address to the data. The VA may be invalid, in which case a page fault is generated and the virtual-to-physical page mapping is defined.

Fixing a mapping of the VIRTUAL to PHYSICAL address.

An MDL is a general mechanism for describing virtual and/or physical addresses. The Cc MDL interface returns an MDL where the virtual-to-physical mapping is fixed (“locked”) so that you may use either one and know that they are both persistent.

A “pin” ensures the virtual address points to the data that you expect, but does not guarantee that the physical memory containing the data is present.

Without pinning, the cache manager may reuse the virtual addresses. Without locking the MDL, the memory manager may reuse the physical memory.

Tony
OSR

First of all, thanks for you.
does It mean that the MDL fix a mapping of the virtual to physical address
and the pin fix a mapping of the virtual address to the data?

2012/9/1 Tony Mason

> There are two important issues in managing things in cache:
>
>

>
> Fixing a mapping of the VIRTUAL address to the data. The VA may be
> invalid, in which case a page fault is generated and the
> virtual-to-physical page mapping is defined.

>
> ****
>
> Fixing a mapping of the VIRTUAL to PHYSICAL address.
>
>
**
>
> An MDL is a general mechanism for describing virtual and/or physical
> addresses. The Cc MDL interface returns an MDL where the
> virtual-to-physical mapping is fixed (?locked?) so that you may use either
> one and know that they are both persistent.
**
>
> ****
>
> A ?pin? ensures the virtual address points to the data that you expect,
> but does not guarantee that the physical memory containing the data is
> present.
>
>

>
> Without pinning, the cache manager may reuse the virtual addresses.
> Without locking the MDL, the memory manager may reuse the physical memory.
>

>
> ****
>
> Tony
>
> OSR

>
> ****
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

I would suggest reading up on how virtual memory works.

The Memory Manager works with the hardware to define the virtual to physical page mappings for the system. Not all virtual addresses point to physical addresses, such as when the data for a given virtual address is not presently in memory - perhaps because it is in a file.

When a virtual to physical page mapping is fixed, we say the page is “locked”. That is a common use for MDLs - see MmProbeAndLockPages.

The Cache Manager has a finite address space, which it manages in “blocks” of 256KB. It may tear down and reuse the regions within its own cache as needed. However, sometimes the file system needs to ensure that the meaning of a virtual memory region remain fixed. This is because the file system is using that virtual address. To ensure that the cache manager does not recycle this virtual address the file system may “pin” it in the CM cache.

So “pinned in the cache” for the Cache Manager and “locked in memory” for the Memory Manager/Hardware are two distinct concepts.

Tony
OSR

oh, i get it. thank you very much.

2012/9/1 Tony Mason

> I would suggest reading up on how virtual memory works.
>
>

>
> The Memory Manager works with the hardware to define the virtual to
> physical page mappings for the system. Not all virtual addresses point to
> physical addresses, such as when the data for a given virtual address is
> not presently in memory ? perhaps because it is in a file.

>
> ****
>
> When a virtual to physical page mapping is fixed, we say the page is
> ?locked?. That is a common use for MDLs ? see MmProbeAndLockPages.
>
>

>
> The Cache Manager has a finite address space, which it manages in ?blocks?
> of 256KB. It may tear down and reuse the regions within its own cache as
> needed. However, sometimes the file system needs to ensure that the
> meaning of a virtual memory region remain fixed. This is because the file
> system is using that virtual address. To ensure that the cache manager
> does not recycle this virtual address the file system may ?pin? it in the
> CM cache.

>
> ****
>
> So ?pinned in the cache? for the Cache Manager and ?locked in memory? for
> the Memory Manager/Hardware are two distinct concepts.
>
>

>
> Tony

>
> OSR **
>
>
**
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>