NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/57718: mstohz rounds down, not up, which leads to surprising bugs when it rounds to zero



>Number:         57718
>Category:       kern
>Synopsis:       mstohz rounds down, not up, which leads to surprising bugs when it rounds to zero
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 22 03:15:00 +0000 2023
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetBugsD Hertz
>Environment:
>Description:
If hz=50, then mstohz(10) returns 0.

This means wait forever with cv_timedwait, or with kpause (which trips an assertion instead because waiting forever with kpause is nonsense).

This also means that timeouts are too short, rather than too long.
>How-To-Repeat:
boot a kernel with hz=50, watch things crash and burn
>Fix:
Yes, please!

1. Audit all mstohz callers to determine whether they need rounding up or rounding down.  My guess: the vast majority need rounding up.

2. Either:
   (a) Change mstohz to round up, and fix any callers that actually needs rounding down.
   (b) Make a new name for the operation that rounds up and convert everything that needs rounding up to use it.



Home | Main Index | Thread Index | Old Index