Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754134AbbDMM5I (ORCPT ); Mon, 13 Apr 2015 08:57:08 -0400 Received: from mta-out1.inet.fi ([62.71.2.227]:34574 "EHLO jenni1.inet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751604AbbDMM5E (ORCPT ); Mon, 13 Apr 2015 08:57:04 -0400 Date: Mon, 13 Apr 2015 15:56:54 +0300 From: "Kirill A. Shutemov" To: Yigal Korman , Matthew Wilcox , Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: mlock() on DAX returns -ENOMEM Message-ID: <20150413125654.GB12354@node.dhcp.inet.fi> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2118 Lines: 52 On Sun, Apr 12, 2015 at 03:56:33PM +0300, Yigal Korman wrote: > Hi, > I've tried to mlock() a range of an ext4-dax file and got "-ENOMEM" in return. Is it comes from mlock_fixup() or -EFAULT from GUP translated to -ENOMEM by __mlock_posix_error_return()? > Looking at the code, it seems that this is related to the fact that > DAX uses VM_MIXEDMAP and mlock assumes/requires regular page cache. > To me it seems that DAX should simply return success in mlock() as all > data is always in memory and no swapping is possible. > Is this a bug or intentional? Is there a fix planned? I think it's a bug. But first we need to define what mlock() means for DAX mappings. For writable MAP_PRIVATE: we should be able to trigger COW for the range and mlock resulting pages. It means we should fix kernel to handle GUP(FOLL_TOUCH | FOLL_POPULATE | FOLL_WRITE | FOLL_FORCE) successfully on such VMAs. For MAP_SHARED and non-writable MAP_PRIVATE we should be able to populate the mapping with PTEs. Not sure if we need to set VM_LOCKED for such VMAs. We probably should, as we want to re-instantiate PTEs on mremap() and such. It means we need to get working at least GUP(FOLL_POPULATE | FOLL_FORCE). In general we need to adjust GUP to avoid going to struct page unless FOLL_* speficly imply struct page, such as FOLL_GET or FOLL_TOUCH. Not sure if we need to differentiate DAX mappings from other VM_MIXEDMAP. Any comments? > Also, the same code path that is used in mlock is also used for > MAP_POPULATE (pre-fault pages in mmap) so this flag doesn't work as > well (doesn't fail but simply doesn't pre-fault anything). > > Thanks, > Yigal > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Kirill A. Shutemov -- 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/