From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx167.postini.com [74.125.245.167]) by kanga.kvack.org (Postfix) with SMTP id C2B136B0032 for ; Wed, 10 Jul 2013 19:38:40 -0400 (EDT) Message-ID: <51DDF071.5000309@intel.com> Date: Wed, 10 Jul 2013 16:38:25 -0700 From: Dave Hansen MIME-Version: 1.0 Subject: Re: [PATCH] mm: add sys_madvise2 and MADV_NAME to name vmas References: <1372901537-31033-1-git-send-email-ccross@android.com> <51DDE974.6060200@intel.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Colin Cross Cc: lkml , Kyungmin Park , Christoph Hellwig , John Stultz , Rob Landley , Arnd Bergmann , Andrew Morton , Cyrill Gorcunov , David Rientjes , Davidlohr Bueso , Kees Cook , Al Viro , Hugh Dickins , Mel Gorman , Michel Lespinasse , Rik van Riel , Konstantin Khlebnikov , Peter Zijlstra , Rusty Russell , "Eric W. Biederman" , Oleg Nesterov , Srikar Dronamraju , KAMEZAWA Hiroyuki , Michal Hocko , Anton Vorontsov , Pekka Enberg , Shaohua Li , Sasha Levin , KOSAKI Motohiro , Johannes Weiner , Ingo Molnar , open@kvack.org, list@kvack.org, DOCUMENTATION open@kvack.orglist@kvack.org, MEMORY MANAGEMENT , "open list:GENERIC INCLUDE/A..." On 07/10/2013 04:23 PM, Colin Cross wrote: > On Wed, Jul 10, 2013 at 4:08 PM, Dave Hansen wrote: >> On 07/03/2013 06:31 PM, Colin Cross wrote: >>> @@ -289,6 +291,7 @@ struct vm_area_struct { >>> #ifdef CONFIG_NUMA >>> struct mempolicy *vm_policy; /* NUMA policy for the VMA */ >>> #endif >>> + struct vma_name *vm_name; >>> }; >> >> You could probably get rid of the extra pointer by unioning this with >> vm_file. They should not ever get used together. We would, however, >> have to transition away from checking vma->vm_file for "is this vma >> file-backed"? We are out of VM_* flag space which is a bummer. > > I considered trying to union with vm_file, but like you said the lack > of space in vm_flags makes it hard. I'd rather see 32 more bits "wasted" on new flags than a pointer that is used very rarely. > It would also prevent naming file > backed mappings, which is supported by this patch set. It's not > required by my primary use case, but it could be useful to have the > dynamic linker identify the various elf segments. That's stretching it a bit. :) Here's one more idea: instead of having a kernel pointer, let's let userspace hand the kernel a userspace address, and the kernel will hang on to it. Userspace is responsible for keeping it valid, kind of like ARGV[]. When the kernel goes to dump out the /proc/$pid/maps fields, it can do a copy_from_user() to get the string back out. If this fails, it can just go and treat it like a non-named VMA, or could output "userspace sucks". That way, the kernel isn't dealing with refcounting and allocating strings. It's got security concerns, just like /proc/$pid/cmdline since it'll let you dig around in another process's address space via /proc. But, I think they're manageable. Hey, doing that would even let you reuse vm_file. >=PAGE_OFFFSET means it's a file. email@kvack.org