From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 11 Oct 1999 17:37:40 -0400 (EDT) From: Alexander Viro Subject: Re: locking question: do_mmap(), do_munmap() In-Reply-To: <38022640.3447ECA6@colorfullife.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org Return-Path: To: Manfred Spraul Cc: "Stephen C. Tweedie" , Andrea Arcangeli , linux-kernel@vger.rutgers.edu, Ingo Molnar , linux-mm@kvack.org List-ID: On Mon, 11 Oct 1999, Manfred Spraul wrote: > Alexander Viro wrote: > > > > On Mon, 11 Oct 1999, Stephen C. Tweedie wrote: > > > > > Hi, > > > > > > On Sun, 10 Oct 1999 15:03:45 -0400 (EDT), Alexander Viro > > > said: > > > > > > > Hold on. In swap_out_mm() you have to protect find_vma() (OK, it doesn't > > > > block, but we'll have to take care of mm->mmap_cache) _and_ you'll have to > > > > protect vma from destruction all way down to try_to_swap_out(). And to > > > > vma->swapout(). Which can sleep, so spinlocks are out of question > > > > here. > > > > > > No, spinlocks would be ideal. The vma swapout codes _have_ to be > > > prepared for the vma to be destroyed as soon as we sleep. In fact, the > > > entire mm may disappear if the process happens to exit. Once we know > > > which page to write where, the swapout operation becomes a per-page > > > operation, not per-vma. > > > > Aha, so you propose to drop it in ->swapout(), right? (after get_file() in > > filemap_write_page()... Ouch. Probably we'ld better lambda-expand the call > > in filemap_swapout() - the thing is called from other places too)... > > What about something like a rw-semaphore which protects the vma list: > vma-list modifiers [ie merge_segments(), insert_vm_struct() and > do_munmap()] grab it exclusive, swapper grabs it "shared, starve > exclusive". > All other vma-list readers are protected by mm->mmap_sem. > > This should not dead-lock, and no changes are required in > vm_ops->swapout(). What does it buy you over the simple semaphore here? Do you really see a contention scenario? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://humbolt.geo.uu.nl/Linux-MM/