linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: Andrea Arcangeli <andrea@e-mind.com>
Cc: "Stephen C. Tweedie" <sct@redhat.com>,
	Zlatko.Calusic@CARNet.hr, Linux-MM List <linux-mm@kvack.org>,
	Andi Kleen <andi@zero.aec.at>
Subject: Re: Update shared mappings
Date: Tue, 1 Dec 1998 15:03:41 GMT	[thread overview]
Message-ID: <199812011503.PAA18144@dax.scot.redhat.com> (raw)
In-Reply-To: <Pine.LNX.3.96.981130204515.498H-100000@dragon.bogus>

Hi,

On Mon, 30 Nov 1998 21:02:05 +0100 (CET), Andrea Arcangeli
<andrea@e-mind.com> said:

>> The only reason that this patch works in its current state is that
>> exit_mmap() skips the down(&mm->mmap_sem).  It can safely do so only

> I guess you have not read the patch well...

I think I have: I can reliably deadlock machines with this patch.

> Stephen I can' t see the obvious deadlocking you are tolking about. The
> mmap semphore can be held for many processes but not two times for the
> same one and never for the current one. The code should work fine also
> with CLONE_VM. I have no pending bug reports btw. 

No.  When you scan vmas to update, you down() the semaphore on their
mm.  You skip the current vma, sure, but it is quite possible to have
the same inode mapped more than once in a mm.  If that happens, then
you *will* deadlock (I've got a console window open right now on a test
machine which is deadlocked in msync).

> Let me know if the code still need fixing. A proggy that trigger the bug
> would be helpful btw ;)

OK, see below.

--Stephen

----------------------------------------------------------------
/*
 * wmem.c
 * 
 * Test msync of shared write mappings
 * 
 * (C) Stephen C. Tweedie, 1998
 */

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#include <unistd.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <sys/fcntl.h>

void try(const char *where, int why)
{
	if (why) {
		perror(where);
		exit(1);
	}
}

int pagesize;

int main(int argc, char *argv[])
{
	int fd;
	int err;
	char * map1, * map2;
	
	pagesize = getpagesize();
	
	fd = open("/tmp/testfile", O_RDWR|O_CREAT, 0666);
	try ("open", fd < 0);
	
	ftruncate(fd, pagesize);
	
	map1 = mmap(0, pagesize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
	try ("mmap", map1 == MAP_FAILED);
	
	map2 = mmap(0, pagesize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
	try ("mmap", map2 == MAP_FAILED);
	
	map1[0] = 0;
	map1[100] = 0;
	
	err = msync(map1, pagesize, 0);
	try ("msync", err < 0);
	
	err = msync(map2, pagesize, 0);
	try ("msync", err < 0);

	exit(0);
}
--
This is a majordomo managed list.  To unsubscribe, send a message with
the body 'unsubscribe linux-mm me@address' to: majordomo@kvack.org

  reply	other threads:[~1998-12-01 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-20  4:10 Zlatko Calusic
1998-11-30 13:52 ` Stephen C. Tweedie
1998-11-30 15:19   ` Zlatko Calusic
1998-11-30 20:02   ` Andrea Arcangeli
1998-12-01 15:03     ` Stephen C. Tweedie [this message]
1998-12-01 17:48       ` Andrea Arcangeli
1998-12-02 16:21         ` Stephen C. Tweedie
1998-12-02 18:32           ` Andrea Arcangeli
1998-12-03  5:44             ` Eric W. Biederman
1998-12-03 11:56             ` Stephen C. Tweedie

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=199812011503.PAA18144@dax.scot.redhat.com \
    --to=sct@redhat.com \
    --cc=Zlatko.Calusic@CARNet.hr \
    --cc=andi@zero.aec.at \
    --cc=andrea@e-mind.com \
    --cc=linux-mm@kvack.org \
    /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