#Zinnia
1 messages ยท Page 27 of 1
if you agree that you didnt hear it from me i do know how to make a DST with whatever pair pointer-sized pair of numbers you want stored in a reference to it
nah i think then it's just easier to write functions in IovecIterator
it's very practical because you don't need to care about whether or not a buffer is in userspace or not
just make it so that the buffer is always in userspace /hj
what's even the issue
although i think until we get place projections it cant quite work properly
nothing
You also kind of need it for proper writev/readv/readmsg/sendmsg support
imo overloading stuff based on this property is a bad idea
hm?
why?
sometimes you want to read from files in kernelmode
i mean i wouldnt but i can see why some people would think this is a good idea
its probably handy for like sockets or something?
then just read into the page cache
except there you could just make a kernel api...
well no you want to move from the page cache to a normalish buffer
pointers to userspace also need to remain in the same address space
there are just too many differences
you can't take the physical address of them
without locking memory
in particular, differences that imply that you need to handle them differently
at the site where they are used
are you saying i should have different APIs for kernel vs user accesses in e.g. the VFS code?
yes
i would just not have kernel accesses
to bootstrap what?
init
ok so wait
yeah
you dont have to use unreachable!()
where
kerne/src/syscall/process.rs
is that noreturn
no
its a bottom type
you can have it in a union
and then that case of the union is unconstructible
and you can match on it to construct whatever value you want
monostate but better?
monostate but it behaves properly in every case ๐
wait no its not monostate
its an unconstructible type
you cannot make a value of type !
ok but what's the change here?
-> Result<!, Errno>
?
ye
๐
btw thanks for the reviews 
i could use all of them
even if they're nitpicks
pitust could you take a look at my shitty vmm when I finish it?
you seem to know stuff about it
i would like to get interrupts working but idfk what I'm doing
especially msis with nvme
iirc that's not stablized, is it?
i.e., in arbitrary places instead of just function returns
yeah but nightly is better anyway
i have to use nightly regardless
you don't have to use nightly
why?
you need a custom target spec
and build-std is unstable
yeah
just patch rustc 
you need nightly to build the patched rustc

amazing 
why can't you just use no_std?
and a freestanding target?
surely there must be a way to do bare metal apps on stable?
different abi
different code model
and abi
and no prebuilt binaries
and in my case i also have dynamic linking enabled
i know ppl who work with rust on bare metal in regulated industries and i'm 90% sure that they cannot use nightly
yeah that makes sense
maybe they use nightly cargo and stable rust 
afaik build-std is done on the cargo level
ok then just RUSTC_BOOTSTRAP=1
thats TOTALLY different right
well the stdlib is built with effectively nightly
well the difference is that the stable compiler is actually, you know, stable
not with RUSTC_BOOTSTRAP=1 it isnt
well, it's built from a stable branch etc
it may have nightly features enabled during bootstrap but the point is that it went through way more QA than a random nightly build
with random nightly features enabled
i increasingly feel freebsd is doing the right thing
by autogenerating the de/marshalling code from SAL annotations
Autogenerated marshalling is 100% the way
Now you can't forget to enforce certain preconditions, especially if you have a type system that can more rigidly enforce it like C++ and Rust
nice!
i cherry picked stuff over from the socket branch
damn vgpu
even 3d?
ah
u can always verify user crap later
i really want to get sockets working with a cool rust abstraction
but i can't think of anything
i have this shit rn
console=/dev/fbcon seems to work
is this a bash port or just fastfetch
ah
lol#
i totally forgot zinnia has a working nvme driver
i did console=/dev/nvme0n1
what does console= do?
opens a file for stdin/out/err for init
oh
you should def make sure that your API for making them is secure by construction, i.e. that you dont have to call a validation function in every usage site to make sure you dont accidentally copyout to userspace
or well i guess its not as big of an issue with smap properly enforced
wdym
currently the only "safe" way of accessing user memory is through UserPtr
which handles SMAP and page faults
yeah good
are there any important cases where having the same API for kernel and user memory is useful? (cc @marsh holly since you have code for iovec_iterator_t in the VFS)
what is iovec
#include <sys/uio.h>
scatter gather
only vaguely
like in socket code MAYBE
and in elf loading code
yeah currently i only have it in elf loading code really
just realized
there are a bunch of names here that start with Z
nvm no there arent
we're the only two

