#Zinnia
1 messages · Page 33 of 1
like if two threads are contending for two different PTE locks but the addresses of those PTEs happen to collide in this hash table, then when one of them is unlocked itll signal that event flag and both threads will be awoken and one of them will just hav eto go back to sleep after finding the PTE still contended
is a risk
The same idea can be used for mutices using mcs nodes
i never implemented pte locks tbh
they needed this bc they had like 1 available PTE bit to use lol
they could have used a spinlock but wanted to be fancy i suppose
i think the ISAs i want to target have maybe 2 bits in common?
i want x86_64, aarch64, riscv64rva, and loongarch64
maybe powerpc
powerpc doesnt even have multi level page tables
it has a hash table that people normally put a multi level table on top of and treat the hash table like an in-memory software refilled TLB
NT and Linux both do that on PPC
i wanted to write generic paging logic
the ppc hash table is particularly problematic though
bc you can get page faults due to a previous hash table collision that overwrote another PTE
and this overwriting loses information
ew
which is bad for certain vmm designs
NT and Linux both sometimes want to store info in PTEs that is not reflected anywhere else, for example the location in swap space of a private anonymous page that has been removed from memory
so they do this on ppc
contrast this however with mach derivative vmms like AIX's and XNU's
mach treats the page tables as like a cache for information in the memory objects
so theyre able to service these hash collision faults just by looking up a memory object and filling the PTE in with the info there
and its fine if they overwrite some other PTE in the process bc the info it stored is fully reflected in the memory object
so AIX and XNU (Mac OS X) do not simulate a multi level page table on PPC
weird instance of a thing where NT and Linux align with one another but not with like, AIX and XNU lol
is how page tables are treated by their vmms
its probably a bad idea to
current meta that the vmm heads in here have moved to is that the mach idea is the more correct one
disposable page tables are good
not just for portability but also for memory usage
basically you can throw away page tables for processes willy nilly at any time if you do page tracking like mach does, where the page tables hold no unique info
so that becomes a source of memory reclamation
the memory objects (or other container such as uvm amaps) are probably/usually more compact than the page tables so this is a win
under this scheme throwing away page tables is basically invalidating a cache, so it has a performance effect (causes page faults to repopulate said cache later), so youd only want to start doing that when memory is really low
that's so dumb then
if it's less portable and uses more memory
NT at least has a solution to the memory thing which is that it can swap out the page tables
linux has no solution the page tables are just wired
a page table holding the swap location of swapped out anonymous pages is just eternal on linux, you dont get to reclaim it after all the contained pages are gone, it only goes away when the process dies or the range is munmap()d which sucks
on NT the page table becomes swappable itself when all contained anon pages are out of memory
and then the page table's own swap location is stored in the upper level page table entry and so on
under NT the whole page table hierarchy for a process can get swapped out in this manner, from the bottom up
i believe
which is obviously more complicated than a scheme where you can just throw them away at any time without doing any writes to disk
at least it does SOMETHING about page table memory though unlike linux
linux is the only major kernel without a solution to this specific thing i think
i wonder if you could DoS linux by like allocating single pages of private anon memory spaced 2MB apart to allocate 1 page table each
and just keep doing this until the OOM killer has to run because it cant swap out or free those page tables
assuming u tiled all of userspace with pages spaced 2mb apart
with 4 level paging
u could cause it to allocate up to apparently 256GB of wired memory in the form of page tables
im sure youd hit quota limits long before that
but itd be fun to test
a scheme that makes pts disposable still has to store swap locations somewhere though
is the DS that stores swap locations swappable in NT?
NT doesnt have disposable PTs so i dont get the relevance of the question
the data structure that stores swap locations on NT (and Linux) is the hardware PTE of the private anon page
which is eventually swappable on NT (after all contained pages have been fully removed from memory) and wired on Linux
the relevance is that disposable PTs does not necessarily mean that more memory is swapable
but this answers my question ^
planned scheme for mintia2 is that the data structures for this (memory objects for shared memory (like files and shared anon pages) and amaps (for private anon pages)) will tend to be much more compact than page tables
and will go in paged pool
and be swappable
a page of paged pool will have 1 pin for each active page tracking entry it contains though
the pin is removed when the tracked page is fully removed from memory and only exists in swap
this is to avoid deadlocks from having to allocate pages in order to free pages
(ie having to allocate a page to read a swapped-out paged pool page into, in order to read a tracking PTE to find a page to swap out)
(this is the same reason NT page tables are pinned until the last contained page is fully gone)
it's iBoot2
it's been known before apple silicon macs became a thing
there's been Project Sandcastle and checkm8 and stuff u know
sorry thats unrelated, but we can see nt's pte struct is a union of like:
ULONGLONG Long;
MMPTE_HARDWARE Hard;
MMPTE_PROTOTYPE Proto;
MMPTE_SOFTWARE Soft;
MMPTE_TIMESTAMP TimeStamp;
MMPTE_TRANSITION Trans;
MMPTE_SUBSECTION Subsect;
MMPTE_LIST List;
MMPTE_ACTIVE_PAGE_TABLE_LINKS PageTableLinks;
maybe you know what type of pte is a TIMESTAMP mmpte
probably some 500 IQ synchronization thing
the BSD larp is advancing
TIMESTAMP is a format that records the TB flush generation at which a mapping was removed, allowing to determine later whether a TB flush entry must be issued
got new info
interesting
whats meant by buddy in _MI_ACTIVE_PFN?
i had a stupid idea
for a microkernel:
- servers can register syscalls
- during registration, it passes a set of descriptors for each argument that the handler expects
- these descriptors can then specify things like "this argument is a pointer and its length is described by argument n" or "this argument is a handle"
or maybe some kind of bytecode can be used for this
ebpf 
lua
yea but how do you enforce this
wdym
i mean the idea behind this is security/validation, right?
no
what is it then
this would be a form of IPC
the kernel would catch the syscall, check how it needs to transform the arguments, and call the handler in the other process
well u send a bunch of descriptors or something for handles and pointers
i don't think i'm talking about the same thing here
i mean that when a server registers the syscall handler, it tells the kernel what to do with each argument
not really
because the kernel needs to translate object handles between processes, right?
yeah but i mean oftentimes it's just included in the request the client sends
yeah i guess
instead of done in the server
but then the kernel knows about the format before hand
my idea was to do this dynamically
so you want to set up such schema for every kind of request or something?
pretty much
(note that i won't probably do this, i'm just brainstorming new methods)
i'll make an example
how about you push all io through shared memory ring buffers? thats what i plan to do, that way you completely bypass the kernel (after ipc setup) and get async io basically for free on top
that doesn't work
you still need to translate handles
well, in my proof of concept i already have all data-only IPC via shared memory
the problem is passing object handles along
i have a channel for this, similar to what Zircon does
where you have a handle buffer and a data buffer
I appreciate that the DEC "TB" terminology has persisted in NT all these years
okay i did some digging
kqueue is pretty cool
i will still expose epoll via mlibc, but internally route it as kqueue
wayland good tho
"being kicked in the balls good tho" bro stop
being kicked in the balls by xorg
maybe i should drop the linux FDs and become a true BSD-like
XFCE is good enough
https://www.youtube.com/watch?v=_RO9beApnec i got this in my yt recommendations
(--------------------------Try out Lumo for free----------------------------------)
https://proton.me/dzuma
OpenBSD Site: https://www.openbsd.org/
OpenBSD Manuals: https://man.openbsd.org/
Intro Song:
https://youtu.be/NXjd50wJkbE
^ give this guy some love he's very small ^
Video where I discovered CDE (Common Des...
i MUST larp
Extremely cool
well it is if you’re into that

okay it seems eventfd is actually a thing on BSDs too
timerfd as well
although no signalfd
which makes sense, since kqueue exists
i'm surprised with how simple the NetBSD schedulers are
both sched_4bsd and sched_m2
they're less than 500 eloc
the logic is in tdq
or runq
this
tho the netbsd schedulers kinda suck
any recommendations
freebsd is better
ULE?
yes
will look into it tomorrow
didnt you already have it
in rust
yea
and also a bastardized version
not really on the same level tho
a scheduler is easy to reimplement
uvm is a whole ass subsystem
yeah i saw
there's a phd thesis on it
well it was made for a phd thesis
i should make netbsd's slab allocator better
(gpt had it)

fr? 😭
only the parts that didn't work
i was too lazy to debug
but that's more or less why i even want to rewrite
if i slop things there's no point in doing it
no fun
i used an llm to check over it and it did find a few errors i made
but it was mostly just me copy pasting code around and forgetting to adapt it
In what ways
ask the llm about minting's
weren't you gonna send me a PR with these improvements for mintia2 ...
i am free from my job for the rest of the week
and it's draining blue collar work so I dont have much time at night to do a lot of stuff
afaik it's pretty similar to solaris's original code
so yea
they do the solaris lock pointer thing tho
* Turnstiles are described in detail in:
*
* Solaris Internals: Core Kernel Architecture, Jim Mauro and
* Richard McDougall.
yea i told you that
solaris book and freebsd book both go over it
tbh I'm not really sure what the XNU and freebsd impls do much more than solaris
XNU's is like 3k lines or something
uses pairing heaps
i decided against that because it wasnt really worth it i thought
ewww I hope they find a cure
NEETs of the world, unite! we have nothing to lose but our chains
🚬
🪰
i will larp more and call my include dir sys/
nah
KeAcquireBitches
i don't like the prefixes everywhere
cool strict-ish layering though
it just gives order to the thing and forces you to separate subsystems which i like
wtf is wrong with clang
Then it's DG/UX larp
did DG/UX do layering
@brisk totem help what is clang smoking
i remember i have the source code but never ended up really digging through it
It also did prefixes on everything with 2-3 letter abbreviations but as snake case instead of pascal case
then don't imitate them
i do Kep
and Exp
and -u for stuff exported to other subsystems but not to kernel modules
lol i forgot it did this
how can you larp then
isn't it awesome ..
oh clanker finally responded
to the mintia thing
idk the mintia code enough to say
I will review these
I'm p sure the last one is wrong it just doesn't understand the reaping logic
you should do this for every function instead

yea i see the prefix things in dgux but it's unclear what those prefixes all mean
clearer
I found the meaning of cm at least, it's "channel manager"
there was something in the late 80s/early 90s that lead people to name everything "X manager"
No it's not
Its configuration manager
claude please generate me huge comments make no mistakes
in dgux
yea ik NT is cache manager, they just happen to share that prefix ig
this guy is larping so hard he even copied the copyright header
they also share ps but idk what that's about yet in dgux
we figured out why NT and DG/UX both do these ridiculous gigantic comments on everything
i think its just an assembly thing
it's bc they were both the product of mainframe OS engineers who had been doing asm for like a decade, where that was basically mandatory to make giant kernel codebases in asm maintainable, doing C for the first time
and carrying over the habit
yeah
oooooooooooooooooooooor
they had secret cia llm tech before it was public
😭😭
they always call it the "PS subsystem" and never say what it actually is 😭
bro this IS a file from NetBSD
Process Structure
I kinda assumed PS meant process subsystem in NT, ig structure makes more sense though otherwise all other prefixes would have S
I realized it meant process structure when i saw that phrase being used everywhere in like VMS and Mica writings
same
or just
ProcesS
I just call it proc because I'm a loser
the best i can figure out on PS is it's something like "process synchronization" since it seems to contain a bunch of IPC primitives
struct lwp
yeah lwp is weird terminology
i think only netbsd uses that
though dflybsd has lwkt
@autumn jasper there's also this
I'll report back how many of these r substantial
@storm bobcat give it my turnstile impl...
which file is it
anyways
ah KeTurnstile
good night, please dont spam so much so i don't have to scroll far
Is its source code open?
The cache manager in NT is Cc
it's an old solarisism (at least i think solaris was the first to use the term, but others might have preceded it)
primarily existing because of a distinction drawn between userland threads and the substrate that they run on (M:N threading models)
not legally but its extremely unlikely anybody would come after you for studying a tape dump of an early version of its sources of DG/UX for the Nova architecture from 1989
considering its been gone since the 90s
i dont even know who owns it
#1 is wrong, it would make no sense to use the priority of the highest priority timeshared thread for this
its intentional that it gets smothered underneath all real time / interactive threads and that only the priority of the former is used if any are in the waiter heap
Yeah
Bring me the soupy macros
can you share where it is
this did inspire a change: timeshared threads no longer bestow their priority and do not reside in the max heap
the code was also generally cleaned up around there
today I'm going to try to get an ELF loaded from memory
signalfd is stupid
the bsd epoll shim redefines read as a macro
Wait didn't you do it before
yes
but i want to move to kqueue
and kqueue has a signal filter
but signalfd is accessed with a read()
are there any ideas on supporting shared locks?
maybe it's already there, but I didn't get it
it is not there
its quite problematic to try to do
as a result ive just not been using shared locks
except for locks that are like at the very tippy top of the kernel's locking hierarchy AND which are only taken by threads that are probably not doing anything latency sensitive
such as a shared lock for the filesystem name cache
iirc even xnu doesnt support
and they have huge turnstile implementation
solaris just keeps track of the first shared acquirer and does PI through him only
any additional ones are forgotten
i dont even bother with that lmfao
one thing xnu does and oyu dont is WaiterPriorityChanged handling
they have turnstile_update_thread_priority_chain
I don't think anyone does
I have heard from reliable sources that autoboost does
I don't know if it's airtight though or if it can fail to track all shared holders sometimes
maybe they're implementing it in a more selective and more expensive way
or maybe their design is just smarter to begin with... I don't know
is it kernel mode only?
netbsd's linux syscall emulation layer probably implements that too lol
so like it may not be idiomatic but there is an implementation in the source
wait so nbsd's timerfd is fake?
no idea
i might leech off of the netbsd mlibc port
ye
the netbsd port will have the linux option unsupported (could change in the future)
i don't support the linux option anyways
you could enable the epoll option tho
then copy the epoll shim to mlibc
it will have the glibc option supported but I also want it to build without the glibc option
pure bsd+posix+ansi
@near tartan
netbsd-mlibc is back to where it was
(it segfaults on flush i think)
yea i couldn't debug it last time
because of time or you didn't know what it was?
seemingly it flushes after the file descriptor is closed?
latter
i mean if you build with debug symbols you should see where it dies
you have the coredump
can you show the disasm?
it seemingly calls flush once then closes then calls flush again
why? what I did is make interactivity its own priority range, easier to manage wrt PI
i love how there's a discussion about mintia and zag in a thread named zinnia, it was meant to be...
Because no priority inversion can result by having a timeshared thread block on a lower priority other timeshared thread
By nature they will all get a turn Eventually
And are assumed not to require responsiveness
yeah but the priority inheritance is so that they get the same turn
So may as well save the cycles
maybe idk
actually there is a problem which is idle priority threads
you could get priority inversion if a timeshared thread blocks on an idle priority thread
bc idle priority threads never run until all timeshared threads have blocked
oopz
one case I know of is when the per thread slots run out
I'm also not sure what it does if the allocation of a head from the lookaside fails
okay i need to find a way to deal with login1 bullshit so i can upstream plasma
i think i'm going to make a portable logind that poeple can use
my solution for now is quite simple, it just stubs the hell out of everything and sends static data over
i know i love changing my mind regarding rewrites
but for now it's still the most effective solution to just fix what i have
this means i have to redo:
- the scheduler (i will adapt the design from Zag)
- signal handling
- VFS operations
the problem with VFS is that currently i separate between an open file and a vnode
this leaves me with two layers of file operations
i think for me it makes a bit more sense to just have FileOps be part of <NodeType>Ops
for the scheduler, i need to start respecting CPU affinity and i want it to be aware of CPU topology
i am also refactoring the arch:: abstraction so it's less confusing
maybe i can make it a public trait and pass it as a generic parameter to functions that call it 🤔
i saw that
but yeah, regarding
, i'm not using it anymore to do kernel code
while it did fix some issues, the code is a liability and i don't want it around anymore
lastly, i want to add support for direct EFI boot
this isn't some vendetta against the limine protocol, but it's something i've wanted to do for a long time
i'm still going to use limine as the bootloader
the birth of ulogind
it's very simple
it's like 3 files
like, i already made it
i just need to wire it up to meson
why do you think this is wrong
there are operations which are only appropriate for an inode and others for an open file
well i found out that every open file needs a backing inode/vnode record anyways
yeah
so now I'm not sure if i want to keep that design, or just route everything through the inode
werent you rewriting
read above
I love making choices but I would never ever ever ever never actually do what I chose to do
Zag mentioned 🗣️ 🗣️ WTF is a useful kernel???
translation: I'm a chud with too little time on my hands to go through with a full rewrite
i spent my vacation working on managarm and now i have like no time left to work on my shit 😔
i just come home exhausted af
I have spent the past 5 days vibecoding late into the night/not sleeping
All I get is more chud rage
y
soyboy website
Some stuff that is not really in the scope of this server
For an event
do nusoi really
Which had to be working last week so we just had to lock the fuck in to get it working now
Its been fun I could larp with 3 other people in a hotel lobby as SF founders
btw @storm bobcat i ended up implementing the initgraph subtrees
these depend on the dt.parse-blob stage at the top of the screenshot
so they get all skipped
I'm assuming this is similar to the Linux efi stub?
Zinnia UKI images confirmed
I'm going to be really honest
multiple boot protocol support is only really useful if the protocols are like genuinely limiting what platforms a kernel can get booted on
Multiboot2 aswell 
like multiboot2+limine+hyper wouldn't really be useful if you're only targeting x86
I think the point is just that you can and to show it's properly abstracted
abstract it between more useful stuff then idk
i am targeting every arch that is supported by rust at some point
right now it's only x86_64, aarch64, riscv64
cool
but I'll probably be limited by what mlibc supports anyways
if you want to support direct EFI boot then most of the bringup (e.g. SMP) will need to be done by your kernel right?
You want to do that yourself anyways
at that point I'd just do efi+linux boot protocol
i already do that
i think the linux boot protocol is legacy and quite shit
linux boot protocol for risc isas*
that's literally just a jump and usually 1-2 registers
yeah the x86 one not so much
because i knew from the beginning that this day is going to come
I limit myself to architectures supported by limine rn
so I go all out on limine features
yea because that is legacy
EFI probably covers enough
ye
i don't see the point quite honestly
doing smp startup is not really hard
yea it's not
but supporting a much more barebones protocol and a much more fleshed out protocol together doesn't really make sense to me
the boundary of where the kernel's responsibilities start is vague then
like if limine will always be booted by EFI and you support EFI why add that extra jump in between
if limine is to be used as a boot manager then do efi chainload ig
all i need from a boot protocol is:
- RSDP or DTB address
- memory map
- hhdm mapping for bootstrap
- initramfs
now what I would get is something like
linux-risc+efi+iboot2 or other vendor specific
even on apple i can use efi
the issue with pure efi boot will probably be loading an initramfs
UKI is not actually that bad of an idea
i don't like ukis even on Linux
or you could take some ideas from the android world
dtb partition initrd partition etc
on disk
you'd need a disk driver but filesystem implementations (other than whatever you're using for your initramfs) can reside in modules or userspace or wherever
you can even a/b the initrd partition
for system upgrades
this sounds funny
it is
having a partition with just a big cpio archive xd
it's not a partition with just a big cpio archive
it is a partition with no fs that is just a cpio archive
nah
that is the initrd
i think the reason android kinda does that is because the "disk" is emmc/ufs and the boot chain is not the only thing that reads those partitions
my initramfs parsing is in kernel anyways, would be hard to load modules otherwise
like they have firmware blob partitions
that are not read by the kernel usually
the other chips themselves read them
yeah i have seen something like this on a few risc-v sbcs
i found this online
real list of partitions from an android phone
there's arm trusted firmware stuff
there's modem stuff
nice date
there's dsp stuff
there's a logo partition ffs
I've modified that before btw
changing boot logos is fun
honestly, i wonder what it would take to boot zinnia on a phone
i will do osdev for a phone if I get a cheap second hand easily moddable phone
pixels are expensive and have never entered the market here
pixels aren't expensive
i actually might
i currently have a turkish special passport
gotta make use of it before it expires
i wonder if I can get my university to fund a 10-15 person trip to fosdem
they're already funding my trip to poland in september
lol
partially*
lol
turkey has a 2-tiered regular passport
special and personal i think?
we don't call them that so I might have remembered the english names wrong
we call them green and red
they're both regular people passports but red is for everyone and green is for state workers and family
green has visa-free entrance to pretty much everywhere
except the us and uk
i am not a state worker I am the child of one so mine is going to expire when I'm 25
i have not made use of it yet
i think android has some superpartition magic btw
"partition"s are kinda more like volumes
i think
i haven't looked too much into this
ew
i don't think they have a set size
does linux have apfs?
think so
i don't think I succeeded in mounting macos in my friends asahi mac
there seems to be a fuse driver
fun fact
one of the SBCs in our rover
runs ubuntu 20.04 userspace with linux 7.1.4
the SBC got mainlined in like 6.18
cursed
but i mean the kernel shouldn't break userspace anyways
ye
I have created nix tooling that builds this
with debootstrap
the kernel is the latest nixpkgs aarch64 kernel
lol
i should port nix to zinnia
for 
oh man so many cool things i could be doing
i don't know where to start
well, i guess i should sort out my outstanding 80 file diff
i have decided i want to port nix to managarm
port it to zinnia too 
i mean
idk it should compile, it's just c++ right?
nix assumes a lot of unix stuff
windows port is damn hard (idk if it has happened yet)
zinnia is posix
but
ports to bsds etc exist
it's doing great
will probably have some bugs in mlibc
then a-ok
whatever fixes you get in mlibc will probably also help me
I have lots of bugs to fix in mlibc fwiw
mlibc in nixpkgs can't get binutils to build
because I build with tests enabled
huh
even a single test in some random dependency failing makes the build not go thru
which i want
it finds a lot of bugs
nix runs the test suite of anything i attempt to build for mlibc
Mlibc can build binutils without the tests (done it for astral) but Ive never tried it with the tests
You should take a look at xens credit1
They do some cool stuff in relation to prioritising cores close to the task during migration, aswell as cores without noisy neighbours and weighting SMT cores accordingly
Although I’d say it’s a lot more affinity / topology aware than the credit2, it doesn’t really handle load as well as the credit2, which replenishes credits differently (which was a source of performance degradation in credit1 due to them replenishing at fixed intervals of time) , doesn’t fall victim to the multiboost problem, and puts an upper bound on cpu utilisation using a deferrable server
credit2 is a lot smarter in how it decides what cores to push/pull from based on what migrations will do to the load of the runqueues involved
actually, good news about running zinnia on a phone
my old phone is a oneplus 9
which has an open bootloader
random side quest
.
only limitation is that it's going to be EL1 only
but that's fine
apparently it's a really good target because i can sideload limine
they use a stripped down edk2 it seems
https://www.goretroid.com/products/retroid-pocket-6-handheld
This thing can boot limine and other shit too, IIRC it has UEFI too??
Could be another good target 
And it's funny
if anyone cares
i LOVE xonotics build system

