From patchwork Tue Jun 27 04:23:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13293984 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 36414EB64DC for ; Tue, 27 Jun 2023 04:23:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3CE48D0009; Tue, 27 Jun 2023 00:23:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA1EC8D0001; Tue, 27 Jun 2023 00:23:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F09E8D0009; Tue, 27 Jun 2023 00:23:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8ED8B8D0001 for ; Tue, 27 Jun 2023 00:23:38 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 59D9D807EA for ; Tue, 27 Jun 2023 04:23:38 +0000 (UTC) X-FDA: 80947234116.28.C7145EF Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf27.hostedemail.com (Postfix) with ESMTP id 99C4640004 for ; Tue, 27 Jun 2023 04:23:36 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=OvvulEsW; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of 3R2SaZAYKCKQWYVIRFKSSKPI.GSQPMRYb-QQOZEGO.SVK@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3R2SaZAYKCKQWYVIRFKSSKPI.GSQPMRYb-QQOZEGO.SVK@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687839816; 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=/bqEyfDb2JHBciJ5X1JfWPHzjf7SmvaClBSwV4xMi6U=; b=nk/uMfCczS8DLNE3LJBsz49lQXzav+ffr9uyNDYL7oSSN4ObPPPUuyolHJEC6bqPMoKjJS eINYRTRVuFyg+Q+kMTOMAw9SwEtQBJepgJBibOSXMBnVem/GD+hp2BZhW4jfHPkYD7xMPa vRJqw6NeWpAKTGE3Pdu7ai0Jw4ShsPo= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=OvvulEsW; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of 3R2SaZAYKCKQWYVIRFKSSKPI.GSQPMRYb-QQOZEGO.SVK@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3R2SaZAYKCKQWYVIRFKSSKPI.GSQPMRYb-QQOZEGO.SVK@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687839816; a=rsa-sha256; cv=none; b=37Bn/rQTgx1QwE5/9fECtEn3XU9oQtwdYSCIhinZGF0s3XW3pK3leIk6S+cgm6SCXsgwP6 WONSSUEuVWEFgM7Moo29U/E7jaW7qReaDNQ8eHzncbFtgaTb6w6mqv4mn4cvLXRpsKZbhv IwgcuYAWTwWzRsNQdFbRdZ70Y9AiQ9s= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-c17812e30b4so3259208276.1 for ; Mon, 26 Jun 2023 21:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687839816; x=1690431816; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/bqEyfDb2JHBciJ5X1JfWPHzjf7SmvaClBSwV4xMi6U=; b=OvvulEsWmawhmtqOLDyG7NX+8MMLCKyrPheIcVIJBGuloUk350HzepAZTTg9GSNFTq Zxyei2vg/f2B5jkrZYoGKPbRxvuLjH35sLV4l1wOBTJafVD0HTbDUzbP6jPQfOdU+KaG 3gIkRMxtJ9DgS5SW0Kt3bWfeu+sXaplrrhq1B7dNLrmsE2meL4KQdekBOG7sWz0zAe0N lkYsG+/en/JT0DT8eW/ip3lW+AyM8tArkN2trbjAuP+aG5gijB434ikFW3ucpom8cFWS 1HC6TfIWomgbHMNnYthALNU+Ilov/TeO7Y284bIljOOAHiqgvbBCXiM9wMHeW6Wjn6nD V8ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687839816; x=1690431816; 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=/bqEyfDb2JHBciJ5X1JfWPHzjf7SmvaClBSwV4xMi6U=; b=F7hyCMknr6FZKgBIg6CD/2atShCKbut7hTJdg4KRgSECOHCBqa/kNC3re3v5JRldd0 36fk7Et5RIMfNexVn3IGnJnjwLlZaTtC8iJRtQk8CJmMxRuLrhy6pcQXYa4LP+tX0ZcM mm/kzO9PEul7vY2Bx7EAK7NvBbffMLN9VrJTFO6K4sO7RQOaDDwXx2eUIn+acUYbgWXw KQqVKVk5DSpID41iZ/1LaEeVPPvUv6JfAjH4SjsLx81Z8cqDXKyh++NU/9ag3CtQH0rj 7vVtAM/aMKknyg73gSjTaUGFYo3gEDTE0IARj/5w6eeh2Mb1DiE5aNP/sIt+KnxdlYAW js7w== X-Gm-Message-State: AC+VfDzzUbIgWDkKb6jwqagKifx2gQQicKFzti6rJJzOF/vK/EeFV9NI lbo7S2OITqUbKtak3v2jqu7YIYd/oOY= X-Google-Smtp-Source: ACHHUZ6bk8wsxPi2CO6Ry//dDv3J6w7VSpDN0W+ynAgt0XYXbCETpv309cOV7KiQRlvOMURiMuow8VTWjRU= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:5075:f38d:ce2f:eb1b]) (user=surenb job=sendgmr) by 2002:a25:d3c8:0:b0:bac:adb8:a605 with SMTP id e191-20020a25d3c8000000b00bacadb8a605mr6458407ybf.2.1687839815785; Mon, 26 Jun 2023 21:23:35 -0700 (PDT) Date: Mon, 26 Jun 2023 21:23:18 -0700 In-Reply-To: <20230627042321.1763765-1-surenb@google.com> Mime-Version: 1.0 References: <20230627042321.1763765-1-surenb@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230627042321.1763765-6-surenb@google.com> Subject: [PATCH v3 5/8] mm: make folio_lock_fault indicate the state of mmap_lock upon return From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: willy@infradead.org, hannes@cmpxchg.org, mhocko@suse.com, josef@toxicpanda.com, jack@suse.cz, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, michel@lespinasse.org, liam.howlett@oracle.com, jglisse@google.com, vbabka@suse.cz, minchan@google.com, dave@stgolabs.net, punit.agrawal@bytedance.com, lstoakes@gmail.com, hdanton@sina.com, apopple@nvidia.com, peterx@redhat.com, ying.huang@intel.com, david@redhat.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, viro@zeniv.linux.org.uk, brauner@kernel.org, pasha.tatashin@soleen.com, surenb@google.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com X-Rspamd-Queue-Id: 99C4640004 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 39fnsebufd4e16xmctx3jrz9b84cikaz X-HE-Tag: 1687839816-279737 X-HE-Meta: U2FsdGVkX1/oabjFS0SdRzNfTw7oyicj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A7663FkUcMagx+RzOM3kfuqj+oFMFf5qWGRr7ScS4TtfW6GeA/Lp8L33uDAjZDp146fYhmL+iYS694Ul6xpP0+SrU1X/R5HGMmaoUk+v6lX2KnnAsP9t5FzopYY+KK2CuFSXBf0tvva7sbuKzYbIQoEQ0yhr07Psgso4CbooC6+gMlaYW5UUul1a+dGTh8+aJgvQeS5bZhm8tbFpUVWrNO5AHmJ1+ynf3sAuexIx2kG7EEkMx8Of7NmQUd+rVLzbsiLNyCTzUwOkJdn1frZmXLu4pG10ylPVEOkesAVkdDbPmidAnvdbo11b6q3nZuIcqo7G5dHXBTW3aXdpE9Al6z3p1bpwV8tQ6ExyndGu1Coa69tw7MdtIDmG81mifq9EEvMOzxBIEd3Hag6fWbgX1CnTDcvrOQyTyds4K2uOyWjbjdZMepTCDZzSwB3HUQ0TPFcRRdZ8AxWJsz8BDeWpsAkYRKC4XtCSmbZ6iNpz0w+QR7M8SxKwqVHQbCGBTnVzNPnz1ExKigAWbu1xuQXQ1jV7uGxpcZ5NzXtLQ4SA== 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: folio_lock_fault might drop mmap_lock before returning and to extend it to work with per-VMA locks, the callers will need to know whether the lock was dropped or is still held. Introduce new fault_flag to indicate whether the lock got dropped and store it inside vm_fault flags. Signed-off-by: Suren Baghdasaryan --- include/linux/mm_types.h | 1 + mm/filemap.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 79765e3dd8f3..6f0dbef7aa1f 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -1169,6 +1169,7 @@ enum fault_flag { FAULT_FLAG_UNSHARE = 1 << 10, FAULT_FLAG_ORIG_PTE_VALID = 1 << 11, FAULT_FLAG_VMA_LOCK = 1 << 12, + FAULT_FLAG_LOCK_DROPPED = 1 << 13, }; typedef unsigned int __bitwise zap_flags_t; diff --git a/mm/filemap.c b/mm/filemap.c index 87b335a93530..8ad06d69895b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1723,6 +1723,7 @@ vm_fault_t __folio_lock_fault(struct folio *folio, struct vm_fault *vmf) return VM_FAULT_RETRY; mmap_read_unlock(mm); + vmf->flags |= FAULT_FLAG_LOCK_DROPPED; if (vmf->flags & FAULT_FLAG_KILLABLE) folio_wait_locked_killable(folio); else @@ -1735,6 +1736,7 @@ vm_fault_t __folio_lock_fault(struct folio *folio, struct vm_fault *vmf) ret = __folio_lock_killable(folio); if (ret) { mmap_read_unlock(mm); + vmf->flags |= FAULT_FLAG_LOCK_DROPPED; return VM_FAULT_RETRY; } } else {