but for the elf code you can just load a flat binary
and then have it be the real elf loader
aka the vdso loader route
kityt

get some help then
i have rebased most of the patches from the socket branch onto main
(minus the big vfs changes)
this afternoon i want to actually get some shit done
let's see...
- switch to iovecs
- rebase the vfs changes
- port rust std
std will be the most annoying part i think
Nah
how so
Or like it's annoying, but not too difficult
sure
i need to do the mlibc definitions too
sadly I can't use a generator so ig i do it by hand
i could make an abi checker maybe
Huh
yeah
maybe haiku
Also, most of it is abstracted away anyway?
the problem for me is libc
i have the base std done
i just need libc
but all structs and functions in there are random
I have lib::maybe_uspan
incredible name, I know
it can either hold kernel or user pointer
I use it for my vfs methods
of course every read and write is checked
i wonder if it's enough to make the iovec iterator thingy in a way that can't be Copy, Clone, Sync, Send
that would mean the only way that struct can be safely constructed is if it's pointing to an address in the active address space
Alright
because you can't send it to another thread, everything stays contained
ofc you can construct raw iovecs from thin air at all times
they just don't carry any meaning since you can't do I/O with them safely
you use it with the iovec iterator
you pass a list of iovecs to this iterator struct, which allows you to do reads and writes
the raw iovec is meant as something like an FFI
and the iterator is a safe wrapper around it
okay
Womenix

i should figure out serial interrupts
this is like the most basic ass form of input
i need to see if the coreutils do their shit right
Womenix
Womenix

pretty sure they're using the same "legacy IRQ" system as ps/2
meaning you need to setup IOAPIC and stuff
unless you have a PCI serial device
i dont have that either
do i need to parse acpi tables for ioapic configuration
like what for example?
do i need to configure the pin polarities?
4 different types of headers
wut
it's not that hard
https://github.com/iProgramMC/Boron/blob/master/drivers/halx86/source/ioapic.c heres my implementation that i stole from somebody else
yeah but idk where to look
i believe it was astral but not sure
i have discovered the ioapic and i have code to configure it
ig im just missing the setup
https://github.com/ilobilix/kernel/blob/master/kernel/source/arch/x86_64/system/ioapic.cpp here's my implementation that I probably stole from somebody else but I don't remember
I've got an idea
I'm going to make Zinnia BSD-like
it already has a BSD license and some BSD ioctls
most of the work will be getting BSD functions into mlibc
Freebsd abi compat
nah
i could, but i explicitly want to help with mlibc
because i believe it's a project that benefits way more people than a shitty hobby kernel
port bsd libc
no
k
linux only unconditionally masks if doing x2apic + iommu
wait so
what am i even supposed to do here
your code reads like there are no GSI overrides if PIC is disabled
I think you need to unmask irq 2 in pic even with ioapic
if u want to be able to use pic as a fallback
i dont
I think isos are for just that
what base revision do you use?
because on base revision 5+ Limine will mask the ExtINT LVT in the local APIC(s) which means that masked or not masked, you're not gonna get PIC interrupts
in any case it's fully masked, in any base revision
like if you wanted to get PIC interrupts with base rev 5+ you'd have to unmask the ExtINT
masking ExtINT is the "proper" way to disable the PIC
per se
damn not using aml to detect serial
๐ญ
imagine not assuming that ISA peripherals just exist
i need to write a uacpi driver wrapper
i dont like the way uacpi does discovery
but that's bound to C ig
@somber solar irq_swtich
the wiki says that masking all PIC IRQs = "disabled" but masking ExtINT is more of a real disabling than that
yeah I'm good at naming how could you tell
you should do both anyways
and good at spelling
indeed
@grave peak have you considered removing anon structs and unions from uacpi headers
:3
Which
this
it's not an issue at all but it makes codegen a bit ugly on langs that don't have it
using enums in C is stupid
example
even more so on public interfaces
Who was talking about enums lol

