Commit graph

22 commits

Author SHA1 Message Date
Timo Kreuzer 987bf80da1 [NTOSKRNL]
Fix a number of warnings from VS /analyze

svn path=/trunk/; revision=58319
2013-02-16 17:37:17 +00:00
Timo Kreuzer 1a64a18b5e [NTOSKRNL]
- Add some missing return value checks
- Add some annotations
- Fix format specifiers
- Fix variable scope conflicts
- Fix possible closing of a NULL handle
- Use ObCloseHandle instead of ZwClose

svn path=/trunk/; revision=57954
2012-12-19 23:49:13 +00:00
Hermès Bélusca-Maïto 24a14abf27 [NTOSKRNL]
- ExFreePool --> ExFreePoolWithTag in some places.
- Remove dead code (section.c)
- Free resource (sysldr.c)

svn path=/trunk/; revision=57412
2012-09-28 12:17:23 +00:00
Dmitry Gorbachev 455caa18fa [NTOSKRNL]
- Remove an unused variable.

[CHARMAP][CSRSRV][MOUNTMGR]
- Declare variables extern.

svn path=/trunk/; revision=57241
2012-09-05 21:38:02 +00:00
Timo Kreuzer 5c32d6c764 [NTOSKRNL]
- Fix amd64 build
- Fix some MSVC/amd64 warnings

svn path=/trunk/; revision=56491
2012-05-04 11:32:07 +00:00
Art Yerkes 644889076d [NTOSKRNL]
Small edit.

svn path=/trunk/; revision=56269
2012-03-29 06:04:34 +00:00
Art Yerkes 8a3e9c37be [NTOSKRKNL]
Write a lot of general prose about the operation of the Mm parts of NewCC.

Dedicate to timo and chongo.

No code changes.

svn path=/trunk/; revision=56267
2012-03-29 04:43:44 +00:00
Timo Kreuzer 3bdad064e3 [NTOSKRNL]
- Make file offsets 64 bit
- Fix lots of MSVC/64 bit warnings

svn path=/trunk/; revision=56264
2012-03-28 19:41:40 +00:00
Amine Khaldi 5491e8fbde [FORMATTING]
* Improve indentation, remove trailing spaces, apply a consistent style, adjust to 80 col... No code changes.

svn path=/trunk/; revision=56262
2012-03-28 18:39:21 +00:00
Cameron Gutman cfb8d5658b [NEWCC]
- Check that the memory area is not being deleted before using it

svn path=/trunk/; revision=56051
2012-03-05 19:48:24 +00:00
Cameron Gutman 9973fe86bf [NEWCC]
- Hold the PFN lock when referencing pages

svn path=/trunk/; revision=56049
2012-03-05 19:29:39 +00:00
Cameron Gutman 9234774efe [NEWCC]
- Tag NewCC sections as ROS section objects so they don't get pulled into ARM3 code paths

svn path=/trunk/; revision=56040
2012-03-05 17:35:07 +00:00
Cameron Gutman 50e1500799 [NTOSKRNL]
- Consolidate most of the PDE reference counting code into the arch-specific RosMm folder where it belongs

svn path=/trunk/; revision=56018
2012-03-04 22:31:30 +00:00
Cameron Gutman 72a7d22233 [NTOSKRNL]
- Fix PDE reference counting
- Now only the recursive fault remains as an issue in the page out path

svn path=/trunk/; revision=55898
2012-02-28 09:30:53 +00:00
Cameron Gutman 24264b8dc2 [NTOSKRNL]
- Change MmDereferencePage to MmReleasePageMemoryConsumer to do proper page usage tracking
- Remove an unnecessary reference and dereference

svn path=/trunk/; revision=55897
2012-02-28 08:34:16 +00:00
Art Yerkes b10383d1ff [NEWCC]
Integrate september's speed improvements, which now work.
Remove the flush hack when unpinning cache segments.

svn path=/trunk/; revision=55839
2012-02-24 11:33:23 +00:00
Art Yerkes 3e19b0bab3 [NEWCC]
Update used page table entry counts when mapping pages in cache sections.

