From patchwork Thu May 18 11:07:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13246485 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 72739C7EE23 for ; Thu, 18 May 2023 11:07:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 933B7900008; Thu, 18 May 2023 07:07:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E509900003; Thu, 18 May 2023 07:07:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75E79900008; Thu, 18 May 2023 07:07:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 64B5C900003 for ; Thu, 18 May 2023 07:07:46 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 38F3AA0661 for ; Thu, 18 May 2023 11:07:46 +0000 (UTC) X-FDA: 80803100532.12.17F69EE Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf28.hostedemail.com (Postfix) with ESMTP id 6A23BC0012 for ; Thu, 18 May 2023 11:07:44 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.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=1684408064; 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=gJ7+QONRShY3K6hgqhkCHXd2gqI69whncgzkLYLB0SY=; b=LUVkBVazIckfQCXrhZVLg+llrOd1fNhitlQ2qPeQ9h6LFNjeQcC2/b70+AxWGAn8IxzcAm miJz3935ky+AlzRi7rfsu3rn17pIhA7yoO0g5o0Z0moejuZ7oD6vTWBXZuJmdpawjkadAR DAZ/HRSivFPR02ISOo1B6xhyMNQhkGs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.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=1684408064; a=rsa-sha256; cv=none; b=AkUpIPAn3q8QZweIjQx23fIICkLklw5ZvLGIFI8WgLdUct0vNcjTN+IyToni+Pr/2P4Elw jixSVr5i5qatn65MTy5uYABpqpbrwteRtKKI2z4vYHgjy7pogM7Iu/JPQwPTOmZAGFoLPb MCQxnIvBNsp9pSq7k7B/nDNPpWLUqjs= 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 65B37113E; Thu, 18 May 2023 04:08:28 -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 0D3093F793; Thu, 18 May 2023 04:07:41 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , SeongJae Park , Christoph Hellwig Cc: Ryan Roberts , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Lorenzo Stoakes , Uladzislau Rezki , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: [PATCH v2 3/5] mm: Fix failure to unmap pte on highmem systems Date: Thu, 18 May 2023 12:07:25 +0100 Message-Id: <20230518110727.2106156-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518110727.2106156-1-ryan.roberts@arm.com> References: <20230518110727.2106156-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6A23BC0012 X-Stat-Signature: gb5u6xa19kpkrddcoeptog7wrdya6edi X-HE-Tag: 1684408064-418431 X-HE-Meta: U2FsdGVkX1/0catlNrurc5e3sZmRjz+UFtMe+oOfJ8L8L6EvZWG8+7/nO4esNxpa1jJaRnbOZG573CM5NfHuEWFn+0S4RNRxEequqjwY2DLsrSGGZYhfr7XBGLWggSPDaus/mvWEmz9TbafLE0AElYXRdmEZgKN+Hdn0711dv4zKwOHlH99rK8rdrfhhJDqIh1iTOLmFuB7xDWpH7PmyP9Twb9E1hVgrsH/QxToDxH1GZaQErVrzOy0fj9lvVuerYwr8Csd9vP0SceHjdQv3H8sjMtPDEzgNvqf0aEm/t5pfS+uGeRHkRKL6B4s2GHxDFh8sxCdpiT662miCkbAwzXgimo96s8vQ9UkMc0+FSD5WC12qXRHkVg+I71WSsXZZpbYrn4QmP5gKkRK1CclZr+lHfgvZOF4Ms30R7Dr5MAHYJ9V2tmFZQObUGIFaCmrGnKCR7scxbtx5w/CTHRmLQNxv62v7CXOra3cjBN76W0JNxFd2wPrT0G1HEY0GVU07YIzeD8nHCV9k2RlFLmYpN5IMO5Y7Qz6qdQcC3s4b0x3OkgGdP4/TY5+dkrPfpyaoXWxOUQSSdRAXRQgUzQjyIjeK+d4bfmXPgf11X6GKdL7hb3w7seNQXgehTdBjVG/iam0MNcuudo8ZsyZ26HjVnACejl507AEVJa4qI2FhVrg+wTqG02aVxIp0BNyxqa1WFf/WV+oRMkj84qVNm8EB8a6thWM/ZRDzYEeHdFLgKpOO9i/v9KZEiX/Aay38bIssxUNyrDuhHXQ0uHgy2HleReqMgSVo5JXt15n1IIzbtDjdEm4jkS91MQJcWcvMUW9Zu/aVuC3LPZl/4866ITMyR4Uob/n28EKKChm0wiXebv4IiD81GDMGDA1s/Uu5vtHgsfZm14PhhBekFN2EbyqDuf+0dXm69URyoOFCI0JyZHXUlRfpwyNgiZzG1IpEQ3nUuvVFD80bMDo9ErWwhPW ljAYbUrd gcP9p4gZNbsKDzEixAkOQAzVmGlxWh1A4lgG+sVUazM6ew6YkLu7TM/34QF4bCYDeSXieK/wNsKiwNcwiTuoDjEGISCZCp264ONspeWB/KwTFAR9eRTFNAu6PshO9TTT+I4gp9DryicS6DHey9W1gidManf5NzlnZn2ivMWSJLE/LLicbextkw0dF3Q== 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 Reviewed-by: Zi Yan Reviewed-by: Mike Rapoport (IBM) --- 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