From patchwork Tue Oct 25 23:36:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 9395705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B5D6060234 for ; Tue, 25 Oct 2016 23:36:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7716529698 for ; Tue, 25 Oct 2016 23:36:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AA112969A; Tue, 25 Oct 2016 23:36:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 095FE29666 for ; Tue, 25 Oct 2016 23:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755969AbcJYXgQ (ORCPT ); Tue, 25 Oct 2016 19:36:16 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37454 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754167AbcJYXgN (ORCPT ); Tue, 25 Oct 2016 19:36:13 -0400 Received: by mail-wm0-f65.google.com with SMTP id 79so2285465wmy.4; Tue, 25 Oct 2016 16:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=BzVNKhrKpj7iO8S+Qs5QoDklrvSmhY16q4/iH8Va5EI=; b=nWjAYnKfR35Y3t4K03IcUuf9XE5of3I6N15TGWRSRr9vq+PdgIPWBx40qPc3Xdyb6n rrfNfE5Ii8WDCgZwzcyYatLJn+3zmT+sPiWgT6evaDDcALq1NTV/PfvMnNt9IlbtNHcQ Xuw10UfQiniaJ/CFrHCHNlHcm+rlRDTWOkQAu0IHCLqClZRZkgZEaGPhI/tcmIlBJ5Ed L5q26uuZrT0b1WiWZISGxnxL5yQiZJ8JIq4p+r5B5aYHvT/ricKehv1eIcib8bWEt1EY jEDmmFvviya8pgUZDWg70pLyIGcSq0cCatOuk+vGHQ+KtubybAu91AbSXKTlsMqyMZxE 6piA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BzVNKhrKpj7iO8S+Qs5QoDklrvSmhY16q4/iH8Va5EI=; b=GE4NQengTbU6sMJBfqY1cUlIzf+MxJlcvPng8jsgVGrFnli/G2oY1kOdUtFKvjMX7E BydDH/tdWdZ0HMETdBQv1FVgLkhNi2hPst/t0fkT7iSujqzcxX8qk0xQgYt6dh4aqA2h J5RvwX/d7S2ZhyTNZ8UGowRt5Uq5VMDwwlHFjMFBHp2UStHnDXU5wItc1oEVQRnrTodW 3pq2eJ9ykQnQPuY7SD9op4ho8lp+Zl5qRvY95ukKXp/GiWq4zBSEnNU5xY7qsUKT0rua NCI7Hd8ekJHgCeXU4d1eNiFqQiC69Ef8WxbGaIt/vJiM1UppChr0KOPkcdlQwHFdiCVu dyPw== X-Gm-Message-State: ABUngvdnPEJPHJ6O/W5M63OBvA5wrb/rIxeDzHL4vWwbyrKDSlee47F3jQsmSVxfpEIQgA== X-Received: by 10.194.115.38 with SMTP id jl6mr18166291wjb.52.1477438571692; Tue, 25 Oct 2016 16:36:11 -0700 (PDT) Received: from localhost (cpc94060-newt37-2-0-cust185.19-3.cable.virginm.net. [92.234.204.186]) by smtp.gmail.com with ESMTPSA id p3sm27431827wjr.31.2016.10.25.16.36.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Oct 2016 16:36:10 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org Cc: Linus Torvalds , Michal Hocko , Jan Kara , Hugh Dickins , Dave Hansen , Rik van Riel , Mel Gorman , Andrew Morton , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lorenzo Stoakes Subject: [PATCH] mm: remove unnecessary __get_user_pages_unlocked() calls Date: Wed, 26 Oct 2016 00:36:09 +0100 Message-Id: <20161025233609.5601-1-lstoakes@gmail.com> X-Mailer: git-send-email 2.10.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In hva_to_pfn_slow() we are able to replace __get_user_pages_unlocked() with get_user_pages_unlocked() since we can now pass gup_flags. In async_pf_execute() we need to pass different tsk, mm arguments so get_user_pages_remote() is the sane replacement here (having added manual acquisition and release of mmap_sem.) Since we pass a NULL pages parameter the subsequent call to __get_user_pages_locked() will have previously bailed any attempt at VM_FAULT_RETRY, so we do not change this behaviour by using get_user_pages_remote() which does not invoke VM_FAULT_RETRY logic at all. Signed-off-by: Lorenzo Stoakes Acked-by: Michal Hocko --- virt/kvm/async_pf.c | 7 ++++--- virt/kvm/kvm_main.c | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) -- 2.10.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index 8035cc1..e8c832c 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -82,10 +82,11 @@ static void async_pf_execute(struct work_struct *work) /* * This work is run asynchromously to the task which owns * mm and might be done in another context, so we must - * use FOLL_REMOTE. + * access remotely. */ - __get_user_pages_unlocked(NULL, mm, addr, 1, NULL, - FOLL_WRITE | FOLL_REMOTE); + down_read(&mm->mmap_sem); + get_user_pages_remote(NULL, mm, addr, 1, FOLL_WRITE, NULL, NULL); + up_read(&mm->mmap_sem); kvm_async_page_present_sync(vcpu, apf); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2907b7b..c45d951 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1415,13 +1415,12 @@ static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault, npages = get_user_page_nowait(addr, write_fault, page); up_read(¤t->mm->mmap_sem); } else { - unsigned int flags = FOLL_TOUCH | FOLL_HWPOISON; + unsigned int flags = FOLL_HWPOISON; if (write_fault) flags |= FOLL_WRITE; - npages = __get_user_pages_unlocked(current, current->mm, addr, 1, - page, flags); + npages = get_user_pages_unlocked(addr, 1, page, flags); } if (npages != 1) return npages;