#Astral
1 messages Β· Page 37 of 1
bruh
also yeah i really wish this thing had proper aml
i wonder if clanker can generate proper asl
by parsing linux driver code
Doesn't it have one?
Iirc when you showed it, it was like hundreds of objects and a thermal zone even
yes but they all just refer to a windows driver iirc
also everything needs nonstandard shit
Lol
When you ask aarch64 people to adopt a standard
They go and manage to make it proprietary
s/aarch64/qcom/
Fair
qcom is like nvidia
Nvidia made an open driver at least
(no open userspace so it is still fucked)
if the company ends with com you know it's dogshit
still waiting for NVK to become good
Fair
But hopefully thats coming
I dont see why they keep it closed source
well, it does run Managarm (sort of) 

"what error is returned if you O_DIRECT read into a framebuffer on linux" google searches by the utterly deranged
why don't you just write some C to test it
Gets me close enough for 90% of things
I don't actually have a /dev/fb0 on this thing 
okay, I have finished page locking/wiring/whatever you wanna call it
I just need to make one of the page in paths better (when it takes a read hint it will do a partial page in only instead)
only 72 more hours until page cache rewrite my compatriots
for that I still need to finish the proper virtio block scatter gather path, and make the filesystems properly do adjacent block reads
were u still gonna do the Advanced Buffer Cache thing
also known as the Pretentiously Named Buffer Cache
very likely yes
What is this I would love to know
xdm working properly now
I can actually log out of root without shit crashin g
and log in as astral
Got aired by both me and mathewnd
Basically it's a silly variant of buffer cache where the data and read path are backed by the normal page cache (applied to the disk device file) but it has a bespoke write path that makes use of buffer control structures that are per-block rather than per-page
thats kinda cool i might consider doing similar if i ever care enough to do that
i mean when i eventually choose to rewrite my page cache impl
It solves:
- aliasing issues where if you use the page cache for metadata block writeback, you risk writing neighboring file blocks back erroneously that are aliased by other pages of the file that they really belong to, causing corruption
- ordering issues for filesystems that need specific writeback ordering at the block level for consistency
okay wow TIL it can do that
big brother is watching you
I've worked on making virtio block do scatter gather dma
I just need to rewrite the DPC and then β¨try it out β¨

