From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC1CDC47E48 for ; Thu, 26 Sep 2019 09:40:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7EA54222BE for ; Thu, 26 Sep 2019 09:40:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EA54222BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 332816B026A; Thu, 26 Sep 2019 05:40:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E2446B026B; Thu, 26 Sep 2019 05:40:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D1F46B026C; Thu, 26 Sep 2019 05:40:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id F2FC16B026A for ; Thu, 26 Sep 2019 05:40:44 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 73152181AC9AE for ; Thu, 26 Sep 2019 09:40:44 +0000 (UTC) X-FDA: 75976577208.02.end88_7acac96ea6833 X-HE-Tag: end88_7acac96ea6833 X-Filterd-Recvd-Size: 5193 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Sep 2019 09:40:43 +0000 (UTC) Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB29B7FDF5 for ; Thu, 26 Sep 2019 09:40:42 +0000 (UTC) Received: by mail-pf1-f199.google.com with SMTP id f2so1359522pfk.13 for ; Thu, 26 Sep 2019 02:40:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mt5SnWXXSk9uI7dmB8jKwFtY/VxQIE33S8hNcu1UngY=; b=ho5sbr5ZVqWTiGcnwJPZBPE6Q//p09Ts7DnWyT6fWIh8Q9xg7rd1HH5GylRGySPA1W UFGNalYZhcmsaKerunULY51uvwGXSzJ2xzXE5V6lgp2/BNGQ4wWtnAtM60UObmNcR0sC yY85rgjnFRB5XmaR9OY8+i+NRs2BpeNL7bujfpxDqSknSRSZY77PTRRqGe9yeQf5yC6S Oy/3kmAwez15Y0N1DwTRqWROKIXgNsIOgpjypVhi+aj28lN/fP/9AOyTaPTlgDf0NhBS v6izY+XuI5lg7QI+e0Fh7dUzXeFff88XFawUiBjuG2KIy5EoQInEq0lPqTlVCp64ysjl rGlA== X-Gm-Message-State: APjAAAVx/TzM6RrTzjtJNr+lXceC1/Gw9Ko4WAHM49e4s/4R4g5bklcr 4Mvimq2FR1LYoAb94Vcu5XLZSahsHgXUo4+0tn8qf5TC7W48jUQu52dkq9Audq/XA2D/1dfuueJ PqhZ3JXaDRNs= X-Received: by 2002:a17:902:7615:: with SMTP id k21mr3125718pll.116.1569490841822; Thu, 26 Sep 2019 02:40:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8FZvMzCaS6tP09HihPyaGx7bD6hMWJf1hsxnBDZsjGhkkZymRtSV9xjgZdU3TLT4rGPDI4Q== X-Received: by 2002:a17:902:7615:: with SMTP id k21mr3125689pll.116.1569490841636; Thu, 26 Sep 2019 02:40:41 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id p68sm3224982pfp.9.2019.09.26.02.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 02:40:40 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: David Hildenbrand , Hugh Dickins , Maya Gokhale , Jerome Glisse , Pavel Emelyanov , Johannes Weiner , peterx@redhat.com, Martin Cracauer , Matthew Wilcox , Shaohua Li , Marty McFadden , Andrea Arcangeli , Mike Kravetz , Denis Plotnikov , Mike Rapoport , Linus Torvalds , Mel Gorman , "Kirill A . Shutemov" , "Dr . David Alan Gilbert" Subject: [PATCH v5 10/16] userfaultfd: Don't retake mmap_sem to emulate NOPAGE Date: Thu, 26 Sep 2019 17:38:58 +0800 Message-Id: <20190926093904.5090-11-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190926093904.5090-1-peterx@redhat.com> References: <20190926093904.5090-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: This patch removes the risk path in handle_userfault() then we will be sure that the callers of handle_mm_fault() will know that the VMAs might have changed. Meanwhile with previous patch we don't lose responsiveness as well since the core mm code now can handle the nonfatal userspace signals even if we return VM_FAULT_RETRY. Suggested-by: Andrea Arcangeli Suggested-by: Linus Torvalds Reviewed-by: Jerome Glisse Signed-off-by: Peter Xu --- fs/userfaultfd.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index fe6d804a38dc..d8777146bae7 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -524,30 +524,6 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, un= signed long reason) =20 __set_current_state(TASK_RUNNING); =20 - if (return_to_userland) { - if (signal_pending(current) && - !fatal_signal_pending(current)) { - /* - * If we got a SIGSTOP or SIGCONT and this is - * a normal userland page fault, just let - * userland return so the signal will be - * handled and gdb debugging works. The page - * fault code immediately after we return from - * this function is going to release the - * mmap_sem and it's not depending on it - * (unlike gup would if we were not to return - * VM_FAULT_RETRY). - * - * If a fatal signal is pending we still take - * the streamlined VM_FAULT_RETRY failure path - * and there's no need to retake the mmap_sem - * in such case. - */ - down_read(&mm->mmap_sem); - ret =3D VM_FAULT_NOPAGE; - } - } - /* * Here we race with the list_del; list_add in * userfaultfd_ctx_read(), however because we don't ever run --=20 2.21.0