Are Windows & Linux Drivers That SLOW !! (AHCI)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by devc1 »

Hello, I've seen that from my successful AHCI Driver it took exactly 1100 ms to read 500 MB from the Hard Drive of an old laptop (Using 0x40000 Bytes per command and Mesured with HPET), ATA_IDENTIFY_DEVICE_DATA.ModelNumber = wdc wd3200bekt-75pvmt1 (Said 300 MB/S 7200 RPM). QEMU Took over 500-600 ms to read 500 MB which is very fast for some HDD. Is it an effect of native command queuing? Windows (and maybe Linux) are way slower than this !
Windows Crystal Disk Mark returns 98 MB/S.
Another Question! I want to know the number of sectors in the hard disk (it is 320 GB), when I read ATA_IDENTIFY_DEVICE_DATA.UserAccessibleSectors it returns only 131000 MB (Around 100GB).
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by nullplan »

devc1 wrote:Another Question! I want to know the number of sectors in the hard disk (it is 320 GB), when I read ATA_IDENTIFY_DEVICE_DATA.UserAccessibleSectors it returns only 131000 MB (Around 100GB).
There is a READ CAPACITY(16) command that will return the block size and the highest LBA. The product of both (OK, one more than highest LBA times block size) is the capacity of the device. Ought to be supported by most devices, as it is typically used by drivers to find the drive capacity. Also, it is the only thing that tells you the block size.
Carpe diem!
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by devc1 »

I will try that, Thanks!
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by Octocontrabass »

devc1 wrote:Another Question! I want to know the number of sectors in the hard disk (it is 320 GB), when I read ATA_IDENTIFY_DEVICE_DATA.UserAccessibleSectors it returns only 131000 MB (Around 100GB).
I have no idea which structure you're referring to there, but it sounds like you're talking about the value in words 60 and 61. That value is limited to 28 bits, which means 128 GiB for a drive with 512-byte sectors. Larger drives will report the maximum 48-bit LBA in words 100-103. I strongly suggest you read the draft of the ATA version supported by your drive to understand what information it reports.
nullplan wrote:There is a READ CAPACITY(16) command
That's SCSI, not ATA.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by devc1 »

Okay but that's not answering my question, why my driver reads the hard drive with almost 500 mb/s, the specs say it is 300 mb/s and windows benchmarks say it is 98 mb/s.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by Octocontrabass »

There may be a problem with how you're using the timer to measure the transfer time, or you may be transferring less data than you think. SATA 3Gb/s is not physically capable of transferring more than 300MB per second.
thewrongchristian
Member
Member
Posts: 426
Joined: Tue Apr 03, 2018 2:44 am

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by thewrongchristian »

devc1 wrote:Okay but that's not answering my question, why my driver reads the hard drive with almost 500 mb/s, the specs say it is 300 mb/s and windows benchmarks say it is 98 mb/s.
Are you doing this under QEMU?

Are you sure you're actually reading from the disk, and not from some virtual disk on the host filesystem, which may well be caching the data and thus giving you inflated read speeds?
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by devc1 »

Yeah it is reading the disk using 0x40000 bytes per cmd, and I print some sectors. Qemu reads 500 mb in 500-650ms and in real hardware (my old mentionned laptop) it reads 500 mb in 1100 ms without Task File Errors.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by devc1 »

My Drive Image in QEMU is only 32MB, Different commands from higher LBA doesn't Task File Error. This is weird ? I know QEMU Skips alot of checks but for this ??
thewrongchristian
Member
Member
Posts: 426
Joined: Tue Apr 03, 2018 2:44 am

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by thewrongchristian »

devc1 wrote:My Drive Image in QEMU is only 32MB, Different commands from higher LBA doesn't Task File Error. This is weird ? I know QEMU Skips alot of checks but for this ??
QEMU is probably using a sparse file, reading blank media that has not yet been written as blocks of zeroes. Hence the seemingly high performance in your test, it's using constant data.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by Octocontrabass »

devc1 wrote:My Drive Image in QEMU is only 32MB, Different commands from higher LBA doesn't Task File Error. This is weird ? I know QEMU Skips alot of checks but for this ??
Congratulations, you've found a QEMU bug.

I wonder if you can use this bug to bypass hypervisor security...
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by devc1 »

How ?
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by devc1 »

Mr. Octoconbrass, can you provide further information ?
I'm now in a vacation and I'll be there in the next 2 weeks, I don't really know what you're talking about (hypervisor security...), do you mean running kernel mode code in Windows ? Or writing system files ? Or logging through users without password ? This is interesting right ?? :)
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by Octocontrabass »

I mean simpler things, like crashing QEMU or making your disk image grow bigger than 32MB. Probably nothing as exciting as you're imagining.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: Are Windows & Linux Drivers That SLOW !! (AHCI)

Post by devc1 »

Okay I'm gonna try that, what does this have with "hypervisor security". And can u answer the question in the last forum "High performance graphics for all GPUS.." :)
Post Reply