klange changed the topic of #osdev to: Operating System Development || Don't ask to ask---just ask! || For 3+ LoC, use a pastebin (for example https://gist.github.com/) || Stats + Old logs: http://osdev-logs.qzx.com New Logs: https://libera.irclog.whitequark.org/osdev || Visit https://wiki.osdev.org and https://forum.osdev.org || Books: https://wiki.osdev.org/Books
<brunothedev> gonna steal it from bare bones hehehehe
<mrvn> And to be correct you need one that specifies memory regions but nearly everyone ignores that and prays it won't break.
<mrvn> (which it does if you leave the 2MB default page size in the linker invokation)
<FireFly> klange: I enjoy the parallel intercal dialect that adds parallelism by letting multiple comefroms reference the same location
<mrvn> Maybe I should look into how to propose an addition to C/C++, intoducing named or numbered loops so you can break/continue and outer loop.
<brunothedev> offtopic, but how to add recursive dependencies in make
<heat> what do you mean
<brunothedev> nevermind, found a fix
<heat> ok
nyah has quit [Quit: leaving]
Vercas has quit [Remote host closed the connection]
Vercas has joined #osdev
hmmmm has quit [Remote host closed the connection]
hmmmm has joined #osdev
xvanc has joined #osdev
_xor has quit [Ping timeout: 246 seconds]
Patater has joined #osdev
DrPatater has quit [Ping timeout: 255 seconds]
arminweigl_ has joined #osdev
bnchs has quit [Ping timeout: 255 seconds]
arminweigl has quit [Ping timeout: 255 seconds]
nortti has quit [Ping timeout: 255 seconds]
arminweigl_ is now known as arminweigl
nortti has joined #osdev
eddof13 has joined #osdev
xvanc has quit [Remote host closed the connection]
eddof13 has quit [Client Quit]
xvanc has joined #osdev
troseman has joined #osdev
xvanc has quit [Remote host closed the connection]
brunothedev has left #osdev [i love how to part messages can be used to troll around and you know me, i love trolling, this is very cool, me love /part]
brunothedev has joined #osdev
zaquest has quit [Remote host closed the connection]
slidercrank has quit [Ping timeout: 268 seconds]
zaquest has joined #osdev
<brunothedev> gnu assembler when inputed with the -c option, just outputs a a.out file, how to change this to the c compiler defualt: [filename].o, i need this for a makefile
<Mutabah> `-o` - this should be in the `--help` output
xvanc has joined #osdev
<heat> you should use gcc to assemble anyway
<brunothedev> heat: oh ol
<brunothedev> Mutabah: i have a variable called SDEPS who include ALL assembly files, quite hard to -o that
<heat> i don't know what you're doing but it sounds like you're makefile is severely borked
<heat> s/you're/your/
<Mutabah> Agreed
<Mutabah> You should be using a makefile with pattern rules for each file type
<Mutabah> so you can easily send the output somewhere sensible
xvanc has quit [Remote host closed the connection]
xvanc has joined #osdev
<brunothedev> how to include makefile variables on the $(shell ...) call? OFFTOPIC
<brunothedev> writing a makefile is getting painful
<brunothedev> should i try meson
<brunothedev> ?
<Mutabah> ... wait, why are you using `$(shell)`?
<Mutabah> Also, you can just stick a `$(VARNAME)` inside the call
<brunothedev> Mutabah: fine ./ -name '*'.c
<brunothedev> * find
<heat> can't wait to find out he's invoking as using shell
<Mutabah> Bad idea
<Mutabah> don't just glob all input files - expliclitly list the
<Mutabah> *list them
<heat> thats also not the GNU make way of doing a wildcard
<Mutabah> (In fact: I list them using the object file form, because that's how they're going to be used)
<heat> same
<brunothedev> i have not found a way to make a if to lists files as per archtecture
<brunothedev> like: if $(ARCH) == i686 then ... end
<brunothedev> heat: > "can't wait to find out he's invoking as using shell" not THAT dumb
<Mutabah> `ifeq ($(ARCH),ii686)` `OBJS += file_for_i686.o` `endif`
<klange> I use 'include' for that: `include ${ARCH}.mk` and then ${ARCH}.mk has all the arch-specific stuff.
<Mutabah> All of this should be well covered in make's documentation
<Mutabah> klange: Nice idea
<brunothedev> klange: cool idea
<klange> There's also a $(wildcard kernel/arch/${ARCH}/*.c) somewhere in the main makefile; the ${ARCH}.mk files mostly define how to run qemu for tests.
<klange> I also do a bunch of other stuff, like ${ARCH} is populated based on a gitignore-d file so you set it once and then `make` does what you want in the future, similar to an autoconf-prepared build.
<klange> I also have a thing that makes loadable modules only build for a given arch if they have "@package ${ARCH}" in them somewhere. I'm big on the automatic discovery and resolution stuff.
pieguy128 has quit [Ping timeout: 248 seconds]
[itchyjunk] has quit [Ping timeout: 248 seconds]
<brunothedev> offtopic: My kernel makefile includes the main makefile to load variables, but the main makefile loads the kernel makefile, how to load variables of the main makefile without it calling again
<klange> you're doing something backwards in one direction or the other
<heat> offtopic: [OFFTOPIC] **TOPIC IS OFF** (NO TOPIC) sup
<klange> if you're doing recursive make, your top-level make file should never include its children - it should cd into their directories and recursively run make
<brunothedev> klange: my top level do not include make, the children does include to load some user variables like ARCH and TOOLCHAIN
<heat> export
<brunothedev> heat: ** ABSOLUTELLY NO TOPIC ** (TOPIC IS DEAD) [TOPIC'S BLOODLINE IS ERASED] lul
<klange> I suggest having just one makefile. recursive make was a mistake
<klange> (or one makefile that includes others for specific configs, like the setup I described)
<brunothedev> klange: yes, you are probaply right, i just took it because linux does this
<brunothedev> also, compiling a whole os with one make doesnt seems right
<klange> lies
<Mutabah> Look at what linux does, and do the opposite :)
<klange> I used to literally build my whole OS with one makefile, but technically it's a few dozen generated ones included in a top-level one now.
<heat> i don't do any of this because make sucks ass
[itchyjunk] has joined #osdev
<klange> the only thing that sucks ass about make is how it handles spaces
<heat> scourge of build systems
<heat> no.
<heat> for one, include is insane, just a copy paste
<klange> yes, hello, i write c
brunothedev has quit [Quit: WeeChat 3.6]
<heat> you need a shit ton of macros just to make a large GNU makefile remotely usable and simple
<heat> at that point... why?
<klange> I _have_ considered turning my whole build process into a Kuroko script. It's already mostly one, anyway - the real fun is all in the tool that builds the makefiles for the userspace apps.
<heat> klange, meson is written in python
<heat> just sayin :))
<klange> really need to get around to writing a gzip compressor, the one last thing my own native build tools lack...
Arthuria has joined #osdev
troseman has quit [Quit: troseman]
[itchyjunk] has quit [Remote host closed the connection]
pieguy128 has joined #osdev
levitating has quit [Ping timeout: 252 seconds]
levitating has joined #osdev
levitating has quit [Ping timeout: 276 seconds]
levitating has joined #osdev
slidercrank has joined #osdev
_xor has joined #osdev
heat has quit [Ping timeout: 248 seconds]
slidercrank has quit [Ping timeout: 276 seconds]
<chibill> Question if I setup the APIC (enable it) should I be getting any new interrupts right away? Or do I have to configure the APIC Timer first?
theboringkid has joined #osdev
<geist> well, you dont have to do anything really, but the apic timer is probably the first one you'll want to fiddle with
<geist> also there's a local and ioapic, they're both sometimes called apic
<geist> but i assume you're tlaking about the local apic
theboringkid has quit [Quit: Bye]
theboringkid1 has joined #osdev
theboringkid1 is now known as theboringkid
eck has quit [Quit: PIRCH98:WIN 95/98/WIN NT:1.0 (build 1.0.1.1190)]
eck has joined #osdev
<chibill> Yea the local APIC. Trying to figure out how to get something that is simular to the timer interrupt you get automatically with PIC. (Since I am using UEFI I can't use the older PIC interface)
<geist> sure. well the local apic timer is pretty simple once you get it set up
<geist> and it just fires directly on whatever vector you set it. usually set it to something high, like 250. though really doesn't matter
<geist> and of course the reason you use it as the timer is because on an SMP machine you almost always want a timer per cpu
<geist> so need one 'local' to each cpu
<chibill> I did read that you have to somehow use other intrrupt to actual figure out how quickly the APIC timer fires or something. Is the PIT still useable even if the PIC isn't?
bgs has joined #osdev
<geist> well. okay there is that problem
<geist> there's a pile of ways to compute the local apic timer speed. one of the advantages of PIT is it runs at a known speed
<geist> you can even use the PIT to calibrate the local apic timer
<Ermine> so PIT is not PITA?
<geist> mmmm, pita
<geist> with some hummus
theboringkid has quit [Quit: Bye]
<Ermine> I guess someone is hungry
night has quit [Read error: Connection reset by peer]
Goodbye_Vincent has quit [Quit: Ping timeout (120 seconds)]
Goodbye_Vincent has joined #osdev
night has joined #osdev
Arthuria has quit [Remote host closed the connection]
valshaped has quit [Read error: Connection reset by peer]
valshaped has joined #osdev
bgs has quit [Remote host closed the connection]
simpl_e has joined #osdev
_xor has quit [Quit: brb]
danilogondolfo has joined #osdev
nyah has joined #osdev
gog has joined #osdev
les has quit [Ping timeout: 252 seconds]
les has joined #osdev
_xor has joined #osdev
craigo has joined #osdev
GeDaMo has joined #osdev
lanodan has quit [Ping timeout: 255 seconds]
sortie has quit [Remote host closed the connection]
lanodan has joined #osdev
bauen1 has joined #osdev
brunothedev has joined #osdev
lanodan has quit [Ping timeout: 248 seconds]
Ali_A has joined #osdev
lanodan has joined #osdev
Ali_A has quit [Quit: Client closed]
gog has quit [Quit: Konversation terminated!]
gog has joined #osdev
<brunothedev> how to get grub-file?
<immibis> what is grub-file?
<immibis> klange: I rather suspect most people would port gzip; creating an OS doesn't mean you have to reinvent all the data-pushing code that has nothing to do with OSes
<zid> sounds fun to write regular ass zip by hand though
<zid> idk about anything newer
<brunothedev> immibis: see it on the multiboot wiki page
<immibis> oh a tool which checks file type
<immibis> zid: zip is actually more of an OS/filesystem thing than a compression thing; you outsource the compression to deflate
<immibis> I have grub-file on my computer; seems to be installed as part of grub
<brunothedev> immibis: what distro
<immibis> gentoo
<brunothedev> using fedora here
<zid> immibis: come over here and say that
<immibis> brunothedev: check if they called it grub2-file instead
<brunothedev> immibis: already did this
<brunothedev> lmao i found it
<brunothedev> now i just need to build grub
<immibis> brunothedev: it's included in grub2-tools RPM. https://koji.fedoraproject.org/koji/rpminfo?rpmID=33669445
<bslsk05> ​koji.fedoraproject.org: grub2-tools-1:2.06-88.fc39.aarch64.rpm | RPM Info | koji
<brunothedev> and make an iso
<immibis> (well, you are probably using x86_64, not aarch64, but it should have the same stuff)
<brunothedev> immibis: wdym
<immibis> i just clicked on the aarch64 package because it was first in the list
<immibis> CPU architecture for fedora. I was looking at fedora packages to see which one had grub-file and I clicked on aarch64 first
<brunothedev> u also clicked on the testing release package
<immibis> that just proves how I'm not using fedora
<immibis> it gets the point across. they don't change this stuff across architectures or releases
<immibis> well, they can change it across releases, but they usually don't
sortie has joined #osdev
<brunothedev> so, shold i set on grub.cfg gfxpayload=keep
<nortti> if your grub boots into graphical mode, yes
<brunothedev> unsupported tag: 0x68
kivikakk has joined #osdev
<brunothedev> idoes anyone know what is the 0x68 tag?
<FireFly> what kind of tag?
<brunothedev> FireFly: see the error above, the multiboot2 command of grub is giving me that
<klange> brunothedev: you either didn't put an end tag, or you have an alignment error
bradd has quit [Ping timeout: 268 seconds]
<klange> alignment errors are a pretty common mistake with a first attempt at doing multiboot2
<brunothedev> klange: my linker script is like the bare bones one but insteand of 4 align it is 8
<klange> not going to be in your linker script, gonna be in the assembly where you build the request tags
<brunothedev> klange: there is align 8 at my assembly header too
<klange> "a" is probably not enough
<klange> you need each tag to be aligned
<brunothedev> klange: i used and modified your multiboot2 header
<klange> you'll need to link some code if you want any help
<brunothedev> klange: just wait
<klange> i'm waitin'
craigo has quit [Quit: Leaving]
craigo has joined #osdev
<klange> brunothedev: your address tag is malformed
<brunothedev> wdym?
<sham1> It's malformed. As in it doesn't work
<brunothedev> sham1: but why
<bslsk05> ​www.gnu.org: Multiboot2 Specification version 2.0
<klange> The address tag is 24 bytes long. Yours its 12. You are missing three longs.
<gog> long long long
<klange> You also don't need this tag at all if you are building a 32-bit ELF. I have one because I occasionally build more exotic things.
<brunothedev> just gonna delete it, since ia m using arch/i686
<gog> uefi uefi uefi uefi uefi
<brunothedev> ong it worked
<brunothedev> just throwed a black screen but it is a good start
<Ermine> gog: may I uefi you
<Ermine> hi btw
<gog> hi
<gog> yes
* Ermine uefis gog
<gog> EFI_GOG_PROTOCOL
<brunothedev> lemme re-bios you
* brunothedev re-bios'ed gog
<gog> sorry i had my bios removed
<Ermine> secure gog boot declined bios?
<gog> bios replacement therapy
<brunothedev> now i need ato atleast draw ONE pixel, i can bootstrap a console latter, just how to draw a pixel
sylvbsd has joined #osdev
brunothedev has left #osdev [2. #osdev│10:07:18 brunothedev | sham1: but why │ \Test_User │10:13:31 Ermine | hi btw │ amj]
brunothedev has joined #osdev
<Ermine> very weird part message
<brunothedev> Ermine: i love part messages
<gog> you just draw a pixal
<brunothedev> gog: how
<gog> idk i've never drawn pixal before
<gog> get its (x, y) into an offset ig
<gog> then add that offset to the base of the framebuffer
<gog> then write the pixel
<brunothedev> gog: it is just easy as this
<gog> it is because i was lying i have drwan pixal before
brunothedev has left #osdev [brunothedev (~bruno@167.249.190.93) has left #osdev (2. #osdev│10:07:18 brunothedev [brunothedev] (bruno) (~bruno@167.249.190.93) has joined #osdev]
brunothedev has joined #osdev
<GeDaMo> base + (row * no_of_columns) + column
<gog> not quite
<gog> row * pitch
<gog> pitch might be greater than width
<GeDaMo> Fair enough :P
<brunothedev> i have the framebuffer address too
<gog> do you know the other properties of the framebuffer
<gog> pitch and pixel format
<gog> and width and height
<gog> if you don't then you can't really do anything with it
<nortti> < GeDaMo> base + (row * no_of_columns) + column < gog> row * pitch ← isn't it base + ((row * pitch) + column) * bytes_per_pixel?
<brunothedev> i have the address, pithch, width and height, and bpp
<gog> yes
<brunothedev> i could list more here
<gog> great
<gog> that's all you need really
<gog> but do you know the pixel format
<brunothedev> color?
<gog> yeah
<gog> bgr or rgb
<gog> bits per field
<brunothedev> apparentlly there is a way to discover, but no
<brunothedev> gog: here it is the example code: https://github.com/cloudblaze/multiboot2
<bslsk05> ​cloudblaze/multiboot2 - multiboot2规范的示例代码 (0 forks/1 stargazers/GPL-3.0)
<gog> do you understand the code or are you just blindly copypasting it
<brunothedev> gog: i understand what i have written
<gog> ok
<brunothedev> do i do not understand what "distance" meand
<brunothedev> * tho i do not understand what "distance" means
elastic_dog has quit [Ping timeout: 248 seconds]
<gog> that's for framebuffers with a configurable palette
<gog> so a pixel value represents an index into that palette
<zid> I have a configurable palette, so i have decided today I shall eat nothing but cake
<gog> keep on trying until you run out of cake
elastic_dog has joined #osdev
<brunothedev> i think this is how to draw: "multiboot_uint32_t *pixel = fb + tagfb->common.framebuffer_pitch * i + 4 * i;"
<brunothedev> i think the bpp is forced to 32 by klange
<klange> None of that framebuffer header forces anything, it is just asking nicely
<gog> if the underlying device can't do it then it won't
<gog> it'll do the next best
<brunothedev> gonna do this:
<klange> it is quite late here, so I am disconnecting from my pseudo-bouncer
<brunothedev> if (tagfb->framebuffer-bpp != 32)
<klange> good night
<brunothedev> while(1) {}
<brunothedev> here in brazil it is 10:36
<brunothedev> timezones are weird
<nortti> you may with to use hlt in your hang-loop, so that it doesn't end up burning CPU power for nothing
<brunothedev> nortti: sooooo: "__asm__ __volatile__("hlt")" /
<brunothedev> ?
<nortti> yeah, I think so. (I usually don't use inline asm)
<gog> nini klange
<brunothedev> what is the best way to separate the video driver from the main kernel?
<brunothedev> like, a driver folder where you ask the user if it wants to include the driver
<brunothedev> on the makefile
<brunothedev> also, my code is doing nothing
<nortti> it's probably fair to build every driver unconditinoally until your kernel gets to like, tens of minutes of compiling
<brunothedev> nortti: ok, bt how to split the two?
<brunothedev> WHAT DO I DO WITH *PIXEL !!!!!!!!!!!!
<gog> you write a value to it
<brunothedev> gog: already did this, what do i do wih it now
<gog> the pixel should appear in your display
<nortti> < brunothedev> nortti: ok, bt how to split the two? ← I'd have kernel/video/fb.c that gets compiled to fb.o and then linked into your final kernel binary
<gog> if it doesn't then you did something wrong
<brunothedev> uint32_t *pixel = fb + tagfb->framebuffer_pitch * i + 4 * i;
<gog> yeah
<gog> then *pixel = <pixel value>;
<brunothedev> wait, maybe it is hitting a hlt
<gog> what you have is the address of the pixel
<brunothedev> gog: what do i do with it?
* gog blinks
<gog> you... write a value to it
<gog> unt32_t *pixel = ... is getting a pointer to the pixel in its framebuffer
<gog> *pixel dereferences the pointer
<gog> = is assignment to the memory at that address
<brunothedev> maybe i should write a color struct to it
<gog> yeah probably
<gog> forgive me if this is an off-base question but how much do you know about programming in general? like what's your background?
<brunothedev> gog: gitlab.com/brunothedev github.com/brunothedev
<bslsk05> ​gitlab.com: Bruno Henrique Silva Aguiar · GitLab
<bslsk05> ​github.com: brunothedev (Bruno Henrique) · GitHub
elastic_dog is now known as Guest2693
Guest2693 has quit [Killed (mercury.libera.chat (Nickname regained by services))]
elastic_dog has joined #osdev
sylvbsd has quit [Remote host closed the connection]
<gog> ok
<gog> so you don't have a lot of experience with low-level programming in C
<gog> but you can learn
<brunothedev> gotta prepare to school
<brunothedev> goodbye
brunothedev has quit [Quit: WeeChat 3.6]
<Matt|home> to be fair i only recently learned something..
<Matt|home> i was curious how you'd write a driver for something like an arduino.. apparently you can just directly write to memory locations using the IDE. i assume it's a fair bit more complex doing something like that with a phone over usb for example?
<Matt|home> if you could do that at all that is, i assume it's mostly write protected
<gog> yeah µc's tend to have GPIO memory-mapped
<gog> so you just blat bytes at it
<zid> I mean, so do real cpus
<zid> memory mapped is both old-hat and super modern :P
<zid> we just had a weird piece in the middle where we were using i/o instructions
<nikolar> got to love 8/16 bit x86
<gog> yes
dormito has quit [Ping timeout: 248 seconds]
<gog> i don't even know why x86 has that separate i/o bus?
<gog> is it because the address bus was so limited?
craigo has quit [Ping timeout: 276 seconds]
<zid> possibly yea, plus it's simpler for low speed cheap isa devices
<zid> to not have to run at memory bus speeds
<gog> makes sense
Left_Turn has joined #osdev
dormito has joined #osdev
<nortti> I think x86 specifically has them because 8080 had them, and there you only got 16 bits of address bus total
<nortti> original IBM PC runs ISA at same speed as memory, I'm pretty sure
<zid> 1MHz?
<zid> that's some nice fast memory
heat has joined #osdev
<nortti> oh did it ran memory at lower speed than the CPU?
<nortti> oh huh yeah, "memory operations happened at 1/4 this frequency, at 1.19 MHz -- crystal / 12." as per https://retrocomputing.stackexchange.com/a/14108
<bslsk05> ​retrocomputing.stackexchange.com: ibm pc - How much did IBM save by limiting the PC to 4.77 MHz? - Retrocomputing Stack Exchange
<heat> linux operating system kernel
<heat> guyz what iz ur favorite linux
<heat> i like freebsd
<nortti> my favourite linux is ELKS
<nortti> one of the very few systems that can claim to be a "different kind of linux" fully literally
<gog> is haikuOS a linux
<gog> if so its the best one
<heat> "Linux kernel developers Alan Cox and Chad Page"
<heat> fake names?
<gog> Chad and Cox
<gog> checks out
<gog> chex
<zid> heat: Chad Linux
<heat> chadOS
<zid> I upgrading from shitpc todayyy
<zid> back to realpc
<Ermine> virginOS where
<zid> Ermine: linux
<Ermine> Hehe
<Ermine> zid: also complexpc where
<heat> hehehehehehehe
<zid> soviet PC biggest PC n the world!
<zid> fitted with forklift handles for easy carrying!
<heat> counterfeit soviet vax >>
<Ermine> I've seen one actually
valshaped has quit [Ping timeout: 255 seconds]
tepperson has joined #osdev
valshaped has joined #osdev
<heat> TIL in C++ void foo(int arg...); = void foo(int arg, ...);
<Ermine> o_O
<heat> it does make sense honestly
<gog> soyuz nerushmii
<heat> i agree
<zid> isn't that you can do A, B style macro expansion where A may not be present
<zid> and not have the extra comma explode you
<zid> I thought C11/23 also had it, but may have been a fever dream
<mrvn> Isn't the first an implicit vardiac template and the second VA_ARGS?
elastic_dog has quit [Ping timeout: 252 seconds]
elastic_dog has joined #osdev
<heat> zid, no that's something else
<heat> that's GNU C specific stuff (__VA_ARGS__ "hiding" the last , when used like VAR_MACRO(10, __VA_ARGS__))
<heat> OR C++20 specific stuff __VA_OPT__(,) expands to , if __VA_ARGS__ isnt empty
<heat> I'm really unsure if C23 has this, maybe it does
<heat> this is literally just a case of varargs in C++ not requiring a comma
<heat> "Where syntactically correct and where “...” is not part of an abstract-declarator, “, ...” is synonymous with “...”."
<mrvn> Isn't a context free grammar beautiful?
<mrvn> Is there ever a reason to use VA_ARGS in C++ outside of extern "C"?
Patater has quit [Quit: Explodes into a thousand pieces]
Patater has joined #osdev
elastic_dog has quit [Ping timeout: 255 seconds]
elastic_dog has joined #osdev
<heat> yes, sane codegen that doesn't blow up your binary
<zid> okay time to do some osdev
<heat> mjg, hello!!!
terminalpusher has joined #osdev
zid has quit [Remote host closed the connection]
<heat> is an atomic OR a bad lock operation?
<heat> with this I mean like a fetch_or
<heat> fwiw it does seem to compile down to a cmpxchg
<heat> (because there's no fetch_or op in x86)
<mjg> it is a massive crapper but if you have to do it...
<mjg> in general cmpxchg *loops* are shit, but not always avoidable
<mjg> see the lockref debacle
<heat> the idea here is to have a page flag also serve as a lock, like linukz
<mjg> welp also see fribzd
<heat> like won't my spinlocks have a cmpxchg loop? or at least an xchg one
<heat> what should I search for? symbol name
<mjg> looping to set something in the var vs to take a lock are very different senarios
<heat> yeah but in this cae something in the var *is* the lock
<mjg> e.g. vm_page_dequeue
<heat> what's a queue here?
<mjg> does it matter?
<heat> yes?
<mjg> see vm_page.h
<heat> i just want a lock_page/unlock_page primitive
<mjg> it's just a bunch of shitters -- is the page in use, is not in use
<mjg> etc.
<mjg> well page "lock" in freebsd is a massive crappe,r see vm_page_sbusy
eck has quit [Quit: PIRCH98:WIN 95/98/WIN NT:1.0 (build 1.0.1.1190)]
<mjg> erm vm_page_trysbusy and similar
<heat> why is everything a crapper to you :(
<heat> do you keep shitting yourself
<mjg> not *everything*
<mjg> i think sequence counters are a great invention
eck has joined #osdev
eddof13 has joined #osdev
<heat> this code is very hard to read
<heat> everything is one 's' away from bussy greatness
<heat> ok so it's also a cmpxchg loop
<heat> great
<mjg> like i said
<mjg> vm likes to boast about being "commented very well"
<heat> better commented than linux for sure
<mjg> was gonna say the comments don't really help
<mjg> what savesthe bacon to some extent is asserts all over the place
<mjg> to document the insane requirements
<heat> are you sure you like freebsd
<heat> have you ever praised any of it, ever?
<mjg> i literally just did
<mjg> > asserts
<heat> > insane requirements
<mjg> how did that slip in there
<mjg> really though, if you are fucking around, freebsd is morel ikely to tell you that you messed up thatn ilnux
<mjg> there is an ingrained culture on asserting the shit out of everything
<mjg> this slowly changes in linux though
<mjg> normally freebsd will have lul_lock_assert_held(&fooobj);
<mjg> while linux will have acomment: /* yo dawg make sure you hold the lock, but i'm not gonnacheck if you do even on a debug kernel */
<Ermine> lul
<mjg> again that last bit is changing
<mjg> i asked an Important Developer once what's up with the comments
<mjg> instead of asserts
<heat> what did linus tell you
<mjg> and he was liek "what's the problem. the comment tells you what to do"
<mjg> not that guy
<heat> matthew garrett for sure
<mjg> i'm gonna protect the guilty on thiso ne
<Ermine> or greg kh?
<heat> actually I know who it is
<mjg> i guarantee you don't
<heat> must be Ingo Molnar
<heat> on god
<mjg> so linux got an annotation to funcs that it expects or rleases a specific lock
<mjg> also the machinery to detect violations, when actually used, is more informative
bauen1 has quit [Ping timeout: 276 seconds]
terminalpusher has quit [Remote host closed the connection]
<heat> why the fuck does vm_page_bits_t change sizes based on page size?
<mjg> it indicates invlalid rangs
<mjg> invalid ranges
<heat> wat the fuck is wrong with these comments
<mjg> thek eyboard on you man
<mjg> take a chill pill
<mjg> #notmedicaladvice
<heat> The following annotations are possible: (A), (B), (C), (F), (M), (O), (Q)
<mjg> what. commented on.
<heat> 250 uint8_t flags;/* page PG_* flags (P) */
<mjg> job done boss
<heat> I SEEMED TO HAVE MISSED P
<mjg> job done boss
<mjg> comments are essintial to deliver high quality
<heat> take some opioids
<heat> #medicaladvice
bgs has joined #osdev
xenos1984 has quit [Ping timeout: 248 seconds]
xenos1984 has joined #osdev
gog has quit [Quit: Konversation terminated!]
slidercrank has joined #osdev
<heat> mjg, is there no benefit in adaptive-spinning instead of sleeping for the page lock?
<mjg> there is massive benefit
<mjg> adaptive spinning is almost always a win
<mjg> in fact waiting on the page lock is one of the biggest bottlenecks
<mjg> you may ask why not done then -- because nobody implemented it
<heat> lol
<mjg> you may notice a tech difficulty here: the entier field is only 4 bytes
<mjg> so a full thread addr wont fit
<mjg> not a huge problem to solve, but there are some competing choices to be made here
<heat> but erm
<heat> so, you say adaptive spinning is almost always a win
<heat> why?
<mjg> however, more important news, is that most of the problem is because there is too much xbusy when it could be sbusy after some effort
<mjg> because going off cpu is costly af
<mjg> and induces even more cost for the thread doing the unlock later
<mjg> and if the lock is heavily contested, performance collapses to nothing if everyone just goes off cpu
<mjg> ... because the idled cpu time which is "gained" is spent on adding more threads to wake up
<mjg> it just works out this way in practice
<mjg> i can't stress the word *adaptive* enough -- it has to *react* to owner going off cpu
<heat> sure but I would think it would suck as an anti-other-threads-in-the-same-CPU measure?
tepperson has quit [Quit: Client closed]
<mjg> as i said previously in practice you *lose* time by going off cpu
<mjg> by the time you context swithc away the lock is very likely free
<heat> ok so this is a stats thing? behaves well for some locks but not for others?
<mjg> except now you added work for the previus owner
<mjg> i already told yu there is one dgenerate case wher it sucks: when locks are taken in lockstep, so tto speak
<mjg> apart from that it is expected to be a win
<mjg> at worst it happens to not be implemented in some cases
<mjg> see above for one
<heat> does this apply to every software system out there?
<heat> could you expect big wins from adaptive spinning in userspace (if you had the previously-discussed oncpu flag stuff)
<mjg> yes
<mjg> i stress the diff between this and just "spin some time deemed long enough and gtfo"
<mjg> also note people handroll spinlocks in hopes of never going off cpu
<mjg> i userspace
<heat> yes but that's mad mkay
<heat> *bad. but mad also works
<mjg> so for example "parking_lot" crate for rust gets a win over stock rust
<mjg> because they spin
<heat> RUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUST
<mjg> arbitrary amount of time, but they spin, instead of blindly going off cpu at the first wiff of contention
<mjg> one thing you may note it shaves a syscall trip, even if ultimatley you do't go off cpu
<mjg> should you get the lock while in the kernel, without going off, now you got extended lock hold time becausey ou have to get back
<mjg> it all goes to shit really fast
<mjg> extended hld time means someone else is more likely to find the lock taken and rinse & repeat
<mjg> fwiw perf goes to shit if i disable adaptive spinning in the ernel
<mjg> simiarly, linukkz got a win after *adding* adaptive spinning to their rwsem
<mjg> laso you may notice they spinlock by default anyway
<heat> yeah
<heat> locking is herd
<mjg> no, just realities suck
<mjg> for user code
<mjg> if you want an example abuser which piles on a poor sap lock, it would be make
<mjg> -j 104 spawns *hundreds* of makes, majority of which keep doing poll() on *the same* pipe
<mjg> and doing r/w on it as well
<mjg> it is bad to the point where lock waiters take long enough, that once they get the lock they happen to get preempted
<mjg> then everyone else has to add themselves to thet urnstile and wake the owner up
<heat> something something spinlock?
<mjg> in fact, with some other patches added, 'pipe lock' is the most contested out there by a large margin
<mjg> 749236678 (sleep mutex:pipe mutex)
<mjg> 73674398 (rw:vmobject)
<mjg> wait times
<heat> so spinlock.
<mjg> that would amage-control the problem to some extent
<mjg> but wont fix it
wand has quit [Ping timeout: 255 seconds]
<mjg> there is a real fix tho
<bslsk05> ​github.com: bmake: Replace token pipe with shared memory. · macdice/freebsd@cfeb5b4 · GitHub
<heat> does a pipe write do broadcast wakeup?
<heat> probably?
<mjg> i don't remember, but that's not where bulk of the cntention is
<mjg> almost all of it is in pipe_poll
<mjg> note it gets queried whether there is a good reason or not
<mjg> as in the main poll loop waits for a bunch of crap and wakes up a lot regardless of what happens to the shared pipe
wand has joined #osdev
<mjg> and when it goes back to poll() it lands in pipe_poll again
<mjg> things get drastically better if this gets replaced with kqueue
<mjg> but they still stuck
<mjg> ooh and when it wakes up from poll it does it *again* :p
<mjg> contention on that sucker is massively amplified
qubasa has quit [Remote host closed the connection]
xenos1984 has quit [Ping timeout: 248 seconds]
bauen1 has joined #osdev
xenos1984 has joined #osdev
danilogondolfo has quit [Quit: Leaving]
zid has joined #osdev
theboringkid has joined #osdev
valshaped has quit [Read error: Connection reset by peer]
valshaped has joined #osdev
bnchs has joined #osdev
theboringkid has quit [Ping timeout: 255 seconds]
zid has quit [Remote host closed the connection]
xvanc has quit [Remote host closed the connection]
xenos1984 has quit [Read error: Connection reset by peer]
xenos1984 has joined #osdev
xvanc has joined #osdev
xvanc has quit [Ping timeout: 248 seconds]
xvanc has joined #osdev
xvanc has quit [Ping timeout: 276 seconds]
theboringkid has joined #osdev
GeDaMo has quit [Quit: That's it, you people have stood in my way long enough! I'm going to clown college!]
zid has joined #osdev
theboringkid has quit [Quit: Bye]
brunothedev has joined #osdev
<brunothedev> gog: are you here?
danilogondolfo has joined #osdev
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
brunothedev has left #osdev [ong i love part command so much unix is very cool, /*-+.3,]
brunothedev has joined #osdev
Turn_Left has joined #osdev
Left_Turn has quit [Ping timeout: 255 seconds]
eddof13 has joined #osdev
<netbsduser> i've just had a eureka moment: the secret to paging the page tables themselves is that for each entry in a table pointing to a lower-level table, you have to consider one pin to exist on the higher-level table. a non-terminal table can be in the swapfile, only if each entry in it is null or the swap address of a lower-level table
<geist> i suppos eyeah. OTOH, swapping page tables is a really bad idea
<heat> i agree with geist, bad idea
<geist> but yeh i think keeping the constraint as you say makes a lot of sense
<heat> do note that you could just outright remove the page tables if you didn't store the swap data in the PTEs
<heat> what stores the page structs can also store the swap data :)
<brunothedev> netbsduser: do you realy use netbsd?
<heat> no, it's the one system he doesn't use
xvanc has joined #osdev
<heat> SVR4 lover, solaris lover, freebsd lover, openbsd mega lover, netbsd hater
<netbsduser> without the constraint you end up in a hell of having to page-in one table so you can update its PTE for the paged-out inferior table to point into swap
<netbsduser> heat: i was keeping the swap address in a separate structure before but i am unhappy with the memory use
<heat> why?
danilogondolfo has quit [Quit: Leaving]
<heat> lets imagine you have a union {u64 swap_data; vm_page_t *page;} vmobj_entry;
<heat> how is this not superior?
<netbsduser> i have that but i also have a lock in there which enlarges it to some 40 bytes
<heat> why a lock?
<netbsduser> my vm_page_t contains a pointer the object that it belongs to and for anonymous memory, since anonymous pages are shareable, the object must be considered the individual anonymous page vmobj_entry
xvanc has quit [Ping timeout: 255 seconds]
<netbsduser> (for a file mapping it points to the actual vnode memory object and the vm_page_t has linkage for a tree to chain it into the object, since file objects aren't subject to 'symmetric cow' like anonymous memory is)
<brunothedev> from someone who likes openbsd, freebsd is the worst one lol
<netbsduser> i like freebsd's capsicum
<heat> oh boy
<heat> someone hold me
<heat> would rather use 1996 SunOS over 2023 openbsd
bgs has quit [Remote host closed the connection]
<CompanionCube> wasn't it Solaris by 1996?
<brunothedev> heat: openbsd looks neat from linuc
<brunothedev> * linux
<netbsduser> sunos already had coherent mmap() and read()/write() in 1996 (well, no later than SVR4 actually) which is one point in its favour there
<heat> CompanionCube, it was
<CompanionCube> yep, Solaris 2.5.1, released May 1996.
<heat> my bad, would rather use 1994 SunOS
<brunothedev> openbsd is very portable and very lightweight
<brunothedev> looks cool
<heat> haha
<netbsduser> >very portable
<brunothedev> heat: someone runned one on a imac g3
<heat> netbsduser, yes they had coherent mmap+rw() through the worst method ever of getting this same coherency
<CompanionCube> had Motif, NFSv3, pthreads, doors
<netbsduser> doesn't even have a vax port smh
<heat> CompanionCube, DOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOORS
<CompanionCube> heat: STREAAAAAMS
<netbsduser> heat: i think it's a cute approach
<nortti> brunothedev: you should look at netbsd if you like a currently developed bsd with high portability
<netbsduser> but i have a bit of an obsession with weird approaches to virtual memory
<heat> netbsduser, you basically throw away any advantage you could have from read()/write()
<brunothedev> nortti: didnt someone run netbsd ON A TOASTER
<heat> for, what, virtual memory in the kernel? fucking hell
<brunothedev> i dont like bloat, so netbsd and openbsd looks cool
<heat> ok i'll bite
<heat> what's so bad about freebsd and linux
<nortti> brunothedev: probably, but like, that's honestly not very interesting? it'd've been a toaster with some commodity chip designed to be able to run a whole OS
<brunothedev> if it wasnt by nvidia, i would run alpine with swaywm
<netbsduser> heat: i suppose you could just walk the vnode's memory object manually too
<heat> netbsduser, yes, something you'll do eventually, but directly
<heat> and with further idea of what you're actually there to do (how much should you prefetch, etc)
<heat> nortti, btw really enjoyed the dig at openbsd, welcome to the club
<heat> sortie would NOT enjoy this
<nortti> haha
<nortti> wasn't even meant as a dig tbh, openbsd just genuinely has less ports than netbsd
<heat> yeah but "current developed bsd" really hit the spot there
<nortti> heh
<nortti> oh, interesting, netbsd doesn't have a luna88k port (openbsd does)
<heat> oh man not the luna88k
<nortti> tho from what I understand it's like, one dev keeping that going, and they probably have their hands full enough with openbsd already
<nortti> netbsd does do luna68k tho
<brunothedev> openbsd is more secure
<heat> mjg
<brunothedev> it does means that it haves by default fewer drivers
<nortti> brunothedev: you might like https://isopenbsdsecu.re/
<bslsk05> ​isopenbsdsecu.re: Is OpenBSD secure?
<heat> nortti, fuck
<heat> ur 2fast
<heat> oh wow it only got syn cookies in 2018
<nortti> < brunothedev> it does means that it haves by default fewer drivers ← not even necessarily, aiui it had the latest (or was it the one gen before?) wifi drivers before other BSDs. might be there is something I don't know, but from what I understand lack of drivers is mainly about lack of developers to work on them
<nortti> *latest gen
<heat> aren't all the wifi drivers taken from linux?
<netbsduser> openbsd is called the queen of open source wifi drivers
<heat> this is a legitimate question
<netbsduser> linux once snatched one of their wifi drivers and tried to strip out the BSD licence which caused a shitstorm
<nortti> huh
<heat> yes but erm, when was that
<netbsduser> 2008 i think
<heat> I seriously doubt any corp is contributing code to openbsd in 2023
<heat> particularly wifi drivers
<netbsduser> oh, they cook them up by themselves
<heat> "how much documentation do you want?" "all of it" "too bad, here's none"
<netbsduser> this was when everyone left the penguin out to dry
<heat> ok so it was the queen of open source wifi drivers 25 years ago
<heat> sorry, 15 years ago
<bslsk05> ​isopenbsdsecu.re: pinsyscall | Is OpenBSD secure?
<brunothedev> klangis bpp the same as pixelwidth
xvanc has joined #osdev
<heat> yes
xvanc has quit [Ping timeout: 276 seconds]
<heat> [84722.098529] Out of memory: Killed process 80888 (shellcheck) total-vm:1073758092kB, anon-rss:4842880kB, file-rss:384kB, shmem-rss:0kB, UID:1000 pgtables:13512kB oom_score_adj:200
<heat> cheers
qubasa has joined #osdev
* kof123 switches to openbsd "I seriously doubt any corp is contributing code to openbsd in 2023"
<brunothedev> kof123: virgin coorporate controlled linx vs. chad independant free openbsd
<AmyMalik> greh
<AmyMalik> Linux has faster wifi
<brunothedev> i dont use wifi anyway
<AmyMalik> probably faster ethernet too
dude12312414 has joined #osdev
dude12312414 has quit [Client Quit]
<brunothedev> what is: "framebuffer_[red/green/blue]_field_position" "framebuffer_[red/green/blue]_mask_size"
levitating has quit [Remote host closed the connection]
levitating has joined #osdev
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Turn_Left has quit [Quit: Leaving]
<immibis> probably the position and size of the red, green and blue fields
<brunothedev> immibis: so to draw, i need to draw at three different buffers for each color?
<immibis> what does your question mean?
<brunothedev> is there three different buffers, and i need to draw to each one for each color?
<immibis> no, there's one buffer with intermixed red, green and blue
<brunothedev> but is the buffer split between colors?
<immibis> these fields are probably telling you which part of each pixel is red, green and blue
<klange> do you know what BGR is?
<immibis> so you have an array of pixels, each pixel has red, green and blue, but sometimes it's like 5 bits red, 6 bits green, 5 bits blue; other times it's 8 bits unused, 8 bits red, 8 bits green, 8 bits blue
<immibis> sometimes it's blue, green, red. It's a shame the specification doesn't actually say what they mean exactly
<brunothedev> klange: blue green red?
<immibis> of course if you are just playing around you could hardcode whichever framebuffer format is used on your computer with your bootloader
<immibis> if that's easier
brunothedev has quit [Quit: WeeChat 3.6]
kivikakk1 has joined #osdev
antranigv has quit [Ping timeout: 260 seconds]
xvanc has joined #osdev
xvanc has quit [Remote host closed the connection]