[*] Fix: axboe is a piss baby retard who cant even write a thread safe ring buffer

This is the dude tasked with managing Linshits IO stack, including the fundamentally flawed muh zero-syscall pissring, the fucked io_submit apis that never worked properly (incl io_cancel that spuriously returns EINVAL despite all magics matching); the retard who stuck to Linus's idea that MUH O_DIRECT IS LE EVIL YOU MUST USE MY CACHES REEE REEE (#a); and the retard who got indirectly called out by Linus as being apart of the database maintainers who Linus didn't/doesnt like and who wanted these APIs in the first place (#b).

"The whole notion of "direct IO" is totally braindamaged. Just say no.

	This is your brain: O
	This is your brain on O_DIRECT: .

	Any questions?

I should have fought back harder. There really is no valid reason for EVER
using O_DIRECT. You need a buffer whatever IO you do, and it might as well
be the page cache. There are better ways to control the page cache than
play games and think that a page cache isn't necessary.

So don't use O_DIRECT."
 - Commit Torbals, maintainer of toy academic kernels

"AIO is a horrible ad-hoc design, with the main excuse being "other, less gifted people, made that design, and we are implementing it for compatibility because database people - who seldom have any shred of taste - actually use it". But AIO was always really really ugly."
 - Commie Torbals, maintainer of toy academic kernels
This commit is contained in:
Reece Wilson 2024-08-05 05:19:58 +01:00
parent 75f6325ee2
commit 3be286c741

View File

@ -19,8 +19,6 @@
namespace Aurora namespace Aurora
{ {
#define read_barrier() __asm__ __volatile__("lfence" ::: "memory")
static const auto kAioRingMagic = 0xa10a10a1u; static const auto kAioRingMagic = 0xa10a10a1u;
void InitLinuxAddresses() void InitLinuxAddresses()
@ -227,15 +225,21 @@ namespace Aurora
while (i < max_nr) while (i < max_nr)
{ {
auto head = pRing->head; auto head = AuAtomicLoad(&pRing->head);
if (head == pRing->tail) if (head == pRing->tail)
{ {
break; break;
} }
events[i++] = pRing->events[head]; events[i++] = pRing->events[head];
read_barrier();
pRing->head = (head + 1) % pRing->nr; auto nextHead = (head + 1) % pRing->nr;
if (AuAtomicCompareExchange(&pRing->head,
nextHead,
head) != head)
{
i--;
}
} }
if (!i && if (!i &&