Page MenuHomeFreeBSD

phys_alloc_seg_contig: don't allocate past seg->end
ClosedPublic

Authored by dougm on Jan 12 2022, 5:47 PM.
Tags
None
Referenced Files
F108664497: D33870.diff
Mon, Jan 27, 4:13 AM
F108558442: D33870.id101379.diff
Sun, Jan 26, 8:10 AM
Unknown Object (File)
Sun, Jan 26, 1:13 AM
Unknown Object (File)
Dec 5 2024, 9:40 AM
Unknown Object (File)
Dec 4 2024, 4:45 PM
Unknown Object (File)
Nov 26 2024, 5:34 PM
Unknown Object (File)
Nov 18 2024, 5:18 PM
Unknown Object (File)
Nov 18 2024, 3:51 PM
Subscribers

Details

Summary

In vm_phys_alloc_seg_contig, check alignment before checking orders of multiple memory blocks, to avoid such deeply nested code. In checking multiple memory blocks, check seg->end only once, against pa_end because there's no need to repeat the test for consecutive values of pa, and because the current code, in the case that pa reaches pa_end and passes seg->end in the same iteration, proceeds to allocate that memory.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm requested review of this revision.Jan 12 2022, 5:47 PM
dougm created this revision.

Undo change involving fictitious seg.

dougm edited the summary of this revision. (Show Details)

Remove some offensive parts.

Update, rearrange comments.

sys/vm/vm_phys.c
1456

insert a blank before the block comment

1462

pa += 1 << (PAGE_SHIFT + VM_NFREEORDER - 1);

then you are shifting by a constant and the compiler will warn if overflow occurs

1463

oind -> VM_NFREEORDER - 1

1465–1466

put this inside the loop

dougm marked 4 inline comments as done.

Accept all proffered advice.

This revision is now accepted and ready to land.Jan 18 2022, 6:05 PM
This revision was automatically updated to reflect the committed changes.