From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754194Ab0KSNmK (ORCPT ); Fri, 19 Nov 2010 08:42:10 -0500 Received: from smtp-out.google.com ([216.239.44.51]:5213 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753793Ab0KSNmI convert rfc822-to-8bit (ORCPT ); Fri, 19 Nov 2010 08:42:08 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=WZyEbyyCvXx1L8eynkzZpJC/a6CKxLDVryCqs6yji8N2q8VSFVGVzBZrzgwRlx0lw5 WKAWMc1QyB4DEd6rt8/w== 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:42:05 -0500 Message-ID: Subject: Re: [PATCH 3/3] mlock: avoid dirtying pages and triggering writeback From: Theodore Tso 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 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 probably be encouraged to do that.   But having mlock() call fallocate() and then return ENOSPC if there's no room? Isn't it confusing that mlock() call ENOSPC? Doesn't that give you cognitive dissonance? It should because fundamentally mlock() has nothing to do with block allocation!! Read the API spec! 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 previously buggy implementation of mlock(). -- Ted From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail138.messagelabs.com (mail138.messagelabs.com [216.82.249.35]) by kanga.kvack.org (Postfix) with ESMTP id 7F2966B004A for ; Fri, 19 Nov 2010 08:42:10 -0500 (EST) Received: from hpaq5.eem.corp.google.com (hpaq5.eem.corp.google.com [172.25.149.5]) by smtp-out.google.com with ESMTP id oAJDg8qk029310 for ; Fri, 19 Nov 2010 05:42:08 -0800 Received: from pwj6 (pwj6.prod.google.com [10.241.219.70]) by hpaq5.eem.corp.google.com with ESMTP id oAJDg5Pq029909 for ; Fri, 19 Nov 2010 05:42:06 -0800 Received: by pwj6 with SMTP id 6so1253437pwj.18 for ; Fri, 19 Nov 2010 05:42:05 -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:42:05 -0500 Message-ID: Subject: Re: [PATCH 3/3] mlock: avoid dirtying pages and triggering writeback From: Theodore Tso Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: On Fri, Nov 19, 2010 at 2:23 AM, Michel Lespinasse wrot= e: > > 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 with= out a mlock(). =A0 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. =A0And in fact, in most cases, userspace should probably be encouraged to do that. =A0 But having mlock() call fallocate() and then return ENOSPC if there's no room? Isn't it confusing that mlock() call ENOSPC? Doesn't that give you cognitive dissonance? It should because fundamentally mlock() has nothing to do with block allocation!! Read the API spec! 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 really rather not perpetuate this particular magic side effect of the previously buggy implementation of mlock(). -- Ted -- 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