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
Unknown Object (File)
Mon, Nov 11, 4:06 PM
Unknown Object (File)
Mon, Nov 11, 9:22 AM
Unknown Object (File)
Sun, Nov 10, 8:28 PM
Unknown Object (File)
Sun, Nov 10, 8:12 PM
Unknown Object (File)
Sat, Nov 9, 4:37 PM
Unknown Object (File)
Wed, Oct 23, 10:20 AM
Unknown Object (File)
Wed, Oct 23, 7:00 AM
Unknown Object (File)
Sep 26 2024, 9:45 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.