Page MenuHomeFreeBSD

db show thread: avoid overlow in tick conversion

Authored by rlibby on May 16 2019, 5:04 AM.



The previous calculations for displaying the time since last switch
easily overflowed, after less than 36 min for hz=1000. Now overflow
takes 2000 times longer (as long as ticks takes to overflow).

Test Plan
vali# cat - &  
[1] 810
vali# sysctl debug.kdb.enter=1
debug.kdb.enter:KDB: enter: sysctl debug.kdb.enter
[ thread pid 843 tid 100153 ]
Stopped at      kdb_sysctl_enter+0x98:  movq    $0,kdb_why
db> show proc 810
Process 810 (cat) at 0xfffff80004a29530:
 state: NORMAL
 uid: 0  gids: 0, 0, 5
 parent: pid 808 at 0xfffff80004c5ca60
 arguments: cat -
 repear: 0xfffff800033e4530 reapsubtree: 1
 sigparent: 20
 vmspace: 0xfffff80004e03000
   (map 0xfffff80004e03000)
   (map.pmap 0xfffff80004e030d0)
   (pmap 0xfffff80004e03130)
 threads: 1
100145                   s                                   cat
db> show thread 100145
Thread 100145 at 0xfffff80004a355a0:
 proc (pid 810): 0xfffff80004a29530
 name: cat
 pcb: 0xfffffe0050cfeb80
 stack: 0xfffffe0050cfb000-0xfffffe0050cfefff
 flags: 0x20844  pflags: 0
 priority: 125
 container lock: sched lock 3 (0xffffffff81eb3ac0)
 last voluntary switch: 588.880 s ago
 last involuntary switch: 588.880 s ago

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

rlibby created this revision.May 16 2019, 5:04 AM
cem accepted this revision.May 16 2019, 5:11 AM
This revision is now accepted and ready to land.May 16 2019, 5:11 AM
markj accepted this revision.May 16 2019, 5:17 AM
This revision was automatically updated to reflect the committed changes.