From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail191.messagelabs.com (mail191.messagelabs.com [216.82.242.19]) by kanga.kvack.org (Postfix) with ESMTP id 64DA96B004A for ; Fri, 19 Nov 2010 08:39:05 -0500 (EST) Received: from wpaz33.hot.corp.google.com (wpaz33.hot.corp.google.com [172.24.198.97]) by smtp-out.google.com with ESMTP id oAJDd2gu000467 for ; Fri, 19 Nov 2010 05:39:02 -0800 Received: from pvg2 (pvg2.prod.google.com [10.241.210.130]) by wpaz33.hot.corp.google.com with ESMTP id oAJDcuP4027915 for ; Fri, 19 Nov 2010 05:39:00 -0800 Received: by pvg2 with SMTP id 2so1092352pvg.30 for ; Fri, 19 Nov 2010 05:38:56 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20101119072316.GA14388@google.com> References: <1289996638-21439-1-git-send-email-walken@google.com> <1289996638-21439-4-git-send-email-walken@google.com> <20101117125756.GA5576@amd> <1290007734.2109.941.camel@laptop> <20101117231143.GQ22876@dastard> <20101118133702.GA18834@infradead.org> <20101119072316.GA14388@google.com> Date: Fri, 19 Nov 2010 08:38:55 -0500 Message-ID: Subject: Re: [PATCH 3/3] mlock: avoid dirtying pages and triggering writeback From: Theodore Tso Content-Type: multipart/alternative; boundary=000e0cd2e0e626451d0495680769 Sender: owner-linux-mm@kvack.org To: Michel Lespinasse Cc: Hugh Dickins , Christoph Hellwig , Dave Chinner , Peter Zijlstra , Nick Piggin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Rik van Riel , Kosaki Motohiro , Michael Rubin , Suleiman Souhlal List-ID: --000e0cd2e0e626451d0495680769 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Nov 19, 2010 at 2:23 AM, Michel Lespinasse wrote: > Approaching the problem the other way - would there be any objection to > adding code to do an fallocate() equivalent at the start of mlock ? > This would be a no-op when the file is fully allocated on disk, and would > allow mlock to return an error if the file can't get fully allocated > (no idea what errno should be for such case, though). > My vote would be against. If you if you mmap a sparse file and then try writing to it willy-nilly, bad things will happen. This is true without a mlock(). Where is it written that mlock() has anything to do with improving this situation? If userspace wants to call fallocate() before it calls mlock(), it should do that. And in fact, in most cases, userspace should be encouraged to do that. But having mlock() call fallocate() and then return ENOSPC if there's no room? That just makes me feel icky as all heck. Look, it was an accident / bug of the implementation that mlock() magically dirtied all these pages. It might have made some situations better, but I very much doubt applications depended upon it, and I'd really rather not perpetuate this particular magic side effect of the buggy implementation of mlock(). -- Ted --000e0cd2e0e626451d0495680769 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Fri, Nov 19, 2010 at 2:23 AM, Michel = Lespinasse <walke= n@google.com> wrote:
Approaching the problem the other way - would there be any= objection to
adding code to do an fallocate() equivalent at the start of mlock ?
This would be a no-op when the file is fully allocated on disk, and would allow mlock to return an error if the file can't get fully allocated (no idea what errno should be for such case, though).

My vote would be against. =A0 If you if you mmap a sparse file = and then try writing to it willy-nilly, bad things will happen. =A0This is = true without a mlock(). =A0 Where is it written that mlock() has anything t= o do with improving this situation?

If userspace wants to call fallocate() before it calls = mlock(), it should do that. =A0And in fact, in most cases, userspace should= be encouraged to do that. =A0 But having mlock() call fallocate() and then= return ENOSPC if there's no room?

That just makes me feel icky as all heck.
Look, it was an accident / bug of the implementation that mlock= () magically dirtied all these pages. =A0It might have made some situations= better, but I very much doubt applications depended upon it, and I'd r= eally rather not perpetuate this particular magic side effect of the buggy = implementation of mlock().

-- Ted

--000e0cd2e0e626451d0495680769-- -- 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/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: email@kvack.org