linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave McCracken <dmccr@us.ibm.com>
To: William Lee Irwin III <wli@holomorphy.com>
Cc: Mika Penttil? <mika.penttila@kolumbus.fi>,
	Linux Memory Management <linux-mm@kvack.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: Race between vmtruncate and mapped areas?
Date: Tue, 13 May 2003 18:00:08 -0500	[thread overview]
Message-ID: <220550000.1052866808@baldur.austin.ibm.com> (raw)
In-Reply-To: <20030513224929.GX8978@holomorphy.com>

[-- Attachment #1: Type: text/plain, Size: 946 bytes --]


--On Tuesday, May 13, 2003 15:49:29 -0700 William Lee Irwin III
<wli@holomorphy.com> wrote:

> That doesn't sound like it's going to help, there isn't a unique
> mmap_sem to be taken and so we just get caught between acquisitions
> with the same problem.

Actually it does fix it.  I added code in vmtruncate_list() to do a
down_write(&vma->vm_mm->mmap_sem) around the zap_page_range(), and the
problem went away.  It serializes against any outstanding page faults on a
particular page table.  New faults will see that the page is no longer in
the file and fail with SIGBUS.  Andrew's test case stopped failing.

I've attached the patch so you can see what I did.

Can anyone think of any gotchas to this solution?

Dave McCracken

======================================================================
Dave McCracken          IBM Linux Base Kernel Team      1-512-838-3059
dmccr@us.ibm.com                                        T/L   678-3059

[-- Attachment #2: vmtrunc-2.5.69-mm3-1.diff --]
[-- Type: text/plain, Size: 982 bytes --]

--- 2.5.69-mm3/mm/memory.c	2003-05-13 10:34:56.000000000 -0500
+++ 2.5.69-mm3-test/mm/memory.c	2003-05-13 17:39:45.000000000 -0500
@@ -1085,21 +1085,21 @@ static void vmtruncate_list(struct list_
 		len = end - start;
 
 		/* mapping wholly truncated? */
-		if (vma->vm_pgoff >= pgoff) {
-			zap_page_range(vma, start, len);
-			continue;
-		}
+		if (vma->vm_pgoff < pgoff) {
 
-		/* mapping wholly unaffected? */
-		len = len >> PAGE_SHIFT;
-		diff = pgoff - vma->vm_pgoff;
-		if (diff >= len)
-			continue;
-
-		/* Ok, partially affected.. */
-		start += diff << PAGE_SHIFT;
-		len = (len - diff) << PAGE_SHIFT;
+			/* mapping wholly unaffected? */
+			len = len >> PAGE_SHIFT;
+			diff = pgoff - vma->vm_pgoff;
+			if (diff >= len)
+				continue;
+
+			/* Ok, partially affected.. */
+			start += diff << PAGE_SHIFT;
+			len = (len - diff) << PAGE_SHIFT;
+		}
+		down_write(&vma->vm_mm->mmap_sem);
 		zap_page_range(vma, start, len);
+		up_write(&vma->vm_mm->mmap_sem);
 	}
 }
 

  reply	other threads:[~2003-05-13 23:00 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-13 20:44 Dave McCracken
2003-05-13 20:58 ` Mika Penttilä
2003-05-13 21:04   ` William Lee Irwin III
2003-05-13 22:26   ` Dave McCracken
2003-05-13 22:49     ` William Lee Irwin III
2003-05-13 23:00       ` Dave McCracken [this message]
2003-05-13 23:11         ` William Lee Irwin III
2003-05-13 23:16           ` Dave McCracken
2003-05-13 23:20             ` William Lee Irwin III
2003-05-13 23:28               ` Dave McCracken
2003-05-13 23:29                 ` William Lee Irwin III
2003-05-13 23:16         ` William Lee Irwin III
2003-05-14  1:10         ` Andrew Morton
2003-05-14 15:02           ` Dave McCracken
2003-05-14  1:10     ` Andrew Morton
2003-05-14 15:02       ` Dave McCracken
2003-05-14 15:06         ` William Lee Irwin III
2003-05-14 15:25           ` Dave McCracken
2003-05-14 16:42           ` Gerrit Huizenga
2003-05-14 17:34         ` Andrew Morton
2003-05-14 17:42           ` Dave McCracken
2003-05-14 17:57             ` Andrew Morton
2003-05-14 18:05               ` Dave McCracken
2003-05-14 18:17                 ` Andrew Morton
2003-05-14 18:24                   ` Dave McCracken
2003-05-14 18:53                     ` Andrew Morton
2003-05-15  8:50                       ` Andrea Arcangeli
2003-05-14 19:02               ` Rik van Riel
2003-05-14 19:04                 ` Rik van Riel
2003-05-14 19:07                   ` Dave McCracken
2003-05-14 19:11                     ` Rik van Riel
2003-05-15  0:49             ` Andrea Arcangeli
2003-05-15  2:36               ` Rik van Riel
2003-05-15  9:46                 ` Andrea Arcangeli
2003-05-15  9:55                   ` Andrew Morton
2003-05-15  8:32               ` Andrew Morton
2003-05-15  8:42                 ` Andrew Morton
2003-05-15  8:55                 ` Andrea Arcangeli
2003-05-15  9:20                   ` Andrew Morton
2003-05-15  9:40                     ` Andrea Arcangeli
2003-05-15  9:58                       ` Andrew Morton
2003-05-15 16:38                       ` Daniel McNeil
2003-05-15 19:19                         ` Andrea Arcangeli
2003-05-15 22:04                           ` Daniel McNeil
2003-05-15 23:17                             ` Andrea Arcangeli
2003-05-17  0:27                               ` Daniel McNeil
2003-05-17 17:29                                 ` Andrea Arcangeli
2003-05-13 21:00 ` William Lee Irwin III
2003-05-17 18:19 Paul McKenney
2003-05-17 18:42 ` Andrea Arcangeli
2003-05-19 18:11 Paul McKenney

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=220550000.1052866808@baldur.austin.ibm.com \
    --to=dmccr@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mika.penttila@kolumbus.fi \
    --cc=wli@holomorphy.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox