Commit graph

25 commits

Author SHA1 Message Date
Colin Finck c2c66aff7d Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
Amine Khaldi ec120a57d3 [NTOS] Improve the FILE header section. Brought to you by Adam Stachowicz. CORE-10114
svn path=/trunk/; revision=69439
2015-10-04 11:54:25 +00:00
Timo Kreuzer 5280b4e3c6 [NTOSKRNL]
Convert MEMORY_AREA::EndingAddress to EndingVpn

svn path=/trunk/; revision=67786
2015-05-16 20:10:26 +00:00
Timo Kreuzer 85f59f294f [NTOSKRNL]
Convert MEMORY_AREA::StartingAddress to StaringVpn

svn path=/trunk/; revision=67785
2015-05-16 20:10:03 +00:00
Timo Kreuzer 0a3873c1c2 [NTOSKRNL]
Remove obsolete FreePage parameter from MmDeleteVirtualMapping

svn path=/trunk/; revision=64532
2014-10-05 07:16:01 +00:00
Amine Khaldi a1bafaeaaf [NTOSKRNL]
* Fix several print specifiers.
* Add some missing variables to debug prints.

svn path=/trunk/; revision=59923
2013-08-31 16:02:13 +00:00
Timo Kreuzer 0bacae2af9 [PSDK]
- Add proper definition for DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE

[NTOSKRNL/RTL]
- Fix a number of warnings about unreferenced local variables
- Add 2 assertions that unmapping a section succeeds

svn path=/trunk/; revision=59151
2013-06-02 19:04:02 +00:00
Hermès Bélusca-Maïto 572d5fcaeb [NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.

CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close

svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
Amine Khaldi aabb4465a0 [FORMATTING]
* Addendum to r56262.

svn path=/trunk/; revision=56273
2012-03-29 12:14:58 +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 03f0cf904e [NTOSKRNL]
- ObReferenceObject() does NOT return an NTSTATUS. It returns the new reference count. Remove pointless NT_SUCCESS check
- Enable interrupts in amd54 page fault handler before calling MmAccessFault
- Add missing MmDecommittedPte for amd64

svn path=/trunk/; revision=56265
2012-03-28 21:09:03 +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 18a6ac6ae4 [NEWCC]
- Don't allow a locked page to be paged out

svn path=/trunk/; revision=56047
2012-03-05 19:15:15 +00:00
Art Yerkes 4d698f45aa [NEWCC]
Fix paging out.
- We know we're in a wait entry in the section.  What we really want to know
is if it's safe to evict this address space when withdrawing the mappings.
- We don't want to corrupt our wait entry in the section page table to keep
accumulating dirty state into the page out process until it's time to finally
evict.

svn path=/trunk/; revision=56024
2012-03-05 02:20:22 +00:00
Cameron Gutman ea50be62a0 [NEWCC]
- Add missing wait entry handling

svn path=/trunk/; revision=56022
2012-03-04 23:45:16 +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
Cameron Gutman 29f3456caf [NEWCC]
- Fix several locking issues to better fit with RosMm
- Page out is critical as we use it now (shutdown) so force address space locking
- Fix an address space lock leak for VM regions
- Quiet some debugging and enable/change some other
- Still some lingering issues in page out exist which seem to be related to zefklop's PDE ref counting stuff and a weird one where we fault on the PFN database
- Besides the aforementioned issues, NewCC is surprisingly solid. I was able to boot to 3rd stage without a problem and run some apps.

svn path=/trunk/; revision=55895
2012-02-28 04:01:33 +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
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
Timo Kreuzer 75a453ceba [NTOSKRNL/NEWCC]
Fix MSVC build and warnings

svn path=/trunk/; revision=55431
2012-02-05 16:42:22 +00:00
Art Yerkes 9e8a4109b0 Make sure to initialize our page operation mutex.
Scan the whole range of the MemoryArea for pages to evict.
This fixes cache section page eviction.

svn path=/trunk/; revision=50134
2010-12-24 22:54:24 +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