svn path=/trunk/; revision=55837
2012-02-24 10:05:06 +00:00
Amine Khaldi e14f67f95d [NEWCC]
A reintegration checkpoint for the NewCC branch, brought to you by Team NewCC.

Differences with current ReactOS trunk:

* A new memory area type, MEMORY_AREA_CACHE, is added, which represents a mapped region of a file. In NEWCC mode, user sections are MEMORY_AREA_CACHE type as well, and obey new semantics. In non-NEWCC mode, they aren't used.
* A way of claiming a page entry for a specific thread's work is added. Placing the special SWAPENTRY value MM_WAIT_ENTRY in a page table, or in a section page table should indicate that memory management code is intended to wait for another thread to make some status change before checking the state of the page entry again. In code that uses this convention, a return value of STATUS_SUCCESS + 1 is used to indicate that the caller should use the MiWaitForPageEvent macro to wait until somebody has change the state of a wait entry before checking again. This is a lighter weight mechanism than PAGEOPs.
* A way of asking the caller to perform some blocking operation without locks held is provided. This replaces some spaghettified code in which locks are repeatedly taken and broken by code that performs various blocking operations. Using this mechanism, it is possible to do a small amount of non-blocking work, fill in a request, then return STATUS_MORE_PROCESSING_REQUIRED to request that locks be dropped and the blocking operation be carried out. A MM_REQUIRED_RESOURCES structure is provided to consumers of this contract to use to accumulate state across many blocking operations. Several functions wrapping blocking operations are provided in ntoskrnl/cache/reqtools.c.
* Image section pages are no longer direct mapped. This is done to simplify consolidation of ownership of pages under the data section system. At a later time, it may be possible to make data pages directly available to image sections for the same file. This is likely the only direct performance impact this code makes on non-NEWCC mode.

RMAPs:

