From patchwork Thu Feb 16 05:17:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13142521 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 1E444C636CC for ; Thu, 16 Feb 2023 05:19:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A930C6B00A9; Thu, 16 Feb 2023 00:19:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A1C3E6B00AA; Thu, 16 Feb 2023 00:19:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C6C76B00AB; Thu, 16 Feb 2023 00:19:04 -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 72CAF6B00A9 for ; Thu, 16 Feb 2023 00:19:04 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 505F0AAEE3 for ; Thu, 16 Feb 2023 05:19:04 +0000 (UTC) X-FDA: 80472001008.28.329C45D Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf19.hostedemail.com (Postfix) with ESMTP id 9723C1A0019 for ; Thu, 16 Feb 2023 05:19:02 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=aDErRd7k; spf=pass (imf19.hostedemail.com: domain of 3xbztYwYKCBwKMJ6F38GG8D6.4GEDAFMP-EECN24C.GJ8@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3xbztYwYKCBwKMJ6F38GG8D6.4GEDAFMP-EECN24C.GJ8@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676524742; a=rsa-sha256; cv=none; b=JAYxtZsdDu/1i+QDo6g74AN1I5yeTXE6qD5j8RwOHwcnivMIGxA1NDZ8ynKE86V62GjjLp wm4Zyk6cxS5BlelT/lJt6kbmgj62hFXvxlA2jq1vnmyXTItVXNde21NZgABtwLXwd0bA56 KMxKRj3QfaawG4W6L4oMUb/F0MQQzX4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=aDErRd7k; spf=pass (imf19.hostedemail.com: domain of 3xbztYwYKCBwKMJ6F38GG8D6.4GEDAFMP-EECN24C.GJ8@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3xbztYwYKCBwKMJ6F38GG8D6.4GEDAFMP-EECN24C.GJ8@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=1676524742; 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=+haucx/0aUjNKP4B5JYWnKqFhX48IZcct98M2E1/jbw=; b=CRfbf0GH93yMo0QQ6dFw2O2CZAtSx53OsUIOP5vEWsmz6KP9v42Ulq/R46p/oN0zLwyCRv oAEZDUTdGW7SGSD4yTJbTSMNr9ydWZToKDdxM+F92TX6QFvWUKj58NSsf1udgRu1n2hANI mEPWdp9CjYyd7PQiuHkW2GU08B3UI00= Received: by mail-yb1-f202.google.com with SMTP id a1-20020a258701000000b008e1de4c1e7dso848908ybl.17 for ; Wed, 15 Feb 2023 21:19:02 -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=+haucx/0aUjNKP4B5JYWnKqFhX48IZcct98M2E1/jbw=; b=aDErRd7kkY+Kp4AaU6gjM3F503YHpBTPjjocmaNoc4zXVCAuMI2RAQKjzcRAbLtJge uySjaOCoHcGS53W7o3RYdOQoeaAfeHvH08PuG1fh1bxXWOGZDVGDBlzIfGuJz8kR8m0P 4LCu9IW21ZFA5+XCq7hXP9c4LIZtK/mDOJpY3r8EhzjVEo7Ti1XlFspuAz3gf99Vo08U GQhyt4xy4/c9ROtLln2G8n+ixCeeiCqz1U0tO8VqF1k+R16fVXyhOw17lx8zHct64i1Z f89mO/K5qgtX3vlh4Aty7U18axNicxnQBp8nhqlTIla4iaOnphrb06qKzWIf+oeLlfcz N8gg== 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=+haucx/0aUjNKP4B5JYWnKqFhX48IZcct98M2E1/jbw=; b=d9ANfJMnaGszjZaC7rhx56Ip0YAiKJwa5CQ59pTpSlkAzC3uptAMXH5N5ReZ7Svh1A JanLom0vm24OqthYoyxlt/URFCJsExRnE7p0rlKrFC77y+STAC4hQJtAVofapl+oMPTj fm8bYSuHDMsnmEjv7NgY3SMVPZQl4qHMuyWmTCOyTFe1GRmx/RWG2JP/usgsAlqiePZo wC3S0dHgni5UOV2VzpI+AZXo40/d4bKQOeMPXSTzQb+Q8rY/0PGyvriGKwzVHgzEh4ax Y47JLGHFKnMaiFqAQHGbxl8NvxHAqeGVEe0TqCSTV7GMM5LmCcFwPxRm4U3+EPkojUZb /zUQ== X-Gm-Message-State: AO0yUKUvz9/1pd1RCmqPp4bJoHClh1+UGkqWkViaDPJyvNHthUDabTPH BijmkHFzRDD5o6DsvDBAWumah/fYtSY= X-Google-Smtp-Source: AK7set9hR8JRk82RlKZHeYCMxCYi1ok7+igo70HcdJvHzw/Nn50rv4GE5Ev7Sgo0D41w7o23DTD5b6roJhQ= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:f781:d5ed:1806:6ebb]) (user=surenb job=sendgmr) by 2002:a5b:c41:0:b0:91d:ddda:665f with SMTP id d1-20020a5b0c41000000b0091dddda665fmr396601ybr.589.1676524741694; Wed, 15 Feb 2023 21:19:01 -0800 (PST) Date: Wed, 15 Feb 2023 21:17:43 -0800 In-Reply-To: <20230216051750.3125598-1-surenb@google.com> Mime-Version: 1.0 References: <20230216051750.3125598-1-surenb@google.com> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230216051750.3125598-29-surenb@google.com> Subject: [PATCH v3 28/35] 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, paulmck@kernel.org, mingo@redhat.com, will@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, chriscli@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, rppt@kernel.org, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, leewalsh@google.com, posk@google.com, michalechner92@googlemail.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, Suren Baghdasaryan , Laurent Dufour X-Rspam-User: X-Rspamd-Queue-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Ow /O/mULbB+TsZXpSQ2Q4Y6OYzNw9BXvl25kWcj+68wJyoj1D0FAsqjyIcMzp4lCHFJNXZTvuNIPKSDf22tciL21w45zstQBz3Quz7NsiwoCuLqxGZNNQExTO7mlhLdx/cXbGOAf2Zn8pNSX3t8szBVdHF4KG3LFTIAejaspuoypnjKm4ycRAB+sZK1vZCPK9Zb8Oevkpo+y5vig/1YxKRTEtcjbWcLg546PpvSdFZay3Tn4C2wrgZ5CQROTvyZ2OthSgYMe6F0YAQD+PX13vhYboTMEee4RYV4/NLwe1wyWy61pl0nBuLOisLJMt27CLdo54hnF6sG0uYhbL9V89gC+KgANFAqDh+/3+Ycrpq0CPJPhnHSbW5GqcW+v81g/qPOKql1tqN4reApua9JWQdlGc7LzQBeBfEh5D4YXR7okLNJ+5ea4Db6FOe4qZh8lulwUVE09PzuP3cw/vNtjE2NQbr0ekNKyj9FJhET2+JnQrBEXe6UlGgcBN3sv14eYLh7aKPeL7GRRBrjzG/KxGXFIH5KfRNZwbazAnvYJZaECdMPmIMnsBaFgSApdkbOy05TsZ7dNuMN/rQ2+tOYpsaqwJt5h1/gjYOOimrMApbbzGhLqmM= 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 13369ff15ec1..555612d153ad 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3688,6 +3688,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)) {