From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx160.postini.com [74.125.245.160]) by kanga.kvack.org (Postfix) with SMTP id AE1046B0032 for ; Fri, 12 Jul 2013 02:42:57 -0400 (EDT) Received: by mail-ve0-f182.google.com with SMTP id ox1so8018386veb.13 for ; Thu, 11 Jul 2013 23:42:56 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <51DFA3FD.2020201@intel.com> References: <1373596462-27115-1-git-send-email-ccross@android.com> <1373596462-27115-2-git-send-email-ccross@android.com> <51DFA3FD.2020201@intel.com> Date: Thu, 11 Jul 2013 23:42:56 -0700 Message-ID: Subject: Re: [PATCH 2/2] mm: add a field to store names for private anonymous memory From: Colin Cross Content-Type: text/plain; charset=ISO-8859-1 Sender: owner-linux-mm@kvack.org List-ID: To: Dave Hansen Cc: lkml , Kyungmin Park , Christoph Hellwig , John Stultz , "Eric W. Biederman" , Pekka Enberg , Rob Landley , 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 , "Paul E. McKenney" , David Howells , Arnd Bergmann , Dave Jones , "Rafael J. Wysocki" , Oleg Nesterov , Shaohua Li , Sasha Levin , KOSAKI Motohiro , Johannes Weiner , Ingo Molnar , "linux-doc@vger.kernel.org" , Linux-MM On Thu, Jul 11, 2013 at 11:36 PM, Dave Hansen wrote: > On 07/11/2013 07:34 PM, Colin Cross wrote: >> + pages_pinned = get_user_pages(current, mm, page_start_vaddr, >> + 1, 0, 0, &page, NULL); >> + if (pages_pinned < 1) { >> + seq_puts(m, "]"); >> + return; >> + } >> + >> + kaddr = (const char *)kmap(page); >> + len = min(max_len, PAGE_SIZE - page_offset); >> + write_len = strnlen(kaddr + page_offset, len); >> + seq_write(m, kaddr + page_offset, write_len); >> + kunmap(page); >> + put_page(page); > > This looks a bit like access_process_vm()? Can you perhaps use it here? It's a lot like __access_remote_vm, and this pattern is repeated in many other places in the kernel. I didn't try to reuse any of them because I wanted to stop reading at a null byte and __access_remote_vm would read the full NAME_MAX every time. I was also avoiding having to allocate a NAME_MAX sized buffer to copy into, instead passing the mapped user page directly to seq_write. -- 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