Page MenuHomeFreeBSD

Export kernel malloc sizes
ClosedPublic

Authored by mjg on Oct 30 2020, 7:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 8, 8:41 AM
Unknown Object (File)
Fri, Mar 8, 8:40 AM
Unknown Object (File)
Fri, Mar 8, 8:40 AM
Unknown Object (File)
Fri, Mar 8, 8:40 AM
Unknown Object (File)
Fri, Mar 8, 8:28 AM
Unknown Object (File)
Dec 22 2023, 5:44 PM
Unknown Object (File)
Dec 20 2023, 6:18 AM
Unknown Object (File)
Dec 16 2023, 9:33 PM
Subscribers

Details

Summary

Nothing exports zones as used by malloc and vmstat blindly assumes it is just powers of 2.

This is a prerequisite to add any extra zones to malloc, but it stands as an improvement on its own. The current dependency is a bug.

I think the patch in the current form is committable (modulo perhaps some names).

Test Plan

Added extra zones:

diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index b7d7e0c2d4b..a981ff0d9e4 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -158,7 +158,11 @@ struct {
 } kmemzones[] = {
        {16, "16", },
        {32, "32", },
+       {48, "48", },
        {64, "64", },
+       {80, "80", },
+       {96, "96", },
+       {112, "112", },
        {128, "128", },
        {256, "256", },
        {512, "512", },

And a toy malloc type. Confirmed the sizes get reported and the allocation done with toy type is correctly reported.

vmstat -m and vmstat -M /dev/mem -m agree on the state.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mjg requested review of this revision.Oct 30 2020, 7:55 PM
sys/kern/kern_malloc.c
231 ↗(On Diff #78985)

Duplicated description.

usr.bin/vmstat/vmstat.c
1423 ↗(On Diff #78985)

This won't work if running against a vmcore.

mjg edited the summary of this revision. (Show Details)
mjg edited the test plan for this revision. (Show Details)

Rework the patch.

markj added inline comments.
lib/libmemstat/memstat_malloc.c
458 ↗(On Diff #78999)

These lines are too long.

541 ↗(On Diff #78999)

It should probably be ((uint64_t)1 << n).

This revision is now accepted and ready to land.Nov 2 2020, 2:16 PM