real
Nah enums aren't going away
:(
For anon structs ill think about it
i'm only talking about anonymous types
what's the problem with enums?
Just a clearer intent when reading code, instead of int thing
especially in c23 they're good
Yep
nobody here isn't using that
i've never had issues with enums?
@grave peak I couldn't find any info about it iirc
even before c23
Cant you like make a custom helper or just tell zig the struct contains one item that you want instead of using raw bindings?
you can use enums, just not in public interfaces, that's my take, but whatever, irrelevant here
no
Why not?
wait, zig?
Oh thats rust, even worse
not C89 but usually something like C99 or C11
@near tartan I could add like a no_anon_struct define, would that help?
how would that look
Ifdef no_anon_struct { field } else union { field1, field2, field3 }
Something like that
it doesn't matter lol, it's a matter of compatibility and type
just give all unnamed unions a name?
that would cover all cases
That breaks all C code tho
(not in C23 but whatever)
Does it not?
no?
Cuz then u have to have a name for the member, which means u have to add a tbl.thing.ptr
i think infy is right
yeah
Which makes all C code as ugly as your rust code
yeah, i'd be against making unions/structs named
removing enums won't :p
But putting that behind an ifdef is fine perhaps
i hate C too <3
no that's useless
no?
No what
you have the same issue then lol
?
@grave peak don't tell me there isn't some instance where you wish you could have typed enum members
sleep marvin
barring C23 of course
I cant in uacpi even if I wanted
It supports openshitcom etc
lol
marving trolling today
im mad okay
what does that have to do? what i mean is that using #defines over enums means you can give them types beyond int
not to mention that having functions take enum parameters or return enums is kind of a meme in C as well
whats the point exactly?
if you need them to be typed
or u could just do enum : type 
i should make myself a uacpi wrapper
write your own aml interpreter
uacpi C++ modules support when
Device (UAR1)
{
Name (_HID, EisaId ("PNP0500") /* Standard PC COM Serial Port */) // _HID: Hardware ID
Name (_UID, One) // _UID: Unique ID
Name (_DDN, "COM1")
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((FUIO (Zero) != 0x0F))
{
Return (0x0F)
}
Return (Zero)
}
Method (_CRS, 0, Serialized) // _CRS: Current Resource Settings
{
Name (BUF0, ResourceTemplate ()
{
IO (Decode16,
0x02E8,
0x02E8,
0x01,
0x08,
_Y2C)
IRQNoFlags (_Y2D)
{3}
})
CreateByteField (BUF0, \_SB.PCI0.UAR1._CRS._Y2C._MIN, IOLO)
CreateByteField (BUF0, 0x03, IOHI)
CreateByteField (BUF0, \_SB.PCI0.UAR1._CRS._Y2C._MAX, IORL)
CreateByteField (BUF0, 0x05, IORH)
CreateWordField (BUF0, \_SB.PCI0.UAR1._CRS._Y2D._INT, IRQL)
Local0 = FUIO (Zero)
Switch (ToInteger (Local0))
{
Case (Zero)
{
IOLO = 0xE8
IOHI = 0x02
IORL = 0xE8
IORH = 0x02
}
Case (One)
{
IOLO = 0xF8
IOHI = 0x02
IORL = 0xF8
IORH = 0x02
}
Case (0x02)
{
IOLO = 0xE8
IOHI = 0x03
IORL = 0xE8
IORH = 0x03
}
Case (0x03)
{
IOLO = 0xF8
IOHI = 0x03
IORL = 0xF8
IORH = 0x03
}
}
IRQL = (One << (FRUI (Zero) & 0x0F))
Return (BUF0)
}
}
Some examples from real hw
PNP0500 + uacpi_get_current_resources
huh kinda funny they have an IRQL field
so does that help strip a prefix completely?
what does the switch case do? is FUIO the thing you pass in to find a port
i mean
is Zero the first parameter or something
it is yes
Method (FUIO, 1, Serialized)
{
If ((IER0 == One))
{
If ((WUR0 == Arg0))
{
Return (Zero)
}
}
If ((IER1 == One))
{
If ((WUR1 == Arg0))
{
Return (One)
}
}
If ((IER2 == One))
{
If ((WUR2 == Arg0))
{
Return (0x02)
}
}
If ((IER3 == One))
{
If ((WUR3 == Arg0))
{
Return (0x03)
}
}
Return (0x0F)
}
its some internal firmware code
who knows
ah ok so you call that function to get the port
only stuff prefixed with _ is public API
bruh
I found something about spcr and dbg2 tables as well
@somber solar serial devices in aml also often times have possible_resources() and set_resources() so u can choose any IRQ u want and any IO port you want
out of the supported values
yeah thats for early serial before aml
not all hw has it but yeah
tlb shootdown can wait
so what device can you actually assume is present for early logging lol
what if I want to log before early table access :P
I chose serial because at least on real hardware it might actually exist vs debugcon
dbg2/spcr tells you
in hypervisors u can test for 0xE9
well
can you just write to com1 and hope it exists?
u can try that
^
in fact infy is implementing uLog as we speak
hmmm
yes
really?
straight up lies

