Page MenuHomeFreeBSD

vm_phys; fix uncalled free_contig
ClosedPublic

Authored by dougm on Dec 4 2023, 5:16 AM.
Tags
None
Referenced Files
F85180917: D42891.id131586.diff
Sun, Jun 2, 4:54 PM
Unknown Object (File)
Mon, May 6, 4:43 PM
Unknown Object (File)
Apr 25 2024, 10:38 PM
Unknown Object (File)
Mar 13 2024, 12:32 AM
Unknown Object (File)
Dec 31 2023, 4:05 PM
Unknown Object (File)
Dec 31 2023, 3:08 PM
Unknown Object (File)
Dec 27 2023, 12:27 AM
Unknown Object (File)
Dec 24 2023, 9:57 PM
Subscribers

Details

Summary

Function vm_phys_free_contig does not always free memory properly when that memory was just allocated with vm_phys_alloc_contig. Change it to free memory properly in all cases.

vm_phys_free_contig was defined, and invoked, in a case when the npages parameter was necessarily bigger than the number of pages in the largest free block of the allocator, but neither its name nor its documentation suggested that it was broken for smaller values of npages. Since then, changes have removed all the calls to this function, so it's correctness doesn't matter much, but testing with a dynamically loaded module that calls vm_phys_free_contig with a too-small npages parameter corrupts memory management structures and should be corrected.

Test Plan

It takes dynamically loading a module I've written to test it. Tests that broke the kernel no longer do so.

Diff Detail

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

Event Timeline

dougm requested review of this revision.Dec 4 2023, 5:16 AM
dougm created this revision.
sys/vm/vm_phys.c
1230

The more common spelling in this file is atop(VM_PAGE_TO_PHYS(m)).

1231

If npages is 1, we'll compute max_order = min(flsll(0) - 1, VM_NFREEORDER - 1) and get max_order = VM_NFREEORDER - 1, but that's not correct.

This revision is now accepted and ready to land.Dec 20 2023, 3:00 PM
This revision was automatically updated to reflect the committed changes.