From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 19 Jun 2002 09:25:06 -0300 (BRT) From: Rik van Riel Subject: Re: [BUG] in do_mmap_pgoff() (2.4.19-preX) In-Reply-To: <20020616191606.GA1888@SandStorm.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org Return-Path: To: Abhishek Nayani Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org List-ID: On Mon, 17 Jun 2002, Abhishek Nayani wrote: > While documenting the do_mmap_pgoff() function, i found this > snippet of code very suspicious: > > /* Private writable mapping? Check memory availability.. */ > if ((vm_flags & (VM_SHARED | VM_WRITE)) == VM_WRITE && > !(flags & MAP_NORESERVE) && > !vm_enough_memory(len >> PAGE_SHIFT)) > return -ENOMEM; > > Here we need to quit if *any* one of the condition is true. So I > think it should be "||" instead of "&&". As according to the present > code, it quits only if all the 3 conditions is true, which is wrong. No, the code is correct. The only case where we end up allocating new pages for this mapping is when the mapping is both writable and private. Read-only mappings and shared mappings always have backing store, the file from which the mapping comes and empty_zero_page. regards, Rik -- Bravely reimplemented by the knights who say "NIH". http://www.surriel.com/ http://distro.conectiva.com/ -- 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/