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: 95793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp413305vqo; Thu, 18 May 2023 04:22:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Fyr5EHg4yZqoFilheNzUHra0+k8KM44GexYp0IlPnME0mnQSiBXsLsB4bbh0pfzgoH2+u X-Received: by 2002:a05:6a00:2e0d:b0:64c:9972:f742 with SMTP id fc13-20020a056a002e0d00b0064c9972f742mr4812018pfb.8.1684408924419; Thu, 18 May 2023 04:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684408924; cv=none; d=google.com; s=arc-20160816; b=tRzdwzSxI+arE1PQ05lV0N0NgDZT8pZ/ew24EdPHf2a4c7NW942EwhUbaFVv/9mv0g FvNmcAICngiusA95gESuhkuaiDMx4j9rrJlrGEqYjJF2pD5xI3PopdX6fF1lObv8o4CL m5PqbZDGDQkNdpnMEN4ZRQFMOZ0hORlbBcabz//OSulCBwqkSdnxlm7Fi5mtxAkf7+r3 dVXG2ZpJrO6IaTgh1YvmaPD3bxWu/R6vES9/bNKLNrkfqR5mjUx+ADK+/PB/YZdmEh/v TqYxJV4d4bdsqFcUK2lETwD4I/KjY/tCy6Buv00sEVRgi+FoL3YD1/KaaIYL5n2EjF1j yqMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gJ7+QONRShY3K6hgqhkCHXd2gqI69whncgzkLYLB0SY=; b=D4vqKZjkgIrJ/zJYLjhNFU/gPmRl0N5MyzeUBg0Y8di48j4Hpjz4tl2Ilk1IhYjS5q z+bCs2BE4cU3OmIOiyEbYg6PQdQz00SOJL681Q5WDmaor2xD2PcFd/JL0mVLZ5tI2pc8 SfKmiIPBrJfcVUV/6YrZhVsi8n59RaMlg8WM7YbBqiYKNj5YaY4hZkd1vhGxqNk+lOdt 51Zr7XuL3XiMt4IH1SftzEhx+NFMNG3hXI5kuAMOJVIiBZQVEl2BHvQAGSWew3FwSjqe L9O/7Kof3LRzPZ/DZuvHg8Jv6bVwCO2nHo6Z2t/91qt4EOSC3EH1shUuuZ15wtDoOy3+ wQpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020aa79e91000000b0063afe9f1fb1si1422760pfq.119.2023.05.18.04.21.52; Thu, 18 May 2023 04:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbjERLHr (ORCPT + 99 others); Thu, 18 May 2023 07:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230417AbjERLHp (ORCPT ); Thu, 18 May 2023 07:07:45 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C92F010E6 for ; Thu, 18 May 2023 04:07:43 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766230772504426956?= X-GMAIL-MSGID: =?utf-8?q?1766230772504426956?= 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