#Managarm and related projects
1 messages · Page 5 of 1
what's this?
elogind
I want to try and get a proper display manager up and running and they all need elogind or systemd-logind
Does dbus work now btw?

Wayland ones do
Many of them working fine on bsds without systemd or logind
I guess that's true
I mean a lot of socket code works fine, including dbus, so I'm not really inclined to blame that
haven't really looked into this tho
yeah never say never but socket code should work but idk
I can now run NVMe admin commands from userspace let's goooooo
nice
ok ig that's enough for a prelim PR
I'll deal with NVMe-oF later
if that still boots tho 

minor details, time to also wire up NVMe-oF info to sysfs
fucking useless dbus elogind piece of shit
I don't have to do the character devices yet tho
there's also the minor detail that NVMe ioctls are absolutely undocumented and the code is unreadable
does this do a passthrough command?
yeah, it uses the ioctl interface to run commands on the admin queue
we should probably keep a whitelist or blacklist of commands for that tho
very nice
given that the point of the interface is to allow for using commands in userspace that are not supported by the driver, the blacklist would be better tbh
I suspect the original point was vendor-specific commands, but it's also nice for managing drives in a SAN env
where you might have a pretty custom software stack
I don't think this is relevant to us tho, as you'd probably want to use io_uring for such a use-case anyways
you can test it on your host, too
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/nvme_ioctl.h>
int main(int argc, char** argv) {
int fd = open(argv[1], O_RDWR);
if (fd < 0) {
perror("open");
exit(1);
}
char buf[4096] = {0};
struct nvme_admin_cmd mib = {0};
mib.opcode = 0x6; // identify
mib.nsid = 0;
mib.addr = (__u64) buf;
mib.data_len = sizeof(buf);
mib.cdw10 = 1; // controller
int ret = ioctl(fd, NVME_IOCTL_ADMIN_CMD, &mib);
if (ret) {
fprintf(stderr, "ioctl failed: %d\n", ret);
exit(1);
}
printf("SN: %.20s\n", &buf[4]);
printf("SN: %.40s\n", &buf[24]);
printf("FW: %.8s\n", &buf[64]);
printf("Status: 0x%04x\n", mib.result);
return 0;
}
success
very nice
also
ok let's goooo
I'm not quite sure how to implement some of the attrs yet but details
also, how should some of the attrs be queried?
for instance, we need to expose stuff like model, serial and a per-queue LBA size attr
putting all of that into mbus attrs doesn't make too much sense to me
for model and serial you could make the case that you might want to match that with mbus filter, but the rest doesn't quite work
esp for capacity data that would change all the time
what does "change all the time" mean?
this changes only rarely, right?
in principle there are just two options: mbus properties or requests
requests probably require more boilerplate than mbus properties
so what's the issue with mbus properties?
hmm I think this is dbus being a dumdum or us launching elogind retardedly, as it's complaining about org.freedesktop.login1 not being provided by any .service files
maybe we should add some generic sysfs attribute infrastructure? such that mbus properties with names sysfs.foobar are automatically turned into sysfs attributes called foobar?
busctl gets killed by signal 18 (that's SIGCONT
)
SIGCONT needs a gh issue if there is none already
yeah I'll open one
SIGSTOP + SIGCONT are relatively easy to implement
can be done entirely in posix, without touching the kernel
afaict there are properties that return the "occupied" size of a namespace, so that would be updated often
among other things
I'm slowly building up the commits here: https://github.com/no92/managarm/tree/nvme-sysfs
Pragmatic microkernel-based OS with fully asynchronous I/O - GitHub - no92/managarm at nvme-sysfs
honestly elogind also feels partially like a cgroup issue
or rather, the lack of cgroups
ah. if it's something that changes multiple times per second, it should be a request
you could also do a generic "get sysfs attribute" request
or integrate it with this idea: #1091278035686268928 message
for example: if there is a sysfs.dynamic-attr.foobar, you add a foobar file and do a showSysfsAttribute request when it's read
relevant logs attached
elogind[41]: (DEBUG) src/login/elogind.c:348:elogind_startup: Daemonizing elogind...
elogind[41]: (DEBUG) src/login/elogind.c:114:elogind_daemonize: Double forking elogind
elogind[41]: (DEBUG) src/login/elogind.c:115:elogind_daemonize: Parent PID : 41
elogind[41]: (DEBUG) src/login/elogind.c:116:elogind_daemonize: Parent SID : 38
elogind[41]: Successfully forked off 'elogind-forker' as PID 42.
elogind-forker[42]: (DEBUG) src/login/elogind.c:128:elogind_daemonize: Child PID : 42
elogind-forker[42]: (DEBUG) src/login/elogind.c:129:elogind_daemonize: Child SID : 38
elogind-forker[42]: (DEBUG) src/login/elogind.c:146:elogind_daemonize: Child new SID : 42
elogind-forker[42]: Successfully forked off 'elogind-daemon' as PID 43.
elogind-forker[42]: (DEBUG) src/login/elogind.c:155:elogind_daemonize: Fork 2 returned: 1
elogind-forker[42]: (DEBUG) src/login/elogind.c:156:elogind_daemonize: Grandchild PID : 43
elogind-daemon[43]: (DEBUG) src/login/logind.c:1347:run: Creating manager...
elogind-daemon[43]: Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy (lies but we're gonna do cgroup2 anyway soon I think)
elogind-daemon[43]: Mounting cgroup2 to /sys/fs/cgroup of type cgroup2 with options nsdelegate,memory_recursiveprot.
elogind-daemon[43]: Failed to mount cgroup2 at /sys/fs/cgroup: No such file or directory (ENOENT)
elogind-daemon[43]: Mounting cgroup2 to /sys/fs/cgroup of type cgroup2 with options nsdelegate.
elogind-daemon[43]: Failed to mount cgroup2 at /sys/fs/cgroup: No such file or directory (ENOENT)
elogind-daemon[43]: Mounting cgroup2 to /sys/fs/cgroup of type cgroup2 with options n/a.
elogind-daemon[43]: Failed to mount cgroup2 at /sys/fs/cgroup: No such file or directory (ENOENT)
elogind-daemon[43]: Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy (lies but we're gonna do cgroup2 anyway soon I think)
elogind-daemon[43]: Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy (lies but we're gonna do cgroup2 anyway soon I think)
elogind-daemon[43]: Failed to read $container of PID 1, ignoring: No such process (ESRCH)
elogind-daemon[43]: Found container virtualization none.
elogind-daemon[43]: Failed to create '/run/systemd/inaccessible', ignoring: File exists already (EEXIST)
elogind-daemon[43]: Failed to create '/run/systemd/inaccessible/reg', ignoring: Invalid argument (EINVAL)
elogind-daemon[43]: Failed to create '/run/systemd/inaccessible/dir', ignoring: File exists already (EEXIST)
elogind-daemon[43]: Failed to create '/run/systemd/inaccessible/fifo', ignoring: File exists already (EEXIST)
elogind-daemon[43]: Failed to create '/run/systemd/inaccessible/sock', ignoring: File exists already (EEXIST)
elogind-daemon[43]: Failed to create '/run/systemd/inaccessible/chr', ignoring: File exists already (EEXIST)
elogind-daemon[43]: Failed to create '/run/systemd/inaccessible/blk', ignoring: File exists already (EEXIST)
elogind-daemon[43]: (DEBUG) src/basic/cgroup-util.c:738:cg_pid_get_path: Searching for PID 1 in "/proc/1/cgroup" (controller "_elogind")
elogind-daemon[43]: Cannot determine cgroup we are running in: No such process (ESRCH)
elogind-daemon[43]: (DEBUG) src/login/logind.c:124:manager_unref: Tearing down all references (manager_unref) ...
elogind-daemon[43]: Failed to allocate manager object: No such process (ESRCH)
I'm not sure converting all sysfs attributes to a request thing would be beneficial, but it might be nice for some of them
i'm not saying that all sysfs attrs should be requests
only the dynamically changing ones
a lot of attributes can be determined from static data by posix, and I'd keep that
or rather, only the very frequently changing ones
like multiple changes per second
ig we'd need to keep a list of dynamic attrs per subsys as we need to realizeAttr them
for example, if it's something that only changes as a result of user integration, it's fine to update it in posix
i'd explore the idea of letting driver declare these via mbus properties
that sounds easier to extend
hmm might be nice
if we put the sysfs side of that in drvcore, then integrating that into sysfs code would mean a single-line diff per subsystem that supports that
this might actually be a very convenient solution tbh
esp now that we have mbus array types 
i could imagine mbus properties like
sysfs.static.foo = 21
sysfs.static.bar = 42
sysfs.dynamic = [baz]
resulting in 3 files foo, bar, baz where the last one uses a request and the others are just static data
hmm I hit a bit of a problem
I may be stupid however
but
I should attach NVMe-oF controllers under /sys/devices/virtual/nvme-fabrics/ctl/nvmeX, but that should also be a nvme-class device
I basically need to inhibi the emission of the nvme in the path before nvmeX
how do we solve that
realpath /sys/class/nvme/nvme1
/sys/devices/virtual/nvme-fabrics/ctl/nvme1
Hmm maybe check how it works in the linux kernel
I tried but I really don't quite understand what's happening there
or more like
how a nvme-fabrics controller is being exposed over sysfs
nvmf_init inits the nvme-fabrics/ctl device tho
can't follow it from there really tbh
the logic in linux is: class devices only get a glue directory if the parent device is not also a class device
and ctl is a class device
okay I think I implemented that correctly now
but booting with NVMe-oF gives me
udevd[22]: worker [34] /devices/pci0000:00/0000:00:02.0 is taking a long time
udevd[22]: worker [27] /class/input/event0 is taking a long time
udevd[22]: worker [33] /class/input/event1 is taking a long time
udevd[22]: worker [31] /class/input/event2 is taking a long time
udevd[22]: worker [30] /class/input/event3 is taking a long time
I have no idea what the problem is
afaict the NVMe-oF appears as wanted in sysfs and stage2 is entered
also after a while
udevd[34]: timeout: killing '/usr/bin/runsvr run /usr/lib/managarm/server/gfx-plainfb.bin' [35]
udevd[34]: slow: '/usr/bin/runsvr run /usr/lib/managarm/server/gfx-plainfb.bin' [35]
I'm really not sure why tbf
weirdly enough it works on regular NVMe boot
ah the problem is probably udevd[22]: sender uid=4280484760, message ignored
yeah it was a me issue, as always
let's goooo
damn this makes a solid chunk of nvme-cli's commands just work™️
Based
ig we're missing some rarely used ioctls for stuff like I/O commands (pls don't) and the character devices
this ought to be enough for the first PR tho
ig the nvme-fabrics char dev would be next
after that, I would deem the nvme work good enough for the foreseeable future
small diff that only spans 35 files
ok, small correction, 33
32
damn very nice
Nice
very nice
how did this happen though?
i guess one useful addition would be supporting configfs
or wait
is that actually needed to connect to nvme-of?
or does it use the char device?
no that's only for hosting a controller
/dev/nvme-fabrics
requesting reviews on https://github.com/managarm/managarm/pull/812
okay I'm struggling to figure out what happens to /dev/input/eventX with systemd udev
Always fun stuff
i still need the relevant patches / branches such that i can debug it 
But my gut feeling is still that it can't be that hard to figure out what happens by logging in posix-subsystem
/dev/ is a tmpfs, so adding all tmpfs-related calls (and mount to check that we're not mounting over it) must yield something useful
Maybe we should even log the tmpfs readDir calls that we do during ls to check that we're reading from the right tmpfs
I've done request logging, I didn't see any remove/rename/rmdir etc in there
the only mounts happening are in stage1
yea, I'm not talking about request logging but about adding logs to tmpfs.cpp
These can maybe even be committed (disabled by default through a constexpr bool)
If all else fails, we could dump the entire tmpfs on every modification
alright, I'll see
one thing I noticed is that our sysfs representation for event devices is really not what linux does
the eventX devices should be under a inputX device afaict
both sharing the input subsystem
and inputX being a class device of the input class
trying to hackily wire that correctly doesn't seem to help either
yeah now kmscon doesn't seem to pick up the input devices, great
however, of note, eudev seems to somehow keep the char devices around
unlike systemd udev
Well, the first question we should answer is not why are the devices deleted but how are they deleted
Since last time we looked at this we didn't even know how they get unlinked
even when logging tmp_fs no unlink of eventX takes place
there is no matching rmdir, unlink or renameat
Bruh
What if you do this ^
And this ^?
I wonder if we're even reading from the right tmpfs
I logged readDir too, it doesn't even call it on /dev/input
Interesting
honestly I'm feeling a bit stuck rn
ig I can run ls -la /dev after the ps2 driver inits
drwxr-xr-x 0 root root 0 Jan 1 1970 char
c--------- 0 root root 1, 7 Jan 1 1970 full
c--------- 0 root root 1, 255 Jan 1 1970 helout
d--------- 0 root root 0 Jan 1 1970 input
c--------- 0 root root 1, 11 Jan 1 1970 kmsg
c--------- 0 root root 1, 3 Jan 1 1970 null
c--------- 0 root root 5, 2 Jan 1 1970 ptmx
d--------- 0 root root 0 Jan 1 1970 pts
c--------- 0 root root 1, 8 Jan 1 1970 random
b--------- 0 root root 8, 0 Jan 1 1970 sda0
b--------- 0 root root 8, 1 Jan 1 1970 sda1
d--------- 0 root root 0 Jan 1 1970 shm
b--------- 0 root root 240, 0 Jan 1 1970 ttyS0
c--------- 0 root root 1, 9 Jan 1 1970 urandom
c--------- 0 root root 1, 5 Jan 1 1970 zero
Maybe check the inode numbers
and ls -la /dev/input/ gives
total 1
drwxr-xr-x 0 root root 0 Jan 1 1970 by-path
that is after /dev/input/event0 is installed by posix tho?????????????
like right after
ig one possible issue is the fact that systemd want a way to resolve an fd to a path
and it uses the linux cancer that is /proc/self/fd/
I'm wondering if we're messing up stuff there
maybe we should just implement a different mechanism for that for now, and path systemd to use that
gottem
posix: MKDIRAT /dev
posix: FSTATAT request
posix: Fix tmpfs getStats()
mlibc: mkdirat() ignores its mode
posix: MKDIRAT /dev/input
posix: FSTATAT request
that is deep in udev code
Or we should fix proc/self/fd?
that is way too advanced shit for me
There must be some vfs bug
If the device is added to /dev/input but never shows up
Hmmm
Maybe udevd creates /dev/input before posix creates it and that somehow causes the bug?
This comment looks sus
Is this path even executed?
This code path
yeah, the input dir is mkdir'ed once
when setting up the first eventX
it also succeeds
And mkdev is also called? For all events?
could you log whether the dir that device.cpp sees is the same that ls sees?
Possibly by logging the tmpfs dir ptr
huh
I don't get that
maybe that's something for vc
ig I could also supply you with my current changes
certified mammogram moment
lmao what
okay I don't quite know why but systemd-udev performance is almost acceptable now
https://github.com/no92/managarm/tree/systemd-udevd is the managarm/managarm side of things to get systemd-udev working
I'll probably break some of the commits out into #760, and keep the rest for a follow up PR
the bootstrap and mlibc changes required should then be merged with the second PR ig
and our waitid implementation doesn't quite respect the flags we provide, that's annoying
Implement it?
yeah I'm considering that
ok yeah I didn't implement all of them, but this should probably be a small decrease in logging spam, a small correctness fix and maybe even a microscopic performance gain (didn't benchmark it tho
)
get in here to hate dunk on it https://github.com/no92/managarm/commit/4129c7a4709fa42fa3d89845a81073cf4077c303
https://github.com/no92/mlibc/tree/eudev is the corresponding mlibc side
Portable C standard library. Contribute to no92/mlibc development by creating an account on GitHub.
ok small problem persists ig, weston crashes 
also I can't compile weston for shit
Yikes
the weston-scanner path is fucked again
the weston patch is basically prog_scanner = find_program('wayland-scanner', dirs: dep_scanner.get_variable(pkgconfig: 'wayland_scanner'))
it's retarded on weston's side
find_program's first param doesn't take absolute paths, yet they dgaf
https://github.com/managarm/bootstrap-managarm/pull/436 is the bootstrap side
these three branches should be enough to get systemd udev working
I really need to offload some stuff from my local bootstrap branches
I can't keep rebasing 30+ commits any longer
PR in what you want; I’ll merge later today or tomorrow if they look good @vestal sapphire
already done
the rest is WIP
Noted
you can take a look at the systemd PR too 
but just taking evtest + mtview off the rebase list is a good start too
No(t now). But I’ll review the qemu one too
the rest of the infra is ModemManager or NetworkManager stacks, WIP GPU stuff, WIP USB passthrough stuff
and some random shit, too
Reviewed and merged some shit
Based
apparently I got iperf3 working
cc @trim eagle
and with a USB ethernet adapter I get this
250Mbps on localhost?
or is it client on managarm in qemu and server on linux
That’s good stuff yeah
ooh, nice
I wonder what's holding them up from saturating the full speed though (I imagine those are gigabit?) 
Rn we only submit a single packet to the NIC at a time
that's an obvious optimization
systemd[1]: systemd 256.8-gd8299e3^ running in system mode (-PAM -AUDIT -SELINUX -APPARMOR -IMA -SMACK -SECCOMP -GCRYPT -GNUTLS -OPENSSL -ACL +BLKID -CURL -ELFUTILS -FIDO2 -IDN2 -IDN -IPTC -KMOD -LIBCRYPTSETUP -LIBCRYPTSETUP_PLUGINS -LIBFDISK -PCRE2 -PWQUALITY -P11KIT -QRENCODE -TPM2 -BZIP2 -LZ4 -XZ -ZLIB -ZSTD -BPF_FRAMEWORK -XKBCOMMON -UTMP +SYSVINIT -LIBARCHIVE)
systemd[1]: Hello from systemd Managarm!
It’s slowly coming alive
real

real
let's make sure we can have as many plusses as possible
let's first make sure that it actually works :^)
I'll look at the udev PR tomorrow
Yes, but not now
I think the udev PR should be broken up
some parts are mature and can be merged / reviewed right away, some definitely need some work
It’s also actively in progress as I’m pushing work for systemd boot to it
So yes; we should
Same goes for the mlibc side (not a PR yet)
Or the bootstrap part
for example, the socket changes can go to their own PR
maybe: socket changes for udevd / other changes for udevd (two separate PRs) -> changes for systemd (separate PR as well)
So rather 3-4 smaller PRs?
I have a feeling the socket memes fixed whatever fucked that
Might be
In general we fixed a whole bunch of virtually undebuggable memes, it might be worthwhile to retest a bunch of ports
Not just for the udev thing
What was the bug?
Bunch of fixes in general, including some netlink fixes and CMSG truncation fixes and support
Hmm. Do I start CGroups next week?
Or do I switch to elogind
And get stuff like SDDM and KDE?
I think top prio should be getting systemd-udevd in
That can be done if we split out the PRs and address some bootstrap comments
Honestly I wouldn't even be surprised if KDE hangs were related to that
I'll be home tomorrow
selinux 
AppArmor, smack, seccomp, libcryptsetup moment
And no, PAM isn’t that hard, locally I have it
So that will turn into a plus I think
Honestly seccomp sounds like a useful idea
Especially given that I see quite the overlap with implementing strace stuff
That needs a special netlink protocol on top of whatever you need in terms of functionality
Let's just say no

Maybe one day. Never say never
Now that I think about it, I should really start implementing strace stuff
It's waaaay too useful to me to just not do it
True
Another idea I had is to write a small utility that enables POSIX request logging for the invoked program
So you could call something like posix-requests ls and get request logging for ls
That would mean some more complexity on the POSIX end but shouldn't be too bad
And even in general having a way to enable request logging by patching a port would be super useful
We could just have a header under /usr/include/managarm/ for that
Sounds good
I don't see how you'd do strace without a lot of effort
and I don't think strace and seccomp overlap either
I mean having hooks placed at the requests goes a long way into integrating both features
for strace you probably want the hooks in mlibc though and for seccomp you want them in posix/other servers
CPU #3 enters load balancing
CPU #3 has load 630
CPU #2 enters load balancing
CPU #2 has load 633
CPU #1 enters load balancing
CPU #1 has load 585
CPU #0 enters load balancing
CPU #0 has load 600
Total system load is 2448 (ideal load: 612)
Moving thread with load 40 from CPU 2 to CPU 1
thor: 0xffffc000024b4030 is moved to CPU 1
Load balancing PR incoming for Managarm 😄
damn nice
Pog
yo that looks far more advanced than my lost copy of when i tried it lol
i just kinda randomly pulled threads from cpus with low idle time to ones with high idle time
at least thats what i think i recall doing
it's not very complicated though
it did requrie a bit of design work but the actual implementation is quite short
yeah but you have skill and i do not
mine was a turbo bodge lol
i recall there being reasons i never pr'd it in although i cant remember what they were
i think one was it randomly shitting itself and hanging? cant remember
Did you by chance try zlib -j4 with this? I know ar will fuck us but still
No, I could try that once it actually works 
hmm, systemd seems to only use malloc_info in two places, and musl doesn't have it
instead, it patches them out
maybe we should do that, too?
if there is a working patch, can we just re-use that one?
Sounds good
Fuck. That’s more getopt debugging (or I’ll try the getopt patch as is while booting systemd-udevd and see if that boots lol)
ah okay
the issue for weston seems to be that we don't support O_NOFOLLOW for openat yet
OOOOOOOOOOOOOH it's the combination of O_NOFOLLOW and O_PATH
Oof
ok I have more bad news
I have now implemented both O_NOFOLLOW and O_DIRECTORY and not even kmscon boots with this
what seems to happen is that the rules don't get executed??????????
I have no clue why they aren't tho
Bruh???
What paths are actually opened using nofollow?
no that many
only sysfs stuff afaict
given that commenting the O_NOFOLLOW flag stuff makes it work again I'll assume it expects something to be a symlink that isn't?
not sure about it
Do we ever return ELOOP?
no
but then it'd have been broken before right?
worked by coincidence ig
No, i suspect that it's not that it expects ELOOP somewhere but rather that something else is behaving differently now
since we never returned ELOOP before, missing ELOOP cannot be the problem
Maybe O_PATH now sometimes refers to a different file and that breaks stuff?
What files are opened using O_PATH?
just sysfs stuff
if does openat("/sys", O_PATH|...)
then openat("/sys/devices", O_PATH|...)
etc
until it just stops, and that's it
not all the time
it hangs when it doesn't pick up the DRM device
but that is because the udev rules are never run
by that I mean no server gets started
dunno why
Does it walk the entire sysfs though?
once, yes
but it doesn't do a second pass
ok I have a function that's failing unexpectedly
The plot thickens
the friggin chaseat function is the bane of my existance right now
jfc I hate this so much
Understandable
oh it comes back to fail in the ... openat?
Bruh?
I'm as confused as you
I have a bad feeling it's trying to do a pass through /proc/self/fd/
ok good, it doesn't
phew
Yeah that would’ve been bad™️
I'm literally being premium trolled rn
no matter what I do, my fprintf is not changed
A classic
ah I think what's happening here is that it tries to openat paths that are ".."
and somehow that fails
unsure why and how tho
Fuck more vfs path memes
I ran into items related to “..” paths in KDE kcalc recently too
tldr seems to be
udev does an fd1 = openat(fd0, "..", <flags>), followed by fd2 = openat(fd1, "..", <flags>)
however, printing the relative_to paths in the openat requests.cpp revleas that fd0 and fd1 are treated the same
ok I am not so sure about that story any more
ok I have found a solution
it's not a good one
anyways I have weston with systemd-udev
for a terminal I need a treeLink impl for /dev/pts/0 tho
I'd be glad if someone could help me out with that
VFS code is not my strong point
treeLink() just returns a directory's own directory entry
so it's needs to return the pts::Link https://github.com/managarm/managarm/blob/master/posix/subsystem/src/pts.cpp#L470 that points to itself
Pragmatic microkernel-based OS with fully asynchronous I/O - managarm/managarm
wait, /dev/pts/0 is not a directory, so it doesn't need to implement treeLink()
treeLink() should only ever be called on directories. so it can be called on /dev/pts but not /dev/pts/0
hmm it might be called from ViewPath's getPath?
not sure
might be due to some debug logging evn
indeed
callers of treeLink() should first check that the node is a directory
if getPath() doesn't do that, it's a bug
alright
maybe that should be documented somewhere, that would be super duper helpful
along with some of the other VFS concepts, it's kinda hard to work with if you don't have a good mental model (like me) or a reference
same goes for the PathResolver flags ig
You can add a comment to treeLink() 
anyways, the udev not working with weston meme seems to be that it compares inode numbers for dirfds, however we report 0 in sysfs 
but actually getPath only calls this on FsLink::getOwner() which should always be a directory
ah ok
are you sure if this crash is caused by getPath() calling treeLink() on /dev/pts/0?
because that'd mean that we have a FsLink that returns a non-directory a containing directory 
I'm not sure what it was exactly, but I just commented out a bunch of my debugging logs and that made the meme go away
it failed with an uncaught exception, so you'd notice if you ever run into that
Nice work Leo on the terminal
nice that works now 😄
more than that but that seemed like the obv source of calls to treeLink()
getPath() should just work on all paths though
so maybe it'd be good to find out which debug log breaks it
or to get a stack trace
and it broke again ...
and open an issue
and it works again
wtf
it was a git add -p meme where it had the hunk diff be weird lol
yooo let's goo
ok but how would we allocate inode numbers for sysfs?
how do we allocate inodes here then? just have an id_allocator?
yes
Based
ig we also free them in the destructor then?
for sysfs, I can just place the inode allocator in the superblock I assume?
ig we can do the same for the EmbeddedNode stuff too
that currently reports a hardcoded inode num of 1
yes, placing it in the superblock makes sense
https://github.com/managarm/managarm/pull/820 contains the fs memes
I haven't done that yet, not sure if I get to that today
I'll review it in the evening
Btw why is this thread now used for Managarm development? :^)
there was a lot of other chat going on in voice-0 so I just switched here at some point lol
I just didn't think much of it
about the CMSG truncation thing, I'll probably write another helper for writing out truncated data
so that you could do something like this:
auto [truncated, remaining_space] = ctrl.message(SOL_NETLINK, NETLINK_PKTINFO, sizeof(info));
remaining_space -= ctrl.write_truncated(info, truncated, remaining_space);
Sure but there's also the Managarm server :^)
also funny that managarm dev happens in voice-0 
hmm I'm not sure about how CMSG truncation works any more
I used to think that the cmsg headers are only placed as a whole, but the data might be truncated
but now I think they are treated as an inseperable unit, and the MSG_CTRUNC flag is set if not all CMSGs fit in the receive buffer for them
I'm not 100 % sure which way it is tho
man 7 unix seems to suggest that some CMSG types get their data truncated, but others are written as whole?
This is easy to test on a linux host though, isn't it?
yeah but I gtg now, I'll pick this back up tomorrow
from what I can tell though, headers are assumed to be complete or missing
ig the details depend on how the CMSG_* macros work
but CMSG_NXTHDR should return a nullptr for a truncated (even if partially copied) header
the one exception being the list thingies that are explicitly stated to drop parts of the list, which basically amounts to the list being truncated if the cmsghdr fits
but that just reports an appropriate CMSG_LEN, which a regular header would not
even if we partially copy descriptors in, the CMSG_LEN should state the regular length so that CMSG_NXTHDR picks up on it being incomplete
if a cmsghdr would only partially fit, it should not be copied over, and CMSG_NXTHDR should pick up on the fact that the remaining space in the control buffer is insufficiient for a cmsghdr, and return a nullptr
okay I think I have this sorted out
my currentt impl isn't entirelly correct but it's close enough ig
I just shouldn't copy in partial cmsg_data (except for the above lists) and keep the CMSG_LEN to what it should be, not what would fit
How does SCM_RIGHTS interact with truncation and MSG_PEEK?
In particular, when are the fds installed?
This should probably be checked using a linux test program
Maybe @quaint fern knows
until fairly recently there was a bug on linux where some FDs could be leaked in this case, and the bsds were also problematic in some way or another
worst case is that we'd need to cache the fds from when we attached them during a MSG_PEEK call
hmm no, by then the data would have been just discarded nvm
our current logic should be simplle to adapt to this ig
something like this should work?
if(!packet->files.empty()) {
auto [truncated, payload_len] = ctrl.message(SOL_SOCKET, SCM_RIGHTS, sizeof(int) * packet->files.size());
for(auto &file : packet->files) {
if(payload_len < sizeof(int))
break;
ctrl.write<int>(process->fileContext()->attachFile(std::move(file), flags & MSG_CMSG_CLOEXEC));
payload_len -= sizeof(int);
}
packet->files.clear();
}
hmm weston doesn't like this
Apparently MSG_PEEK installs the fds and recv installs them again?
This should be double checked by compiling a test program though
But it seems to be what the linux code does
cursed
Which means that peek + recv could return different fd numbers afaict
holy shit what
Elixir Cross Referencer - source code of Linux v6.12.6: net/unix/af_unix.c
if(!packet->files.empty()) {
auto [truncated, payload_len] = ctrl.message_truncated(SOL_SOCKET, SCM_RIGHTS, sizeof(int) * packet->files.size());
for(auto &file : packet->files) {
if(truncated && payload_len < sizeof(int))
break;
ctrl.write<int>(process->fileContext()->attachFile(std::move(file), flags & MSG_CMSG_CLOEXEC));
payload_len -= sizeof(int);
}
if(truncated)
reply_flags |= MSG_CTRUNC;
if(!(flags & MSG_PEEK))
packet->files.clear();
}
works with weston™️
where message_truncated sets the correct CMSG_LEN for the truncated fd list
anyways see you tomorrow
Until tomorrow, does this impl look reasonable?
@carmine current did some digging in the statx man page
stx_mnt_id
The mount ID of the mount containing the file. This is the same number reported by name_to_handle_at(2) and corresponds to the number in the first field in one of the records in
/proc/self/mountinfo.
so I guess we should also implement /proc/self/mountinfo? That was something on the TODO list for me anyway so not a really big detour (and gives us working mount calls to list all mounts which is nice)
Does systemd use that field?
the mount id?
yes
and it would eliminate another hack in dev_is_devtmpfs
which parses mountinfo
I’ll be rechecking that, I might’ve mislooked and they might use a different field
Looks like it’s way simpler
So scratch that field
I think it’s just the type field
Easy stuff
yeah that can be implemented entirely in terms of FsNode::getStats() I guess
We should probably still add a statx request such that it's easier to extend in the future
Btw, can you promote the last libasync version into stable?
Then I can restart the GHA ci on my PR
Our name to handle at is stubbed with ENOSYS tho
At least in my udev work
Same here
But statx is picked over name_to_handle_at
At least here
statx is way easier to implement than name_to_handle_at
Yeah I hope
statx is basically just stat() with a couple extra fields
But the fact that they are linked is annoying tbh
while name_to_handle_at needs special handling in all fses that support it
Linked?
Field corresponds etc
Referring to this
Yeah that’s meh
But we’ll need that field if we want proc self mountinfo anyway
And we do
So I don’t care about name to handle at there for now
Well it's just that some of the data that they return is identical
Yep
But they don't depend on each other
Thank god for that
Hmmm i fear that for correct handling of the mount point attribute of statx() we need to change the type that associatedLink() returns to ViewPath instead of just FsLink
which is not terribly difficult but a lot of search and replace 
#userland message at least if the answer to this question is "yes"

couldnt you just add the statx fields to your default stat and thats it, maybe make some sort of frankestein of both and do some processing in software
not even necessarily talking managarm, just like, in general
okay let's gooooo
Pog
managarm, booted into weston, using systemd-udev, booted compeltely diskless with PXE and NVMe-over-fabrics
cc @trim eagle
no btop? /j
anyway very very cool
highly based
now do iSCSI
or nvme over infiniband
that is a consideration ngl
iSCSI is effort so no
NVMEoIB is a lot more effort
Insane
Are we close to kde
yeah but I don't have to implement the entire command set
just the RDMA transport binding spec and mellanox drivers 
jokes on you, I'm trying to port it rn
Yeah yeah
That’s probably rookie shit
Only after a chromium port 
ok it fails due to no /proc/stat support
DONT FUCKING TEMPT ME!
Noted
just make it always return ```
cpu 10710711 4467 3001155 80734813 26252 614687 137502 0 0 0
cpu0 1830304 362 418882 9279482 3131 263737 60564 0 0 0
cpu1 2182626 716 389194 9172304 4945 91249 22156 0 0 0
cpu2 2129518 528 392976 9229754 5084 89892 17169 0 0 0
cpu3 2074664 473 388940 9294103 4673 88469 25097 0 0 0
cpu4 826870 937 399498 10673104 2525 25826 5777 0 0 0
cpu5 557527 535 215947 11133139 2197 24475 2518 0 0 0
cpu6 615486 492 394391 10926874 1985 12031 1567 0 0 0
cpu7 493714 419 401322 11026051 1709 19005 2652 0 0 0
intr 1150324246 0 60882860 494004957 0 0 0 178571 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 369216291 0 67889441 154 404182 0 0 0 0 0 0 0 3825 0 28242241 0 4296883 0 0 0 0 7122515 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50140 0 0 0 0 0 0 0 0 0 37702310 0 0 0 0 0 0 564 72560952 5672 29941 5672 0 4485389 60 0 0 0 0 0 0 7045 0 90 286 0 3233613 592
ctxt 1565363764
btime 1736630431
processes 412261
procs_running 2
procs_blocked 0
softirq 305882733 1556 23603978 338 12657688 3804303 0 38122174 107634865 4393 120053438
what even is correctness
this is the real managarm style
hardcode random values unrelated to reality
we can prob provide reasonable values for that even
0=user, 1=nice, 2=system, 3=idle, 4=iowait, 5=irq, 6=softirq, 7=steal, 8=guest, 9=guest_nice
We probably can
I only added proc/self/stat
Not global stat
But shouldn’t be too hard
but yeah, porting btop seems easy on the porting side
it wants a few things we don't have implemented yet tho
It has been added to the list for tomorrow
W
VC tomorrow is guaranteed good, even earlier than before
do it no balls
- name: btop
labels: [aarch64, riscv64]
architecture: '@OPTION:arch@'
source:
subdir: ports
git: 'https://github.com/aristocratos/btop.git'
tag: 'v1.4.0'
version: '1.4.0'
tools_required:
- host-cmake
- system-gcc
pkgs_required:
- mlibc
revision: 1
configure:
- args:
- 'cmake'
- '-GNinja'
- '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/scripts/CMakeToolchain-@OPTION:[email protected]'
- '-DCMAKE_INSTALL_PREFIX=/usr'
- '-DBTOP_GPU=false'
- '@THIS_SOURCE_DIR@'
build:
- args: ['ninja']
- args: ['ninja', 'install']
environ:
DESTDIR: '@THIS_COLLECT_DIR@'
quiet: true
Been there done that
its part of the linux backend
Lemme find the picture
I just stubbed it to return 0
lmfao
which is how I got to the proc memes
the managarm way
where's ur udev
you can add yourself to the list of systems without timedjoin_np
where's your graph-based <insert something here>?
src/btop.cpp:317, add || defined __managarm__
see, i have no need for udev because i have a significantly better device composition model based on the abstract beauty of ansi colors
and also some macro memes i threw together
i wonder how bad it would be to try making a hobby os which tries to hit the apple and/or BSD code paths instead of the linux code paths
#678608576151027734 message or
Current status: broken, sure
But it worked way back when
Damn
And that’s what counts
Revive it 
So @serene portal got your shit
It’s in the pipeline
But systemd gets priority
Didnt you get it working?
It bitrotted away
Systemd?
So my priorities are keeping xbbs working -> simple port requests or similar -> systemd -> fixing webkit -> chromium atm
what did i do
You dared me. I fulfilled it
Chromium
Yeah but you posted a screenshot of systemd booting in managarm right
That was Linux with mlibc
Ah
Managarm is next tho
Letsgo
Literally today after uni I’ll be fixing systemd until stuck, then webkitgtk until Korona and Leo are back, then back to systemd
I might be around all day actually
depends
gimme an ETA and I'll have my alarm set for that -20 mins
Let’s say 1pm?
sure
based
Aight. Noted
I will bring it back this year and upstream it
The year TODO list is basically: systemd -> KDE (or GNOME, both are blocked on logind in the end) -> Chromium
ok given that I wrapped up some nice stuff, time to do a small thing I've been meaning to do for a while
it's going pretty ok so far
it's a secret project tho 
Nice
The entire command set of iscsi to run libblockfs is probably 3 commands or so though
one thing that we haven't implemented yet is when a process dies, we should move it's children to the dying process' parent
We don't do that? Lol
Also isn't there some meme regarding threads as well
I don't think so
what meme
Wasn't it that PID == TID and that killing one thread didn't kill everything else or something
thats also a problem
Is this what's supposed to happen?
I don't think it is
When a process dies, it's children are moved to init
I'm not sure if the ppid changes
Ah yes, ppid will change, see https://man7.org/linux/man-pages/man2/getppid.2.html
ah yes
so ig we just move to some PID?
don't know which one tho
the lowest available?
init is always pid 1
We may also have a pointer to the init Process struct somewhere in global namespace? Not sure
ah yes and subreapers would take precedence over init
yeeeeeeeeeees
that was my thinking
what I did not figure out yet though is how we would determine when to do path MTU discovery
each tcp socket should do it individually i guess
on connect?
this can happen simultaneously with normal operation
Yes systemd will want this
However that's only necessary for systemd user service manager
The system service manager if it runs as pid 1 no problem
Makes sense
yeah we figured that. My issue now is cgroups and the fact that it actually wants shit 
so we'll attempt to tackle that this evening
meanwhile, webkitgtk upgrading is in progress.....
based
it only took me like 10 seconds to find a defect so
umask is indeed not implemented
yep
lets see how linux does it
mask = xchg(¤t->fs->umask, mask & S_IRWXUGO); okay seems easy enough
there are lots of low hanging fruits regarding POSIX compliance
hostnames 
wow my new changes look great

but, the umask does get changed
.. is resolved in the vfs so it's a bit strange that this returns ENOENT
posix: FsNode::getStats() returned illegal mode of 8624
this isnt worrying or anything
that is 0o20660
ah, posix handles mode and type in different fields and merges them only at the end
that makes sense i guess
i was chmoding a directory to have weird mode flags
still nope
but this time its not that
i'm uh
not sure if it is even my fault
what exactly are you doing?
i added a new UmaskRequest, and i and the mode given by the client with the one stored by the last umask request
and a corresponding patch to mlibc
can i turn off logging to framebuffer?
I don't think so, why would that be useful?
I don't think it's that slow
hmm maybe not
serial is probably way slower than framebuffer
does that work?
i guess if you've already built x86, it's annoying to build again
also, wouldn't that take another hour to build
yes, I think it does CC @upbeat smelt
oh no a faster development cycle might be useful
i only care about base tbf
i have built some of weston-desktop, and gave up at 200/600
because my m1 is kinda fast but not THAT fast
aarch64 with kvm should work, i recall testing it on my pi4 and fixing some bugs that cropped up in eir-virt that way
okay then
vm-util should also automagically start using kvm ```py
have_kvm = False
if not args.no_kvm:
# Make sure we have KVM, and are going to run the same architecture
if os.access("/dev/kvm", os.W_OK) and os.uname().machine == args.arch:
qemu_args += ["-enable-kvm"]
have_kvm = True
else:
print("No hardware virtualization available!", file=sys.stderr)
uh actually I think you're right that this is not your fault
the .. bug
that's incredibly weird, i need to debug this in the vfs code
okay thanks
ls -la works but ls -la dir/ breaks
since it is not my fault
i will try debugging the rest of the code then
okay how do i change the target ISA
https://github.com/managarm/managarm/blob/master/ci/bootstrap-site-aarch64.yml put the define_options: into bootstrap-site.yml
ok thanks cool
and probably nuke the tool-builds / pkg-builds and similar dirs
ugh
also want the labels: part maybe, although it only really matters when you're messing with installing packages
okay this is gonna be fun (not)
../../../src/mlibc/meson.build:38:1: ERROR: Unknown compiler(s): [['aarch64-managarm-gcc']]
``` okay that was fast
more rm rf needed
yeah
may i recommend having target specific packages :^)
so you have host-@@ARCH@@-gcc
instead of host-gcc
you could also just create a second build dir for this purpose
hm yeah something like that would definitely be needed if we want to support multiple archs from the same build dir
i wanted to add this feature in the past because it saves building llvm multiple times
shouldn't be too hard to generate that with an y4 macro :^)
oh god
please save me from this
btw
do you build a single-target llvm?
no
you could've kept {tools,tool-builds}/host-llvm-toolchain ig
i only rm -rf'ed tools/*gcc
hm, might be a good idea actually
we only build llvm for x86, aarch64 and riscv64
when 32 bit managarm
did you mean: managarm that is even slower than it is now somehow
lol
i'm not touching 32-bit
yeah no
never
I'd rather chop my balls off very slowly
it could use that monkuous' profiler
please do
what does it tell you?
where IP is after N retired insns
ah
also you may not want to use N retired insns
but N cycles if thats a thing, idk if it is
or N uops
hm on intel we do clock cycles
don't know what the amd pmc code is doing because i don't know what the msrs are
but i'd guess clock cycles as well actually?
yeah
about that, no idea actually
might be a good idea to check :^)
i haven't personally looked
ah okay
it tells us that the kernel does not dominate the overall running time 
and profiling userspace is a bit harder
profiling userspace would also be very useful
and i guess i won't be looking today ```
thor: Fix exiting fibers
thor: Fix exiting fibers
tallocating 2
qemu: terminating on signal 15 from pid 153102 (python3)
Traceback (most recent call last):
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
Exception ignored in sys.unraisablehook: <built-in function unraisablehook>
Exception ignored in: <function BaseSubprocessTransport.del at 0x7fd757aabba0>
Traceback (most recent call last):
File "/usr/lib/python3.12/asyncio/base_subprocess.py", line 126, in del
File "/usr/lib/python3.12/asyncio/base_subprocess.py", line 104, in close
File "/usr/lib/python3.12/asyncio/unix_events.py", line 568, in close
File "/usr/lib/python3.12/asyncio/unix_events.py", line 592, in _close
File "/usr/lib/python3.12/asyncio/base_events.py", line 794, in call_soon
File "/usr/lib/python3.12/asyncio/base_events.py", line 540, in _check_closed
RuntimeError: Event loop is closed
hor: Fix exiting fibers
xbstrap: Action run of task qemu failed
do you have ASLR?
you want a system profiler
not gprof
hm?
okay then, is there a way to make it always place each library at a fixed place?

not without hacks i guess?
one unique to that library
okay then time to write an ugly hack
oh on arm at least i get frame pointers
vm-util dies during boot (i assume when we try to dump the ring buffer with the traces?)
and i have linux perf kvm
looks like an exception when trying to decode data as utf-8?
uh no
pulled bootstrap-managarm and now it works
lmfao
top few results ```
2.96% (5328 samples) in:
thor::FbDisplay::setBlanks(unsigned int, unsigned int, int, int) in 0
3.00% (5397 samples) in:
frg::slab_pool<thor::KernelVirtualAlloc, thor::IrqSpinlock>::allocate(unsigned long) in 0
3.36% (6029 samples) in:
thor::Stream::Submitter::run() in 0
4.02% (7225 samples) in:
helSubmitAsync in 0
4.07% (7314 samples) in:
thor::IrqSpinlock::lock() in 0
4.85% (8711 samples) in:
thor::restoreExecutor(thor::Executor*) in 0
5.25% (9434 samples) in:
thor::sendPingIpi(thor::CpuData*) in 0
179701 (= 65.55% of all samples) in the kernel
100.00% of all kernel samples could be resolved
from just booting into weston and running some commands in the terminal
the number of ping IPIs could definitely be reduced
we could be a bit smarter about that
4% of hits in thor::IrqSpinlock::lock is rather worrying
i think i know one source of your problems
that word "ticket" over there
uh
yeah please dont
this isnt very impactful on perf, but:
no inline fast path???
in my testing, they face a large performance penalty
what do you suggest instead, just regular test and set a bit ones?
i guess it doesn't hurt to try that
re inline fast path: that's a good point. also we could enable LTO
wonder how much ub that'd uncover 
LTO wouldnt help
llvm cant half inline a function
Wdym
the spinlock is simple enough that i think it'd just inline it wholesale
with lto even if the slow path was in a separate fn
what you want is a single fast path
no thats why you mark the branch cold
fair enough
btw libguestfs mounts are broken on fedora

qemu-system-aarch64: can't apply global host-arm-cpu.migratable=no: Property 'host-arm-cpu.migratable' not found
``` also this is exciting
yeah libguestfs is kinda a pain
or in managarm idk
testing is hard
isn't libguestfs mainly sponsored by redhat? 
i recall it was also broken on arch a while ago and i had to manually build it to use it from an older PKGBUILD
but yeah libguestfs is quite unstable
ig migratable=no is x86-specific?
it is yeah
okay how do i specify a custom qemu path?
actually nvm my build wouldnt work either because its riscv only and not kvm
you can install the host-qemu tool via xbstrap to have a locally-built qemu
and vm-util should pick it up automatically
fuck.
wait M1 doesn't support 4K pages?
also that sounds wrong
it... does
it is a managarm skill issue
i wanted to only send userspace patches, not thor patches too 
Maybe because apple native is 16k it only propagates that via kvm
no
Lol
my id is 19868771418113
0x0000_1212_0f10_0001
okay
i found the bug
0xf is a signed int
0xf << 28 is still signed
and gets improperly sign extended
trolled again
you're welcome
i keep getting trolled by sign ext on aarch64 in vmm-related code
looks like SMP startup is broken
is the BSP == cpu zero?
IIRC there's a TODO in the aarch64 code that we assume this
you can try to boot without SMP
but yeah seems that this time it didn't get to SMP init
weird
it gets here a lot
either here or the smp thing
qemu pins one core to 100%
so
i think it is running SOMETHING
i believe the m1 has a vgic
cc @brittle mauve
If it's in eoi it's probably getting an irq storm?
yeah i think so
you can set logEveryIrq = true to confirm this
hm is irq 30 the generic timer?
Is it the timer irq?
yeah
inb4 the math for computing the deadline overflows
i should port it over to the new helper class for doing the math
checking whether that's the case would be easy with __builtin_mul_overflow
true but i didn't consider it when i first wrote it
and the helper is already there so
i think i didn't think of it as an issue because for qemu-virt without kvm and on the pi4 the frequency of the timer is <50MHz or something like that
true
i suspect the frequency on m1 is very much more
The helper class that uses the 128 bit fixed point math can probably be used just like in the rv code
where is the frequency stored?
oh FRQ not FREQ
^ that's how rv does it
trolled again
thor/arch/arm/timer.cpp line 88
on m1 its the standard m1 reference clock
24mhz
same as the watchdog timer, fwiw
btw i was thinking we could probably abstract the whole logic for multiplexing the preemption timer and alarm timers into one hw timer into generic code?