lol
well, sort of, rather, you can check if it exists
if anything he should make one instead
without AML
who, me?
ofc
just convert my zig back to C++
your ring supports 32 bit

that relies on zig shenanigans though
zig to C bindings
ring?
since I can do u<arbitrary> so I do u<usize bits - 2>
even more pnps PNP0500 PNP0501 PNP0510 PNP0511
yeah theres a few
if only you could have that many ways of detecting pit
here's the thing: for ISA devices you can assume that they are either where you'd expect them to be, or they are not, but there's not going to be something else in their place
that's just not a thing that happens
yeah thats why I opted for com over debugcon
so you can test if they are there with readbacks/init and whatnot
yeah they're scared af to break nt boot
I do both com and e9
you just read from it
yea
e9 detection is in(e9) == e9 lol
ye
tbf i don't think there is much of an advantage to using e9 once you have com anyways
omw to implement e9 on real hardware
tbh its actually harder
if ((bochs_bios_in_smbios || in_hypervisor) && in(e9) == e9)
I mean when would you ever read back 0xe9 from port 0xe9 if it wasn't present
never
this is for detection
if a port isn't connected to anything you usually read back ff
on real hw (and probably emulators/qemu)
yeah but if there's something else at that port you may cause side effects
unlikely
that's why you don't use e9 if you have com :p
can one detect absence of pit?
yeah by probing, but like
that's not enough
for example ARL has a PIT but it's clock gated by default
most probing mechanisms would tell you there is a PIT there
what did u mean btw
it fails to generate if i leave it blank
i mean who needs it for anything other than calibration
so yeah, no, heuristics are a better approach
oh ok
so would ifdef help you then?
e.g. you can assume there is a PIT if a machine is old enough to not have e.g. invariant TSC
I should mask pit if something else is used
does that matter
like the IRQ? yes. ideally you should have all IRQs/GSIs masked unless you need them lol
bragging rights
lol
bruh
cant u pass c flags from rust?
also theres proper bindings being worked on anyway so
this is the case btw if you use Limine
yes but it doesn't help me bro
the only thing that is not masked as per spec are MSIs which are left as firmware set them up, but that is usually all masked as well
how lol
i still have to type the whole path
it's not like C where it skips anon structs
or not
better a proper name instead of anon_1
oh ok if u want it then yes
if u have to do the cast anyway u can just have one single field and no need for a union
the entire idea of a union is to minimize the number of casts required
it's not so deep
๐ญ
ah i thought you wanted to just not use a union if you passed that define
okay so I think I'll:
- dump everything to com1 until table access
- check for spcr/dbg2 when tables are available
- evaluate pnps once acpi is initalised
like, and have multiple fields instead
LIMINE_PTR(x) 
thats what i thought
it can have multiple fields if marvin really wanted to
i dont care anymore :3
like as i said, it's a bit more wasteful, but it would also be similar enoughโข
but a void ptr or something would also work ig
marvin probably regrets bringing it up 
yeah
lol
this isn't useful
at least with that option u can have a readable prefix
in your builder thing i mean
rust doesnt have anon unions at all right
c just can't stop winning 
es
real
why is smbios even useful
why is it useful to know what system you're running on?
i wrote a tool once that can register itself in a netbox setup by fetching all dmi info and system info and uploading it
yes unironically
why does it matter what the bios vendor is
the actual proper solution is to not do that btw
like just have a log buffer
It contains a ton more than just the bios vendor
Same as rsdp
Which
your smbios code
In the pr that's open
do you do it with hyper?
Yes
im trying to depend as less as possible on the bootloader but that kinda stuff is optional anyway so I think I will depend on it for that
for what?
Well in bios mode u can find smbios yourself
smbios?
In UEFI mode its in the configuration table same as rsdp
So it requires boot services
yea
yes
what is smbios useful for though
what kinda stuff can I do
just run sudo dmidecode to get an idea
i will crash if the manufacturer is not crucial
why not both
should the kernel have a generic way of allocating msis?
considering drivers using msis are also generic
Yes
On x86_64 I think you have all the flexibility you can get
You can even remap legacy IRQs onto any vector
So IRQ 0 you could map to vector 0xAF or whatever for example
and then what
?
what's the difference to other archs
other archs might not have nearly as much flexibility
e.g. x86 without apic has fixed legacy IRQ numbers which you cant change
makes sense
so to answer this question
it's no
right?
platform irqs like what
well yeah
also you'll want such a feature if you implement irq priority levels using the TPR/cr8
are you only planning to support x86?
since those block interrupts depending on the interrupt vector number
no
e.g. a TPR of 0x8 blocks interrupts with numbers 0x00-0x8F
ok, so far what I'm thinking is that a generic api for allocating interrupt lines (of any kind, msi or something else) is useful for drivers, but the implementation really depends on the platform and interrupt controller configuration.
yeah figured that much
there's a paper that fadanoid(?) linked recently that I thought was really interesting for this, I dont know if you read it
#1385970208631427173 message this one
for non MSI, the routing is usually fixed or almost fixed though
I think anybody who wants to design a proper IRQ abstraction needs to look at multiple architectures and IRQ controllers since they are all different
You cannot look at x86 and extrapolate from there
yeah
as there is too much x86 specific stuff
I have made that mistake in the past
true, I probably should have said acquiring instead of allocating there.
All of these assumptions are wrong:
- IRQ routing is fixed / constrained and not fully dynamic
- IRQ routing is fully dynamic
- The CPU has a concept of an IRQ vector number
- The device has a concept of an IRQ number
- The interrupt number that the device uses matches the one on the CPU side
- There is only one IRQ controller between the device and the CPU
- MSIs are sent directly to the CPU
- You need to send EOI before handling the IRQ
- You need to send EOI after handling the IRQ
- IRQs are either edge or level
- The kernel knows if IRQs are edge or level
- All IRQs have the same priority
unsigned _BitInt(bits)
You can just use masks
In zig they're useful because you don't have to use masks
But Linux does
i'm rewriting zinnia in C++ and i'm doing linux abi compat

