From patchwork Mon Feb 27 17:36:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13153989 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 0E826C7EE23 for ; Mon, 27 Feb 2023 17:37:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A333C28000A; Mon, 27 Feb 2023 12:37:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E33A280001; Mon, 27 Feb 2023 12:37:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A9A628000A; Mon, 27 Feb 2023 12:37:41 -0500 (EST) 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 7A787280001 for ; Mon, 27 Feb 2023 12:37:41 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5DE64AAE1D for ; Mon, 27 Feb 2023 17:37:41 +0000 (UTC) X-FDA: 80513779122.21.93DECFA Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf30.hostedemail.com (Postfix) with ESMTP id 8CC6180010 for ; Mon, 27 Feb 2023 17:37:39 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=oVVsUrq9; spf=pass (imf30.hostedemail.com: domain of 3Yur8YwYKCFEBDAx6uz77z4x.v75416DG-553Etv3.7Az@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3Yur8YwYKCFEBDAx6uz77z4x.v75416DG-553Etv3.7Az@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=1677519459; 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=u/Oe5vIeahqwi5sYk+6bCjyqP36jyrRz0eAbwTkYv10=; b=iAMW1KWFXFSv9RtMClLiuYIkS5kexbzwqbylk5LotLn3F/VApsiReCuxzpzI8t7goj5Bim zwcHB6jQQ3wmZMFh/UUx+FNjxfwBOnpIte6C9YBPZHtMPSYxCNUl5slNkuVogTPBW6H9Ow MrWv1CmY/g7Smq1ohKQ6N7R3z2lx7Ss= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=oVVsUrq9; spf=pass (imf30.hostedemail.com: domain of 3Yur8YwYKCFEBDAx6uz77z4x.v75416DG-553Etv3.7Az@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3Yur8YwYKCFEBDAx6uz77z4x.v75416DG-553Etv3.7Az@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677519459; a=rsa-sha256; cv=none; b=pz9QsCKoPBxxfCC5O2pQbqlDov4NixWmtBki0wDhnqZbWpoMMaQ1zYRyJCxIJLIzEgbffF zmswJDQIXJaI7golG8jeyXvP2Mi2s5kEcYbe/rHaT2KcqdqC2Ov/heiTdkvdy5g7FEonWm nkZBp+O3YR74/MjeUs4XduHkxcUI/ds= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-536c039f859so154201887b3.21 for ; Mon, 27 Feb 2023 09:37:39 -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=u/Oe5vIeahqwi5sYk+6bCjyqP36jyrRz0eAbwTkYv10=; b=oVVsUrq9J7ftO0x2n5rOfx5Vuu5nhzvFsm0M1/orxQW1l03nlBX1oBt9Z3PeMUwxB8 EXB0rSNNqcp6UVy0odo1Y2qU2vLsCHExXTtZRuAA28OmedCWSwEPwJ/vb5UPfrQv5PJW ecTpj0oKN79TWuriZXNGVkql1JYRLuNigyKob+qED9T9sBsRaNyBmXPE+YrDxEJo7iH1 ubKjcF24jylzmHXYDSJCXBFRNZiczfW6Yvvr4W8sLGpkz89otOdurivgyE6QG9AxV0ch vbIsOJhdZ8Z0YDKh5k0bAgyDf+j5LXFUYUSVRKs5nZ5bUnBRVL57+VXMgXm8R+LTRb+i YnrA== 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=u/Oe5vIeahqwi5sYk+6bCjyqP36jyrRz0eAbwTkYv10=; b=mkBW2zlX7da7MqJGHchM/Gi6jJVazSkr8ondorcAvacpg0dBodDhiUdYM65FNRwYUk nI42PgQhhTDLzPM/ajv4zPSNwaIsM34L+AB0tA4SZiU3dYHv8Q/O0tL9whzg07OI3Osz VKSl74INV622s3LIB8X/RKVwG4l+YtaIPUfc5zPtfPq5BO5nQHdmdcI27e2siIgCtHki HvQHkWPzQ1HswOenEfEYDc4cwwF/ll9yb+q+KGsVZmEayXWodwbYzaIrWLXl82Go2vnY SL0ig96BtDMJwk/d05/HTb3pypmLlCOY2vprdu7fXT47Y7xqbP+tZ+ApsT1l0uh/oi6A PLFg== X-Gm-Message-State: AO0yUKWaMqaNyxDHewuHHtZFYNcLyCGdOxCRKu6zE3wUntIhDeClPc1G /gpbmoSE1OYOHiw49zE/XS8PYNv4Elw= X-Google-Smtp-Source: AK7set+K4/t0896rH5imu1aS5MRSoxg+vS9UwsZogQaAvLfU1/2OHkdV+UAhVM9dEQWx1b4yJz5LZ0tC6/0= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:200:e1f6:21d1:eead:3897]) (user=surenb job=sendgmr) by 2002:a81:3e21:0:b0:533:cf4e:9a80 with SMTP id l33-20020a813e21000000b00533cf4e9a80mr10559241ywa.6.1677519458641; Mon, 27 Feb 2023 09:37:38 -0800 (PST) Date: Mon, 27 Feb 2023 09:36:25 -0800 In-Reply-To: <20230227173632.3292573-1-surenb@google.com> Mime-Version: 1.0 References: <20230227173632.3292573-1-surenb@google.com> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Message-ID: <20230227173632.3292573-27-surenb@google.com> Subject: [PATCH v4 26/33] 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8CC6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vRmuwCiXzesQixc/ThJSCl7gh4wBI2qtP/eoMpFCKXvlU/Sk270j5+umPbf8yipe4WF+Cm9tcjceucqs3eWGaIiqwh4ptl47RO3pUKtNQU7UDiPwSYOnxEGfA4+fydBSNbPpcUWn2Sw8rh3GCmOLgGimzKMQSs9huISDYnNy7/i7OAo0tpnJtZfbA5nZ38OoeFVwxTWmxzlDXnL19HOGghH7xFVsMA754rSJL+3zdAZ3RQf1QfrJ0BrLB9zF3PjNfPMfQmCr5nmHTQprQAeQFzj0YA8zYq2E/g3xf8lBjZw7Te1gfGBeTKiW4Rxx6TH37YDufoB7sEEyJKCiRi+Z589RQBJ3W2iWe1Jm5Jl0aWcADZqUGlQt9l+oW7L9T+OVK1eXiYKxCsHdQkU1w0ql1Do8krDbE+UE2/j8X3acXlrq2lG0mIxpMGy3xJst52kRxAtXO5zCEV2aIF8KPQLYHOE5L93SBdYkoHs8BDPTZz9Xa2ZmRX3FoQJYgVAnuVpayJsDXXvn+slG5dHYI84C2I7+qY4mP6fi00E56t1UB5OCurgoxCTn9ux5lX4FhjIMOCDixJ8KmVevz+SHIOyz3zWXgjiZjTAUYmSMTRTrxNlpRWPsgT/HD8oWAc7RXFyasQXBJj8MkXrgqrsPZZyG0usZtIs9NgoG54Aw61l241IeNvANz0XVbz 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 8855846a361b..af3c2c59cd11 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3689,6 +3689,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)) {