From patchwork Thu Sep 1 17:35:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12962985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5439AECAAD1 for ; Thu, 1 Sep 2022 17:36:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E87AE80029; Thu, 1 Sep 2022 13:36:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E10398000D; Thu, 1 Sep 2022 13:36:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C89E380029; Thu, 1 Sep 2022 13:36:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B130B8000D for ; Thu, 1 Sep 2022 13:36:12 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8F9EE160A01 for ; Thu, 1 Sep 2022 17:36:12 +0000 (UTC) X-FDA: 79864220184.10.98D2BDA Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf31.hostedemail.com (Postfix) with ESMTP id 3BF2920060 for ; Thu, 1 Sep 2022 17:36:12 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id z4-20020a5b0a44000000b006a1c47c36beso1426604ybq.15 for ; Thu, 01 Sep 2022 10:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=OeaHSvnl3LkKr4l31U2Volg5xaVk+RMFLZSi6dgjePI=; b=YWMUacgHyaw45xClfelut3B8D4opaNKe1Jn1EvQGqzRnq9IAzY1SbxxDOw3yyYq+BA clLIFH+vCJyTvZqkcuk+nPAAVvk+cIcjjJaBgcqIDZI820XVBHBVS4HV09O0+jx02gz/ GF82/kOz5NOA2SL5LGwa69qRF4uUvf5PcNaP24Dp6cprq2xiDwA1y9+n/C6LME/0C0u+ LXVRqnwXAQFfakRcmYHnZMbYxKQr/xy2mJHdmdiugDAKPQMxfZlI1xF8c8WSAaPgs+Sf 8cODiZAHBJrDioo32O0YL9A9GYzXrzP7oLTKiCYFarAedegbhpTrR5084qGw0ahgqNnD Ah8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=OeaHSvnl3LkKr4l31U2Volg5xaVk+RMFLZSi6dgjePI=; b=XLGlLRlG+6fA+0La4DqKNIBVfj2z0pn9Ast6zKxkQdZThTzbrTjF3nYEFAGvGXjMcB C4AKEfyDBUhRg4SanTBKqX29wVXDyVml0YBgMVCjDkhz5xPe88Bwqbox2tZbKvvzuBQa YcSwA8cvoIN5xO1aIn4tPa3YM4Yuf5oXka5DkvIrQ33P/OnAL7I3zawryLcAj7afoDYM IFgbIP9EfF8CySLa+o4Lr0C88MtDLU0ISY5wxd+JI5iBli5pucXHFhatScfHiJJLAnPy E5CaYyaAtNryKJqwYu+tCu1BRA/mlqezKcY2Q4YpVTEw39mUqf9ZoBct3V/bOIkdVauj In0Q== X-Gm-Message-State: ACgBeo1U0+ORHK7J66dD0BJtyVE5wK/wPh3lDIUe7Rg+5IoZRAuT9A13 ZvyATKnr9XUPNtMvpwE4RWumY+he8Eo= X-Google-Smtp-Source: AA6agR5WRy5fZ7FOeYwPAz+MoQjsxloN5BfCZpV2SaYdV4girws1lZ0WYC4kcT46D4arwsdXcJqkq+Ln5bw= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:1bfc:e7ee:6530:4449]) (user=surenb job=sendgmr) by 2002:a25:6744:0:b0:696:52a9:2d84 with SMTP id b65-20020a256744000000b0069652a92d84mr20473184ybc.256.1662053771488; Thu, 01 Sep 2022 10:36:11 -0700 (PDT) Date: Thu, 1 Sep 2022 10:35:07 -0700 In-Reply-To: <20220901173516.702122-1-surenb@google.com> Mime-Version: 1.0 References: <20220901173516.702122-1-surenb@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220901173516.702122-20-surenb@google.com> Subject: [RFC PATCH RESEND 19/28] mm: disallow do_swap_page to handle page faults under VMA lock From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, surenb@google.com, kernel-team@android.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662053772; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OeaHSvnl3LkKr4l31U2Volg5xaVk+RMFLZSi6dgjePI=; b=ag5Ieo7KRj89JzaNJ5mJRg0wXee7nbfpoKeqH7w3SPMCO+rd1j4olhLR9j74xVImzlY7yQ fyj/VyVGXx+G1IyBqv9cgEMO/ysC40yk083lB2bSAZ9ng4nMCQPKHcJFmLhKZE3Dp8rozX xhVXFh2ne2Q8IGlnEeBQIsVihQ3E6ps= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=YWMUacgH; spf=pass (imf31.hostedemail.com: domain of 3i-0QYwYKCMg685s1pu22uzs.q20zw18B-00y9oqy.25u@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3i-0QYwYKCMg685s1pu22uzs.q20zw18B-00y9oqy.25u@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662053772; a=rsa-sha256; cv=none; b=kKSYyxb9bpc9+hXqJEgAY5rRL7X9vdm2IZm/Qy2YbWAS/r691Dk9JIzaI0B/yd+YkqXZJP SE+sVCspLJOxrRHn2jwlsYVv/pc8zKxmfIhbFGmL2IFb+Z+Sx2i9Y5CwnNCbpJj3Qmyd2e ALi5WF1HCngPIG4pdDWofNjFYygKe84= Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=YWMUacgH; spf=pass (imf31.hostedemail.com: domain of 3i-0QYwYKCMg685s1pu22uzs.q20zw18B-00y9oqy.25u@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3i-0QYwYKCMg685s1pu22uzs.q20zw18B-00y9oqy.25u@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspam-User: X-Stat-Signature: ooshmzjiy9qggkkwetkt75cxqd1raxfs X-Rspamd-Queue-Id: 3BF2920060 X-Rspamd-Server: rspam05 X-HE-Tag: 1662053772-243238 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: Due to the possibility of do_swap_page dropping mmap_lock, abort fault handling under VMA lock and retry holding mmap_lock. This can be handled more gracefully in the future. Signed-off-by: Suren Baghdasaryan Reviewed-by: Laurent Dufour --- mm/memory.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 9ac9944e8c62..29d2f49f922a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3738,6 +3738,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) vm_fault_t ret = 0; void *shadow = NULL; + if (vmf->flags & FAULT_FLAG_VMA_LOCK) { + ret = VM_FAULT_RETRY; + goto out; + } + if (!pte_unmap_same(vmf)) goto out;