STRUCT NBCON_STATE(9)
π struct nbcon_state(9) β the vibe check on nbcon console state
okay bestie, welcome to the Kernel API Manual β¨ this one's short and sweet, so grab your iced coffee π
πΈ NAME πΈ
struct nbcon_state β console state for nbcon consoles. that's it, that's the whole name. iconic brevity π
π SYNOPSIS π
like, here's the actual struct, copied character for character because we do not mess with the source π«Ά
struct nbcon_state {
union {
unsigned int atom;
struct {
unsigned int prio : 2;
unsigned int req_prio : 2;
unsigned int unsafe : 1;
unsigned int unsafe_takeover : 1;
unsigned int cpu : 24;
};
};
};
β¨ Members β¨
okay so this is where it gets juicy, let's go through every single one because we don't skip π
{unnamed_union}β anonymous. yes babe, it has no name, it's mysterious like that πatomβ the compound of the state fields, made for atomic operations. so you can grab the whole thing in one shot, no cap π₯{unnamed_struct}β also anonymous. two anonymous things in one struct, it's giving main character energy πprioβ the priority of the current owner. the real one, the one actually holding it πreq_prioβ the priority of a handover request. like someone politely (or not) asking for the unlock π«Άunsafeβ console is busy in a non takeover region. lowkey do NOT touch this one πunsafe_takeoverβ a hostile takeover in an unsafe state happened in the past. the console cannot be safe until re-initialized. fr fr, this is a permanent scar until you re-init πcpuβ the CPU on which the owner runs. 24 bits of "who's your CPU bestie" π
π¦ Description π¦
so what's this struct for? it's to be used for reading and preparing of the value stored in the nbcon state variable console::nbcon_state. that's the whole job, and it slays at it β¨
now here's the important bit, ngl β the prio and req_prio fields are particularly important. why? because they allow spin-waiting to timeout and give up without the risk of a waiter being assigned the lock after giving up. like, no phantom lock handoff, none of that chaos. that's the whole reason these fields exist and they ate π
π₯
π§ SEE ALSO π§
go read these next, i promise they're worth it:
- Kernel file
./include/linux/console.h struct consw(9)enum cons_flags(9)enum nbcon_prio(9)struct nbcon_context(9)struct nbcon_write_context(9)struct console(9)console_srcu_read_flags(9)console_srcu_write_flags(9)for_each_console_srcu(9)for_each_console(9)
and that's the page bestie!! π brought to you from ./include/linux, dated October 2026, in the Kernel API Manual β struct nbcon_state(9) out, mwah ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms