svn commit: r316073 - in stable/11/sys: dev/drm dev/drm2 kern vm
Konstantin Belousov
kib at FreeBSD.org
Tue Mar 28 06:08:01 UTC 2017
Author: kib
Date: Tue Mar 28 06:07:59 2017
New Revision: 316073
URL: https://svnweb.freebsd.org/changeset/base/316073
Log:
MFC r315281:
Use atop() instead of OFF_TO_IDX() for convertion of addresses or
addresses offsets, as intended.
MFC r315580 (by alc):
Simplify the logic for clipping the range returned by the pager to fit
within the map entry.
Use atop() rather than OFF_TO_IDX() on addresses.
Modified:
stable/11/sys/dev/drm/drm_scatter.c
stable/11/sys/dev/drm2/drm_scatter.c
stable/11/sys/kern/kern_proc.c
stable/11/sys/kern/vfs_bio.c
stable/11/sys/vm/vm_fault.c
stable/11/sys/vm/vm_kern.c
stable/11/sys/vm/vm_map.c
stable/11/sys/vm/vm_mmap.c
stable/11/sys/vm/vm_object.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/dev/drm/drm_scatter.c
==============================================================================
--- stable/11/sys/dev/drm/drm_scatter.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/dev/drm/drm_scatter.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -48,7 +48,7 @@ drm_sg_alloc(struct drm_device *dev, str
entry = malloc(sizeof(*entry), DRM_MEM_DRIVER, M_WAITOK | M_ZERO);
size = round_page(request->size);
- entry->pages = OFF_TO_IDX(size);
+ entry->pages = atop(size);
entry->busaddr = malloc(entry->pages * sizeof(*entry->busaddr),
DRM_MEM_SGLISTS, M_WAITOK | M_ZERO);
Modified: stable/11/sys/dev/drm2/drm_scatter.c
==============================================================================
--- stable/11/sys/dev/drm2/drm_scatter.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/dev/drm2/drm_scatter.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -74,7 +74,7 @@ int drm_sg_alloc(struct drm_device *dev,
DRM_DEBUG("request size=%ld\n", request->size);
size = round_page(request->size);
- entry->pages = OFF_TO_IDX(size);
+ entry->pages = atop(size);
entry->busaddr = malloc(entry->pages * sizeof(*entry->busaddr),
DRM_MEM_SGLISTS, M_NOWAIT | M_ZERO);
if (!entry->busaddr) {
Modified: stable/11/sys/kern/kern_proc.c
==============================================================================
--- stable/11/sys/kern/kern_proc.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/kern/kern_proc.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -2272,7 +2272,7 @@ kern_proc_vmmap_resident(vm_map_t map, v
if (m_adv != NULL) {
m = m_adv;
} else {
- pi_adv = OFF_TO_IDX(entry->end - addr);
+ pi_adv = atop(entry->end - addr);
pindex = pi;
for (tobj = obj;; tobj = tobj->backing_object) {
m = vm_page_find_least(tobj, pindex);
@@ -2296,7 +2296,7 @@ kern_proc_vmmap_resident(vm_map_t map, v
(pmap_mincore(map->pmap, addr, &locked_pa) &
MINCORE_SUPER) != 0) {
kve->kve_flags |= KVME_FLAG_SUPER;
- pi_adv = OFF_TO_IDX(pagesizes[1]);
+ pi_adv = atop(pagesizes[1]);
} else {
/*
* We do not test the found page on validity.
Modified: stable/11/sys/kern/vfs_bio.c
==============================================================================
--- stable/11/sys/kern/vfs_bio.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/kern/vfs_bio.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -3918,7 +3918,7 @@ biodone(struct bio *bp)
start = trunc_page((vm_offset_t)bp->bio_data);
end = round_page((vm_offset_t)bp->bio_data + bp->bio_length);
bp->bio_data = unmapped_buf;
- pmap_qremove(start, OFF_TO_IDX(end - start));
+ pmap_qremove(start, atop(end - start));
vmem_free(transient_arena, start, end - start);
atomic_add_int(&inflight_transient_maps, -1);
}
Modified: stable/11/sys/vm/vm_fault.c
==============================================================================
--- stable/11/sys/vm/vm_fault.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/vm/vm_fault.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -352,8 +352,7 @@ vm_fault_populate(struct faultstate *fs,
MPASS(fs->lookup_still_valid);
pager_first = OFF_TO_IDX(fs->entry->offset);
- pager_last = OFF_TO_IDX(fs->entry->offset + fs->entry->end -
- fs->entry->start) - 1;
+ pager_last = pager_first + atop(fs->entry->end - fs->entry->start) - 1;
unlock_map(fs);
unlock_vp(fs);
@@ -404,18 +403,20 @@ vm_fault_populate(struct faultstate *fs,
* In case the pager expanded the range, clip it to fit into
* the map entry.
*/
- map_first = MAX(OFF_TO_IDX(fs->entry->offset), pager_first);
- if (map_first > pager_first)
+ map_first = OFF_TO_IDX(fs->entry->offset);
+ if (map_first > pager_first) {
vm_fault_populate_cleanup(fs->first_object, pager_first,
map_first - 1);
- map_last = MIN(OFF_TO_IDX(fs->entry->end - fs->entry->start +
- fs->entry->offset) - 1, pager_last);
- if (map_last < pager_last)
+ pager_first = map_first;
+ }
+ map_last = map_first + atop(fs->entry->end - fs->entry->start) - 1;
+ if (map_last < pager_last) {
vm_fault_populate_cleanup(fs->first_object, map_last + 1,
pager_last);
-
- for (pidx = map_first, m = vm_page_lookup(fs->first_object, pidx);
- pidx <= map_last; pidx++, m = vm_page_next(m)) {
+ pager_last = map_last;
+ }
+ for (pidx = pager_first, m = vm_page_lookup(fs->first_object, pidx);
+ pidx <= pager_last; pidx++, m = vm_page_next(m)) {
vm_fault_populate_check_page(m);
vm_fault_dirty(fs->entry, m, prot, fault_type, fault_flags,
true);
@@ -1548,7 +1549,7 @@ vm_fault_copy_entry(vm_map_t dst_map, vm
* actually shadow anything - we copy the pages directly.)
*/
dst_object = vm_object_allocate(OBJT_DEFAULT,
- OFF_TO_IDX(dst_entry->end - dst_entry->start));
+ atop(dst_entry->end - dst_entry->start));
#if VM_NRESERVLEVEL > 0
dst_object->flags |= OBJ_COLORED;
dst_object->pg_color = atop(dst_entry->start);
Modified: stable/11/sys/vm/vm_kern.c
==============================================================================
--- stable/11/sys/vm/vm_kern.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/vm/vm_kern.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -162,8 +162,7 @@ kmem_alloc_attr(vmem_t *vmem, vm_size_t
vm_paddr_t high, vm_memattr_t memattr)
{
vm_object_t object = vmem == kmem_arena ? kmem_object : kernel_object;
- vm_offset_t addr, i;
- vm_ooffset_t offset;
+ vm_offset_t addr, i, offset;
vm_page_t m;
int pflags, tries;
@@ -176,7 +175,7 @@ kmem_alloc_attr(vmem_t *vmem, vm_size_t
for (i = 0; i < size; i += PAGE_SIZE) {
tries = 0;
retry:
- m = vm_page_alloc_contig(object, OFF_TO_IDX(offset + i),
+ m = vm_page_alloc_contig(object, atop(offset + i),
pflags, 1, low, high, PAGE_SIZE, 0, memattr);
if (m == NULL) {
VM_OBJECT_WUNLOCK(object);
@@ -217,8 +216,7 @@ kmem_alloc_contig(struct vmem *vmem, vm_
vm_memattr_t memattr)
{
vm_object_t object = vmem == kmem_arena ? kmem_object : kernel_object;
- vm_offset_t addr, tmp;
- vm_ooffset_t offset;
+ vm_offset_t addr, offset, tmp;
vm_page_t end_m, m;
u_long npages;
int pflags, tries;
@@ -232,7 +230,7 @@ kmem_alloc_contig(struct vmem *vmem, vm_
VM_OBJECT_WLOCK(object);
tries = 0;
retry:
- m = vm_page_alloc_contig(object, OFF_TO_IDX(offset), pflags,
+ m = vm_page_alloc_contig(object, atop(offset), pflags,
npages, low, high, alignment, boundary, memattr);
if (m == NULL) {
VM_OBJECT_WUNLOCK(object);
@@ -343,7 +341,7 @@ kmem_back(vm_object_t object, vm_offset_
VM_OBJECT_WLOCK(object);
for (i = 0; i < size; i += PAGE_SIZE) {
retry:
- m = vm_page_alloc(object, OFF_TO_IDX(offset + i), pflags);
+ m = vm_page_alloc(object, atop(offset + i), pflags);
/*
* Ran out of space, free everything up and return. Don't need
@@ -395,7 +393,7 @@ kmem_unback(vm_object_t object, vm_offse
offset = addr - VM_MIN_KERNEL_ADDRESS;
VM_OBJECT_WLOCK(object);
for (i = 0; i < size; i += PAGE_SIZE) {
- m = vm_page_lookup(object, OFF_TO_IDX(offset + i));
+ m = vm_page_lookup(object, atop(offset + i));
vm_page_unwire(m, PQ_NONE);
vm_page_free(m);
}
Modified: stable/11/sys/vm/vm_map.c
==============================================================================
--- stable/11/sys/vm/vm_map.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/vm/vm_map.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -2904,7 +2904,7 @@ vm_map_entry_delete(vm_map_t map, vm_map
{
vm_object_t object;
vm_pindex_t offidxstart, offidxend, count, size1;
- vm_ooffset_t size;
+ vm_size_t size;
vm_map_entry_unlink(map, entry);
object = entry->object.vm_object;
@@ -2921,7 +2921,7 @@ vm_map_entry_delete(vm_map_t map, vm_map
KASSERT(entry->cred == NULL || object->cred == NULL ||
(entry->eflags & MAP_ENTRY_NEEDS_COPY),
("OVERCOMMIT vm_map_entry_delete: both cred %p", entry));
- count = OFF_TO_IDX(size);
+ count = atop(size);
offidxstart = OFF_TO_IDX(entry->offset);
offidxend = offidxstart + count;
VM_OBJECT_WLOCK(object);
Modified: stable/11/sys/vm/vm_mmap.c
==============================================================================
--- stable/11/sys/vm/vm_mmap.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/vm/vm_mmap.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -888,7 +888,7 @@ RestartScan:
/*
* calculate index into user supplied byte vector
*/
- vecindex = OFF_TO_IDX(addr - first_addr);
+ vecindex = atop(addr - first_addr);
/*
* If we have skipped map entries, we need to make sure that
@@ -934,7 +934,7 @@ RestartScan:
/*
* Zero the last entries in the byte vector.
*/
- vecindex = OFF_TO_IDX(end - first_addr);
+ vecindex = atop(end - first_addr);
while ((lastvecindex + 1) < vecindex) {
++lastvecindex;
error = subyte(vec + lastvecindex, 0);
Modified: stable/11/sys/vm/vm_object.c
==============================================================================
--- stable/11/sys/vm/vm_object.c Tue Mar 28 06:05:26 2017 (r316072)
+++ stable/11/sys/vm/vm_object.c Tue Mar 28 06:07:59 2017 (r316073)
@@ -279,16 +279,16 @@ vm_object_init(void)
mtx_init(&vm_object_list_mtx, "vm object_list", NULL, MTX_DEF);
rw_init(&kernel_object->lock, "kernel vm object");
- _vm_object_allocate(OBJT_PHYS, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
- kernel_object);
+ _vm_object_allocate(OBJT_PHYS, atop(VM_MAX_KERNEL_ADDRESS -
+ VM_MIN_KERNEL_ADDRESS), kernel_object);
#if VM_NRESERVLEVEL > 0
kernel_object->flags |= OBJ_COLORED;
kernel_object->pg_color = (u_short)atop(VM_MIN_KERNEL_ADDRESS);
#endif
rw_init(&kmem_object->lock, "kmem vm object");
- _vm_object_allocate(OBJT_PHYS, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
- kmem_object);
+ _vm_object_allocate(OBJT_PHYS, atop(VM_MAX_KERNEL_ADDRESS -
+ VM_MIN_KERNEL_ADDRESS), kmem_object);
#if VM_NRESERVLEVEL > 0
kmem_object->flags |= OBJ_COLORED;
kmem_object->pg_color = (u_short)atop(VM_MIN_KERNEL_ADDRESS);
@@ -1036,7 +1036,7 @@ vm_object_sync(vm_object_t object, vm_oo
(void) vn_start_write(vp, &mp, V_WAIT);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (syncio && !invalidate && offset == 0 &&
- OFF_TO_IDX(size) == object->size) {
+ atop(size) == object->size) {
/*
* If syncing the whole mapping of the file,
* it is faster to schedule all the writes in
More information about the svn-src-stable
mailing list