From patchwork Thu May 11 12:58:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13237872 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 4B510C7EE2A for ; Thu, 11 May 2023 12:59:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA8F76B0080; Thu, 11 May 2023 08:59:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE1FD6B0081; Thu, 11 May 2023 08:59:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD1BC6B0082; Thu, 11 May 2023 08:59:14 -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 C0C4B6B0080 for ; Thu, 11 May 2023 08:59:14 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 59AB4A0444 for ; Thu, 11 May 2023 12:59:14 +0000 (UTC) X-FDA: 80777979828.18.1F6062D Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 9D3474000B for ; Thu, 11 May 2023 12:59:12 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.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=1683809952; 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=u61qk2Ws3bjDjcxGQt6UZYgHfEc0987qlns+07QD2SGeh4OoZH5c8AHdgCfQBKH3LNf5P+ /AGG5AIrS/g2DA0HWV7R/uLx2M9Yl2yNMoCrlvRltfi/k0kx+i90Ib6i3p7Ryr7t+Amv6z on3fElfAi8VpwdMmpjY6TMKpYufQ3B8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683809952; a=rsa-sha256; cv=none; b=HixuEvFgrpYOwrsJ+S+T0+01Ko9f17o1HZW6xWCLyPs/96qzfCWgjUDCe/FhSl7GzfRTd5 irLQjtzKtoKvD7AGsoBEg4lfkJQ7QjN6gbsdghe5bQKHBt16G8bhZKEbm9X9MCIa59pdWb Ds+WbFLyNxaAvBCcKq2JUQJdeXflDfA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.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 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 0E5AB1684; Thu, 11 May 2023 05:59:56 -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 67D033F5A1; Thu, 11 May 2023 05:59:10 -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: [PATCH v1 3/5] mm: Fix failure to unmap pte on highmem systems Date: Thu, 11 May 2023 13:58:46 +0100 Message-Id: <20230511125848.78621-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230511125848.78621-1-ryan.roberts@arm.com> References: <20230511125848.78621-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Stat-Signature: jrm3p8uuxg1nm46j3cyasn99awsidowh X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 9D3474000B X-HE-Tag: 1683809952-356778 X-HE-Meta: U2FsdGVkX18HJ5dE52nVgoJ+XDNNhLfaDdlJyVN2iBmU9NmYIOUXvP0MNqs6aNfnu22lZpWRBruquiHs9n+NL+OskZqfbQNBDdEq7EhQVpc+6n747Q4TgK5M8H4BCAeg6o4AZkQyWnzwntyqhcyEkdm2A41JO7g0d9g5m+tKrVjU951Ev8bMO8nfKKQ8szS6DOWuS5+FueUSOst8rMQH0Ef7w7m1Z8LCCwnl8/HVAUknfM73zxkfEJVd8wlIfCCIVuD9zSwsD/WF1eYwxz4X9wQjSq2vvVuqc8Sg73ZRo/TsDwz5259xgYDceVwV+I1Q+a8durWgDtrD4mVFmv448Q/YRHUTieg8Zn6owPlhurn3oWgHJOkUnmMxyEOM//gLb3QZbHqx7SpSufSXcWPN4PNi56wN4+V0+7C3f7g3EPXsl30ohxvVcWowYeZdbK9nq4HJ4dWo/JYHHuMzcNPkzmu6Lq+yhOC7RB2GN5fiLENB24XPpCSt75pqy0WDReBWOevcsXD/ay7L2SwTfvv7UPdIK3gGSGAtrxAHwMHua47jobAuRr9FgN1/YZsvpdAgshslpG7WOc+mG5ZSlJAeTaPzDfpFVJqsW551XfCgNyM8cG0GUwmWmqq0rHuHN8ikSM6FJlArCKFK8Cg3aFh/zYocR4WrM9anvklTXx0a5hpFGS5DdO1ZnvAFPIHpHEzgfA+PHnh9FMaqgYtRVuKhZWi4Y4b0j2Wp24pTHfoQ63ox2RdmSQ1BWz/zRZAnWO6e8RGIGO1B3vUnIPffFlnQwDMG9RKMpHCShwdAZ1eWTBmYcGkW5MiWNHSBQTaXuOv+c2L6uJ3rKGxTdDGlFcWvu6I6slsA/KnCsIwIYHtYmcoaigjE1KFVUbmHuqe0X71Hvq7XwV2rEgcYgyKE+VftZQuovn+JXR8Sv5QkRGh+2Xh44ivtrXvmNGrRb0+IaY4UKVGKx15+DTGTyv8POy4 CTRy/KXl P2VMXP5k3/kB/oEBnqIy54eNy6pU/8FWxbh48+Sg5Elt8iulFrfjeOTjMYGtn03s61dZ393Mfn2C86ia3OY8pnq0GEwEHIQCXqPD7E7DGZzemJgE0fVJY9zSu0WLkPjw6ywcFZ/foTp+lkjUK4EnJf3LMIg== 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(-) 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