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
F96644551: D33870.diff
Wed, Sep 25, 9:16 PM
Unknown Object (File)
Thu, Sep 19, 7:57 PM
Unknown Object (File)
Thu, Sep 19, 4:54 AM
Unknown Object (File)
Wed, Sep 18, 3:02 AM
Unknown Object (File)
Sun, Sep 15, 9:11 AM
Unknown Object (File)
Wed, Sep 11, 1:47 PM
Unknown Object (File)
Fri, Sep 6, 2:12 AM
Unknown Object (File)
Thu, Sep 5, 8:14 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.