Cache Replacement policy

As my previous design fails to give the I/O priority to my process, so there
is change in the design.
I just want to know that whether its possible to change the cache page
replacement policy while sitting over the file system filter driver. I don’t
want the windows default LRU to replace the files that are accessed by my
process upto a certain limit.
In case of page fault mine filter driver to filesytem will allocate a page
in the memory in case of empty free page list and zero page list.

suggest some readings or give some hints
Thanks in Advance.

The best of way of doing this is to use memory-mapping as appropriate in
your application to force ranges of the files that you use into memory.
It’s not possible to dictate policy like this to the Cache Manager.

vikram wrote:

As my previous design fails to give the I/O priority to my process, so there
is change in the design.
I just want to know that whether its possible to change the cache page
replacement policy while sitting over the file system filter driver. I don’t
want the windows default LRU to replace the files that are accessed by my
process upto a certain limit.
In case of page fault mine filter driver to filesytem will allocate a page
in the memory in case of empty free page list and zero page list.

suggest some readings or give some hints
Thanks in Advance.


Nick Ryan
(Microsoft Windows MVP for DDK)

Thanks Nick,
But i don;t want this. I have an alogrithm according to which i gotto know
if x page is accessed at some moment then f(x) should be the next. and f(x)
= f(y) even if x!=y. where x is increasing linearly. so i know that what are
the pages which my process needs in future. And i don’t want OS to overwrite
those pages by its default page replacement algorithm.
Can i make a page free before the OS uses its default page replacement by
sitting on the filesystem.

“Nick Ryan” wrote in message news:xxxxx@ntfsd…
> The best of way of doing this is to use memory-mapping as appropriate in
> your application to force ranges of the files that you use into memory.
> It’s not possible to dictate policy like this to the Cache Manager.
>
> vikram wrote:
>
> > As my previous design fails to give the I/O priority to my process, so
there
> > is change in the design.
> > I just want to know that whether its possible to change the cache page
> > replacement policy while sitting over the file system filter driver. I
don’t
> > want the windows default LRU to replace the files that are accessed by
my
> > process upto a certain limit.
> > In case of page fault mine filter driver to filesytem will allocate a
page
> > in the memory in case of empty free page list and zero page list.
> >
> > suggest some readings or give some hints
> > Thanks in Advance.
> >
> >
> >
>
> –
> Nick Ryan
> (Microsoft Windows MVP for DDK)
>

You can always force pages into the cache by generating your own cached
reads, and there are APIs to ‘pin’ ranges in the cache so they aren’t
purged (but I’ve never heard of a filesystem filter using these APIs in
this manner, so be careful).

vikram wrote:

Thanks Nick,
But i don;t want this. I have an alogrithm according to which i gotto know
if x page is accessed at some moment then f(x) should be the next. and f(x)
= f(y) even if x!=y. where x is increasing linearly. so i know that what are
the pages which my process needs in future. And i don’t want OS to overwrite
those pages by its default page replacement algorithm.
Can i make a page free before the OS uses its default page replacement by
sitting on the filesystem.

“Nick Ryan” wrote in message news:xxxxx@ntfsd…
>
>>The best of way of doing this is to use memory-mapping as appropriate in
>>your application to force ranges of the files that you use into memory.
>>It’s not possible to dictate policy like this to the Cache Manager.
>>
>>vikram wrote:
>>
>>
>>>As my previous design fails to give the I/O priority to my process, so
>
> there
>
>>>is change in the design.
>>>I just want to know that whether its possible to change the cache page
>>>replacement policy while sitting over the file system filter driver. I
>
> don’t
>
>>>want the windows default LRU to replace the files that are accessed by
>
> my
>
>>>process upto a certain limit.
>>>In case of page fault mine filter driver to filesytem will allocate a
>
> page
>
>>>in the memory in case of empty free page list and zero page list.
>>>
>>>suggest some readings or give some hints
>>>Thanks in Advance.
>>>
>>>
>>>
>>
>>–
>>Nick Ryan
>>(Microsoft Windows MVP for DDK)
>>
>
>
>
>

