There is code for creating objects to back map entries that is duplicated, and this change seeks to eliminate that duplication.
Details
Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Add a 'modify' argument to vm_map_lookup_clip_start and use it everywhere vm_map_clip_start is used now.
vm_map.c | ||
---|---|---|
2065–2066 | May be convert this to static function (optionally inline) ? | |
2071 | Assert that entry->object.vm_object == NULL. | |
2094 | Assert locks. Assert that the entry is not a submap. | |
2100 | Use the opportunity to fix indentation of these two lines. | |
2597–2598 | I prefer to either have {} in both branches for if(), or to not have {} in both. |
vm_map.c | ||
---|---|---|
2123 | Do we need this function standalone ? If vm_map_clip_start() do at the very beginning if(start <= entry->start) return; and then put the body of the _vm_map_clip_start(), it seems to make the code simpler. I believe the old structure was for some quite non-optimizing compiler. |
vm_map.c | ||
---|---|---|
2090 | The comment doesn't really make sense anymore; what does "now" mean? | |
2110 | I don't really understand the purpose of lifting this portion out into a separate function: it doesn't eliminate any duplication. I also find it hard to reason about what this function is supposed to do given its name. | |
2130 | Can't the assertion come before the check? | |
3850 | IMO it would be more natural to return the new object from vm_map_entry_attach_backing_object(). |
vm_map.c | ||
---|---|---|
2090 | I have tried to make it more sensible. | |
2110 | The code appears in both clip_start and clip_end functions, so that duplication is removed. I could change the name vm_map_entry_find_backing_object, but if I drop "vm_map_entry", Alan will object, and if I drop "backing_object", I'm dropping what the comment that precedes this code block says it's about. It either creates a backing object, or uses one already there. Maybe I can do better than "find"? | |
2130 | Okay. | |
3850 | In one place, I would cast away the returned result. In the other, I would get to drop one assignment line, but I would also need to shorten the function name to fit in 80 columns after doing proper line wrapping. |
vm_map.c | ||
---|---|---|
2110 | What about vm_map_entry_clip_object() ? |
vm_map.c | ||
---|---|---|
2110 | I'm willing to do it, if that will satisfy everyone, but I don't think that name makes much sense. It seems like the actual clipping depends on a 'start' or 'end' value that isn't passed to this function. |
vm_map.c | ||
---|---|---|
3850 | ... implied by virtue of the fact that the function doesn't take an object parameter. |
vm_map.c | ||
---|---|---|
2168–2169 | This can't compile. |
Fixed syntax error. Snuck a minute on the test box to verify that there were no other syntax errors arising from this patch to this file in one particular configuration.
Drop an inessential assertion. It would be useful to keep it, to see if any callers led it to fail so that those callers could be taught not to send out-of-bounds addresses. But it's not essential to correctness here.
Restrict the scope of this patch just to reducing code duplication. On this amd64, it reduces the size of vm_map.o from 456608 to 455816, with no obvious impact on performance.
vm_map.c | ||
---|---|---|
2071 | You did not asserted that the map is locked there. |
vm_map.c | ||
---|---|---|
2071 | There is no map here. I could assert something in the caller, or pass a map here so that I could assert that it is locked. In the case of the call from *_fork, I'm not sure which map I would assert as locked. |
vm_map.c | ||
---|---|---|
2071 | That would be the map which owns the entry. But ok, I think it is fine to not add an argument only used for assert. |