* A new type of RMAP entry is introduced, distinguished by RMAP_IS_SEGMENT(Address) of the rmap entry. This kind of entry contains a pointer to a section page table node in the Process pointer, which in turn links back to the MM_SECTION_SEGMENT it belongs to. Therefore, a page belonging only to a segment (that is, a segment page that isn't mapped) can exist and be evicted using the normal page eviction mechanism in balance.c. Each of the rmap function has been modified to deal with segment rmaps.
* The low 8 bits of the Address field in a segment rmap denote the entry number in the generic table node pointed to by Process that points to the page the rmap belongs to. By combining them, you can determine the file offset the page belongs to.
* In NEWCC mode, MmSharePageEntry/UnsharePageEntry are not used, and instead the page reference count is used to keep track of the number of mappings of a page, allowing the last reference expiring to allow the page to be recycled without much intervention. These are still used in non-NEWCC mode. One change has been made, the count fields have been narrowed by 1 bit to make room for a dirty bit in SSE entries, needed when a page is present but unmapped.

Section page tables:

* The section page tables are now implemented using RtlGenericTables. This enables a fairly compact representation of section page tables without having the existence of a section object imply 4k of fake PDEs. In addition, each node in the generic table has a wide file offset that is a multiple of 256 pages, or 1 megabyte total. Besides needing wide file offsets, the only other visible change caused by the switch to generic tables for section page tables is the need to lock the section segment before interacting with the section page table.

Eviction:

* Page eviction in cache sections is accomplished by MmpPageOutPhysicalAddress. In the case of a shared page, it tries to remove all mappings of the indicated page. If this process fails at any point, the page will simply be drawn back into the target address spaces. After succeeding at this, if TRUE has been accumulated into the page's dirty bit in the section page table, it is written back, and then permanently removed.

NewCC mode:

* NEWCC mode is introduced, which rewrites the file cache to a set of cache stripes actively mapped, along with unmapped section data.
* NewCC is more authentic in its interpretation of the external interface to the windows cache than the current cache manager, implementing each of the cache manager functions according to the documented interface with no preconceived ideas about how anything should be implemented internally. Cache stripes are implemented on top of section objects, using the same memory manager paths, and therefore economizing code and complexity. This replaces a rather complicated system in which pages can be owned by the cache manager and the memory manager simultaneously and they must cooperate in a fairly sophisticated way to manage them. Since they're quite interdependent in the current code, modifying either is very difficult. In NEWCC, they have a clear division of labor and thus can be worked on independently.
* Several third party filesystems that use the kernel Cc interface work properly using NEWCC, including matt wu's ext3 driver.
* In contrast with code that tries to make CcInitializeCacheMap and CcUninitializeCacheMap into a pair that supports reference counting, NEWCC lazily initializes the shared and private cache maps as needed and uses the presence of a PrivateCacheMap on at least one file pointing to the SharedCacheMap as an indication that the FILE_OBJECT reference in the SharedCacheMap should still be held. When the last PrivateCacheMap is discarded, that's the appropriate time to tear down caching for a specific file, as the SharedCacheMap data is allowed to be saved and reused. We honor this by making the SharedCacheMap into a depot for keeping track of the PrivateCacheMap objects associated with views of a file.

svn path=/trunk/; revision=55833
2012-02-23 12:03:06 +00:00
Dmitry Gorbachev f7e57490c6 [CSRSRV|NTOSKRNL|KERNEL32|NTDLL]
Fix multiple definition of variables.

svn path=/trunk/; revision=52859
2011-07-25 05:54:37 +00:00
Rafal Harabien 2861515d78 [NTOSKRNL]
- Use tags when allocation and freeing memory and define them in tag.h
- Fix some wrongly used tags when freeing
- Our new memory manager doesn't check tags when ExFreePoolWithTag is used. It will be fixed after testing

svn path=/trunk/; revision=52043
2011-06-01 13:39:36 +00:00
Art Yerkes 0cb645cb12 Part 1 of fixes: For some reason beyond me, I had abbreviated
MiCowSectionPage to always assume CoW rather than always not
CoW for cache sections.  

Make sure we're looking for cache type sections rather than
(as we were in the branch) data file sections.  More needed.

svn path=/trunk/; revision=49555
2010-11-11 08:15:50 +00:00
Art Yerkes f2e646d5b4 [CACHE]
The cache manager rewrite I started years ago has finally appeared in
ReactOS' trunk and although at this point it's not quite perfectly
integrated, it's enough to boot up the bootcd or livecd. To check out
the more mature original, check out arty-newcc-reactos, branch
arty-newcc on bitbucket.org . Amine Khaldi encouraged me quite a bit
to not give up on it, and was able to reach out and be an advocate
when i really wasn't able to.  Others agree that the time has come to
begin removing the old cache manager. I expect the remaining problems
in the version going to trunk will be taken care of relatively
quickly.

The motivation for this effort lies in the particularly hairy
relationship between ReactOS' cache manager and data sections. This
code completely removes page sharing between cache manager and section
and reimagines cache manager as being a facility layered on the memory
manager, not really caring about individual pages, but simply managing
data section objects where caching might occur.

It took me about 2 years to do the first pass of this rewrite and most
of this year to fix some lingering issues, properly implement demand
paging in ReactOS (code which didn't come with this patch in a
recognizable form), and finish getting the PrivateCacheMap and
SharedCacheMap relationship correct.

Currently, the new ntoskrnl/cache directory contains an own
implementation of data file sections. After things have settled down,
we can begin to deprecate and remove the parts of ReactOS' section
implementation that depend on a close relationship with cache
manager. Eventually, I think that the extra code added to
ntoskrnl/cache/section will be removed and ReactOS' own sections will
replace the use of the special MM_CACHE_SECTION_SEGMENT in the cache
path.

Note also, that this makes all cache manager (and new section parts)
use wide file offsets. If my section code were to take over other
parts of the ReactOS memory manager, they would also benefit from
these improvements.

I invite anyone who wants to to peek at this code and fix whatever
bugs can be found.


svn path=/trunk/; revision=49423
2010-11-02 02:32:39 +00:00