For real?
Ah fuck April fools
:)
Unironically do that tho
that would be the good choice tbh
ilobilix :P
see i want to do bsd source compat
its not focused on quality etc
i think it's cool
now that i can actually interact with my kernel i think i can test it much better
i need to add tty discipline
Which
yeah out of all bsds
what's the diff
at least pick the popular one
ok
yeah
what's the difference between source and abi compat
what is nvmm
kvm but good
source means u have to recompile
abi means u can cp native programs
The good choice imo is doing like I'm doing which is building Linux compat as a separate subsystem that's built on my own design
ah
virtualization API
i want to do bsd + mlibc
thats freebsd with extra steps
unlike freebsd jails
Well yes but not cloning freebsd
the thing is, because i'm not claiming to be literal freebsd, i can do whatever i want and pick my favorite APIs from everywhere
I'm not cloning anything in particular
buzz lightyear meme 
lol
lol
linux abi compat used to be a novel concept
fishix, ultra, mine
but everyone stole it from me
who else does it?
๐ญ
I did it before you did
!
Like two years ago
damn
I hadn't even heard of your kernel when I started mine
probably because it didnt exist
this rewrite is a bit more than a year old
has it always been linux compat?
ah ok
I was using mlibc before this rewrite
i'm doing a mix of everything
drm + evdev + nvmm + posix_devctl + epoll + bsd style device management
and pe instead of elf
arguably
It's definitely simpler
bhyve doesn't support qemu
Most of the logic is in userspace, the actual hypervisor code in netbsd is like 2k lines and really readable
is bhyve like part of that or
ohh nvmm is netbsd
yea
and bhyve is freebsd i guess
Yes, but now the development is done in dflybsd because the author got mad
if all the logic is in userspace that probably means a lot of vmexits become userspace vmexits which are incredibly slow btw
average open source project 
sure its simpler but its not something ud want for production
Not all of it, I'm not sure how it works
But like it is pretty good from what I've heard
is it supported by qemu also?
its kinda funny they keep splitting into more forks
mitosis
lol

