Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTFSD

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


minifilter IRP_MJ_READ has unstable performance

stevezhougsstevezhougs Member Posts: 9
edited July 2020 in NTFSD

In my driver,IRP_MJ_READ is like:

if(FLT_IS_IRP_OPERATION(Data))
{
FsRtlEnterFileSystem();
if(BooleanFlagOn(IrpFlags, IRP_PAGING_IO))
{
ExAcquireResourceSharedLite(&Fcb->PagingIoResource,TRUE);
fltStatus = FltCheckOplock( &Fcb->Oplock, Data, NULL, NULL, NULL);
BytesToRead = ALIGNED(ULONG, Length, Fcb->SectorSize); //SectorSize = 512
FltReadFile(BytesToRead,FLTFL_IO_OPERATION_NON_CACHED);
KeSaveExtendedProcessorState()
AVX_Decrypt(BytesToRead);
KeRestoreExtendedProcessorState
ExReleaseResourceLite(&Fcb->PagingIoResource);
}
FsRtlExitFileSystem();
}
else if(FLT_IS_FASTIO_OPERATION(Data))
{
FsRtlEnterFileSystem();
Buffer = MapUserBuffer(Data);
Status = FsRtlCopyRead();
FsRtlExitFileSystem();
}

In user mode test code,like:

DWORD start = timeGetTime();
HANDLE target = CreateFileA("1G.txt");
file_size = GetFileSize(target,NULL);
do {
ReadFile(out_buffer, ONE_M,);//ONE_M = 1M
} while (read_len < file_size);
CloseHandle(target);
DWORD end = timeGetTime();
float speed = (file_size / ONE_M) / ((end - start) / 1000.00);

Every record is first test after computer just started.
You can see unstable performance for reading,but write has stable performance.
Why write is stable and read is so unstable?

read 1024MB need 14.05s 72.91MB/S
read 1024MB need 8.37s 122.28MB/S
read 1024MB need 7.01s 145.97MB/S
read 1024MB need 25.92s 39.51MB/S very slowly
read 1024MB need 7.28s 140.66MB/S
read 1024MB need 6.31s 162.23MB/S
read 1024MB need 23.95s 42.75MB/S very slowly
read 1024MB need 37.81s 27.08MB/S very slowly
read 1024MB need 30.85s 33.19MB/S very slowly
read 1024MB need 9.72s 105.37MB/S

write 1024MB need 10.37s 98.71MB/S
write 1024MB need 10.19s 100.53MB/S
write 1024MB need 10.50s 97.53MB/S
write 1024MB need 11.48s 89.18MB/S
write 1024MB need 11.40s 89.79MB/S
write 1024MB need 10.09s 101.46MB/S
write 1024MB need 10.09s 101.46MB/S
write 1024MB need 9.78s 104.70MB/S
write 1024MB need 11.50s 89.05MB/S

Post edited by Peter_Viscarola_(OSR) on

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 26 Feb - 1 Mar 2024 Live, Online