Page MenuHomeFreeBSD

vm_map_submap(): Avoid unnecessary clipping.
ClosedPublic

Authored by markj on Jan 21 2020, 3:41 PM.
Tags
None
Referenced Files
F132379615: D23299.id67103.diff
Thu, Oct 16, 9:40 AM
F132379610: D23299.id67108.diff
Thu, Oct 16, 9:40 AM
F132379599: D23299.id.diff
Thu, Oct 16, 9:40 AM
F132379596: D23299.id67210.diff
Thu, Oct 16, 9:39 AM
Unknown Object (File)
Wed, Oct 15, 9:57 PM
Unknown Object (File)
Mon, Oct 13, 2:14 AM
Unknown Object (File)
Sun, Oct 12, 10:14 AM
Unknown Object (File)
Sat, Oct 4, 1:16 PM

Details

Summary

A submap can only be created from an entry spanning the entire request
range. In particular, if vm_map_lookup_entry() returns false or the
returned entry contains "end".

I don't think this represents any functional change since we only use
submaps in one place, and that is unaffected.

This is based on a patch submitted by Wuyang Chung.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/vm/vm_map.c
2485 ↗(On Diff #67103)

Doesn't the 'end' test in line 2481 ensure that this line does nothing? It doesn't seem to represent the test "the returned entry contains end".

sys/vm/vm_map.c
2485 ↗(On Diff #67103)

I don't quite follow: we can't treat the entry as a submap if it doesn't contain "end", but before turning into a submap we must clip it to ensure that it does not extend beyond "end".

sys/vm/vm_map.c
2485 ↗(On Diff #67103)

vm_map_clip_end:

if ((endaddr) < (entry->end)) \ ...

but line 2481 ensures that we get here only if entry->end <= end. So vm_map_clip_end is a no-op.

I'm have no view on what submaps should or should not do. I'm just trying to understand why clip-end needs to be called when the need to clip has been ruled out already.

Fix a backwards comparison.

sys/vm/vm_map.c
2485 ↗(On Diff #67103)

Sorry, I see now. The comparison is backwards. I'm not sure how I was able to boot with the original patch.

This revision is now accepted and ready to land.Jan 21 2020, 7:45 PM
This revision was automatically updated to reflect the committed changes.