From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbbKQDfW (ORCPT ); Mon, 16 Nov 2015 22:35:22 -0500 Received: from mga01.intel.com ([192.55.52.88]:45741 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751679AbbKQDfS (ORCPT ); Mon, 16 Nov 2015 22:35:18 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,305,1444719600"; d="scan'208";a="601541225" Subject: [PATCH 04/37] mm: simplify __get_user_pages() To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Dave Hansen , dave.hansen@linux.intel.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, aarcange@redhat.com, n-horiguchi@ah.jp.nec.com From: Dave Hansen Date: Mon, 16 Nov 2015 19:35:16 -0800 References: <20151117033511.BFFA1440@viggo.jf.intel.com> In-Reply-To: <20151117033511.BFFA1440@viggo.jf.intel.com> Message-Id: <20151117033516.4A3EB4B3@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen Now that we have one fewer callers of __get_user_pages(), we only have one way in which it is called. Neither of the two remaining callers need to pass 'locked' nor set notify_drop=1. We can drop both those arguments. Signed-off-by: Dave Hansen Cc: Andrew Morton Cc: Kirill A. Shutemov Cc: Andrea Arcangeli Cc: Naoya Horiguchi --- b/mm/gup.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff -puN mm/gup.c~simplify-get_user_pages mm/gup.c --- a/mm/gup.c~simplify-get_user_pages 2015-11-16 12:35:36.119207285 -0800 +++ b/mm/gup.c 2015-11-16 12:35:36.123207466 -0800 @@ -625,18 +625,10 @@ static __always_inline long __get_user_p int write, int force, struct page **pages, struct vm_area_struct **vmas, - int *locked, bool notify_drop, unsigned int flags) { + int locked = 1; long ret, pages_done; - bool lock_dropped; - - if (locked) { - /* if VM_FAULT_RETRY can be returned, vmas become invalid */ - BUG_ON(vmas); - /* check caller initialized locked */ - BUG_ON(*locked != 1); - } if (pages) flags |= FOLL_GET; @@ -646,16 +638,12 @@ static __always_inline long __get_user_p flags |= FOLL_FORCE; pages_done = 0; - lock_dropped = false; for (;;) { ret = __get_user_pages(tsk, mm, start, nr_pages, flags, pages, - vmas, locked); - if (!locked) - /* VM_FAULT_RETRY couldn't trigger, bypass */ - return ret; + vmas, &locked); /* VM_FAULT_RETRY cannot return errors */ - if (!*locked) { + if (!locked) { BUG_ON(ret < 0); BUG_ON(ret >= nr_pages); } @@ -670,7 +658,7 @@ static __always_inline long __get_user_p if (!nr_pages) break; } - if (*locked) { + if (locked) { /* VM_FAULT_RETRY didn't trigger */ if (!pages_done) pages_done = ret; @@ -685,8 +673,7 @@ static __always_inline long __get_user_p * without FAULT_FLAG_ALLOW_RETRY but with * FAULT_FLAG_TRIED. */ - *locked = 1; - lock_dropped = true; + locked = 1; down_read(&mm->mmap_sem); ret = __get_user_pages(tsk, mm, start, 1, flags | FOLL_TRIED, pages, NULL, NULL); @@ -703,14 +690,6 @@ static __always_inline long __get_user_p pages++; start += PAGE_SIZE; } - if (notify_drop && lock_dropped && *locked) { - /* - * We must let the caller know we temporarily dropped the lock - * and so the critical section protected by it was lost. - */ - up_read(&mm->mmap_sem); - *locked = 0; - } return pages_done; } @@ -730,12 +709,10 @@ __always_inline long __get_user_pages_un unsigned int gup_flags) { long ret; - int locked = 1; down_read(&mm->mmap_sem); ret = __get_user_pages_locked(tsk, mm, start, nr_pages, write, force, - pages, NULL, &locked, false, gup_flags); - if (locked) - up_read(&mm->mmap_sem); + pages, NULL, gup_flags); + up_read(&mm->mmap_sem); return ret; } EXPORT_SYMBOL(__get_user_pages_unlocked); @@ -826,7 +803,7 @@ long get_user_pages(struct task_struct * int force, struct page **pages, struct vm_area_struct **vmas) { return __get_user_pages_locked(tsk, mm, start, nr_pages, write, force, - pages, vmas, NULL, false, FOLL_TOUCH); + pages, vmas, FOLL_TOUCH); } EXPORT_SYMBOL(get_user_pages); _