Data that is “pinned” into the system cache via the various pinning APIs
just ensures that the data stays mapped into the system cache’s virtual
address space. The memory manager could still choose to page this data
out of physical memory if it deems this necessary. The only way you can
ensure a page of data is not paged out is to lock it into memory
(MmProbeAndLockPages is the API commonly used).

BUT – I will strongly second Nick’s warning about doing this. By
locking the data into physical memory, you limit the flexibility of the
memory manager to respond to the memory demands of the system. If you
tie the memory manager’s hands too tightly, at best the system’s
performance will get much worse, at worst the system bugchecks.

I would suggest doing your best to design your product such that you use
techniques to prime the cache with the data your are interested in
(Nick’s suggestions will do just that for you), but you can cope with
your data not being resident in memory when the system is memory
constrained.

Thanks,
Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Nick Ryan
Sent: Saturday, January 24, 2004 4:40 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Cache Replacement policy

You can always force pages into the cache by generating your own cached
reads, and there are APIs to ‘pin’ ranges in the cache so they aren’t
purged (but I’ve never heard of a filesystem filter using these APIs in
this manner, so be careful).

vikram wrote:

Thanks Nick,
But i don;t want this. I have an alogrithm according to which i gotto

know if x page is accessed at some moment then f(x) should be the
next. and f(x) = f(y) even if x!=y. where x is increasing linearly. so

i know that what are the pages which my process needs in future. And i

don’t want OS to overwrite those pages by its default page replacement
algorithm.
Can i make a page free before the OS uses its default page replacement

by sitting on the filesystem.

“Nick Ryan” wrote in message news:xxxxx@ntfsd…
>
>>The best of way of doing this is to use memory-mapping as appropriate
>>in your application to force ranges of the files that you use into
memory.
>>It’s not possible to dictate policy like this to the Cache Manager.
>>
>>vikram wrote:
>>
>>
>>>As my previous design fails to give the I/O priority to my process,
>>>so
>
> there
>
>>>is change in the design.
>>>I just want to know that whether its possible to change the cache
>>>page replacement policy while sitting over the file system filter
>>>driver. I
>
> don’t
>
>>>want the windows default LRU to replace the files that are accessed
>>>by
>
> my
>
>>>process upto a certain limit.
>>>In case of page fault mine filter driver to filesytem will allocate a
>
> page
>
>>>in the memory in case of empty free page list and zero page list.
>>>
>>>suggest some readings or give some hints Thanks in Advance.
>>>
>>>
>>>
>>
>>–
>>Nick Ryan
>>(Microsoft Windows MVP for DDK)
>>
>
>
>
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> -----Original Message-----

From: Molly Brown [mailto:xxxxx@windows.microsoft.com]

The only way you can
ensure a page of data is not paged out is to lock it into memory
(MmProbeAndLockPages is the API commonly used).

BUT – I will strongly second Nick’s warning about doing this. By
locking the data into physical memory, you limit the
flexibility of the
memory manager to respond to the memory demands of the system. If you
tie the memory manager’s hands too tightly, at best the system’s
performance will get much worse, at worst the system bugchecks.

How to determine the safe limit for the number of locked pages from a kernel
driver?

Permon doesn’t provide any relevant statistics.
WinDbg’s “!vm” extension is useful but it uses debug symbol files to read
non-exported
memory manager’s internals.

Dmitriy Budko

There isn’t a hard limit as to what a “safe” amount of locked pages
would be. It always depends on what else is going on in the system.
Therefore, you should do your best to minimize the amount of memory
locked down and the length of time you leave these pages locked so that
it is just as long as needed to do the required processing of the data.

You do have to balance this requirement with the fact that it is
relatively expensive to lock down memory. For that reason, it is
typical that once a buffer is locked down for an IO by one device in the
IO processing stack (say the a filter driver), it remains locked
throughout remainder of the IO so that other drivers that may need to
access the data will not have to lock the memory down again. For
example, if you create a MDL to represent a user data buffer and use
MmProbeAndLockPages to lock this buffer down in your filter driver, this
MDL stays locked down until the IRP processing for this IO is completed
and the MDL will be unlocked and freed by the IO Manager.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dmitriy Budko
Sent: Monday, January 26, 2004 2:08 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Cache Replacement policy

