mm: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
Subsystems (9)
PATCH 1/6 mm: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
(*->vm_end - *->vm_start) >> PAGE_SHIFT operation is implemented as a inline funcion vma_pages() in linux/mm.h, so using it.
--- mm/memory.c | 2 +- mm/mmap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
mm/memory.c +1 -1
@@ -2866,7 +2866,7 @@ static inline void unmap_mapping_range_tree(struct rb_root *root, details->first_index, details->last_index) { vba = vma->vm_pgoff; - vea = vba + ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) -1 ; + vea = vba +vma_pages (vma) -1 ;/* Assume for now that PAGE_CACHE_SHIFT == PAGE_SHIFT */ zba = details->first_index;if (zba < vba)
mm/mmap.c +1 -1
@@ -919,7 +919,7 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,if (is_mergeable_vma (vma, file, vm_flags) &&is_mergeable_anon_vma (anon_vma, vma->anon_vma, vma)) {pgoff_t vm_pglen; - vm_pglen = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; + vm_pglen =vma_pages (vma);if (vma->vm_pgoff + vm_pglen == vm_pgoff)return 1 ; }
Signature · 1 line
1.8.2.1
PATCH 2/6 PCI: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
(*->vm_end - *->vm_start) >> PAGE_SHIFT operation is implemented as a inline funcion vma_pages() in linux/mm.h, so using it.
--- drivers/pci/pci-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-sysfs.c +1 -1
@@ -897,7 +897,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma,if (pci_resource_len (pdev, resno) ==0 )return 0 ; - nr = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; + nr =vma_pages (vma); start = vma->vm_pgoff; size = ((pci_resource_len (pdev, resno) -1 ) >>PAGE_SHIFT ) +1 ; pci_start = (mmap_api == PCI_MMAP_PROCFS) ?
Signature · 1 line
1.8.2.1
Re: [PATCH 2/6] PCI: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
Quoted 4 lines · Libin
(*->vm_end - *->vm_start) >>
PAGE_SHIFToperation is implemented as a inline funcionvma_pages()inlinux/mm.h, so using it.Signed-off-by Libin <[email protected]>
Applied to my pci/misc branch for v3.10, thanks!
Bjorn
Quoted 18 lines
--- drivers/pci/pci-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci-sysfs.c +1
-2@@ -897,7 +897,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma,if (pci_resource_len (pdev, resno) ==0 )return 0 ; - nr = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; + nr =vma_pages (vma); start = vma->vm_pgoff; size = ((pci_resource_len (pdev, resno) -1 ) >>PAGE_SHIFT ) +1 ; pci_start = (mmap_api == PCI_MMAP_PROCFS) ? --
Quoted 3 lines
1.8.2.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/6 ncpfs: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
In reply to Libin(*->vm_end - *->vm_start) >> PAGE_SHIFT operation is implemented as a inline funcion vma_pages() in linux/mm.h, so using it.
--- fs/ncpfs/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ncpfs/mmap.c +1 -1
@@ -117,7 +117,7 @@ int ncp_mmap(struct file *file, struct vm_area_struct *vma)return -EINVAL ;/* we do not support files bigger than 4GB... We eventually supports just 4GB... */ -if (((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) + vma->vm_pgoff +if (vma_pages (vma) + vma->vm_pgoff > (1U << (32 -PAGE_SHIFT )))return -EFBIG ;
Signature · 8 lines
1.8.2.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/6 char: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
In reply to Libin(*->vm_end - *->vm_start) >> PAGE_SHIFT operation is implemented as a inline funcion vma_pages() in linux/mm.h, so using it.
--- drivers/char/mspec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/mspec.c +1 -1
@@ -168,7 +168,7 @@ mspec_close(struct vm_area_struct *vma)if (!atomic_dec_and_test (&vdata->refcnt))return ; - last_index = (vdata->vm_end - vdata->vm_start) >>PAGE_SHIFT ; + last_index =vma_pages (vdata);for (index =0 ; index < last_index; index++) {if (vdata->maddr[index] ==0 )continue ;
Signature · 1 line
1.8.2.1
Re: [PATCH 4/6] char: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
Quoted 14 lines · Libin
(*->vm_end - *->vm_start) >>
PAGE_SHIFToperation is implemented as a inline funcionvma_pages()inlinux/mm.h, so using it.Signed-off-by Libin <[email protected]>--- drivers/char/mspec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/mspec.c +0
-0
drivers/char/mspec.c mspec_close(struct vm_area_struct *vma) · line 174
Quoted 8 lines
drivers/char/mspec.c +1
-1@@ -168,7 +168,7 @@ mspec_close(struct vm_area_struct *vma)if (!atomic_dec_and_test (&vdata->refcnt))return ; - last_index = (vdata->vm_end - vdata->vm_start) >>PAGE_SHIFT ; + last_index =vma_pages (vdata);for (index =0 ; index < last_index; index++) {if (vdata->maddr[index] ==0 )continue ;
This function mspec_mmap also need modification... And you can change int to unsigned long.
static int
mspec_mmap(struct file *file, struct vm_area_struct *vma,
enum mspec_page_type type)
{
struct vma_data *vdata;
int pages, vdata_size, flags = 0;
if (vma->vm_pgoff != 0)
return -EINVAL;
if ((vma->vm_flags & VM_SHARED) == 0)
return -EINVAL;
if ((vma->vm_flags & VM_WRITE) == 0)
return -EPERM;
pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
vdata_size = sizeof(struct vma_data) + pages * sizeof(long);
if (vdata_size <= PAGE_SIZE)
vdata = kzalloc(vdata_size, GFP_KERNEL);
else {
vdata = vzalloc(vdata_size);
flags = VMD_VMALLOCED;
}
if (!vdata)
return -ENOMEM;Re: [PATCH 4/6] char: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
In reply to Libindrivers/char/mspec.c mspec_close(struct vm_area_struct *vma) · line 174
Quoted 13 lines · Libin
drivers/char/mspec.c +1
-1@@ -168,7 +168,7 @@ mspec_close(struct vm_area_struct *vma)if (!atomic_dec_and_test (&vdata->refcnt))return ; - last_index = (vdata->vm_end - vdata->vm_start) >>PAGE_SHIFT ; + last_index =vma_pages (vdata);for (index =0 ; index < last_index; index++) {if (vdata->maddr[index] ==0 )continue ;
vdata is of type struct vma_data * and vma_pages() takes a formal of type struct vm_area_struct *, so these are incompatible. Hopefully you tested the other changes and simply lack an ia64 cross compiler for this one, because it will emit a warning.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/6 drm: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
In reply to Libin(*->vm_end - *->vm_start) >> PAGE_SHIFT operation is implemented as a inline funcion vma_pages() in linux/mm.h, so using it.
--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -2
@@ -147,7 +147,7 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) page_offset = ((address - vma->vm_start) >>PAGE_SHIFT ) + bo->vm_node->start - vma->vm_pgoff; - page_last = ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) + + page_last =vma_pages (vma) + bo->vm_node->start - vma->vm_pgoff;if (unlikely (page_offset >= bo->num_pages)) {
@@ -258,7 +258,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,read_lock (&bdev->vm_lock); bo =ttm_bo_vm_lookup_rb (bdev, vma->vm_pgoff, - (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ); +vma_pages (vma));if (likely (bo !=NULL ) && !kref_get_unless_zero (&bo->kref)) bo =NULL ;read_unlock (&bdev->vm_lock);
Signature · 8 lines
1.8.2.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 6/6 uio: use vma_pages() to replace (vm_end - vm_start) >> PAGE_SHIFT
In reply to Libin(*->vm_end - *->vm_start) >> PAGE_SHIFT operation is implemented as a inline funcion vma_pages() in linux/mm.h, so using it.
--- drivers/uio/uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/uio/uio.c +1 -1
@@ -676,7 +676,7 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)if (mi <0 )return -EINVAL ; - requested_pages = (vma->vm_end - vma->vm_start) >>PAGE_SHIFT ; + requested_pages =vma_pages (vma); actual_pages = ((idev->info->mem[mi].addr & ~PAGE_MASK ) + idev->info->mem[mi].size +PAGE_SIZE -1 ) >>PAGE_SHIFT ;if (requested_pages > actual_pages)
Signature · 8 lines
1.8.2.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · Libin
(*->vm_end - *->vm_start) >>
PAGE_SHIFToperation is implemented as a inline funcionvma_pages()inlinux/mm.h, so using it.Signed-off-by Libin <[email protected]>
Looks good to me.
Signature · 2 lines
Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.