All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Ben LaHaise <bcrl@redhat.com>
Cc: torvalds@transmeta.com, alan@redhat.com, linux-mm@kvack.org,
	Chris Blizzard <blizzard@redhat.com>
Subject: Re: resend Re: [PATCH] final merging patch -- significant mozilla speedup.
Date: Sun, 19 Aug 2001 04:59:06 +0200	[thread overview]
Message-ID: <20010819045906.E1719@athlon.random> (raw)
In-Reply-To: <20010819034050.Z1719@athlon.random>; from andrea@suse.de on Sun, Aug 19, 2001 at 03:40:50AM +0200

Ok, at the light of this thread I did these changes:

diff -urN mmap-rb-ref/include/linux/mm.h mmap-rb-5/include/linux/mm.h
--- mmap-rb-ref/include/linux/mm.h	Sun Aug 19 04:51:13 2001
+++ mmap-rb-5/include/linux/mm.h	Sun Aug 19 04:56:07 2001
@@ -578,6 +578,10 @@
 {
 	unsigned long grow;
 
+	/*
+	 * vma->vm_start/vm_end cannot change under us because the caller is required
+	 * to hold the mmap_sem at least in read mode.
+	 */
 	address &= PAGE_MASK;
 	if (prev_vma && prev_vma->vm_end + (heap_stack_gap << PAGE_SHIFT) > address)
 		return -ENOMEM;
@@ -587,7 +591,21 @@
 		return -ENOMEM;
 	spin_lock(&vma->vm_mm->page_table_lock);
 	vma->vm_start = address;
+
+	/*
+	 * vm_pgoff locking is a bit subtle: everybody but expand_stack is
+	 * playing with the vm_pgoff with the write semaphore acquired. The
+	 * only one playing with vm_pgoff with only the read semaphore
+	 * acquired is expand_stack and it serializes against itself with the
+	 * spinlock.
+	 *
+	 * More in general this means that it is not enough to grab the mmap_sem
+	 * in read mode to avoid vm_pgoff to change under you. You either
+	 * need the write semaphore acquired, or the read semaphore plus
+	 * the spinlock.
+	 */
 	vma->vm_pgoff -= grow;
+
 	vma->vm_mm->total_vm += grow;
 	if (vma->vm_flags & VM_LOCKED)
 		vma->vm_mm->locked_vm += grow;
diff -urN mmap-rb-ref/mm/mmap.c mmap-rb-5/mm/mmap.c
--- mmap-rb-ref/mm/mmap.c	Sun Aug 19 04:49:51 2001
+++ mmap-rb-5/mm/mmap.c	Sun Aug 19 04:52:05 2001
@@ -785,14 +785,19 @@
 
 	/* Work out to one of the ends. */
 	if (end == area->vm_end) {
+		/*
+		 * here area isn't visible to the semaphore-less readers
+		 * so we don't need to update it under the spinlock.
+		 */
+		area->vm_end = addr;
 		lock_vma_mappings(area);
 		spin_lock(&mm->page_table_lock);
-		area->vm_end = addr;
 	} else if (addr == area->vm_start) {
 		area->vm_pgoff += (end - area->vm_start) >> PAGE_SHIFT;
+		/* same locking considerations of the above case */
+		area->vm_start = end;
 		lock_vma_mappings(area);
 		spin_lock(&mm->page_table_lock);
-		area->vm_start = end;
 	} else {
 	/* Unmapping a hole: area->vm_start < addr <= end < area->vm_end */
 		/* Add end mapping -- leave beginning for below */

Andrea
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

  reply	other threads:[~2001-08-19  2:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-16 21:02 [PATCH] final merging patch -- significant mozilla speedup Ben LaHaise
2001-08-18 18:22 ` resend " Ben LaHaise
2001-08-18 23:27   ` Andrea Arcangeli
2001-08-19  0:10     ` Ben LaHaise
2001-08-19  0:35       ` Andrea Arcangeli
2001-08-19  0:50         ` Rik van Riel
2001-08-19  0:55           ` Andrea Arcangeli
2001-08-19  1:17             ` Andrea Arcangeli
2001-08-19  0:53         ` Andrea Arcangeli
2001-08-19  1:02           ` Andrea Arcangeli
2001-08-19  1:25           ` Andrea Arcangeli
2001-08-19  1:40             ` Andrea Arcangeli
2001-08-19  2:59               ` Andrea Arcangeli [this message]
2001-08-19  3:53                 ` Andrea Arcangeli
2001-08-19  3:53                   ` Andrea Arcangeli
2001-08-19  5:11                   ` Andrea Arcangeli
2001-08-19  5:11                     ` Andrea Arcangeli
2001-08-19  0:54         ` Rik van Riel
2001-08-19  1:00           ` Andrea Arcangeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010819045906.E1719@athlon.random \
    --to=andrea@suse.de \
    --cc=alan@redhat.com \
    --cc=bcrl@redhat.com \
    --cc=blizzard@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.