Created attachment 251155 [details] mbuf_leak.c Before run program: # netstat -m 1067/9868/10935 mbufs in use (current/cache/total) 1024/6596/7620/4062959 mbuf clusters in use (current/cache/total/max) 0/4318 mbuf+clusters out of packet secondary zone in use (current/cache) 0/4318/4318/2031479 4k (page size) jumbo clusters in use (current/cache/total/max) 0/0/0/601919 9k jumbo clusters in use (current/cache/total/max) 0/0/0/338579 16k jumbo clusters in use (current/cache/total/max) 2314K/32931K/35245K bytes allocated to network (current/cache/total) 0/0/0 requests for mbufs denied (mbufs/clusters/mbuf+clusters) 0/0/0 requests for mbufs delayed (mbufs/clusters/mbuf+clusters) 0/0/0 requests for jumbo clusters delayed (4k/9k/16k) 0/0/0 requests for jumbo clusters denied (4k/9k/16k) 0 sendfile syscalls 0 sendfile syscalls completed without I/O request 0 requests for I/O initiated by sendfile 0 pages read by sendfile as part of a request 0 pages were valid at time of a sendfile request 0 pages were valid and substituted to bogus page 0 pages were requested for read ahead by applications 0 pages were read ahead by sendfile 0 times sendfile encountered an already busy page 0 requests for sfbufs denied 0 requests for sfbufs delayed After run: # netstat -m 17981378/324922/18306300 mbufs in use (current/cache/total) 1025/7611/8636/4062959 mbuf clusters in use (current/cache/total/max) 1/4571 mbuf+clusters out of packet secondary zone in use (current/cache) 0/4572/4572/2031479 4k (page size) jumbo clusters in use (current/cache/total/max) 0/0/0/601919 9k jumbo clusters in use (current/cache/total/max) 0/0/0/338579 16k jumbo clusters in use (current/cache/total/max) 4497394K/114740K/4612135K bytes allocated to network (current/cache/total) 0/0/0 requests for mbufs denied (mbufs/clusters/mbuf+clusters) 0/0/0 requests for mbufs delayed (mbufs/clusters/mbuf+clusters) 0/0/0 requests for jumbo clusters delayed (4k/9k/16k) 0/0/0 requests for jumbo clusters denied (4k/9k/16k) 0 sendfile syscalls 0 sendfile syscalls completed without I/O request 0 requests for I/O initiated by sendfile 0 pages read by sendfile as part of a request 0 pages were valid at time of a sendfile request 0 pages were valid and substituted to bogus page 0 pages were requested for read ahead by applications 0 pages were read ahead by sendfile 0 times sendfile encountered an already busy page 0 requests for sfbufs denied 0 requests for sfbufs delayed
Created attachment 251158 [details] mbuf_leak.c fixed typo
Possibly related to https://reviews.freebsd.org/D45443 ?
(In reply to Mark Johnston from comment #2) Yes, it's related. After apply D45443, memory consumption returned to normal.
Can you please test these two? https://reviews.freebsd.org/D45477 https://reviews.freebsd.org/D45478
(In reply to Gleb Smirnoff from comment #4) Memory leak fixed!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=a9b55a66440ce67e545b60f2861badbfc5ec6327 commit a9b55a66440ce67e545b60f2861badbfc5ec6327 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2024-06-04 00:22:33 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2024-06-04 00:23:06 +0000 unix: use m_freemp() when disposing unix socket buffers The new unix/dgram uses m_nextpkt linkage, while the old unix/stream uses m_next linkage. This fixes memory leak. Diagnosed by: khng Reviewed by: khng, markj PR: 279467 Fixes: 458f475df8e5912609c14208c189414a8255c738 Differential Revision: https://reviews.freebsd.org/D45478 MFC After: 1 week sys/kern/uipc_usrreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
I guess we can close this now?
(In reply to Daniel Engberg from comment #7) The commit still needs to be MFCed. (And probably we need to release an EN for this...?)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f70581ff7d556aa49a130fa24c876e74b877278c commit f70581ff7d556aa49a130fa24c876e74b877278c Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2024-06-11 01:31:08 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2024-06-11 01:31:08 +0000 unix: use m_freemp() when disposing unix socket buffers The new unix/dgram uses m_nextpkt linkage, while the old unix/stream uses m_next linkage. This fixes memory leak. Diagnosed by: khng Reviewed by: khng, markj PR: 279467 Fixes: 458f475df8e5912609c14208c189414a8255c738 Differential Revision: https://reviews.freebsd.org/D45478 (cherry picked from commit a9b55a66440ce67e545b60f2861badbfc5ec6327) sys/kern/uipc_usrreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)