|
From: Hartmut B. <har...@te...> - 2001-10-24 17:58:21
|
> -----Ursprungliche Nachricht-----
> Von: David Welch [SMTP:we...@cw...]
> Gesendet am: Dienstag, 23. Oktober 2001 23:56
> An: ros...@re...
> Betreff: [ros-kernel] Re: AW: Re: AW: Re: Cache and memory manager
>
> Okay, for reference what are the bugs exactly?
MiAllocPageFromPagingFile() returns for each reserved page
the entry 1 and the calculation of the used and free pages is wrong.
See also the comments in the diff output (marked with '-->').
- Hartmut
Index: pagefile.c
===================================================================
RCS file: /CVS/ReactOS/reactos/ntoskrnl/mm/pagefile.c,v
retrieving revision 1.12
diff -u -r1.12 pagefile.c
--- pagefile.c 2001/10/10 21:57:00 1.12
+++ pagefile.c 2001/10/24 17:21:56
@@ -97,7 +97,7 @@
*/
#define FILE_FROM_ENTRY(i) ((i) >> 24)
#define OFFSET_FROM_ENTRY(i) (((i) & 0xffffff) - 1)
-#define ENTRY_FROM_FILE_OFFSET(i, j) (((i) << 24) || ((j) + 1))
+#define ENTRY_FROM_FILE_OFFSET(i, j) (((i) << 24) | ((j) + 1))
/* FUNCTIONS *****************************************************************/
@@ -123,7 +123,7 @@
Mdl,
&file_offset,
&Iosb,
- FALSE);
+ TRUE);
return(Status);
}
@@ -204,24 +204,23 @@
MiAllocPageFromPagingFile(PPAGINGFILE PagingFile)
{
KIRQL oldIrql;
- ULONG i;
ULONG off;
KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
- for (i = 0; i < PagingFile->AllocMapSize; i++)
- {
- off = find_first_zero_bit(PagingFile->AllocMap,
- PagingFile->AllocMapSize * 32);
- clear_bit(off % 32, &PagingFile->AllocMap[off / 32]); --> The bit must be set.
- PagingFile->UsedPages--; --> Must be increment.
- PagingFile->FreePages++; --> Must be decrement.
+ off = find_first_zero_bit(PagingFile->AllocMap,
+ PagingFile->AllocMapSize * 32);
+ if (off < PagingFile->CurrentSize) --> Check for a valid offset.
+ {
+ set_bit(off % 32, &PagingFile->AllocMap[off / 32]);
+ PagingFile->UsedPages++;
+ PagingFile->FreePages--;
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
return(off);
- }
+ }
KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql);
- return(0);
+ return(0xffffffff); --> Return a nonvalid entry.
}
VOID
@@ -237,7 +236,7 @@
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
KeAcquireSpinLockAtDpcLevel(&PagingFileList[i]->AllocMapLock);
- set_bit(off % 32, &PagingFileList[i]->AllocMap[off / 32]); --> Bit must be reset.
+ clear_bit(off % 32, &PagingFileList[i]->AllocMap[off / 32]);
PagingFileList[i]->FreePages++;
PagingFileList[i]->UsedPages--;
@@ -271,11 +270,10 @@
PagingFileList[i]->FreePages >= 1)
{
off = MiAllocPageFromPagingFile(PagingFileList[i]);
- if (off != 0)
+ if (off == 0xffffffff) --> Check vor invalid value.
{
+ DPRINT1("MiAllocPageFromPagingFile() doesn't return a free page, but FreeCount is %d\n", PagingFileList[i]->FreePages);
KeBugCheck(0);
- KeReleaseSpinLock(&PagingFileListLock, oldIrql); --> Has no effect after KeBugCheck().
- return(STATUS_UNSUCCESSFUL);
}
MiUsedSwapPages++;
MiFreeSwapPages--;
====================================================
= To remove yourself from this mailing list, go to =
= http://www.reactos.com/home/mailing.html =
====================================================
|