From patchwork Mon Jan 9 20:53:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13094297 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 C8E95C61DB3 for ; Mon, 9 Jan 2023 20:55:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63BE78E000B; Mon, 9 Jan 2023 15:55:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EC688E0001; Mon, 9 Jan 2023 15:55:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48D2E8E000B; Mon, 9 Jan 2023 15:55:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3BBB98E0001 for ; Mon, 9 Jan 2023 15:55:02 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 18D22A0BEF for ; Mon, 9 Jan 2023 20:55:02 +0000 (UTC) X-FDA: 80336465244.27.83BC828 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf14.hostedemail.com (Postfix) with ESMTP id 833B6100011 for ; Mon, 9 Jan 2023 20:55:00 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=i8mCfCut; spf=pass (imf14.hostedemail.com: domain of 3I3-8YwYKCDgmolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3I3-8YwYKCDgmolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673297700; 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=wzUeswsih4PBYsAGoTi9IuotyhbGAzkWIDmV0FovK6Q=; b=as5m6XM4ib7crIuEFQEexuXj1Y1/7MDulOOfYHt4HNdvAjgWHc8URqoHSCw5/nkhebI1kL ZadhaWemUrjlzzcvkB3Lq6SaDqTn/PunAKUrJrU1hdXsjBh+uZpAPjNaatfGWTjpaNQkfg ca7wiQdVFacD5eOvRs7QsNiHCemNxrg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=i8mCfCut; spf=pass (imf14.hostedemail.com: domain of 3I3-8YwYKCDgmolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com designates 209.85.214.202 as permitted sender) smtp.mailfrom=3I3-8YwYKCDgmolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673297700; a=rsa-sha256; cv=none; b=SNXtmxDABEKyjzDxJqfycy5kkUCD31yokCwBfScLhZ+UzG7ZV7E/QUr442gTwbI3exw8u2 hRiUijzfKfzUstQ+TXfPjB8FSps87z3O/rnd9EzRZ2tg5ZKsv96LZo/rQRtm0Q1ByBqWNh IFn1XEqlBngD8mDnP5tL+cPGQ3H4PA0= Received: by mail-pl1-f202.google.com with SMTP id c17-20020a170902d49100b00192be705f76so7049859plg.13 for ; Mon, 09 Jan 2023 12:55:00 -0800 (PST) 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:message-id:reply-to; bh=wzUeswsih4PBYsAGoTi9IuotyhbGAzkWIDmV0FovK6Q=; b=i8mCfCut8WK6+zjWPXPrBAn0OVK3TZZqUir2pgpkQNWhenu43X3/akUsts/8WrGL5U Ag1lqNnPrK3Lht8c6bYeEHv2p/KYkV84L0N5RKup3Lqh7FNgEiwz2qb9iAaK8aobnie5 SWRp3Ej3gvy6Gx0qa+UPT0Wm9SDIcbH9qbkEiBwV9a/y0P6JGxAF3x2bjosqkuWs4x2Q 7wdZhW31F8FFO8VMgBTx/6RIzfF9caT2DmPvdENgd9fKarg0jWwQoD/+83rrhQbpzEQp l4T3tmRoZNr6BoK1+IwDWlh9AP60sfKufgosjp9Mre5rIBM3jgdbCDpmS0FgJglfxzEq wvVg== 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:message-id:reply-to; bh=wzUeswsih4PBYsAGoTi9IuotyhbGAzkWIDmV0FovK6Q=; b=OCo5vGkfTO1CK1pXSHH9PEWL+oQIcs/x5kj0QCCMjCxs1jN1mGOLRdtUzXS9se/miq +sfeKrWfDQVbfEw1ghNtCoF29k855KLrLPNvrEbO9k4p/9VyKFfhIGxB1Sj1BPV7ZP5/ snzpq+Idp0Nu27oe9PyGAabcm0f2Wy1sfa2VyHExAgYAmYdYxqgOTDsZKQeIEmt48BOR ymFJoBd3xetp/KosYnmJJCkKcyF3JquTDNQiN6umW3szcIXv5pW38786ptNWLAdIRKMo hasvCbm1vgC+4/FNU5jENS2LaZohRNDegpPKu+bBFnYrglNTDbnPh7KhNX82oJRML1A7 yJNA== X-Gm-Message-State: AFqh2ko3/zQL1deSMjyO+/5ISlb46kD7lGodL/5vFDwVBAwuNWekGP/p B/DSGcZAsuU8uUu6D97GDmNowTHbZLk= X-Google-Smtp-Source: AMrXdXtXcDh9ACK+yDPMFgwqnCidD6d48HBoOS8XbTQx42HB6Mm5GZSyonzBvXPdXaN+wlg8/pxMUTj5geU= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:9393:6f7a:d410:55ca]) (user=surenb job=sendgmr) by 2002:a17:902:7d8a:b0:189:754b:9d9c with SMTP id a10-20020a1709027d8a00b00189754b9d9cmr4530740plm.120.1673297699405; Mon, 09 Jan 2023 12:54:59 -0800 (PST) Date: Mon, 9 Jan 2023 12:53:26 -0800 In-Reply-To: <20230109205336.3665937-1-surenb@google.com> Mime-Version: 1.0 References: <20230109205336.3665937-1-surenb@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230109205336.3665937-32-surenb@google.com> Subject: [PATCH 31/41] mm: prevent do_swap_page from handling 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@techsingularity.net, 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, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, surenb@google.com X-Rspamd-Queue-Id: 833B6100011 X-Stat-Signature: sm48e9dp1og69fjwexsk98mr11kn35x7 X-Rspam-User: X-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iD72o5ejRB1ZqQWyTDWEbWmanG7oIjMYaJyXqb/AjntdsMi0N196SbaDJzEWAfiatXoYfHKOZ9dcdHlgTG2GkdvTi0X7E6gch2HfsrRSuEmaRkyKnVrEAecaEcpx8+6CO9073mOVecEgBeDaj4WsGDZ8h6itRvKhcwAUvrkAtQSvdradYeZq/HfdUkyd45D8ERjsQCZDFIe2CXZebeqMgVXrpvPou4u4JCUZgbgtehaKXKL2jJQpgu5UwrVUrNmKuh0zQh9TsajTBTMXwcUf+FO5ImaErZu+5OTwA4TSKcLxrpq6C6vjvkzsc0uWTZlTFFtBCELY+MrBdSMpxJWzpK3xfS5gwNTeDQvEhea3r33AWhI7N0ZFpGjiIi4icmAGaR X-Bogosity: Ham, tests=bogofilter, spamicity=0.000022, 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 2560524ad7f4..20806bc8b4eb 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3707,6 +3707,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) if (!pte_unmap_same(vmf)) goto out; + if (vmf->flags & FAULT_FLAG_VMA_LOCK) { + ret = VM_FAULT_RETRY; + goto out; + } + entry = pte_to_swp_entry(vmf->orig_pte); if (unlikely(non_swap_entry(entry))) { if (is_migration_entry(entry)) {