Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sat, 10 Aug 2002 14:37:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sat, 10 Aug 2002 14:37:39 -0400 Received: from neon-gw-l3.transmeta.com ([63.209.4.196]:12807 "EHLO neon-gw.transmeta.com") by vger.kernel.org with ESMTP id ; Sat, 10 Aug 2002 14:37:38 -0400 Date: Sat, 10 Aug 2002 11:42:44 -0700 (PDT) From: Linus Torvalds To: Jamie Lokier cc: Andrew Morton , lkml Subject: Re: [patch 6/12] hold atomic kmaps across generic_file_read In-Reply-To: <20020810185508.A423@kushida.apsleyroad.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1421 Lines: 37 On Sat, 10 Aug 2002, Jamie Lokier wrote: > > Don't forget to include the need for mmap(... MAP_ANON ...) prior to the > read. Ahhah! But I _don't_. Yes, with read() you have to do a brk() or mmap(MAP_ANON) (and brk() is the _much_ faster of the two). But with mmap() you need to do a fstat() and a munmap() (while with read you just re-use the area, and we'd do the right thing thanks to the COW-ness of the pages). So I don't think the MAP_ANON thing is a loss for the read. And read() is often the much nicer interface, simply because you don't need to worry about the size of the file up-front etc. Also, because of the delayed nature of mmap()/fault, it has some strange behaviour if somebody is editing your file in the middle of the compile - with read() you might get strange syntax errors if somebody changes the file half-way, but with mmap() your preprocessor may get a SIGSEGV in the middle just because the file was truncated.. In general, I think read() tends to be the right (and simpler) interface to use if you don't explicitly want to take advantage of the things mmap offers (on-demand mappings, no-write-back pageouts, VM coherency etc). Linus - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/