-----Original Message-----
From: Molly Brown [mailto:xxxxx@windows.microsoft.com]

The only way you can
ensure a page of data is not paged out is to lock it into memory
(MmProbeAndLockPages is the API commonly used).

BUT – I will strongly second Nick’s warning about doing this. By
locking the data into physical memory, you limit the flexibility of
the memory manager to respond to the memory demands of the system. If

you tie the memory manager’s hands too tightly, at best the system’s
performance will get much worse, at worst the system bugchecks.

How to determine the safe limit for the number of locked pages from a
kernel driver?

Permon doesn’t provide any relevant statistics.
WinDbg’s “!vm” extension is useful but it uses debug symbol files to
read non-exported memory manager’s internals.

Dmitriy Budko


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks Molly,
I have few issues doing this:

  1. Can I use CcMdlRead and CcMdlReadComplete inorder to lock the pages in
    the system cache while sitting in FSD filter driver. If possible give some
    hints. We have tried using this but it is crashing because of
    privateCacheMap is NULL.

  2. Is it possible to pin the pages from FSD filter driver. using Pin
    Interface of cache manager

  3. How can i lock the pages using MmProbeAndLockPages while sitting over the
    FSD.(Is it possible?)

Thanks in Advance.
=vikramsingh

“Molly Brown” wrote in message
news:xxxxx@ntfsd…
Data that is “pinned” into the system cache via the various pinning APIs
just ensures that the data stays mapped into the system cache’s virtual
address space. The memory manager could still choose to page this data
out of physical memory if it deems this necessary. The only way you can
ensure a page of data is not paged out is to lock it into memory
(MmProbeAndLockPages is the API commonly used).

BUT – I will strongly second Nick’s warning about doing this. By
locking the data into physical memory, you limit the flexibility of the
memory manager to respond to the memory demands of the system. If you
tie the memory manager’s hands too tightly, at best the system’s
performance will get much worse, at worst the system bugchecks.

I would suggest doing your best to design your product such that you use
techniques to prime the cache with the data your are interested in
(Nick’s suggestions will do just that for you), but you can cope with
your data not being resident in memory when the system is memory
constrained.

Thanks,
Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Nick Ryan
Sent: Saturday, January 24, 2004 4:40 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Cache Replacement policy

You can always force pages into the cache by generating your own cached
reads, and there are APIs to ‘pin’ ranges in the cache so they aren’t
purged (but I’ve never heard of a filesystem filter using these APIs in
this manner, so be careful).

vikram wrote:

> Thanks Nick,
> But i don;t want this. I have an alogrithm according to which i gotto

> know if x page is accessed at some moment then f(x) should be the
> next. and f(x) = f(y) even if x!=y. where x is increasing linearly. so

> i know that what are the pages which my process needs in future. And i

> don’t want OS to overwrite those pages by its default page replacement
algorithm.
> Can i make a page free before the OS uses its default page replacement

> by sitting on the filesystem.
>
> “Nick Ryan” wrote in message news:xxxxx@ntfsd…
>
>>The best of way of doing this is to use memory-mapping as appropriate
>>in your application to force ranges of the files that you use into
memory.
>>It’s not possible to dictate policy like this to the Cache Manager.
>>
>>vikram wrote:
>>
>>
>>>As my previous design fails to give the I/O priority to my process,
>>>so
>
> there
>
>>>is change in the design.
>>>I just want to know that whether its possible to change the cache
>>>page replacement policy while sitting over the file system filter
>>>driver. I
>
> don’t
>
>>>want the windows default LRU to replace the files that are accessed
>>>by
>
> my
>
>>>process upto a certain limit.
>>>In case of page fault mine filter driver to filesytem will allocate a
>
> page
>
>>>in the memory in case of empty free page list and zero page list.
>>>
>>>suggest some readings or give some hints Thanks in Advance.
>>>
>>>
>>>
>>
>>–
>>Nick Ryan
>>(Microsoft Windows MVP for DDK)
>>
>
>
>
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Yes, the CcMdl interfaces will lock the cache buffers into physical
memory. If the file object’s private cache map is NULL, it has not been
setup for caching. For all file objects passed to the cache manager
interfaces (either copy, mdl, or pin), caching must have been
initialized for the file object.