and once thats done all of my block drivers will now properly support scatter gather dma
then its making the filesystems do adjacent block reads, abc and make the file systems use it, and finally page cache
72 more hours
excited to see how your implementation of abc turns out
I'll have to re read our old convo to get the idea fully refreshed in my head but it'll be fun to implement
you have NVMe right?
and AHCI?
i love SGLs with those
what do PRPs not count as SGLs?
i scatter pages then gather them back in my driver 
ohhh i didnt realize
that actually sounds pretty nice but my block devices are only accessed by page cache kek
I don't think I have ever touched a device that supports SGLs, I don't think there is too much point in caring
i mean its interesting
even qemu only supports a single descriptor type or something like that
speaking of qemu when are we getting that rtl8169 driver you totally promised me
whenever IΒ have time + motivation to do that
I forgot about that in the meantime, I've been doing other shit
nvidia-open debugging (hell), os-test score improvements, SIMDΒ strcmp for mlibc, ...
doesnt SIMD have like a single instruction that just does strcmp
yesn't
depends on the exact set, and even then you need to be wary of e.g. page boundaries
mmmm i see
SSE4.2 for example:
kill it
the 16-byte wide compare is basically a single pcmpistri instruction, it just takes 3 lines of C to get the index, carry and zero from that lol
the assembly is shorter than the C++ impl π
I am honestly not yet sure how to impl some other stuff though
e.g. how do you implement strcasecmp_l efficiently?
just precompute masks at locale load time?
I have no idea
in constructor perhaps
just precompute them
who is fat
joe mama
Weird al
weird ai
Advanced buffer cache
oh duh :p
I saw you talking about it :p so in hindsight yeah that makes sense
YOU COULDNT HAVE KNOWN MAN! ABSOLVE YOURSELF OF YOUR GUILT!
lol
@prime mulch okay so, I think I got it refreshed in my memory
just to confirm:
uses memory backed by the page cache
writeback directly dmas out of the page cache memory, skipping the page cache's own writeback mechanism
operation is roughly:
check if the sector is already in memory (I likely will use a trie for this) -> if not, ask the page cache for the page containing it -> keep a reference to the page -> return the memory from the page cache -> mark the abc object as dirty if needed (and increase a ref on the abc object and add to a dirty list etc) -> on writeback, dma out of page cache pages and coalescing the block i/o if possible -> when abc object ref reaches zero, free it (for simplicity) and release the page cache page
I don't think the complexity of keeping an abc object in memory when refcount reaches zero is worth it considering how quick it is to initialize when a page cache hit happens
especially since allocating with a slab cache is just extremely quick
Wouldn't it be easier for the filesystem to provide a list of regions that the partition's / disk's page cache can modify? E.g. on FAT, you can only modify the first sector and the FATs, and files and directories are modified using their own page cache
Or better yet, a function that the FSD can provide that compares the desired linear offset within the partition's page cache with regions allowed to write to
And make the page cache use it and split up writes by block
no because now the filesystem driver has to be aware of that issue
rather than just being able to say "use this API set to do cached metadata access"
this is an alternative that i have considered and i thought it was ugly, it also does not solve the ordering issue
I mean, as part of the "file system driver -> page cache" interface
yes that is extra code and an extra thing for each filesystem driver to worry about
like the FSD would have a function called something like BlocksToWriteForPage
you already have to write extra code?
also youre ignoring the ordering issue
for?
the issue with doing naive page caching is that if you write to filesystem metadata, you're using the partition's page cache, and when you write to files, you're using their own page cache. and those could be at the same page offset (divide either offset by the page size)
e.g. metadata ends at some offset x * 4K + 1K, and file contents start at x * 4K + 2K and continue
page x is dual purpose
yes
so what i was pointing out is you could just prevent writing to anything that isn't filesystem metadata, by adding a callback into the filesystem driver that the page cache flush-to-backing-store code would use
so for page x, only writes to offsets 0-1kb would flush
is the ordering issue you mentioned, the issue where the files' page cache is flushed to disk first and then the filesystem metadata, causing stale data to be written to each file?
no
no? what is it, then
the ordering issue is that some filesystems rely on blocks to be written out in specific orders for consistency guarantees in the event of stuff like unexpected power loss
this is not easily captured with just a page cache
to fully express the orderings youd need per-block structures anyway
I see, so I was trying to fix an issue not pointed out here
which filesystems require this?
i assume ext4?
for journalling purposes
basically any filesystem that has an fsck, the fsck process relies on things having been written out in specific orders to constrain the range of errors that can occur
and yeah most journaling fses need something like this
the issue you pointed out we tend to call the aliasing issue
and its another motivating factor for this
because its probably cleaner to have the filesystem just call bread/bwrite/bdirty/whatever type functions when it wants to touch its metadata than to force it to have an awareness of the aliasing issue and have extra code to identify which ranges are metadata blocks to the kernel proper (which again doesnt fix the ordering issue anyway)
so you're saying it'd be safer not to use a page cache at all, and just to use a buffer cache, for FS metadata?
also yez, you should be able to reorder dirtied blocks by coalescing them into long extents to write out all at once except for ones that are dirtied with a flag that says "you cant reorder around me" (but you can still coalesce those into an extent as long as the order the blocks in the extent were dirtied matches the order on disk)
its a buffer cache backed by the page cache
no offense but did you not even read the conversation before you started asking questions this was all discussed
is it called ABC because it's a funny name
its becaud im fat
a big cache......
do you have a link to the conversation where you talk about that?
One thing to note is that for journaling file systems, the ordering guarantees become stricter
and cross multiple parts of the fs stack
for example, for the default journaling mode on ext4, the ordering is: flush data writes first, then write metadata changes to the journal, then write metadata changes to the fs (potentially from a separate checkpointing mechanism / thread / etc)
for Managarm, the current plan to solve this is:
- data pages go from page cache to disk directly (in reaction to memory pressure)
- metadata pages use a page cache but order writeback explicitly instead of reacting directly to memory pressure
and data page writeback has to issue metadata page writeback as needed (for example when allocating backing pages for a hole in a file)
as in: prevent metadata pages from showing up in data page caches and vice versa?
some filesystems intermix metadata blocks and file data blocks within the same page aligned area of the disk
this can cause problems if a metadata page containing file data blocks is dirtied and gets written back
and is aliased by a page in a file page cache
Ah. We don't have that issue right now because we don't support such an FS yet
but that's a valid point
What do you propose as a solution?
thats one of the things that motivated this fancy buffer cache idea
basically the idea is that theres a buffer cache for metadata which is backed by a normal page cache of the disk device for reads, but has per-block buffer control structures and has a bespoke writeback mechanism
which works in terms of the block buffers and does direct IO to disk from the contents of the page cache pages
the disk device's page cache is owned by the buffer cache and the normal writeback never gets ahold of its pages bc they are never marked dirty in the normal way
Have you looked into how other kernels solve that?
Yes
what did you find
Oh. That's actually a big problem with the idea of page caches per file.
My current VFS "solves" this by making the contract that the fs should ignore excess writeback data from page cache, however this is inefficient afaik.
It's a problem with using a normal page cache for disk metadata
it's not an issue for file page caches because they're virtual
I'm not sure I understand the difference between mine and your systems
Or do you mean by this, that file page caches read/write disk directly and a single, separate metadata page cache also does?
I.e. a system wherein they do not share the cache and yet the cache can overlap
A file page is made up of blocks from only the file
stitched together
so there's no way for it to alias anything else on disk
a metadata page on the other hand is the raw disk blocks and can contain file blocks from various different files
Oh I see what you mean now
So the solution then is to use a cache that is more fine-grained than a page cache would be, right?
Yeah except you can still reuse the read-in machinery of the page cache since the real problems occur during writeback
hence the idea to use a buffer cache that is atop pages of the page cache but has per-block buffer control structures and a bespoke writeback mechanism that operates on those rather than on the pages themselves
Today I will implement a trie
trie-rs
"I am skill issued and can never write any code myself" damn
For wap
abc
did you talk anywhere about how that bespoke writeback mechanism should actually work in practice?
probably it would have some kind of per volume dirty list of buffers (may or may not be a literal linked list) and it would walk this and write them out, coalescing where possible
The write would be a direct IO to disk from the page cache page contents
the part containing that block
When you dirty a buffer it'd insertion sort it into the list (or equivalent operation for other structures like RB tree) to maximize coalescing opportunities, except for buffers dirtied with a flag demanding strict ordering
Something like that
The writeback would be done by worker thread(s) periodically and when sync is called
I think I had an idea for representing extents of dirty buffers in the dirty list with a single buffer structure
and have them contain a dirty length field so that the first buffer in a dirty extent can represent the whole extent in the list
@analog berry I tried hl goty edition and it got past cdrom drm (I had to find a key online lmfao) but crashed starting a new game
via wine?
Yeah
Damn, whats the error?
It just crashes for some reason, no idea
Sadge
What are you going to use it for
Advanced buffer cache + new page cache
Maybe I can find other places in the kernel where I used stupid datastructures too
@prime mulch I think I will have the abc be a per fs instance object rather than something that spans the whole disk, that fits better with my design and kinda also makes sense (block devices without a fs dont really need an abc, and ordered writes for e.g. journaling don't need to cross partition boundaries)
Might still want the dirty list and writeback stuff to be per physical disk
Is there a reason for this?

a nice thing about this is that this is quite similar to how my new page cache is going to be so this already gives me some solutions to problems I would face
the core of the code is set, I just need to finish some more TODOs (like abc_sync())
a b c d e f g
h
ok abc seems to be done
other than a TODO or two
time to switch over filesystem metadata read/write to it
another thing I need to do is finish my pushlock rewrite to fix one of the TODOs (moving it to a proper rwlock, which I did kind of write it with that in mind)
Committed?
not yet, do u want me to
its not really plugged into anything so theres no harm in commiting it
sure im interested
its pretty small
damn once I finish the filesystem plumbing I think thats everything needed for the page cache rewrite to start
i have 2 comments
1 is that it might be bettter to have a global dirty thread rather than per-volume
another is that rather than running it on a periodic tick, you should start a timer for like 5 seconds into the future or something when a block is dirtied (and the timer is not currently set)
so that it never runs if nothing is dirtied
and that it fits all the potential dirtying that might be about to happen into an interval that starts on the first dirtied block
so it possibly doesnt have to wake up again
thats true
why is that?
could take up an unnecessary amount of cpu time
well nvm if youre doing it synchronously then
prob better to have per-volume threads to parallelize it per volume
but then it should be per physical disk
which is the reason for that
I don't see a big benefit in having a single dirty list per physical disk and it would add a lot more complexity around it in the kernel
how come
I don't really have a "disk" as a concept other than as very thin layer between a devfs and the device drivers, what is exposed to the filesystem drivers is just a vnode and this is what they use to do i/o. changing that would require some annoying reworking
the only benefit I could think of having a per-disk dirty list it is doing some scheduling on the disk i/o to make it faster on spinny disks, but I don't have that implemented and it could likely just be implemented transparently anyways
soon page cache rewrite wallahi
support clustered page in/out at the very least + especially better locking than the current shitty page cache (currently a global page cache lock π π π π π π π π π π π π π π π on a linked list with a hash indexed bucket that can go for hundreds of nodes on real usage π π π π π π π π π π π π π π π π π π π π π π π π π π π π π π π π )
what are your holes
What are your hoes
"I enjoy kicking pregnant dogs" wtf marvin why would you do that
π¬
It's not used that much, it makes sense for e.g. qemu tho
/goal port nvo to astral and get 3d accel no mistakes
wtf bro
what the fuck
I can't believe you just said that mathew
/plan get rid of marvin
what happened the fuck
is this a deleted text π
no he just said that
"I am a heartless chud"
damn marvin it is true but you don't need to tell us that
I'm finishing my pushlock rewrite, its been sitting half done in my tree for like a year at this point
and I want to start using rwlocks π
page cache rewrite not happening this week nor next week probably
as much as I would have hoped to because that is one of the more ridiculous parts of the kernel
pushlock rewrite is done
another thing I need to do is improve lock granularity in the vmm
as it stands every space has one mutex and so any operation that takes more than just a bit holds everything up (especially the fact that this lock is held during page-in β οΈβ οΈβ οΈβ οΈβ οΈβ οΈβ οΈβ οΈβ οΈ)
so at the very least I would add a rwlock protecting the range tree and another per-range mutex and refcount
the scaling must happen wallahi
I also need to stop being stupid and lazy and actually implement a dentry cache
<----- had write combining set in the private framebuffer mappings instead of the shared ones award
this is how you know astral isn't vibecoded, clanker isn't that retarded
do you have any plans for priority inheritance with pushlocks
not really atm
well I did bring my laptop with me so maybe I can actually slowly start the page cache rewrite
Late to saying this but getting CDE working is pretty neat
Its not cde proper (old ahhh bug filled codebase full of security issues) but nscde
Which is similar enough but not the actual cde
Ohhh I see, still, pretty cool nonetheless
I managed to rice it pretty decently too, all the buttons on the taskbar work and theres a default astral theme
Oh nice ^^
I think it's neat this project has evolved so much, I still remember seeing it a few years ago when it only really had the console working
Guess I need to lock in or something x3
Soon I will be fully self hosting inshallah
Just need to finish the page cache rewrite and make this 23083393893 times more scalable
Got it got it :3
A lot of the base code is done albeit untested
I gotta do writeback now
And dirtying
Managarm in a nutshell