dflybsd is pretty old
nvmm is, bhyve is not
diddybsdm
diddybdsm 
@marble salmon btw the solution was to turn on interrupts in syscalls 
it's the reason the serial interrupt didn't arrive in the kernel
because it did fire in qemu
my ioapic code was mostly fine already 
do you keep track of interrupt state with a counter like preemption?
mine is also broken. it assumes that the last thing unlocked was the first locked
gotta fix that
lol
well in my case the mask for syscall doesn't have 0x200
so i have to manually enable interrupts in the handler
doesn't that go in some mask msr
idr
anyways, now that i can get interrupts routed and send input to user programs it's time to tackle ttys and ptys

finally fixed mounting
i still need to do the tty shit
i want to fix some things that i had stubbed out for way too long
- Signals
- Process groups
- devctl instead of ioctl
- ext2
- fix mount and chroot
speaking of, how does one go from initramfs to rootfs? i know linux has pivot_root, but how is this usually implemented?
my idea would've been to just mount the rootfs and chroot into it from init
but idk if dinit can cope with that
maybe I'll just switch back to openrc
just mount some partition to / and exec to /bin/init for example
oh true
yeah it feels like it is
it predates bind mounts which can solve this more cleanly
so i guess my initramfs "init" is just a simple mount + chroot + execve
or, at least, the magic chdir change of pivot_root is a hack
HOLY SHITTTTT
bro ๐ญ

i hate my life
i forgot to swap out the raw CStrs in execve
that's why its dying
i think
you can now mount partitions by their partuuid
is that not a symlink?
why not use /dev/disk/by-partuuid :P
lol
mmm, stringly typed kernel APIs
my favorite
idk how else to do it 
u8 source[] = {0x53, 0x2c, ..., 0xed};
struct zn_mount_op mount_op = {
.fstype = ZN_FS_EXT4,
.target = "/tmp", .target_len = 4,
.source_type = ZN_MOUNT_BY_PARTUUID, .source = source, .source_len = sizeof(source)
};
if (zn_mount(&mount_op) != 0) { perror("zn_mount"); return 1; }
ur welcome
that's not very ergonomic
what if you don't want to mount anything
you just want to open the device
and then do what with it
io?
yeah i mean like what io
creating and managing partitions?
you can do that with a kernel api ๐
you kinda need a kernel api for that anyway
you need to sync against the kernel
well i guess you dont need a lot of sync
you could just tell the kernel to rescan partitions or smth
for a bit i'll stop working on this to focus on doing mlibc work
I mean you'll have to end up doing it for ptys

