From patchwork Thu May 11 13:21:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13237925 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 B6179C7EE22 for ; Thu, 11 May 2023 13:21:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 684556B0080; Thu, 11 May 2023 09:21:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F1EB900002; Thu, 11 May 2023 09:21:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32E916B0080; Thu, 11 May 2023 09:21:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0DF9C6B0080 for ; Thu, 11 May 2023 09:21:31 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6DEE3C0D42 for ; Thu, 11 May 2023 13:21:30 +0000 (UTC) X-FDA: 80778035940.12.A7DDC81 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id B62AF1C0002 for ; Thu, 11 May 2023 13:21:27 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683811287; 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:in-reply-to:references:references; bh=lzgZOEGznLZwXHG2uMOWyrmtdrzDY9bWWF3EWrJ2RNM=; b=HYNJFMI0ByWlgfAoGLQncNlztXAsYqMhSChvdHkhZzFC934DgXL3UgPi3zi1cxcvSrIUia wht/HjEq64SVFReLm6sNNA6EAd+pSYy8rhsH3MBofB38vkN4wFJiRLir8B9Ap8h8zlLvW2 fYX2GSHBx7wjaD6SllIiHmKavE7YGns= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683811287; a=rsa-sha256; cv=none; b=LiJ49CTclcRy4wdxBAIM5TI4n/UDeqtuJEsfG9k5bGX0KQtMFppEnjKWcWirZaotdY3+Qy CNqxQ5BUjhtNxdvPfOPZZuH2Q7tXWMl4MpVpN8MvrHGMJtt3mbu5+y8jtwGGlYEQKFQ22C wD14vKlF7VsrfBh1PPwr2FBCpkOs8uc= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5EF9C1684; Thu, 11 May 2023 06:22:11 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B85EA3F5A1; Thu, 11 May 2023 06:21:25 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , SeongJae Park Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: [RESEND PATCH v1 3/5] mm: Fix failure to unmap pte on highmem systems Date: Thu, 11 May 2023 14:21:11 +0100 Message-Id: <20230511132113.80196-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230511132113.80196-1-ryan.roberts@arm.com> References: <20230511132113.80196-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Stat-Signature: aoc6zp1uyegqwjzdtfhgg7yxx4me6jyr X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B62AF1C0002 X-Rspam-User: X-HE-Tag: 1683811287-37615 X-HE-Meta: U2FsdGVkX19SlurWq4T2ACZyhZvtNdiOlzqJVc6tDwJwgD981OeDQCSFdS2fVWI+KPe/baUne8+V4tRrx6YPXuV7L5DGL0qI3vYqa+aZ0c5lSFR+/LJNviOEDU25tAILR1VbXikfeYQyDMvyUFKVpnUgVwy/hC/alJhrKPml0buwDhdZIjlPoyR6Cu0OElRleMY1tEqME0AiQtas6Bj6qGMI72uqpMgTSs1q3OuK5txWtjNcIlh2vv2wu6kCsYpzF9XhJvnBBvYbqMUZa6jCC5mOKi5d06lufCnMAxr0DLT9Vk6R5o/6bBmUWKa530Gze5Wsd1bHusr/pOefp8OtUrVq0voXqbHOZgTmICpw94OMJ24ZXxhCJ6icADPKJeVU92EmkwsTH+4RF2VpUPd3jZC2bUd7E3DcMSyUFF2yUMBQl/OncuGzIuDNPPV48reDFJd2y+PcovTTO4956ES7AEy2v755qXqO6ZIhCf8Z1rdPTH+HlNGj1eOeTeSTHDrPwsQeov7uzbEZz31S4wQ2lIFpMdOkAGJOC7SohPYWRiaHc6PZ8ZN5h1bE8K9tk1AaYjxAAnRnrWegd/LueDMGzpHC4nPbMxmkNG/TJppAEWnxFu4aRubjtOsfTkI7LFZtvEsXHye6Mywqmc1VqGPyaGjoGkqXtAPX1s3gIVXKAyscndWisWXKX6EXAKoEfgGx7ltJt8gjaulYqlIALnBTezNj5vOfodBJKF9cfTT6qYZfdEDCwL+S7HTJymLZVRybKih1tuixJdlIVYTryWLs/8UgaoFt/XDJPqDcZhRCrTv94zz6W1QAlGFaSzZYIDZkXM5fymNSt+0bXnigAsPYiHod/G87s6fEHncdSssqb+MUWFLxGWOVNU52UnsOqovqfOHtGKJEv8A4adV+bUc6++ZBvI4vAN3NrZGnszzonFZRA+kUXI1g96XheiqXsu40jQqKMdPoLUXtAcpibE0 XIV2QlY+ MOcFtCx5rTqQ3/Oh4aYdJ+Nerry+60ItenNIUXydVM/DrfCdosLeaNMOtlOdaimy8GexTMNexOQ2tqdRILOPXjpBJZadWVJEqPAhVj/3UJZiuEneYUv5cuFa9FSgdLrX9RvKnexfQXbcR6yx34JWWupX5xw== 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: The loser of a race to service a pte for a device private entry in the swap path previously unlocked the ptl, but failed to unmap the pte. This only affects highmem systems since unmapping a pte is a noop on non-highmem systems. Fixes: 16ce101db85d ("mm/memory.c: fix race when faulting a device private page") Signed-off-by: Ryan Roberts --- mm/memory.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/mm/memory.c b/mm/memory.c index f69fbc251198..ed429e20a1bb 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3728,10 +3728,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) vmf->page = pfn_swap_entry_to_page(entry); vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, vmf->address, &vmf->ptl); - if (unlikely(!pte_same(*vmf->pte, vmf->orig_pte))) { - spin_unlock(vmf->ptl); - goto out; - } + if (unlikely(!pte_same(*vmf->pte, vmf->orig_pte))) + goto unlock; /* * Get a page reference while we know the page can't be