Bug 279467 - mbuf leaks in PF_LOCAL
Summary: mbuf leaks in PF_LOCAL
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Gleb Smirnoff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-02 12:12 UTC by Dmitry Wagin
Modified: 2024-06-11 02:01 UTC (History)
4 users (show)

See Also:


Attachments
mbuf_leak.c (1.02 KB, text/plain)
2024-06-02 12:12 UTC, Dmitry Wagin
no flags Details
mbuf_leak.c (1001 bytes, text/plain)
2024-06-02 13:56 UTC, Dmitry Wagin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Wagin 2024-06-02 12:12:18 UTC
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
Comment 1 Dmitry Wagin 2024-06-02 13:56:48 UTC
Created attachment 251158 [details]
mbuf_leak.c

fixed typo
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2024-06-02 14:00:20 UTC
Possibly related to https://reviews.freebsd.org/D45443 ?
Comment 3 Dmitry Wagin 2024-06-02 14:57:54 UTC
(In reply to Mark Johnston from comment #2)

Yes, it's related.

After apply D45443, memory consumption returned to normal.
Comment 4 Gleb Smirnoff freebsd_committer freebsd_triage 2024-06-03 20:13:48 UTC
Can you please test these two?

https://reviews.freebsd.org/D45477
https://reviews.freebsd.org/D45478
Comment 5 Dmitry Wagin 2024-06-03 20:38:46 UTC
(In reply to Gleb Smirnoff from comment #4)

Memory leak fixed!
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-06-04 00:24:19 UTC
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(-)
Comment 7 Daniel Engberg freebsd_committer freebsd_triage 2024-06-06 14:27:42 UTC
I guess we can close this now?
Comment 8 Mark Johnston freebsd_committer freebsd_triage 2024-06-06 14:50:46 UTC
(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...?)
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-06-11 01:34:19 UTC
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(-)