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.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 77DFBC11D0C for ; Thu, 20 Feb 2020 16:02:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3147920658 for ; Thu, 20 Feb 2020 16:02:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZWKlJ3QQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3147920658 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 BF3176B0003; Thu, 20 Feb 2020 11:02:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BCACB6B0006; Thu, 20 Feb 2020 11:02:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE2716B0007; Thu, 20 Feb 2020 11:02:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 9664C6B0003 for ; Thu, 20 Feb 2020 11:02:43 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F3AC6E0A4 for ; Thu, 20 Feb 2020 16:02:42 +0000 (UTC) X-FDA: 76510973364.28.boats59_51bc47ccc521c X-HE-Tag: boats59_51bc47ccc521c X-Filterd-Recvd-Size: 6039 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 16:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IyMzyx3h4CnCPR8N2mJzD7NxgnsdEs1Zlb2bdklQDko=; b=ZWKlJ3QQ17Nvglp3g0ZTicriqF9mH3eVpGiPchn1zpCbmAhN+SU/V+H/ovtqe6XX4iBXVY EZMRoRgbfDfpDz9Ov8GtvyPoSsQ6m15SJjwHaU4UHxwjI8QnWGU2smD923Z9nteBiEEK2g XH2Tx4ReVIzLgQBz+FxrUMbkYCp7HBE= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-OazyKsSjPsm-Nb48T2ot9Q-1; Thu, 20 Feb 2020 11:02:38 -0500 Received: by mail-qv1-f72.google.com with SMTP id cn2so2879807qvb.1 for ; Thu, 20 Feb 2020 08:02:38 -0800 (PST) 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=Mmxs1xZU/E+YLRZuVpERmcrfUBlYfy8dMItOYHlmr9U=; b=YbPLnggbifkL6pLt/jaQ55fd/sls3+rmNJQGtE+k6ExC0p65yX3q1pKeaK2vIF5RH9 T7mVcnKuvubP0PN08bx1QUfrW/pJlWUQv0uQ2AM7/Wu+Wu0Req6N0QMrp+M++Nv3Qhu8 m4ZLMKa0ASESgAb2ya3j4WMxT4zyVA/i38tbTlRzkQQ+slgFni/opRkN4cpmfYmw4EOx eyz7olkKkiNYiILoTPWto+mrJaArvl9nDwRRV7ZDfes+QwH83uKuh3bO67QM84i4qWOJ JNWQvm45FKi5H4jh8IDoAYe/FFYXTnSTzO0SwA/hKrSQvwe+Olpr5zM2GgP4Oy42rjDy VlOA== X-Gm-Message-State: APjAAAViLeEQB4nQKoNm0dd8+7LxY6jFcFnMkL791fpLHTZRjaYH2OZ+ 15m2N0pROlpqJ4s5lGxn316XSfXOHV9ZQaRfBlEv8EeK7h9KKKEbZ9bwvM09n7yYjyRxCP9Z8zr kVB0qMX9ktIU= X-Received: by 2002:ac8:74c:: with SMTP id k12mr27355008qth.185.1582214557412; Thu, 20 Feb 2020 08:02:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxbR/o5dZzJVwqozB6pVsi0h53nUmmL1eNtnvEIEnyfDfc3KEByAnUqiFKZnf2XeJuMIgqoAg== X-Received: by 2002:ac8:74c:: with SMTP id k12mr27354978qth.185.1582214557140; Thu, 20 Feb 2020 08:02:37 -0800 (PST) Received: from xz-x1.redhat.com ([104.156.64.75]) by smtp.gmail.com with ESMTPSA id v10sm2032884qtj.26.2020.02.20.08.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 08:02:36 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Peter Xu , Martin Cracauer , Mike Rapoport , Hugh Dickins , Jerome Glisse , "Kirill A . Shutemov" , Matthew Wilcox , Pavel Emelyanov , Brian Geffon , Maya Gokhale , Denis Plotnikov , Andrea Arcangeli , Johannes Weiner , "Dr . David Alan Gilbert" , Linus Torvalds , Mike Kravetz , Marty McFadden , David Hildenbrand , Bobby Powers , Mel Gorman Subject: [PATCH RESEND v6 10/16] userfaultfd: Don't retake mmap_sem to emulate NOPAGE Date: Thu, 20 Feb 2020 11:02:34 -0500 Message-Id: <20200220160234.9646-1-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200220155353.8676-1-peterx@redhat.com> References: MIME-Version: 1.0 X-MC-Unique: OazyKsSjPsm-Nb48T2ot9Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII 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 37df7c9eedb1..888272621f38 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -524,30 +524,6 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsi= gned long reason) =20 =09__set_current_state(TASK_RUNNING); =20 -=09if (return_to_userland) { -=09=09if (signal_pending(current) && -=09=09 !fatal_signal_pending(current)) { -=09=09=09/* -=09=09=09 * If we got a SIGSTOP or SIGCONT and this is -=09=09=09 * a normal userland page fault, just let -=09=09=09 * userland return so the signal will be -=09=09=09 * handled and gdb debugging works. The page -=09=09=09 * fault code immediately after we return from -=09=09=09 * this function is going to release the -=09=09=09 * mmap_sem and it's not depending on it -=09=09=09 * (unlike gup would if we were not to return -=09=09=09 * VM_FAULT_RETRY). -=09=09=09 * -=09=09=09 * If a fatal signal is pending we still take -=09=09=09 * the streamlined VM_FAULT_RETRY failure path -=09=09=09 * and there's no need to retake the mmap_sem -=09=09=09 * in such case. -=09=09=09 */ -=09=09=09down_read(&mm->mmap_sem); -=09=09=09ret =3D VM_FAULT_NOPAGE; -=09=09} -=09} - =09/* =09 * Here we race with the list_del; list_add in =09 * userfaultfd_ctx_read(), however because we don't ever run --=20 2.24.1