From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932392AbaHATVa (ORCPT ); Fri, 1 Aug 2014 15:21:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52771 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932248AbaHATV1 (ORCPT ); Fri, 1 Aug 2014 15:21:27 -0400 From: Naoya Horiguchi To: Andrew Morton Cc: Dave Hansen , Hugh Dickins , "Kirill A. Shutemov" , Jerome Marchand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Naoya Horiguchi Subject: [PATCH -mm v6 03/13] pagewalk: add walk_page_vma() Date: Fri, 1 Aug 2014 15:20:39 -0400 Message-Id: <1406920849-25908-4-git-send-email-n-horiguchi@ah.jp.nec.com> In-Reply-To: <1406920849-25908-1-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1406920849-25908-1-git-send-email-n-horiguchi@ah.jp.nec.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduces walk_page_vma(), which is useful for the callers which want to walk over a given vma. It's used by later patches. ChangeLog v3: - check walk_page_test's return value instead of walk->skip Signed-off-by: Naoya Horiguchi Acked-by: Kirill A. Shutemov --- include/linux/mm.h | 1 + mm/pagewalk.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git mmotm-2014-07-30-15-57.orig/include/linux/mm.h mmotm-2014-07-30-15-57/include/linux/mm.h index 1640cf740837..84b2a6cf45f6 100644 --- mmotm-2014-07-30-15-57.orig/include/linux/mm.h +++ mmotm-2014-07-30-15-57/include/linux/mm.h @@ -1131,6 +1131,7 @@ struct mm_walk { int walk_page_range(unsigned long addr, unsigned long end, struct mm_walk *walk); +int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk); void free_pgd_range(struct mmu_gather *tlb, unsigned long addr, unsigned long end, unsigned long floor, unsigned long ceiling); int copy_page_range(struct mm_struct *dst, struct mm_struct *src, diff --git mmotm-2014-07-30-15-57.orig/mm/pagewalk.c mmotm-2014-07-30-15-57/mm/pagewalk.c index 91810ba875ea..65fb68df3aa2 100644 --- mmotm-2014-07-30-15-57.orig/mm/pagewalk.c +++ mmotm-2014-07-30-15-57/mm/pagewalk.c @@ -272,3 +272,21 @@ int walk_page_range(unsigned long start, unsigned long end, } while (start = next, start < end); return err; } + +int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk) +{ + int err; + + if (!walk->mm) + return -EINVAL; + + VM_BUG_ON(!rwsem_is_locked(&walk->mm->mmap_sem)); + VM_BUG_ON(!vma); + walk->vma = vma; + err = walk_page_test(vma->vm_start, vma->vm_end, walk); + if (err > 0) + return 0; + if (err < 0) + return err; + return __walk_page_range(vma->vm_start, vma->vm_end, walk); +} -- 1.9.3 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qa0-f49.google.com (mail-qa0-f49.google.com [209.85.216.49]) by kanga.kvack.org (Postfix) with ESMTP id 583AD6B0038 for ; Fri, 1 Aug 2014 15:21:13 -0400 (EDT) Received: by mail-qa0-f49.google.com with SMTP id dc16so4383487qab.22 for ; Fri, 01 Aug 2014 12:21:13 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id t7si12668769qgd.100.2014.08.01.12.21.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Aug 2014 12:21:12 -0700 (PDT) From: Naoya Horiguchi Subject: [PATCH -mm v6 03/13] pagewalk: add walk_page_vma() Date: Fri, 1 Aug 2014 15:20:39 -0400 Message-Id: <1406920849-25908-4-git-send-email-n-horiguchi@ah.jp.nec.com> In-Reply-To: <1406920849-25908-1-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1406920849-25908-1-git-send-email-n-horiguchi@ah.jp.nec.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Dave Hansen , Hugh Dickins , "Kirill A. Shutemov" , Jerome Marchand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Naoya Horiguchi Introduces walk_page_vma(), which is useful for the callers which want to walk over a given vma. It's used by later patches. ChangeLog v3: - check walk_page_test's return value instead of walk->skip Signed-off-by: Naoya Horiguchi Acked-by: Kirill A. Shutemov --- include/linux/mm.h | 1 + mm/pagewalk.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git mmotm-2014-07-30-15-57.orig/include/linux/mm.h mmotm-2014-07-30-15-57/include/linux/mm.h index 1640cf740837..84b2a6cf45f6 100644 --- mmotm-2014-07-30-15-57.orig/include/linux/mm.h +++ mmotm-2014-07-30-15-57/include/linux/mm.h @@ -1131,6 +1131,7 @@ struct mm_walk { int walk_page_range(unsigned long addr, unsigned long end, struct mm_walk *walk); +int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk); void free_pgd_range(struct mmu_gather *tlb, unsigned long addr, unsigned long end, unsigned long floor, unsigned long ceiling); int copy_page_range(struct mm_struct *dst, struct mm_struct *src, diff --git mmotm-2014-07-30-15-57.orig/mm/pagewalk.c mmotm-2014-07-30-15-57/mm/pagewalk.c index 91810ba875ea..65fb68df3aa2 100644 --- mmotm-2014-07-30-15-57.orig/mm/pagewalk.c +++ mmotm-2014-07-30-15-57/mm/pagewalk.c @@ -272,3 +272,21 @@ int walk_page_range(unsigned long start, unsigned long end, } while (start = next, start < end); return err; } + +int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk) +{ + int err; + + if (!walk->mm) + return -EINVAL; + + VM_BUG_ON(!rwsem_is_locked(&walk->mm->mmap_sem)); + VM_BUG_ON(!vma); + walk->vma = vma; + err = walk_page_test(vma->vm_start, vma->vm_end, walk); + if (err > 0) + return 0; + if (err < 0) + return err; + return __walk_page_range(vma->vm_start, vma->vm_end, walk); +} -- 1.9.3 -- 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