do_smart_update(9)
π do_smart_update(9)
okay so real talk, this is a page from the Kernel API Manual (the do_smart_update one, yes bestie, section 9) and it's honestly kind of iconic β it's the optimized version of update_queue and it does exactly as much work as it needs to and not a single syscall more. main character energy fr fr π
β¨ NAME β¨
do_smart_update β the optimized update_queue, slay π
π¦ SYNOPSIS π¦
void do_smart_update (struct sem_array *sma , struct sembuf *sops , int
nsops , int otime , struct wake_q_head *wake_q );
like, look at that signature. gorgeous. no notes. β
πΈ ARGUMENTS πΈ
smaβ the semaphore array π (the whole vibe of this function revolves around it)sopsβ the operations that were actually performed β¨ (past tense, bestie, they already happened)nsopsβ the number of operations π«Ά (count 'em)otimeβ force settingotimeπ (yes, force β it's giving assertive)wake_qβ the lockless wake-queue head π§ (lockless!! we love a low-contention queen)
π₯ DESCRIPTION π₯
okay so here's the tea: do_smart_update does the required calls to update_queue and wakeup_zero, based on the actual changes that were performed on the semaphore array. like, it's smart about it β hence the name, iykyk π
β οΈ but listen β the function does not do the actual wake-up. not me being responsible for my own callbacks π the caller is responsible for calling wake_up_q. it is safe to perform this call after dropping all locks, though, which is genuinely such a relief. π«Ά
π SEE ALSO π
Kernel file ./ipc/sem.c, plus the whole friend group:
unmerge_queues(9)merge_queues(9)newary(9)wake_const_ops(9)do_smart_wakeup_zero(9)update_queue(9)set_semotime(9)find_alloc_undo(9)
π and that's the page!! this little icon lives over in ./ipc, dropping in October 2026 β mwah, periodt, no cap, go read update_queue(9) next if you're obsessed with me πβ¨
π¦ 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