summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_map.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2012-03-19 18:47:34 +0000
committerjhb <jhb@FreeBSD.org>2012-03-19 18:47:34 +0000
commit9628d3dbf8d90a560573b5f82b1e52e3b2eb4605 (patch)
tree241c7fa3e8584990822d1ad78f12a03bb221b953 /sys/vm/vm_map.c
parent2e0db42a5f7e8ff9bb190dd0a5ac5475580cb905 (diff)
downloadFreeBSD-src-9628d3dbf8d90a560573b5f82b1e52e3b2eb4605.zip
FreeBSD-src-9628d3dbf8d90a560573b5f82b1e52e3b2eb4605.tar.gz
Fix madvise(MADV_WILLNEED) to properly handle individual mappings larger
than 4GB. Specifically, the inlined version of 'ptoa' of the the 'int' count of pages overflowed on 64-bit platforms. While here, change vm_object_madvise() to accept two vm_pindex_t parameters (start and end) rather than a (start, count) tuple to match other VM APIs as suggested by alc@.
Diffstat (limited to 'sys/vm/vm_map.c')
-rw-r--r--sys/vm/vm_map.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index a180601..6198629 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -2100,8 +2100,7 @@ vm_map_madvise(
}
vm_map_unlock(map);
} else {
- vm_pindex_t pindex;
- int count;
+ vm_pindex_t pstart, pend;
/*
* madvise behaviors that are implemented in the underlying
@@ -2119,30 +2118,29 @@ vm_map_madvise(
if (current->eflags & MAP_ENTRY_IS_SUB_MAP)
continue;
- pindex = OFF_TO_IDX(current->offset);
- count = atop(current->end - current->start);
+ pstart = OFF_TO_IDX(current->offset);
+ pend = pstart + atop(current->end - current->start);
useStart = current->start;
if (current->start < start) {
- pindex += atop(start - current->start);
- count -= atop(start - current->start);
+ pstart += atop(start - current->start);
useStart = start;
}
if (current->end > end)
- count -= atop(current->end - end);
+ pend -= atop(current->end - end);
- if (count <= 0)
+ if (pstart >= pend)
continue;
- vm_object_madvise(current->object.vm_object,
- pindex, count, behav);
+ vm_object_madvise(current->object.vm_object, pstart,
+ pend, behav);
if (behav == MADV_WILLNEED) {
vm_map_pmap_enter(map,
useStart,
current->protection,
current->object.vm_object,
- pindex,
- (count << PAGE_SHIFT),
+ pstart,
+ ptoa(pend - pstart),
MAP_PREFAULT_MADVISE
);
}
OpenPOWER on IntegriCloud