From patchwork Sat Aug 12 00:20:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13351592 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 37BC2C001B0 for ; Sat, 12 Aug 2023 00:20:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 906F96B007B; Fri, 11 Aug 2023 20:20:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B7146B007D; Fri, 11 Aug 2023 20:20:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A6976B007E; Fri, 11 Aug 2023 20:20:43 -0400 (EDT) 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 6B2966B007B for ; Fri, 11 Aug 2023 20:20:43 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 257671A06F3 for ; Sat, 12 Aug 2023 00:20:43 +0000 (UTC) X-FDA: 81113546766.03.0A18B3C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 787B640018 for ; Sat, 12 Aug 2023 00:20:41 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=puwh+Yen; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691799641; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=tASdx5qAzNNCFny4O99kL92QeZvTsRnN3HpUWE7SM1o=; b=w0IbZzqDGPhaQNAdgjo+r297hjssYYTeSqWxIlxp/8bOC5en0joIQHSV9jY7UjZ0QCGh2b zxFFg9nxqZRsrRAYRyUgUnqEPm+i6SvBwW3lHNMwCyS7k/2bCmXR/zoEHW1pWgNHERuHdA q5J/MGEsQnDwPeYUREQ9vB8byvtGr3U= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=puwh+Yen; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691799641; a=rsa-sha256; cv=none; b=Axexs04znmEabwWB+lP+wiDN7AeIn6TSa0HW3x2IVGVtsSN747MP+ILJL5za6F70qmDGdO W6LOJA+y/jIpTA7qn5VIxhqZv/s+VZ5JvGTOrgwO+5zQ+oyxPyfLc0BCTHPmob9kF7Vb+B 7EuDR5al8/WmnmEhCG2L27oPBwcd2sY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=tASdx5qAzNNCFny4O99kL92QeZvTsRnN3HpUWE7SM1o=; b=puwh+YenZ7U1/dEMJy2uiJZLBy g6N0mEaoDsfQjZGNfrwJjPaRsmiZu8N7ZWhOb4ZiRjE01EhSPshk9U00di1CNZPCG9tuqdr7zv/8J xabyj/y20iUnwtGk5Isc2ImO/v/je17oA0gXzyX+zWT/6kFTYX7mDs9d3ZOwApxaxxmlA2lNDimRB U5KF2ajNXKgG1urjlE+0Yk/4GBjoALZJsH9LZVQzdNLNIBWDDKlTBzgrioFFCWU1NY3S+lnihYbwv bsEjEisNlw0hx5N6cb6RKv6+U7JipeVhyRDaNWQK4gtPWQOgbnrZIoSt0hREihzZrSLef5Cp+KYEq f+TlndGQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qUcMu-004Clw-2U; Sat, 12 Aug 2023 00:20:36 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , David Hildenbrand , Suren Baghdasaryan Subject: [PATCH] mm: Allow fault_dirty_shared_page() to be called under the VMA lock Date: Sat, 12 Aug 2023 01:20:33 +0100 Message-Id: <20230812002033.1002367-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 787B640018 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: r5kt9u9me95ohyhnikhk4oapjftfp9zb X-HE-Tag: 1691799641-745971 X-HE-Meta: U2FsdGVkX19wrnA4JaES8YN2J6kKZY38pw4lmnVgSTbdXzODs0g001Gf9NGX2m+sCb9HPbzFeaG7R6rhWKc2/p4z+UjwNuoNleRGnO3OeKO3sTgi4E/5xjz9hIEaEu0sLW9P6DQQ5CKqEhk7Kw8F5AOjQ4ItXMIVcsMc8D2AYKlvidOq4BEbAOz7Y/Qceior9+2uWkGUwChSG7RlogijBHcnnQM5Ux5yqs4/svwq32DHS4kX9TZ0kK0aJJGB0jwzgIfjAIBmacSx4TPRvUG/ErFENvCd3AC7YnOHjO+ssDvpLWCgDeS8wPvvdkbGy9uBogo9wRoazzQ6X6KvNl23BasOYrogP5+/+rKjMUAomshF5NC+mCcjQAn7+0emaiKROv3LeKKX2qc+vDwh9Ar+6XA/37Sg0J1GkbKotozJz6eWXhRrloigMmYSpMJRK85E0vQMFGJOWhmq8MCyH1c98CtS6C+szzU4rBkmw67mh8Er+YyC1/6u0NjLueQMiarl2BykBDJwSCvFvG9/EGCumn02EEXFySLbh0r6qpuKjlTZHQcNDlHV0adIP/xcuUmKEcemxvGUPP4spwmJK94Z/atghO9wEDXXyBYrvi7A9mzvSZ4duzQtKAprHNiWLMX1NdplzVJDYnW6pzcJG4pwnPmlMJUhVGSAW8ez1sCYHR4zE6qYyYgOEeHEfpmOOnzGcMUK1OA0qjpihPuDbShAnMcuXMiCK/WqlySTyVunRvj+jgOEB0RlqbnFmMVdIENSlNt4Nbyvo5GiyF57P0uZ7WmDYdk0D3/uTU9pu3ZuU/tdCzSX3esBEAN7aAYVq8Pwe8nPz4WTeLpDsX5/V7Bn5Be21fKoOmIf5zB3Y/LVnPWPfTrD4EcilPR1HEypwkWPWuQhcoJuuAkwf4CDc0ozqVqNewjlAuomA4xa0ytl25BbDClurki/cmQhVccDsuOzLapqhrPv4PphFhrnLJa mr/IEQ/1 XFJvOy6aAwj6B7UZVPIbauuejyiYydPkE0CfRWfJEVHtYn6ImwPl7kR4lPyJdwK6suz3RFQboQGfKFfr0MWf4YfRysj6yrQbKuJSuuZ1tzw2qclnR2Th3aSwA4RBPgwAjgliSMyLNDJoW7nBVJR3Xqh/zIbh8BbWJxYOLa87Z7ZxznGnH0yzqJ6i33Xw/ToZxR7PMLVQCxvD/ll36/2vtKOEGOCpOAXkXhlVXOvkjhooD160qjTyAyweNBKnJmog/iEdl/F0XpggDSdI= 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: By making maybe_unlock_mmap_for_io() handle the VMA lock correctly, we make fault_dirty_shared_page() safe to be called without the mmap lock held. Signed-off-by: Matthew Wilcox (Oracle) Reported-by: David Hildenbrand Tested-by: Suren Baghdasaryan --- Andrew, can you insert this before "mm: handle faults that merely update the accessed bit under the VMA lock" please? It could be handled as a fix patch, but it actually stands on its own as a separate patch. No big deal if it has to go in after that patch. mm/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/internal.h b/mm/internal.h index 8611f7c5bd16..c7720e83cb3c 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -706,7 +706,7 @@ static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf, if (fault_flag_allow_retry_first(flags) && !(flags & FAULT_FLAG_RETRY_NOWAIT)) { fpin = get_file(vmf->vma->vm_file); - mmap_read_unlock(vmf->vma->vm_mm); + release_fault_lock(vmf); } return fpin; }