linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: Alexander Viro <viro@math.psu.edu>
Cc: linux-mm@kvack.org, Stephen Tweedie <sct@redhat.com>
Subject: Re: Contention on ->i_shared_lock in dup_mmap()
Date: Thu, 8 Jun 2000 15:19:51 +0100	[thread overview]
Message-ID: <20000608151951.H3886@redhat.com> (raw)
In-Reply-To: <Pine.GSO.4.10.10006072235360.10800-100000@weyl.math.psu.edu>; from viro@math.psu.edu on Wed, Jun 07, 2000 at 11:45:58PM -0400

Hi,

On Wed, Jun 07, 2000 at 11:45:58PM -0400, Alexander Viro wrote:
> 
> 	In effect it's COW for ->mmap. Comments?

Sounds plausible, definitely.  However, for the lock to be shared by
mm's which share the mmap list, we need the mmap semaphore to be in
the shared structure.  What then locks the pointer from the mm to the
mmap struct?  In other words, if two tasks share the mmap list and
one blocks on the lock in the mmap list, there's no guarantee that it
still owns the lock when it wakes up.

Think about mm A (with threads X, Y, and Z):

	X forks
	Y starts a mmap COW
	Y goes for the mmap lock (still shared between X, Y and Z)
	Z goes for the mmap lock (still shared between X, Y and Z) 
	X does COW, goes for the mmap lock
	Y finishes, unlocks the two mmaps

Y and Z now have a different mmap, but Z is still waiting
for the old mmap lock on X's mmap list!

If the next thing X does is to exit, that exit may get the lock
before Z gets scheduled, so the mmap lock is deallocated while Z
is still waiting for it.

In other words, to make it work I think you also need to bump up the
refcount on the mmap struct when you wait on the mmap semaphore.  Is
there a danger, then, that we'll be doing unnecessary COW due to the
temporarily-raised refcount?

--Stephen
--
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.eu.org/Linux-MM/

  reply	other threads:[~2000-06-08 14:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-08  3:45 Alexander Viro
2000-06-08 14:19 ` Stephen C. Tweedie [this message]
2000-06-08 16:21 ` Manfred Spraul
2000-06-08 23:07   ` Alexander Viro

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=20000608151951.H3886@redhat.com \
    --to=sct@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=viro@math.psu.edu \
    /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