plan9fox/sys/src/9/port
cinap_lenrek eed90aa0ad kernel: don't cap the minimum sleep time to TK2MS(1) for syssleep()
on HZ 100 systems like pc and pc64, the minium sleep time
was 10ms, which is quite high. the cap isnt really needed
as arch specific timerset() enforces its own limit, but on
a higher resolution.

background:

from Charles Forsyth:

I haven't really got an opinion on it. The 10ms interval was first used on
machines that were much slower.
I thought someone did set HZ to a bigger value, partly to support better
in-kernel timing. I haven't done it because I never had a need for it.
If I were doing (say) protocol implementation in user mode, I'd certainly
reconsider. Sleep itself forces at best ms granularity,
and for some applications that's too big.

initial mail from qwx raising the issue:

> Hello,
>
> I found out recently that sleep(2)'s resolution on 386 and 9front's amd64
> kernel is 10 ms rather than 1 ms.  The reason is that on those kernels,
> HZ is set to 100 rather than say 1000.  In syssleep, we get 1 tich every
> 10 ms.
>
> What is unclear is why.
>
> To paraphrase cinap_lenrek's answer to my question:
>
> In syssleep:
>                 if(ms < TK2MS(1))
>                         ms = TK2MS(1);
>                 tsleep(&up->sleep, return0, 0, ms);
>
> "TK2MS(1)" can be replaced with just "1", and the arch specific
> timerset() routine would do its own capping of the period if it's too
> small for the timer resolution, and make better decisions based on what
> the minimum timer period should be given the latency overhead of the
> given arch's interrupt handling and performance characteristics.
>
> Alternatively, HZ could be raised to 500 or 1000.
>
> It seems it's just trying to prevent excessive context switches and
> interrupts, but it seems somewhat arbitrary.  A ton of syscalls can be
> done in 1 ms, and it's the lowest we can go without changing the unit.
>
>
> What do you think?
>
> Thanks in advance,
>
> qwx
2018-06-10 19:47:21 +02:00
..
alarm.c kernel: make sure procalarm() remaining time doesnt become negative 2016-09-08 01:28:34 +02:00
alloc.c libc: move calloc() into its own compilation unit 2016-11-05 18:00:10 +01:00
allocb.c kernel: fix missing ; in panic() call 2016-11-05 20:08:20 +01:00
aoe.h
audioif.h
auth.c kernel: make fversion()/mntversion() types consistent 2016-03-10 03:02:28 +01:00
cache.c kernel: make the mntcache robust against fileserver like fossil that do not change the qid.vers on wstat 2017-01-12 20:13:20 +01:00
chan.c kernel: fix namelenerror(), avoid memrchr() and make it static 2017-05-07 18:13:37 +02:00
cis.c
dev.c kernel: stop the practice of passing DMDIR to devir() perm argument 2018-06-03 23:33:35 +02:00
devaoe.c devaoe: fix dotdot walk in devlinkdir, make perms consistent 2018-06-03 23:30:57 +02:00
devaudio.c kernel: properly handle bad attach specifiers 2018-02-25 17:11:18 +01:00
devbridge.c kernel: properly handle bad attach specifiers 2018-02-25 17:11:18 +01:00
devcap.c devcap: timeout capabilities after a minute, fix memory leak, paranoia 2016-09-07 21:14:23 +02:00
devcons.c devvga: re-render text from kmesg after resize 2017-11-26 04:49:30 +01:00
devdraw.c devdraw: ignore drawdebug command 2017-04-29 21:09:11 +02:00
devdup.c kernel: stop the practice of passing DMDIR to devir() perm argument 2018-06-03 23:33:35 +02:00
devenv.c devenv: make #ec files not show up as world writable 2018-06-03 23:30:05 +02:00
devether.c kernel: properly handle bad attach specifiers 2018-02-25 17:11:18 +01:00
devflash.c kernel: properly handle bad attach specifiers 2018-02-25 17:11:18 +01:00
devfs.c kernel: stop the practice of passing DMDIR to devir() perm argument 2018-06-03 23:33:35 +02:00
devkprof.c
devloopback.c devloopback: reassign device letter from #X to #λ to avoid collision with devvmx 2018-02-25 19:06:37 +01:00
devmnt.c devmnt: use u32int for tagmask, simplify alloctag() 2017-12-28 18:25:15 +01:00
devmouse.c add usb tablet support 2018-05-08 08:28:48 +00:00
devpipe.c kernel: stop the practice of passing DMDIR to devir() perm argument 2018-06-03 23:33:35 +02:00
devpnp.c
devproc.c kernel: stop the practice of passing DMDIR to devir() perm argument 2018-06-03 23:33:35 +02:00
devroot.c provide /n and /mnt early in bootrc to allow consistent use in /lib/namespace 2016-02-14 01:42:32 +01:00
devsd.c kernel: properly handle bad attach specifiers 2018-02-25 17:11:18 +01:00
devsdp.c kernel: properly handle bad attach specifiers 2018-02-25 17:11:18 +01:00
devsegment.c kernel: stop the practice of passing DMDIR to devir() perm argument 2018-06-03 23:33:35 +02:00
devshr.c kernel: pgrpcpy(), simplify Mount structure 2015-08-09 21:16:10 +02:00
devsrv.c
devssl.c devtls, devssl: avoid ~0UL comparsion (from drawterm) 2017-12-28 19:13:53 +01:00
devswap.c stats: show amount of reclaimable pages (add -r flag) 2018-01-05 00:52:14 +01:00
devtls.c devtls, devssl: avoid ~0UL comparsion (from drawterm) 2017-12-28 19:13:53 +01:00
devuart.c
devusb.c kernel: stop the practice of passing DMDIR to devir() perm argument 2018-06-03 23:33:35 +02:00
devwd.c
ecc.c
edf.c kernel: fix twakeup()/timerdel() race condition 2017-03-29 00:30:53 +02:00
edf.h
error.h
etherif.h devether: remove (unimplemented) detach, allow device creation on attach 2018-02-25 03:42:38 +01:00
ethersink.c ethersink: after the experiment, the zeros get dismantled. and then destroyed. 2018-02-12 01:48:20 +01:00
fault.c sdram: experimental ramdisk driver 2018-05-27 22:59:19 +02:00
flashif.h
initcode.c
led.c kernel: fix cb->f[0] nil dereferences due to short control request 2016-05-05 18:54:58 +02:00
led.h
lib.h devfs: rewrite cryptio() 2017-10-29 22:01:58 +01:00
log.c
master.local
mkbootrules
mkdevc sdram: experimental ramdisk driver 2018-05-27 22:59:19 +02:00
mkdevlist
mkerrstr
mkextract
mkfile
mkfilelist
mkroot
mkrootall
mkrootc
mksystab
mul64fract.c kernel: more (arm) compiler friendly mul64fract() 2016-06-26 15:13:10 +02:00
nandecc.h
netif.c kernel: stop the practice of passing DMDIR to devir() perm argument 2018-06-03 23:33:35 +02:00
netif.h
page.c kernel: fix memory leak in checkpagerefs() debug function (thanks aiju) 2017-04-04 20:13:31 +02:00
parse.c
pgrp.c kernel: pgrpcpy(), simplify Mount structure 2015-08-09 21:16:10 +02:00
portclock.c kernel: fix twakeup()/timerdel() race condition 2017-03-29 00:30:53 +02:00
portdat.h sdram: experimental ramdisk driver 2018-05-27 22:59:19 +02:00
portfns.h sdram: experimental ramdisk driver 2018-05-27 22:59:19 +02:00
portmkfile kernel: fix missing header dependency for ethersink.$O 2018-02-18 02:05:22 +01:00
portusbehci.h
print.c
proc.c kernel: add support for sticky segments (cached, preallocated, never paged) 2017-06-20 21:53:45 +02:00
qio.c kernel/qio: make readblist() offset of type ulong as the rest 2016-11-12 17:41:58 +01:00
qlock.c kernel: cleanup qlock.c to use nil instead of 0 for pointers 2015-08-02 05:36:35 +02:00
random.c kernel: rekey chacha state on each randomread() invocation 2016-09-11 19:07:17 +02:00
rdb.c
rebootcmd.c kernel: pass bootargs also in multiboot command line, retire the bootline mechanism to pass arguments to /boot/boot 2017-06-28 18:56:16 +02:00
sd.h devsd: remove unused timeout field from SDreq 2015-09-20 14:27:41 +02:00
sdaoe.c devaoe: more nil vs. 0 2015-07-23 22:05:46 +02:00
sdloop.c
sdmmc.c sdmmc: handle fakescsi emulation 2015-09-20 14:53:44 +02:00
sdram.c sdram: properly support multiple ramdisks, so that ramdiskX corresponds to sdZX 2018-05-29 22:50:04 +02:00
sdscsi.c
segment.c sdram: experimental ramdisk driver 2018-05-27 22:59:19 +02:00
semaphore.p
swcursor.c
syscallfmt.c fix fuckup 2015-08-25 09:35:10 +00:00
sysfile.c kernel: fix rewinding in directories with pread() offset 2017-04-30 01:51:07 +02:00
sysproc.c kernel: don't cap the minimum sleep time to TK2MS(1) for syssleep() 2018-06-10 19:47:21 +02:00
taslock.c zynq: fix barriers 2015-06-18 04:35:46 +02:00
thwack.c
thwack.h
tod.c kernel: remove todfix overflow iprint() spam 2016-01-07 19:37:05 +01:00
ucalloc.c
ucallocb.c kernel: cleanup exit()/shutdown()/reboot() code 2015-11-30 14:56:00 +01:00
unthwack.c
usb.h usbehci: add uframes control request to return uframes one at a time 2018-03-06 17:18:48 +00:00
usbehci.c usbehci: catch interrupt in tsleep 2018-03-07 08:45:06 +00:00
wifi.c devether: mux bridges, portable netconsole 2018-02-18 19:56:01 +01:00
wifi.h kernel: move devether and wifi to port/ 2018-02-11 18:08:03 +01:00
xalloc.c kernel: ignore last page at the top of virtual kernel address space for xalloc() 2015-06-19 02:45:58 +02:00