From patchwork Mon Aug 29 21:25:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 12958443 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 6343CECAAD8 for ; Mon, 29 Aug 2022 21:26:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D472E940017; Mon, 29 Aug 2022 17:26:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBB42940008; Mon, 29 Aug 2022 17:26:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92318940017; Mon, 29 Aug 2022 17:26:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6A980940008 for ; Mon, 29 Aug 2022 17:26:11 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 435E3120B48 for ; Mon, 29 Aug 2022 21:26:11 +0000 (UTC) X-FDA: 79853913342.29.1B196FB Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf20.hostedemail.com (Postfix) with ESMTP id E99121C004E for ; Mon, 29 Aug 2022 21:26:10 +0000 (UTC) Received: by mail-pg1-f201.google.com with SMTP id m34-20020a634c62000000b0042aff6dff12so4547519pgl.14 for ; Mon, 29 Aug 2022 14:26:10 -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; bh=K93TFWAb7JwQdWCvuFbBF/NwLgqzppA/TxAstG/QPvU=; b=f8ZHy6CiTcDXROb3pFMLfetBSV+kFVTeZws7OjDiiohYptMrJjGynWZ4jN+J/j3SJj dCEDPAmPkmnX5B3X46hqeY2mb8ZvMpLB7j64gw3uDHSYMAUM2B6ucp8KKPug6MxLnEu7 BmebG6DC6czjsVXnb7ENc9u7p9QGYJElvc7qRNsIMqXvgjewnR2ulhT9EyPiZ2zz1B9D 56/cpf1MfCjBxFK5vFsjvAIH2zjjfVoYxcmJWgmvbc3eCKVdp1qhJM+tuigQjNUJJMgZ jrHBPRDF7lp+rxYzH8zskIPXprMRBcWxeh9qo4POOeyeUnThUPILDVIwum49CxVeKLEs T9zA== 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; bh=K93TFWAb7JwQdWCvuFbBF/NwLgqzppA/TxAstG/QPvU=; b=MW5u5/JJRi/7eLs8V9DycfsqKh6A6Oo1ToK9Bk4B0aXVXaWsDliKPhdkllCcKkCW15 4IHMwwV3KWkWvwxq+S9ahxPN13JD484CeHnC1RmX2EsmJJQ0H+H/FyKXuDciq3CLYadK T20W25V3yJnUxV0hvlmSQ79PjJ5RSEJ8MurzVMO+yjj1/mLLvxzk9gWN+rMNfusbneZJ BFu8igjBIouSuj+O0FiLtuQHVsR6kbfs6wrEw9FZVTbvYp1cQn9wTJ2X8DI8aRTDiax7 VdzCs/cVKR+iFDZ5KIKnCUmn6C9UAIt4e7r4nC7pGWN+Ur8oqlDWmHSRaWZkmmtx+my7 M5HQ== X-Gm-Message-State: ACgBeo2ipPkVKSrP0PsUZfDC6zaulBnLvAp6RdAo1riv3OmwqhOVbirz InR51ce2gCFcSVyQewevUa0pCb9LM68= X-Google-Smtp-Source: AA6agR7nf9+ItGZZ0+7hqrcNY7xNhTop6ny3nOph/OxIOFh5WmAm4Kp1l2Jp+ca/L6EEvcmkimt0snMwAs0= X-Received: from surenb-spec.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e30]) (user=surenb job=sendgmr) by 2002:a17:902:b094:b0:173:12d1:4ece with SMTP id p20-20020a170902b09400b0017312d14ecemr18383730plr.117.1661808370030; Mon, 29 Aug 2022 14:26:10 -0700 (PDT) Date: Mon, 29 Aug 2022 21:25:22 +0000 In-Reply-To: <20220829212531.3184856-1-surenb@google.com> Mime-Version: 1.0 References: <20220829212531.3184856-1-surenb@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220829212531.3184856-20-surenb@google.com> Subject: [RFC PATCH 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@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, riel@surriel.com, 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661808370; a=rsa-sha256; cv=none; b=t37jJ/k1k1Qg1AaqfzNsrDMKy2f3RygO7ErC8KM2D8hAP+SuDTUe7Jwwciq1VoWWKRRE1t JFPn0xPu5oVXDEVHEoghq+wWlmlqTTab65OQlrPwteh83R6Qwt5GqXp66to5a0ZzMSYIXP R/uQk+4hl3L5OPBdU+MM9O/WWTFds1o= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=f8ZHy6Ci; spf=pass (imf20.hostedemail.com: domain of 38i4NYwYKCKMVXUHQEJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--surenb.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=38i4NYwYKCKMVXUHQEJRRJOH.FRPOLQXa-PPNYDFN.RUJ@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=1661808370; 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=K93TFWAb7JwQdWCvuFbBF/NwLgqzppA/TxAstG/QPvU=; b=K+boanrmJrtp+ggLvCVhSTUTevYGPuWOB2S6bAndlT7bIrFPBVi1e5UczVJtt7e33CUZ5T ZA+qSDTrsdb53GPSNn86KCjk4BLIEzccrGER92w/ZbfjR93vJTKAhQrLARp3Q+f9VSkysF 9beBl7PmKsBC9d686Ok4Siyx52VrEQw= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=f8ZHy6Ci; spf=pass (imf20.hostedemail.com: domain of 38i4NYwYKCKMVXUHQEJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--surenb.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=38i4NYwYKCKMVXUHQEJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam05 X-Stat-Signature: qkoorhagoidibjmf8abp39mia5ehx3a9 X-Rspamd-Queue-Id: E99121C004E X-Rspam-User: X-HE-Tag: 1661808370-389666 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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 --- 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;