From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Emelyanov Subject: Re: [PATCH 3/6] shm: add memfd_create() syscall Date: Thu, 20 Mar 2014 13:01:47 +0400 Message-ID: <532AAE7B.2030501@parallels.com> References: <1395256011-2423-1-git-send-email-dh.herrmann@gmail.com> <1395256011-2423-4-git-send-email-dh.herrmann@gmail.com> <20140320084748.GK1728@moon> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20140320084748.GK1728@moon> Sender: owner-linux-mm@kvack.org To: Cyrill Gorcunov , David Herrmann Cc: linux-kernel@vger.kernel.org, Hugh Dickins , Alexander Viro , Matthew Wilcox , Karol Lewandowski , Kay Sievers , Daniel Mack , Lennart Poettering , =?ISO-8859-1?Q?Kristian_H=F8gsberg?= , john.stultz@linaro.org, Greg Kroah-Hartman , Tejun Heo , Johannes Weiner , dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Linus Torvalds , Ryan Lortie , "Michael Kerrisk (man-pages)" List-Id: dri-devel@lists.freedesktop.org On 03/20/2014 12:47 PM, Cyrill Gorcunov wrote: > On Wed, Mar 19, 2014 at 08:06:48PM +0100, David Herrmann wrote: >> memfd_create() is similar to mmap(MAP_ANON), but returns a file-descriptor >> that you can pass to mmap(). It explicitly allows sealing and >> avoids any connection to user-visible mount-points. Thus, it's not >> subject to quotas on mounted file-systems, but can be used like >> malloc()'ed memory, but with a file-descriptor to it. >> >> memfd_create() does not create a front-FD, but instead returns the raw >> shmem file, so calls like ftruncate() can be used. Also calls like fstat() >> will return proper information and mark the file as regular file. Sealing >> is explicitly supported on memfds. >> >> Compared to O_TMPFILE, it does not require a tmpfs mount-point and is not >> subject to quotas and alike. > > If I'm not mistaken in something obvious, this looks similar to /proc/pid/map_files > feature, Pavel? Thanks, Cyrill. It is, but the map_files will work "in the opposite direction" :) In the memfd case one first gets an FD, then mmap()s it; in the /proc/pis/map_files case one should first mmap() a region, then open it via /proc/self/map_files. But I don't know whether this matters. Thanks, Pavel -- 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/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754625AbaCTJCM (ORCPT ); Thu, 20 Mar 2014 05:02:12 -0400 Received: from relay.parallels.com ([195.214.232.42]:42797 "EHLO relay.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750743AbaCTJCI (ORCPT ); Thu, 20 Mar 2014 05:02:08 -0400 Message-ID: <532AAE7B.2030501@parallels.com> Date: Thu, 20 Mar 2014 13:01:47 +0400 From: Pavel Emelyanov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Cyrill Gorcunov , David Herrmann CC: , Hugh Dickins , Alexander Viro , Matthew Wilcox , Karol Lewandowski , Kay Sievers , Daniel Mack , Lennart Poettering , =?ISO-8859-1?Q?Kristian_H=F8gsberg?= , , Greg Kroah-Hartman , Tejun Heo , Johannes Weiner , , , , Andrew Morton , Linus Torvalds , Ryan Lortie , "Michael Kerrisk (man-pages)" Subject: Re: [PATCH 3/6] shm: add memfd_create() syscall References: <1395256011-2423-1-git-send-email-dh.herrmann@gmail.com> <1395256011-2423-4-git-send-email-dh.herrmann@gmail.com> <20140320084748.GK1728@moon> In-Reply-To: <20140320084748.GK1728@moon> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.30.16.114] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/20/2014 12:47 PM, Cyrill Gorcunov wrote: > On Wed, Mar 19, 2014 at 08:06:48PM +0100, David Herrmann wrote: >> memfd_create() is similar to mmap(MAP_ANON), but returns a file-descriptor >> that you can pass to mmap(). It explicitly allows sealing and >> avoids any connection to user-visible mount-points. Thus, it's not >> subject to quotas on mounted file-systems, but can be used like >> malloc()'ed memory, but with a file-descriptor to it. >> >> memfd_create() does not create a front-FD, but instead returns the raw >> shmem file, so calls like ftruncate() can be used. Also calls like fstat() >> will return proper information and mark the file as regular file. Sealing >> is explicitly supported on memfds. >> >> Compared to O_TMPFILE, it does not require a tmpfs mount-point and is not >> subject to quotas and alike. > > If I'm not mistaken in something obvious, this looks similar to /proc/pid/map_files > feature, Pavel? Thanks, Cyrill. It is, but the map_files will work "in the opposite direction" :) In the memfd case one first gets an FD, then mmap()s it; in the /proc/pis/map_files case one should first mmap() a region, then open it via /proc/self/map_files. But I don't know whether this matters. Thanks, Pavel