can we use pinning interfaces provided by cache maneger in mini-filter drivers. like Ccmapdata(), CcPreparePinWrite().
Hi Piyush,
can we use pinning interfaces provided by cache maneger in mini-filter drivers.
like Ccmapdata(), CcPreparePinWrite().
What’s your objective?
Regards,
Ayush Gupta
hi ayush,
i want to keep data pinned for some specific files in cache itself and i dont want them to be flushed. for that i am trying to use CcPreparePinWrite() which maps as well as pins specified range of data. So can i do it through mini-filter? is there any special care (other than unpinning same data)that should be taken ,because i am not getting desired results.
The concept of ‘pinning’ has to do with controlling the mapping of the address, not the residency of the pages. Thus, if you want to ensure that the pages are not flushed, you need to LOCK them, not pin them in the cache. This is a subtle distinction and one I’ve seen cause trouble for people in the past.
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
Hi Tony,
The concept of ‘pinning’ has to do with controlling the mapping of the address, not the residency of >the pages. Thus, if you want to ensure that the pages are not flushed, you need to LOCK them, not >pin them in the cache.
Locking will preserve data in cache but it will not allow MM to flush data to page file. My intention was that the data should not be flushed by lazy writer thread on its own but only when i unpin it.
I read in Rajeev Nagar’s book that CcFlushCache() function does not flush modified buffers which are currently pinned in memory. But are flushed asynchronously by lazy writer thread when unpinned.
> I read in Rajeev Nagar’s book that CcFlushCache() function does not flush
modified buffers which are currently pinned in memory. But are flushed
asynchronously by lazy writer thread when unpinned
I think this is more about propagating the dirty flag from PTE to PFN - when
CcFlushCache is called this flag is not forcelly propagated for the pinned
data so if the pinned data(i.e. virtual pages) are backed by physical
pages( or real pages ) then they won’t be flushed but they can be flushed if
the physical( or real) memory becomes exhausted and in that case the flag is
propagated by the system. When the data is unpinned the dirty flag is
forcelly propagated from PTE to PFN. Windows kernel has a very sophisticated
politicy for dirty flag propagation.
Locking will preserve data in cache but it will not allow MM to flush data
to page file.
Cached data is never flushed to a pagefile, the data is flushed to a file
which is cached and therefore this file backs the cache.
–
Slava Imameyev, xxxxx@hotmail.com
wrote in message news:xxxxx@ntfsd…
> Hi Tony,
>>The concept of ‘pinning’ has to do with controlling the mapping of the
>>address, not the residency of >the pages. Thus, if you want to ensure that
>>the pages are not flushed, you need to LOCK them, not >pin them in the
>>cache.
>
> Locking will preserve data in cache but it will not allow MM to flush data
> to page file. My intention was that the data should not be flushed by lazy
> writer thread on its own but only when i unpin it.
>
> I read in Rajeev Nagar’s book that CcFlushCache() function does not flush
> modified buffers which are currently pinned in memory. But are flushed
> asynchronously by lazy writer thread when unpinned.
>
>
>
Then what is the difference between CcMapxxx and CcPinMappedData?
Clearly there are 2 concepts - “mapping” and “pinning”. Am I wrong that
mapping is reserving an address range while pinning is locking (suspending
flushes)?
–
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
wrote in message news:xxxxx@ntfsd…
> The concept of ‘pinning’ has to do with controlling the mapping of the
address, not the residency of the pages. Thus, if you want to ensure that the
pages are not flushed, you need to LOCK them, not pin them in the cache. This
is a subtle distinction and one I’ve seen cause trouble for people in the past.
>
> Tony
>
> Tony Mason
> Consulting Partner
> OSR Open Systems Resources, Inc.
> http://www.osr.com
>
>
> Clearly there are 2 concepts - “mapping” and “pinning”. Am I wrong that
mapping is reserving an address range while pinning is locking (suspending
flushes)?
My perception of “mapping” and then “pinning” is as the following -
- “mapping” just says the OS to map the file in the cache but the OS
considers the mapped range as read only(but not impose this restriction in
PTE) so it might not check for dirty flag in PTE for this range when
flushing the cache or writing dirty data to free physical( real ) pages,
Windows kernel uses dirty flag in PFN not PTE for flushing and modified
pages writing, so the flag must be transferred from PTE to PFN but the
system might skip this if the range has been mapped but not pinned. So
“mapping” - this is a mapping for read. - “pinning” says the OS that the range might be modified, so it must check
for dirty flag in PTEs and transfer it in PFNs when flushing the cache or
freeing physical pages backing this region. So “pinning” - this is an adding
of a write attribute to a mapping with only a read attribute. The flushing
might be just optimized to not consider the pinned region until unpinning is
done, but Memory Manager can invalidate virtual to physical mapping to free
physical pages backing the region but now it must check for the dirty flag
in PTEs and transfer it to PFNs.
–
Slava Imameyev, xxxxx@hotmail.com
“Maxim S. Shatskih” wrote in message
news:xxxxx@ntfsd…
> Then what is the difference between CcMapxxx and CcPinMappedData?
>
> Clearly there are 2 concepts - “mapping” and “pinning”. Am I wrong that
> mapping is reserving an address range while pinning is locking (suspending
> flushes)?
>
> –
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> wrote in message news:xxxxx@ntfsd…
>> The concept of ‘pinning’ has to do with controlling the mapping of the
> address, not the residency of the pages. Thus, if you want to ensure that
> the
> pages are not flushed, you need to LOCK them, not pin them in the cache.
> This
> is a subtle distinction and one I’ve seen cause trouble for people in the
> past.
>>
>> Tony
>>
>> Tony Mason
>> Consulting Partner
>> OSR Open Systems Resources, Inc.
>> http://www.osr.com
>>
>>
>
>