Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932182Ab1CMUXz (ORCPT ); Sun, 13 Mar 2011 16:23:55 -0400 Received: from mout.perfora.net ([74.208.4.194]:65091 "EHLO mout.perfora.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932083Ab1CMUXy (ORCPT ); Sun, 13 Mar 2011 16:23:54 -0400 From: Stephen Wilson To: Andrew Morton , Alexander Viro Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Michel Lespinasse , Andi Kleen , Rik van Riel , KOSAKI Motohiro , Matt Mackall , David Rientjes , Nick Piggin , Andrea Arcangeli , Mel Gorman , Hugh Dickins , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Stephen Wilson Subject: [PATCH 07/12] mm: factor out main logic of access_process_vm Date: Sun, 13 Mar 2011 15:49:19 -0400 Message-Id: <1300045764-24168-8-git-send-email-wilsons@start.ca> X-Mailer: git-send-email 1.7.3.5 In-Reply-To: <1300045764-24168-1-git-send-email-wilsons@start.ca> References: <1300045764-24168-1-git-send-email-wilsons@start.ca> X-Provags-ID: V02:K0:D/2Aamkxi/4RKHCPuhob6sRRqTKiTAgpeIoK6CiZzp+ M14MiMer3cpiYp0JRL+eYUnc/yU7R9rEO0T96plJXfqfHjutj7 3whw2SgRwdxSQvQCylXOtOxrVLOwHV8TJe9egmJa63y5CZ8Dn/ R9OZp7genQgz25b+1svI9PzBmO4Z6zQsXquVfIB7UYO/PNTbMR o2g4DJlq0r9BQqHbwsTO6gWS/cBCtx7mbB9MNyrnfA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2408 Lines: 81 Introduce an internal helper __access_remote_vm and base access_process_vm on top of it. This new method may be called with a NULL task_struct if page fault accounting is not desired. This code will be shared with a new address space accessor that is independent of task_struct. Signed-off-by: Stephen Wilson --- mm/memory.c | 35 +++++++++++++++++++++++++---------- 1 files changed, 25 insertions(+), 10 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 36445e3..68eec4f 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3593,20 +3593,15 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, #endif /* - * Access another process' address space. - * Source/target buffer must be kernel space, - * Do not walk the page table directly, use get_user_pages + * Access another process' address space as given in mm. If non-NULL, use the + * given task for page fault accounting. */ -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) +static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm, + unsigned long addr, void *buf, int len, int write) { - struct mm_struct *mm; struct vm_area_struct *vma; void *old_buf = buf; - mm = get_task_mm(tsk); - if (!mm) - return 0; - down_read(&mm->mmap_sem); /* ignore errors, just check how much was successfully transferred */ while (len) { @@ -3655,12 +3650,32 @@ int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, in addr += bytes; } up_read(&mm->mmap_sem); - mmput(mm); return buf - old_buf; } /* + * Access another process' address space. + * Source/target buffer must be kernel space, + * Do not walk the page table directly, use get_user_pages + */ +int access_process_vm(struct task_struct *tsk, unsigned long addr, + void *buf, int len, int write) +{ + struct mm_struct *mm; + int ret; + + mm = get_task_mm(tsk); + if (!mm) + return 0; + + ret = __access_remote_vm(tsk, mm, addr, buf, len, write); + mmput(mm); + + return ret; +} + +/* * Print the name of a VMA. */ void print_vma_addr(char *prefix, unsigned long ip) -- 1.7.3.5 -- 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/