From 9628d3dbf8d90a560573b5f82b1e52e3b2eb4605 Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 19 Mar 2012 18:47:34 +0000 Subject: 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@. --- sys/vm/vm_map.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'sys/vm/vm_map.c') 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 ); } -- cgit v1.1