[patch 11/18] remap_file_pages protection support: also set VM_NONLINEAR on nonuniform VMAs

blaisorblade_at_yahoo.it
Date: 08/26/05

  • Next message: blaisorblade_at_yahoo.it: "[patch 04/18] remap_file_pages protection support: cleanup syscall checks"
    To: akpm@osdl.org
    Date:	Fri, 26 Aug 2005 18:53:42 +0200
    
    

    From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

    To simplify the VM code, and to reflect expected application usage, we decide
    to also set VM_NONLINEAR when setting VM_NONUNIFORM. Otherwise, we'd have to
    possibly save nonlinear PTEs even on paths which cope with linear VMAs. It's
    possible, but intrusive (it's done in one of the next patches).

    Obviously, this has a performance cost, since we potentially have to handle a
    linear VMA with nonlinear handling code. But I don't know of any application
    which might have this usage.

    Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

    ---
     linux-2.6.git-paolo/mm/fremap.c |   27 ++++++++++++++-------------
     1 files changed, 14 insertions(+), 13 deletions(-)
    diff -puN mm/fremap.c~rfp-nonuniform-implies-nonlinear mm/fremap.c
    --- linux-2.6.git/mm/fremap.c~rfp-nonuniform-implies-nonlinear	2005-08-25 12:50:00.000000000 +0200
    +++ linux-2.6.git-paolo/mm/fremap.c	2005-08-25 12:50:00.000000000 +0200
    @@ -246,8 +246,9 @@ retry:
     	if (!vma->vm_private_data ||
     			(vma->vm_flags & (VM_NONLINEAR|VM_RESERVED))) {
     		/* Must set VM_NONLINEAR before any pages are populated. */
    -		if (pgoff != linear_page_index(vma, start) &&
    -		    !(vma->vm_flags & VM_NONLINEAR)) {
    +		if (!(vma->vm_flags & VM_NONLINEAR) &&
    +			(pgoff != linear_page_index(vma, start) ||
    +			pgprot_val(pgprot) != pgprot_val(vma->vm_page_prot))) {
     			if (!(vma->vm_flags & VM_SHARED))
     				goto out_unlock;
     			if (!has_write_lock) {
    @@ -264,19 +265,19 @@ retry:
     			vma_nonlinear_insert(vma, &mapping->i_mmap_nonlinear);
     			flush_dcache_mmap_unlock(mapping);
     			spin_unlock(&mapping->i_mmap_lock);
    -		}
     
    -		if (pgprot_val(pgprot) != pgprot_val(vma->vm_page_prot) &&
    -				!(vma->vm_flags & VM_NONUNIFORM)) {
    -			if (!(vma->vm_flags & VM_SHARED))
    -				goto out_unlock;
    -			if (!has_write_lock) {
    -				up_read(&mm->mmap_sem);
    -				down_write(&mm->mmap_sem);
    -				has_write_lock = 1;
    -				goto retry;
    +			if (!(vma->vm_flags & VM_NONUNIFORM) &&
    +				pgprot_val(pgprot) != pgprot_val(vma->vm_page_prot)) {
    +				if (!(vma->vm_flags & VM_SHARED))
    +					goto out_unlock;
    +				if (!has_write_lock) {
    +					up_read(&mm->mmap_sem);
    +					down_write(&mm->mmap_sem);
    +					has_write_lock = 1;
    +					goto retry;
    +				}
    +				vma->vm_flags |= VM_NONUNIFORM;
     			}
    -			vma->vm_flags |= VM_NONUNIFORM;
     		}
     
     		/* Do NOT hold the write lock while doing any I/O, nor when
    _
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: blaisorblade_at_yahoo.it: "[patch 04/18] remap_file_pages protection support: cleanup syscall checks"

    Relevant Pages