lol
fix yo getdents
tty1 is gone
console is still linked to it :P
oops
you probably still want /dev/tty
i'm doing ttys right now
cool
I'm doing UVM-style VMM for BadgerOS ATM
nice
Still some bugs to iron out
i can start gcc now :3
After that I'm going to do IoKit-like device rewrite

I was thinking about looking into UVM, any resources you'd recommend?
The UVM paper combined with NetBSD sauce kodes for it
very productive day today ๐
i can even start openrc now
somewhat
once i figure out unix sockets we can do xorg
@magic charm iirc you did something with keyronex udp sockets and xorg
todo for today
- check ppoll impl for bash input
- implement get/setresid, deprecate the individual setid syscalls
- finish ttys
- unix sockets
I did get xorg happily running remote apps over TCP
how was that set up? running the server on linux?
Xorg on keyronex and apps on Linux
ah
that's cool
i have no idea how to even start with sockets tbh
i have no resources
how is it that literally everyone is doing advanced shit
and im still failing at baby allocator implementation
advanced
bro have you seen ANY of my impls
it's the most cursed dogshit ever
yes but you have userspace
ok and
and i have a hello world tier kernel without an allocator
is the solution to just not do good impls then
bc if so then thats lame
korona said something about that as well
"make it exist first, then make it good"
and i mean my impls aren't the worst
they're above average i guess
and im stuck in a loop trying to do a page cache before i refactor the kernel ๐ญ
lmao
right now i didnt even get to a page cache
it's literally a year that i say i have to do it
im refactoring my allocator rn
and i never get to do it
but my old allocator was garbage
turns out a 4kloc syscalls.c file is not the best design ever
my vmem allocator for userspace is a bump allocator 
fucking what
i mean true
yeah i have enough virtual space so shrug
personally id just have libc choose the address
like, even if you allocate 1GB/s
and then only do MAP_FIXED in kernel mode
it's literally 2 days of uptime
ooh good point
TCP/IP Illustrated vol 2 is excellent, it covers the socket architecture more broadly not just tcp/ip itself. And cross referenced with the actual bsd sockets code from BSD Net 3
thats what im gonna do for my kernel bc easier (well im doing MAP_FIXED_NOREPLACE because posix sucks, i want to do strict accounting, making an allocator that refuses to take memory back is fucking insane, and while you can make failure-free munmap/mprotect work its really fucking annoying)
is it available online?
yes
Either vol 2 or vol 3 even specifically has a section on unix domain sockets
a unix domain socket is just a duplex pipe + duplex fd passing, right? (with some extra headers to make the two line up right)
so if you dont care about quality of impl, you can just make a pipe of messages where each message owns the data inside
It supports the full sockets interface including the cmsg api but in principle you might special case and implement it trivially
and to optimize this you can store a range over a data ring instead of a separate alloc
yeah thats true, it does kinda suck to have a separate path for uds
hmm. i wanted to make a bitmap for tracking which objects within my slab allocator are in use, but it kinda sucks to reserve 512 bytes from each zone for a bitmap, when almost all objects in practice are big enough that you wont use all of it
Xorg certainly doesnt demand much and can live without cmsg support and the like
i guess its still less than 1% overhead
i found it much easier to just keep it as a linked list of messages, that can be either control or data
i think i got this from keyronex
yeah but linked list slow and ugly
mitshm-using applications dont really write much data to the socket
xterm is an absolute hog tho
What are you thinking of
rn I have a classic slab thing but I wanna improve it
One thing I can immediately think of is having alloc and free magazines
yeah I already do that
and i dont have anything ๐
What's a bit annoying is the hashmap
why do you need a hashmap?
For large slabs you need one to convert an object pointer to its bufctl
or you can just not have large slabs ๐
they're useful but not that common
idk are they useful
I cant use a tree because that would make the bufctls huge
in vmem I was able to replace the hashmap with a rbtree tho
im trying to avoid having a hashmap
by making consumers keep track of the alloc state structures
It's probably not that big of a problem since large slabs aren't that common, but I still need to have some kind of mechanism to resize it
just preallocate it
Which would be done in a thread or something
a large slab is how big?
actually, what do you even use them for?

