3 Commits
Author SHA1 Message Date
lotherk df81373057 MCDE: the WEB_URL data type and the hanging test_sysload child (t0303)
A .url file is a WEB_URL now (the reference sdturl.dt): a text file
whose content is a URL, ACTIONS McdeWeb,Print, ICON Dtdata,
NAME_TEMPLATE %s.url, MIME text/x-url.  Measured in dtfile: test.url
shows the URL icon beside note.txt (screenshot).

test_sysload: the child that waits for a signal sets alarm(60), so a
hung or killed test no longer leaves it in pause() and blocks the
build lock with waitpid.
2026-11-16 13:04:42 +00:00
lotherkandClaude Sonnet 5.5 6676102ec8 McdeSys: network and disk counters for the activity window (t0091, McdeSys part 2)
mcde_sys_net_io: bytes and packets each way, for each interface (the loopback
too).  mcde_sys_disk_io: bytes and operations read and written, for each whole
disk (no partitions; no loop, ram or zram devices).  The difference of two
readings over the seconds between them is the rate the Network and Disk
Activity tabs draw.

NetBSD (read in the tree first): the interface counters are the struct if_data
of the link-level address from getifaddrs(3) (ifi_ibytes, ifi_obytes,
ifi_ipackets, ifi_opackets); the disks come from sysctl hw.iostats
{CTL_HW, HW_IOSTATS, sizeof(struct io_sysctl)}, asked for its size and then for
the array (usr.bin/vmstat/drvstats.c:183-188, :323-328), type IOSTAT_DISK,
rbytes/wbytes/rxfer/wxfer (sys/sys/iostat.h).  Cross-compiled with
x86_64--netbsd-gcc -Wall -Wextra: no diagnostic.  NEVER RUN on NetBSD.
Linux: /proc/net/dev (64-bit counters), /proc/diskstats (512-byte sectors),
whole disks only: those with a directory in /sys/block.

test_sysload (make check, 7 of 7) now also: 2 MB sent over a TCP connection on
127.0.0.1 raise the loopback's rx and tx bytes by at least 2,000,000 and its
packets; 8 MB written and fsync'ed next to the test move the disks' write
counters (measured here: 25,595,904 bytes for 8 MB -- the device-mapper volume
and the physical disk under it are both whole devices, so a window should not
add them up); the counters never go back by name; the write check says SKIP
instead of failing where the file system has no disk.  Mutants: rx bytes taken
from packets fails 2 checks, write bytes taken from the read sectors fails 1,
sectors not multiplied by 512 fails 1.

Not done of t0091: the program (programs/dtactivity).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 05:03:08 +00:00
lotherkandClaude Sonnet 5.5 ecef3334a2 McdeSys: CPU times, memory and signals for the activity window (t0091, McdeSys part)
mcde_sys_cpu_times: one McdeSysCpu (user, nice, system, idle, other ticks since
boot) per processor.  mcde_sys_memory: bytes, total = free + cached + used (cached
is what the system gives back when asked), and swap.  mcde_sys_signal: TERM, KILL,
STOP, CONT, HUP or INT to a process above pid 1 -- never init, a group or "all my
processes" (kill(2) with 0 or a negative number is refused before it is asked);
EPERM for another user's process, ENOENT for one that is gone.

Backends, read in the tree before they were written:
- NetBSD: kern.cp_time given room for every CPU (hw.ncpu x CPUSTATES x 8 bytes)
  returns each CPU's counters in CP_ order (sys/kern/init_sysctl.c,
  sysctl_kern_cptime: "alternately, you can pass an additional mib number and get
  cp_time for that particular processor"; a buffer of one CPU's size gets the
  SUM); memory from vm.uvmexp2 (struct uvmexp_sysctl, pages; top(1) reads it
  too, external/bsd/top/dist/machine/m_netbsd.c).  Cross-compiled with
  x86_64--netbsd-gcc -Wall -Wextra: no diagnostic.  NEVER RUN on NetBSD.
- Linux: /proc/stat (cpuN lines, "other" = iowait + irq + softirq + steal),
  /proc/meminfo (cached = MemAvailable - MemFree, else Buffers + Cached).

test_sysload (make check, 7 of 7): the memory adds up and agrees with
sysconf(_SC_PHYS_PAGES) within 5 per cent; the CPU counters never go down and
0.4 s of work of the test's own shows as at least 5 ticks; children are stopped
(state T in mcde_sys_processes), continued and ended by TERM, KILL, HUP and INT
(the exit status says which signal); pid 1, 0, -1, a group and a bad signal are
refused; a waited-for child is "gone"; another user's process answers EPERM (to
SIGCONT only, and only when the test is not run by root).  Mutants: memory
without the x1024 fails 2 checks, a parser that loses the busy ticks fails 1.
Not checkable on a busy host: that user, nice, system and idle are not swapped
(the shares depend on the load); the NetBSD backends are not run.

Not done of t0091: mcde_sys_disk_io and mcde_sys_net_io (the Disk Activity and
Network tabs), and the program itself.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 05:00:36 +00:00