patch-2.3.9 linux/mm/mmap.c

Next file: linux/mm/mprotect.c
Previous file: linux/mm/mlock.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.8/linux/mm/mmap.c linux/mm/mmap.c
@@ -62,7 +62,7 @@
 	if (sysctl_overcommit_memory)
 	    return 1;
 
-	free = buffermem >> PAGE_SHIFT;
+	free = atomic_read(&buffermem) >> PAGE_SHIFT;
 	free += atomic_read(&page_cache_size);
 	free += nr_free_pages;
 	free += nr_swap_pages;
@@ -313,7 +313,7 @@
 		if (error)
 			goto unmap_and_free_vma;
 		vma->vm_file = file;
-		file->f_count++;
+		atomic_inc(&file->f_count);
 	}
 
 	/*
@@ -547,7 +547,7 @@
 		mpnt->vm_file = area->vm_file;
 		mpnt->vm_pte = area->vm_pte;
 		if (mpnt->vm_file)
-			mpnt->vm_file->f_count++;
+			atomic_inc(&mpnt->vm_file->f_count);
 		if (mpnt->vm_ops && mpnt->vm_ops->open)
 			mpnt->vm_ops->open(mpnt);
 		area->vm_end = addr;	/* Truncate area */
@@ -786,8 +786,11 @@
 	 */
 	flags = vma->vm_flags;
 	addr = vma->vm_start;
+
+	lock_kernel();		/* kswapd, ugh */
 	insert_vm_struct(mm, vma);
 	merge_segments(mm, vma->vm_start, vma->vm_end);
+	unlock_kernel();
 	
 	mm->total_vm += len >> PAGE_SHIFT;
 	if (flags & VM_LOCKED) {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)