Page MenuHomeFreeBSD

Introduce m_get3()
ClosedPublic

Authored by kp on Aug 7 2021, 8:05 PM.

Details

Summary

Introduce m_get3() which is similar to m_get2(), but can allocate up to
MJUM16BYTES bytes (m_get2() can only allocate up to MJUMPAGESIZE).

This simplifies the bpf improvement in f13da24715.

Suggested by: glebius

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kp requested review of this revision.Aug 7 2021, 8:05 PM

Q: why can’t we extend m_get2 to not fail for 9..16k packets?

Please do not introduce new usages of mbuf clusters > PAGE_SIZE into
the network stack. When under memory pressure attempting to
allocating >PAGE_SIZE clusters will DoS the whole system if done at
the packet rates seen on modern networks.

Please do not introduce new usages of mbuf clusters > PAGE_SIZE into
the network stack. When under memory pressure attempting to
allocating >PAGE_SIZE clusters will DoS the whole system if done at
the packet rates seen on modern networks.

This particular use case (in f13da24715a7) is for bpf, so not directly in the data path, and it shouldn't be allocating millions of times per second. I suppose that does form a good argument for not extending m_get2() rather than having an m_get3() (or keeping the current bpf approach of m_get2()/m_getjcl()).

glebius added a subscriber: glebius.
glebius added inline comments.
sys/kern/kern_mbuf.c
1387

Can we short circuit beginning of the function to m_get2()?

if (size <= MJUMPAGESIZE)

return (m_get2(size, how, type, flags);
1411

Should be updated to m_free_raw(m) after the recent changes.

This revision is now accepted and ready to land.Aug 16 2021, 4:45 PM
This revision now requires review to proceed.Aug 17 2021, 7:09 AM
This revision is now accepted and ready to land.Aug 17 2021, 5:19 PM
This revision was automatically updated to reflect the committed changes.