Commit Graph

376 Commits

Author SHA1 Message Date
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
Oleksandr Tymoshenko
e457729f18 Fix inconsistency in return values introduced by r343222
Consistently return 1 or the case of missing arguments in both functions

PR:		219689
MFC after:	1 week
X-MFC-With:	343222
2019-01-20 19:55:54 +00:00
Oleksandr Tymoshenko
13fe9f7f82 Fix crash in systat(4) when certain commands are called without arguments
Add check for missing arguments to dsmatchselect and dsselect

PR:		219689
Submitted by:	Marko Turk <mt@markoturk.info>
MFC after:	1 week
2019-01-20 19:47:33 +00:00
Michael Tuexen
970bdbf5d7 Fix printing of 64-bit counters on 32-bit ppc platforms.
Several statistic counters are uint64_t values and are printed by systat
using %lu. This results in displaying wrong numbers. Use PRIu64 instead.
While there, print variables of size_t using %zd.

MFC after:i		3 days
Differential Revision:	https://reviews.freebsd.org/D17838
2018-11-12 13:26:13 +00:00
Cy Schubert
61bbe5bf9f Chasing r337661, fix systat after arc accounting change. 2018-08-12 07:47:44 +00:00
Xin LI
80cb4b11eb Don't leak tmpstr.
MFC after:	2 weeks
2018-06-21 07:42:28 +00:00
Dag-Erling Smørgrav
6bff85ff9a Reduce <sys/queue.h> pollution.
While <sys/sysctl.h> includes <sys/queue.h> unconditionally, it is only
actually used in code which is conditional on _KERNEL.  Make the #include
itself conditional as well, and fix userland code that uses <sys/queue.h>
for other purposes but relied on <sys/sysctl.h> to bring it in.

MFC after:	1 week
2018-05-11 00:01:43 +00:00
Michael Tuexen
2caa5afc9c Don't show the number of currently established SCTP associations,
since this is not monotonically increasing. It's number can be
derived from the other counters shown.

MFC after:	3 days
2018-04-10 08:19:14 +00:00
Michael Tuexen
9f0abda051 Retire SCTP_WITH_NO_CSUM option.
This option was used in the early days to allow performance measurements
extrapolating the use of SCTP checksum offloading. Since this feature
is now available, get rid of this option.
This also un-breaks the LINT kernel. Thanks to markj@ for making me
aware of the problem.
2017-12-07 22:19:08 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Konstantin Belousov
1b7a3d1f5f Order declarations alphabetically.
Match signess of the format and the value.

Noted by:	bde
Sponsored by:	The FreeBSD Foundation
2017-11-22 22:04:27 +00:00
Konstantin Belousov
90dd3e79cc systat: use and correctly display 64bit counters.
Following struct vmtotal changes, make systat use and correctly
display 64-bit counters.  Switch to humanize_number(3) to overcome
homegrown arithmetics limits in pretty printing large numbers.  Use
1024 as a divisor for memory fields to make it consistent with other
tools and users expectations.

Submitted by:	Pawel Biernacki <pawel.biernacki@gmail.com>
Sponsored by:	Mysterious Code Ltd.
PR:	2137
Differential revision:	https://reviews.freebsd.org/D13105
2017-11-21 19:55:32 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Bryan Drewery
ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Gleb Smirnoff
0e229f343f Hide struct socket and struct unpcb from the userland.
Violators may define _WANT_SOCKET and _WANT_UNPCB respectively and
are not guaranteed for stability of the structures.  The violators
list is the the usual one: libprocstat(3) and netstat(1) internally
and lsof in ports.

In struct xunpcb remove the inclusion of kernel structure and add
a bunch of spare fields.  The xsocket already has socket not included,
but add there spares as well.  Embed xsockbuf into xsocket.

Sort declarations in sys/socketvar.h to separate kernel only from
userland available ones.

PR:		221820 (exp-run)
2017-10-02 23:29:56 +00:00
Jung-uk Kim
795cd431cb Fix systat(1) regression. It was broken by r317061. 2017-04-20 22:30:39 +00:00