A filter can use the pinning interfaces, but you cannot mix their use
arbitrarily with the CcCopy interfaces. For example, a filter may want
to use the pinning interfaces to access its own private metadata file.

To lock pages, you first need a buffer which is backed by the pages you
are interested in locking. You create a MDL structure to represent the
buffer by calling IoAllocateMdl, then pass that MDL to
MmProbeAndLockPages. Both the DDK and IFS Kit documentation describe
these routines in more detail.

Thanks,
Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of vikram
Sent: Saturday, February 21, 2004 7:25 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Cache Replacement policy

Thanks Molly,
I have few issues doing this:

  1. Can I use CcMdlRead and CcMdlReadComplete inorder to lock the pages
    in the system cache while sitting in FSD filter driver. If possible give
    some hints. We have tried using this but it is crashing because of
    privateCacheMap is NULL.

  2. Is it possible to pin the pages from FSD filter driver. using Pin
    Interface of cache manager

  3. How can i lock the pages using MmProbeAndLockPages while sitting over
    the FSD.(Is it possible?)

Thanks in Advance.
=vikramsingh

“Molly Brown” wrote in message
news:xxxxx@ntfsd…
Data that is “pinned” into the system cache via the various pinning APIs
just ensures that the data stays mapped into the system cache’s virtual
address space. The memory manager could still choose to page this data
out of physical memory if it deems this necessary. The only way you can
ensure a page of data is not paged out is to lock it into memory
(MmProbeAndLockPages is the API commonly used).

BUT – I will strongly second Nick’s warning about doing this. By
locking the data into physical memory, you limit the flexibility of the
memory manager to respond to the memory demands of the system. If you
tie the memory manager’s hands too tightly, at best the system’s
performance will get much worse, at worst the system bugchecks.

I would suggest doing your best to design your product such that you use
techniques to prime the cache with the data your are interested in
(Nick’s suggestions will do just that for you), but you can cope with
your data not being resident in memory when the system is memory
constrained.

Thanks,
Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Nick Ryan
Sent: Saturday, January 24, 2004 4:40 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Cache Replacement policy

You can always force pages into the cache by generating your own cached
reads, and there are APIs to ‘pin’ ranges in the cache so they aren’t
purged (but I’ve never heard of a filesystem filter using these APIs in
this manner, so be careful).

vikram wrote:

> Thanks Nick,
> But i don;t want this. I have an alogrithm according to which i gotto

> know if x page is accessed at some moment then f(x) should be the
> next. and f(x) = f(y) even if x!=y. where x is increasing linearly. so

> i know that what are the pages which my process needs in future. And i

> don’t want OS to overwrite those pages by its default page replacement
algorithm.
> Can i make a page free before the OS uses its default page replacement

> by sitting on the filesystem.
>
> “Nick Ryan” wrote in message news:xxxxx@ntfsd…
>
>>The best of way of doing this is to use memory-mapping as appropriate
>>in your application to force ranges of the files that you use into
memory.
>>It’s not possible to dictate policy like this to the Cache Manager.
>>
>>vikram wrote:
>>
>>
>>>As my previous design fails to give the I/O priority to my process,
>>>so
>
> there
>
>>>is change in the design.
>>>I just want to know that whether its possible to change the cache
>>>page replacement policy while sitting over the file system filter
>>>driver. I
>
> don’t
>
>>>want the windows default LRU to replace the files that are accessed
>>>by
>
> my
>
>>>process upto a certain limit.
>>>In case of page fault mine filter driver to filesytem will allocate a
>
> page
>
>>>in the memory in case of empty free page list and zero page list.
>>>
>>>suggest some readings or give some hints Thanks in Advance.
>>>
>>>
>>>
>>
>>–
>>Nick Ryan
>>(Microsoft Windows MVP for DDK)
>>
>
>
>
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com