What does the state of the sbwait process at the top of FreeBSD mean?

On FreeBSD, at the top exit below, the mysql daemon is in the "sbwait" state. What does it mean?

last pid: 12833; load averages: 0.18, 0.26, 0.25 up 3+17:40:21 04:58:46 26 processes: 1 running, 25 sleeping CPU: 16.5% user, 0.0% nice, 12.8% system, 6.8% interrupt, 63.9% idle Mem: 184M Active, 137M Inact, 88M Wired, 6308K Cache, 53M Buf, 7192K Free Swap: 4096M Total, 420K Used, 4095M Free PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND 1772 mysql 17 30 0 224M 165M sbwait 511:31 14.79% mysqld 12833 root 1 20 0 9944K 1488K RUN 0:00 0.10% top 1472 root 1 20 0 9612K 828K select 5:07 0.00% powerd 1465 root 1 20 0 11296K 1644K select 2:01 0.00% ntpd 1804 root 1 20 0 11324K 2140K select 0:37 0.00% sendmail 1403 root 1 20 0 12200K 2320K select 0:27 0.00% nmbd 1814 root 1 20 0 9644K 1004K nanslp 0:08 0.00% cron 1407 root 1 20 0 20756K 3756K select 0:06 0.00% smbd 1273 root 1 20 0 9612K 1036K select 0:04 0.00% syslogd 11937 root 1 20 0 15788K 3124K select 0:03 0.00% sshd 1808 smmsp 1 20 0 11324K 1864K pause 0:01 0.00% sendmail 1438 root 1 20 0 20840K 3696K select 0:00 0.00% smbd 1111 _dhcp 1 20 0 9540K 1136K select 0:00 0.00% dhclient 11941 root 1 20 0 10940K 2024K pause 0:00 0.00% csh 1517 mysql 1 52 0 9924K 1072K wait 0:00 0.00% sh 1073 root 1 47 0 9540K 1012K select 0:00 0.00% dhclient 1797 root 1 20 0 13064K 1892K select 0:00 0.00% sshd 
+6
source share
2 answers

This means that one of the process threads in the process is waiting for data to arrive on the socket. The top mode by default is not very informative for a thread process such as mysqld; while you have 17 mysql threads, top can only show one of them in this mode. You must use the “-H” flag at the top (or the “H” keyboard command at the top) to see the individual threads separately, which will show each individual report.

+6
source

Use source:

 find /usr/src -type f -exec grep -H sbwait {} \+ 

This will give you some files to view.

See /usr/src/sys/kern/uipc_sockbuf.c :

 /* * Wait for data to arrive at/drain from a socket buffer. */ int sbwait(struct sockbuf *sb) { SOCKBUF_LOCK_ASSERT(sb); sb->sb_flags |= SB_WAIT; return (msleep(&sb->sb_cc, &sb->sb_mtx, (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH, "sbwait", sb->sb_timeo)); } 
+3
source

Source: https://habr.com/ru/post/922911/