From patchwork Mon Jan 21 07:57:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 10772791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 166371390 for ; Mon, 21 Jan 2019 07:58:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 065FE29D39 for ; Mon, 21 Jan 2019 07:58:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED28E29D3D; Mon, 21 Jan 2019 07:58:06 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E84829D39 for ; Mon, 21 Jan 2019 07:58:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 990268E0007; Mon, 21 Jan 2019 02:58:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 941038E0001; Mon, 21 Jan 2019 02:58:05 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82FEB8E0007; Mon, 21 Jan 2019 02:58:05 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 5B7E38E0001 for ; Mon, 21 Jan 2019 02:58:05 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id d31so20336200qtc.4 for ; Sun, 20 Jan 2019 23:58:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=5i3UnXFERP4rofpBwMYKkqKKJI/2hArru+36QcQJrxE=; b=DaJI/xY4RIry7AN4lybF8DlkfD+SA2H8olbEYrlHNpibwxF8gkNGHAttoh64ba2zCv 5pC3xYA/L+p9zEzTqHshhD7AZInY6TtjgB5fCyrQDbU3JVKr4F+KsQbRsx8NudEjyD0Q u5VzGkxfmI50YUeROiNJw2HZFFJ7gDgYIPq/K4fc1JcgDPPgUhwQrCzhupPHPGkATtFe mI7oafYdCUnkjy72X36JxOlgGnWcf/XACO4CnxwsbCSRyYz8EeuQOP6WTJ/ogeM0fAtS cAIN+K9nHel9xSsLDoWbAYbhi+yZJbz4/YJ+ev4ggZyyk8OKPDA/tUqnXBVc8F5gXiel rjpg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukc1u5aD9GoROpyYfjBT5u3kDwyK7sLHqZUPq4olHyXESyYszt3Y I1ohd1VUmLP2qm4B7Dla8hjOdy3wG/I+azYN5BZyeG393WPgoo7HgrKuZsOxvY0i7or4Z//NIm4 E1PVrHdqfVLGKqW5310ELUiZ69UNhdtQspuVV2ws2Rlu85d8FKnYsKMkvRadaYgKd9A== X-Received: by 2002:a0c:cb85:: with SMTP id p5mr24613451qvk.162.1548057485165; Sun, 20 Jan 2019 23:58:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN4zyuUCHtwT6/Qhl9gttuC6EcFpcppBlWG4Iih4/IlemrEhE5oVJ490GWU2UlINvoruys51 X-Received: by 2002:a0c:cb85:: with SMTP id p5mr24613403qvk.162.1548057483867; Sun, 20 Jan 2019 23:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057483; cv=none; d=google.com; s=arc-20160816; b=WJBr9aDibQg8GRZppVq846Wop0r8DJcljrjq79HL4mEK+zqqawfXDly8luy71QSbUm olNhTvjLrwXKmyRSOOZgqawzdcWmbl1kQ2W7GWzfMS95Qw4k6xs9py2KspL/+gXWck4h VwI7aVmfrRzRZt+RY7bgmMeppSFcOjd0AwhpgVLxmXXXcdXs4BzpiYxKH5SOgK1zrWrW d5qpw1rGKx2ZC2ppaYKJB1sYQ3IG3E42v2rTDTq4uS0oPu+6DS6JRb/leNF2xFmkb6nC 11sgFkqXP5kxKSuDXmxlfhmbXQiSmJmCeGfEQ4QIc2HV8He3QrVwpmmQFAy4VUgREAqo 8ESA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=5i3UnXFERP4rofpBwMYKkqKKJI/2hArru+36QcQJrxE=; b=CLC72/6mm9wnwCoRvOOMMIP1jskptEfnqARpks/Fo5CWA5KPXD2twccf4j0pSPY71v Rb+mROgXOZK/BL0V3hXuAvo+ialw3og+yKumOntlCoD5Jb0L2EbSZK20nbKAWtEF5wBJ w3V+1gsdNh2S+744PqULoRM05ldkpQs9DQm2uBR1W9+2UVMFbj69JD1J0pnBT4GSHGtv meJkKZGdliIVkf1r/5Wg8VItCSkLpprpcL8xbyuycqUoWS0cCZiQuXUlNXnOJyilnUHf ZAlYy5vkdbWwBhK0VESCRjgrvpBGnjDpVzo+i5EMfrIEj8tLTZNEMSTVIres9dN0mKG1 HBqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id m28si2624893qtf.328.2019.01.20.23.58.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 23:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA7EE394D4D; Mon, 21 Jan 2019 07:58:02 +0000 (UTC) Received: from xz-x1.nay.redhat.com (dhcp-14-116.nay.redhat.com [10.66.14.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id F39F8608C2; Mon, 21 Jan 2019 07:57:54 +0000 (UTC) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hugh Dickins , Maya Gokhale , Jerome Glisse , Johannes Weiner , peterx@redhat.com, Martin Cracauer , Denis Plotnikov , Shaohua Li , Andrea Arcangeli , Pavel Emelyanov , Mike Kravetz , Marty McFadden , Mike Rapoport , Mel Gorman , "Kirill A . Shutemov" , "Dr . David Alan Gilbert" Subject: [PATCH RFC 04/24] mm: gup: allow VM_FAULT_RETRY for multiple times Date: Mon, 21 Jan 2019 15:57:02 +0800 Message-Id: <20190121075722.7945-5-peterx@redhat.com> In-Reply-To: <20190121075722.7945-1-peterx@redhat.com> References: <20190121075722.7945-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 21 Jan 2019 07:58:03 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This is the gup counterpart of the change that allows the VM_FAULT_RETRY to happen for more than once. Signed-off-by: Peter Xu Reviewed-by: Jérôme Glisse --- mm/gup.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 7b1f452cc2ef..22f1d419a849 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -528,7 +528,10 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma, if (*flags & FOLL_NOWAIT) fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT; if (*flags & FOLL_TRIED) { - VM_WARN_ON_ONCE(fault_flags & FAULT_FLAG_ALLOW_RETRY); + /* + * Note: FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_TRIED + * can co-exist + */ fault_flags |= FAULT_FLAG_TRIED; } @@ -943,17 +946,23 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk, /* VM_FAULT_RETRY triggered, so seek to the faulting offset */ pages += ret; start += ret << PAGE_SHIFT; + lock_dropped = true; +retry: /* * Repeat on the address that fired VM_FAULT_RETRY - * without FAULT_FLAG_ALLOW_RETRY but with + * with both FAULT_FLAG_ALLOW_RETRY and * FAULT_FLAG_TRIED. */ *locked = 1; - lock_dropped = true; down_read(&mm->mmap_sem); ret = __get_user_pages(tsk, mm, start, 1, flags | FOLL_TRIED, - pages, NULL, NULL); + pages, NULL, locked); + if (!*locked) { + /* Continue to retry until we succeeded */ + BUG_ON(ret != 0); + goto retry; + } if (ret != 1) { BUG_ON(ret > 1); if (!pages_done)