Page MenuHomeFreeBSD

Eliminate MAXCPU from subr_smp.c
ClosedPublic

Authored by kib on May 5 2023, 8:28 PM.
Tags
None
Referenced Files
F82866515: D39981.diff
Fri, May 3, 8:55 AM
Unknown Object (File)
Mar 4 2024, 9:56 PM
Unknown Object (File)
Mar 4 2024, 9:56 PM
Unknown Object (File)
Mar 4 2024, 9:56 PM
Unknown Object (File)
Mar 4 2024, 9:56 PM
Unknown Object (File)
Feb 13 2024, 11:40 AM
Unknown Object (File)
Feb 10 2024, 10:02 AM
Unknown Object (File)
Dec 20 2023, 7:06 AM
Subscribers

Details

Summary
smp_topo: dynamically allocate group array

Limit its size to mp_maxid + 1 times MAX_CACHE_LEVELS instead MAXCPU.
Allocate the array on the first call into smp_topo(9) functions, where
the mp_maxid is already known.
quiesce_cpus(): do not overallocate generation array

Also switch to mallocarray().

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.May 5 2023, 8:28 PM

BTW, tcp_init_hptsi() calls smp_topo() - does it allocate a second copy of the topology?

This revision is now accepted and ready to land.May 7 2023, 5:58 PM

BTW, tcp_init_hptsi() calls smp_topo() - does it allocate a second copy of the topology?

I do not think so. Thee function

BTW, tcp_init_hptsi() calls smp_topo() - does it allocate a second copy of the topology?

Out of the existing group[] array, yes. So in theory it could overflow the array and corrupt unrelated memory.
I think we should make smp_topo() idempotent.

Make smp_topo() idempotent.

This revision now requires review to proceed.May 7 2023, 6:40 PM
sys/kern/subr_smp.c
729

These two lines can just be top = smp_topo_alloc(1);, right? That is, can group become private to smp_topo_alloc()?

kib marked an inline comment as done.

Move the 'group' variable to smp_topo_alloc().

markj added inline comments.
sys/kern/subr_smp.c
783
805
This revision is now accepted and ready to land.May 9 2023, 2:12 PM
sys/kern/subr_smp.c
783

Do you think it affects anything? Because the 'child' variable slides over the 'group' array in the below loop, without coordinating with the allocator.

Or rather, if it changes anything for the patch, it is pre-existing bug.

sys/kern/subr_smp.c
783

I don't think it affects anything, but it looks wrong.

smp_topo(): correct allocation sizes for trivial topologies

This revision now requires review to proceed.May 9 2023, 3:11 PM
This revision is now accepted and ready to land.May 9 2023, 3:16 PM