Commit graph

391 commits

Author SHA1 Message Date
Gleb Smirnoff 1a8d176432 inpcb: fully retire inp_ppcb pointer
Before a protocol specific control block started to embed inpcb in self
(see 0aa120d52f, e68b379244, 483fe96511) this pointer used to point
at it.

Retain kf_sock_inpcb field in the struct kinfo_file in <sys/user.h>.  The
exp-run detected a minimal use of the field in ports:
  * sysutils/lsof - patched upstream
  * net-mgmt/netdata  - patch accepted upstream
  * emulators/qemu-user-static - upstream master branch seems not using
    the field anymore
We can keep the field around for some time, but eventually it may be
reused for something else.

PR:			277659 (exp-run)
Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D44491
2024-03-29 12:18:32 -07:00
Hiroki Sato 4594eb4548
systat(1): Plug memory leak
The procstat_getprocs() function call in procgetinfo() allocated
a buffer but it was not freed properly.
2024-02-08 15:45:04 +09:00
Warner Losh 5e3934b15a usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Warner Losh 5b31cc94b1 sccs: Manual changes
For the uncommon items: Go through the tree and remove sccs tags that
didn't fit any nice pattern. If in the neighborhood, other SCM tags were
removed when they were detritis of long-ago CVS somehow in the early
mists of the project. Some adjacent copyrights stringswere removed (they
duplicated the copyright notices in the file). This also removed
non-standard formations of omission of SCCS tags (usually by adding an
extra #if 0 somewhere.

After this commit, a number of strings tagged with the 'what' @(#)
prefix remain, but they are primarily copyright notices.

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh bdcbfde31e usr.bin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:30 -07:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh e5d258c9e5 Remove $FreeBSD$: two-line .c pattern
Remove /^#include\s+<sys/cdefs.h>.*$\n\s+__FBSDID\("\$FreeBSD\$"\);\n/
2023-08-16 11:54:34 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Warner Losh bf46512a54 systat: Remove obsolete copyright string
This is unused, so remove it. We don't put a copyright string in most of
the other binaries. This one doesn't need one either.

Sponsored by:		Netflix
2023-08-15 21:22:50 -06:00
Cy Schubert e36b028933 systat: Chase 70ea484e3e, removing vdev_cache
As of 70ea484e3e vdev_cache has been removed. Stop reporting on it.
Without this systat reports:

	sysctl(kstat.zfs.misc.vdev_cache_stats.misses...) failed:
	No such file or directory

Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40742
2023-06-27 11:34:29 -07:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Gleb Smirnoff eaabc93764 tcp: retire TCPDEBUG
This subsystem is superseded by modern debugging facilities,
e.g. DTrace probes and TCP black box logging.

We intentionally leave SO_DEBUG in place, as many utilities may
set it on a socket.  Also the tcp::debug DTrace probes look at
this flag on a socket.

Reviewed by:		gnn, tuexen
Discussed with:		rscheff, rrs, jtl
Differential revision:	https://reviews.freebsd.org/D37694
2022-12-14 09:54:06 -08:00
Gleb Smirnoff e68b379244 tcp: embed inpcb into tcpcb
For the TCP protocol inpcb storage specify allocation size that would
provide space to most of the data a TCP connection needs, embedding
into struct tcpcb several structures, that previously were allocated
separately.

The most import one is the inpcb itself.  With embedding we can provide
strong guarantee that with a valid TCP inpcb the tcpcb is always valid
and vice versa.  Also we reduce number of allocs/frees per connection.
The embedded inpcb is placed in the beginning of the struct tcpcb,
since in_pcballoc() requires that.  However, later we may want to move
it around for cache line efficiency, and this can be done with a little
effort.  The new intotcpcb() macro is ready for such move.

The congestion algorithm data, the TCP timers and osd(9) data are
also embedded into tcpcb, and temprorary struct tcpcb_mem goes away.
There was no extra allocation here, but we went through extra pointer
every time we accessed this data.

One interesting side effect is that now TCP data is allocated from
SMR-protected zone.  Potentially this allows the TCP stacks or other
TCP related modules to utilize that for their own synchronization.

Large part of the change was done with sed script:

s/tp->ccv->/tp->t_ccv./g
s/tp->ccv/\&tp->t_ccv/g
s/tp->cc_algo/tp->t_cc/g
s/tp->t_timers->tt_/tp->tt_/g
s/CCV\(ccv, osd\)/\&CCV(ccv, t_osd)/g

Dependency side effect is that code that needs to know struct tcpcb
should also know struct inpcb, that added several <netinet/in_pcb.h>.

Differential revision:	https://reviews.freebsd.org/D37127
2022-12-07 09:00:48 -08:00
John Baldwin f6fdf9214a systat: Fix a bunch of use after frees in fetch_ifstat().
I think this was probably just a typo.  initifstat() continues around
a similar loop if the mib data fails to fetch, and fetch_ifstat() was
already using a FOREACH_SAFE loop here so expected to keep going.
Calling clearifstat() from the fetch routine also seems wrong, and the
sort_interface_list() call triggered by the existing needsort = 1 will
itself set needclear to trigger a future clearifstat().

Reported by:	GCC 12 -Wuse-after-free
Differential Revision:	https://reviews.freebsd.org/D36823
2022-11-22 11:11:42 -08:00
Gleb Smirnoff 51c0184297 systat: remove INP_TIMEWAIT 2022-10-06 19:24:37 -07:00
Randall Stewart 08af8aac2a Tcp progress timeout
Rack has had the ability to timeout connections that just sit idle automatically. This
feature of course is off by default and requires the user set it on (though the socket option
has been missing in tcp_usrreq.c). Lets get the progress timeout fully supported in
the base stack as well as rack.

Reviewed by: tuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D36716
2022-09-27 13:38:20 -04:00
Mateusz Piotrowski e6013eb071 systat.1: Fix lists
Some of the lists were not displaying correctly. Fix that.

Also, address linters errors.

Fixes:	22054f8891 Report I/O stats from the CAM_IOSCHED_DYNAMIC extension
MFC after:	1 week
2022-04-02 00:49:53 +02:00
Warner Losh 22054f8891 Report I/O stats from the CAM_IOSCHED_DYNAMIC extension
Report, on a periodic basis, the I/O latencies the CAM I/O scheduler
computes. These times are only for the hardware portion of the I/O as
measured from the time the operation is scheduled with the SIM using
xpt_action() until the SIM reports it has completed with xpt_dine(). Any
time the I/O operation spends in a software queue is no included.

The P50 (median), P90, P99 and P99.9 statistics about the latency of
each of the read, write and trim operations that completed during the
polling interval are reported. If there are fewer than 2, 10, 100 or
1000 operations during the polling interval, no statistic is reported
and a single dash '-' is displayed.

The read, write and trim commands (either on the command line or at run
time) toggle display of these operations. The color command toggles
color (it defaults to on, like gstat). When color is enabled, unknown
statistics are reported in blue, high latency for a statistics is
reported in red, medium in magenta and low in green (as with gstat). The
med= and hi= commands can set these latency thresholds.

Limitations: The entire sysctl space for all the devices is walked for
each polling period. This should be optimized to remember the OIDs and
only do such polling with the xpt generation changes. There is also no
way to filter devices displayed. This command only works on physical
devies that are connected to SCSI, ATA or NVME sims as those are the
only ones that are instrumented in the CAM I/O scheduler (the
CAM_IOSCHED_DYNAMIC option must be in the kernel, and the dynamic
scheduler can't be disabled).

MFC After:		1 month
Relnotes:		yes
Sponsored by:		Netflix
Reviewed by:		pauamma_gundo.com, chs
Differential Revision:	https://reviews.freebsd.org/D34259
2022-02-28 10:44:47 -07:00
Warner Losh 5e8e302087 systat: Eliminate write-only unit variable
Sponsored by:		Netflix
2022-02-07 14:51:45 -07:00
Warner Losh d167318506 systat/iostat: Use bools for numbers and kbpt
These are really bools, declare them as such.

Sponsored by:		Netflix
2022-02-07 14:51:45 -07:00
Peter Jeremy c9d1fa7003
systat: Display seconds in vmstat mode
Providing a timestamp with seconds granularity helps make it obvious
that the display is updating.

Reviewed by:    mckusick
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D29181
2022-01-29 20:41:19 +11:00
Kirk McKusick a115a4aa51 systat -vm: Humanize output for ease of reading.
Using 8 width is too wide for large numbers like 1379991K;
1330M is easier to read.

Submitted by: ota_j.email.ne.jp
Reviewed by:  mckusick
MFC after:    2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D33495
2022-01-01 19:48:06 -08:00
Mike Karels a2e7dfca86 systat: clean up code assuming network classes
Similar to netstat, clean up code that uses inet_lnaof() to check for
binding to "host 0" (lowest host on network) as a "network" bind.
Such things don't happen, and current networks are seldom if ever
found in /etc/networks.

MFC after:	1 month
Reviewers:	tuexen
Differential Revision: https://reviews.freebsd.org/D32720
2021-11-09 09:35:16 -06:00
Mateusz Guzik 932c2667d9 systat: fix stack overflow when running -iostat
The new buffer is arbitrarily sized to likely "big enough".

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-11-01 23:57:27 +00:00
Mateusz Guzik 6d88f9fed6 systat: mostly clean up warns
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-11-01 23:11:16 +00:00
Konstantin Belousov 57e5da2c98 Augment systat(1) -swap to display large swap space processes
This change updates the systat(1) -swap display to use libprocstat to
obtain and display per-process swap space usage infomation following its
existing swap devise/file statistics. It also incorporates the disk I/O
information from the -vmstat display.

The new screen looks like below with 'systat -swap':
                    /0   /1   /2   /3   /4   /5   /6   /7   /8   /9 /10
     Load Average   |

Device/Path       Size  Used |0%  /10  /20  /30  /40  / 60\  70\  80\ 90\ 100|
ada0s1b          2048M 2034M
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
zvol/sys/tempora 1024M 1015M
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
zvol/sys/swap    1024M 1014M
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Total            4096M 4063M
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Pid    Username   Command     Swap/Total Per-Process    Per-System
 24153 hiro       seamonkey   98M /   1G  7%              2%
 23677 hiro       xfce4-pane  28M /  81M 34% XXX          0%
 23629 hiro       xfce4-sess  25M / 118M 21% XX           0%
 23681 hiro       xfdesktop   20M /  58M 34% XXX          0%
 23678 hiro       thunar      15M /  43M 36% XXX          0%
 23658 hiro       at-spi-bus  14M /  23M 63% XXXXXX       0%
 23660 hiro       gvfsd       12M /  21M 56% XXXXX        0%

Disks  ada0  ada1  ada2   cd0 pass0 pass1 pass2 pass3
KB/t   8.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00
tps       0     0     0     0     1     0     0     0
MB/s   0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00
%busy     0     0     0     0     0     0     0     0

Submitted by:	Yoshihiro Ota
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29754
2021-10-26 15:50:29 +03:00
Baptiste Daroussin cbc83e378a ncurses: chase dependency changes in the source tree
Differential Revision:	https://reviews.freebsd.org/D32098
2021-10-04 11:38:24 +02:00
Kirk McKusick 9e16b9530a Clean up copyright messages.
Reported by:  Yoshihiro Ota
MFC after:    3 days
Differential Revision: https://reviews.freebsd.org/D29354
2021-05-10 23:14:35 -07:00
Michael Reifenberger 6648383803 systat: Handle SIGWINCH to properly window resizing and adjust
-swap disk stat based on new size.

Display corrupts after resizing a window.
Process SIGWINCH to redraw all window.

Submitted by:   Yoshihiro Ota ota@j.email.ne.jp
Differential Revision:  https://reviews.freebsd.org/D29337
2021-04-21 20:31:58 +02:00
Michael Reifenberger dcc2fb3707 systat: Avoid incorrect reallocation in pigs.c
Stop free() even if kvm_getprocs as we can come back but set nprocs = 0.
Check nprocs in showpigs() to ensure not try displaying with kvm_getprocs failed.
Current code can have pt with non-null after kvm_getprocs() failure.

Replace to realloc for simpler operations.

Submitted by:	Yoshihiro Ota ota@j.email.ne.jp
Reviewed by:	mckusick@
Differential Revision:	https://reviews.freebsd.org/D29303
2021-04-21 20:09:21 +02:00
Michael Reifenberger 8d06c3e7a4 Improve size readability.
Preserve more space for swap devise names.
Prevent line overflow with long devise name.
Don't draw a bar when swap is not used at all.
Simplify and optimize code.
Change the label to end at end of 100%.
PR:		251655
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27496
2021-02-15 20:23:32 +01:00
Mateusz Piotrowski e6f59be239 systat.1: Fix synopsis
systat does not have a "-display" flag. Use Ar to indicate that
"display" is meant to be substituted with an actual display command.

MFC after:	1 week
2021-02-10 18:09:49 +01:00
Mateusz Piotrowski fcbaf46b76 systat.1: Remove Tn macros
They are no longer supported by mdoc(7).

MFC after:	1 week
2021-02-10 18:09:27 +01:00
Stefan Eßer dbb25cbe55 Adjust to display more than 999 sleeping threads 2020-12-27 22:32:22 +01:00
Stefan Eßer 6fe8fbdc1c Statistics are for threads, not processes 2020-12-27 22:32:22 +01:00
Michael Reifenberger 2717b998b2 Improve number reading by rounding up to a next unit earlier for memory display.
Submitted by:	ota@j.email.ne.jp
Differential Revision:	https://reviews.freebsd.org/D26503
2020-11-21 19:14:11 +00:00
Michael Reifenberger 4b9ac8a0a6 Handle device removal and removal+add cases to fix infinity rate.
PR:		219829
Submitted by:	ota@j.email.ne.jp
Reported by:	rezo@live.cn
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25226
2020-07-11 13:56:36 +00:00
Michael Reifenberger 9a8fc6bba3 Introduce sysputpage() to display large page size with human readable format.
Using UI units allows to fit larger numbers in columns.
Stop calling v_page_size - this is a value that doesn't change at runtime.
Renamed WINDOW *wnd to *wd to avoid conflict with global *wnd variable.
Use bit-shift to convert page size to byte.

PR:             246458
Submitted by:   ota@j.email.ne.jp
MFC after: 2 weeks
Differential Revision:  D24834
2020-05-15 17:37:08 +00:00
Michael Reifenberger b4532d408d Add missing sysput.c
PR:		237664
Submitted by:	ota@j.email.ne.jp
Reported by:	imb, cy
2020-05-11 21:22:16 +00:00
Michael Reifenberger 4bde63536c Patch systat -zarc to display cumulative rate and round down large numbers by SI units
PR:		237664
Submitted by:	ota@j.email.ne.jp
MFC after:	2 weeks
2020-05-11 20:34:52 +00:00
Kyle Evans 9a9f88cc11 systat: remove redundant definition of kd
kd is already properly declared in extern.h and defined in main.c, rendering
this definition useless. This fixes the -fno-common build.

MFC after:	3 days
2020-03-29 02:30:23 +00:00
Cy Schubert 5452c16c21 Sync with r356645. desiredvnodes is now maxvnodes. 2020-01-13 06:55:38 +00:00
Cy Schubert a4b840be50 As of r356642 desiredvnodes is u_long. 2020-01-13 06:55:35 +00:00
Tom Jones 2946a9415c Add stat counter for ipv6 atomic fragments
Add a stat counter to track ipv6 atomic fragments. Atomic fragments can be
generated in response to invalid path MTU values, but are also a potential
attack vector and considered harmful (see RFC6946 and RFC8021).

While here add tracking of the atomic fragment counter to netstat and systat.

Reviewed by:    tuexen, jtl, bz
Approved by:    jtl (mentor), bz (mentor)
Event:  Aberdeen hackathon 2019
Differential Revision:  https://reviews.freebsd.org/D17511
2019-04-19 17:06:43 +00:00
Michael Reifenberger 4551884596 systat -zarc to display disk activities like -vm
PR:		213310
Submitted by:	ota
MFH:		4 weeks
Differential Revision:	https://reviews.freebsd.org/D18726
2019-04-02 14:01:03 +00:00
Oleksandr Tymoshenko d65e72a818 Fix systat's :only command parser for the multiple arguments case
According to systat(1) :only option is supposed to accept multiple drives
but the parser for its arguments stops after first entry. Fix the parser
logic to accept multiple drives.

PR:		59220
Reported by:	Andy Farkas <andyf@speednet.com.au>
MFC after:	1 week
2019-01-23 02:46:35 +00:00