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: 92558 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4357074vqo; Thu, 11 May 2023 06:08:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zMiw6W6S1RSE+7Y+y0oiWdydT809HVLWFt1gHNDlCZAnNlVSuBl8UfGNI56Su8QOvl+ek X-Received: by 2002:a6b:f60b:0:b0:760:eb94:c971 with SMTP id n11-20020a6bf60b000000b00760eb94c971mr13578427ioh.11.1683810503586; Thu, 11 May 2023 06:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683810503; cv=none; d=google.com; s=arc-20160816; b=lvrWjhbJEep6HSF1/+zvbxFUMMs1JcAXPd1X9VnjvT/VupcwEuCFLKgjzY+gwjTd8X rCE7YF2vmaQgk+A0g+Iwu9u1+1co7C2nWaffRBmPwiekaPAeCSpSmu+XecYwVv74PSgT JZ+meEZQ7TGppKcdwiWkGsZM/jcB8Y3Yk+jPaN+mfNY7x/SpuT8cLFHc6X1LSbD3WTHs qCNRwL9Zf1t03h5rSNOqEsEHLptPqd+vguLGA3yVfDc6WrWsqcGv1qiuxb2IrLfWruBJ GpDgw8T6jPutPEaYRa0wyqQH8ZvavYIYUots0qrP5UKgRR1QPB8s2QaxqxfSpXnhV7h7 D+tw== 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=lzgZOEGznLZwXHG2uMOWyrmtdrzDY9bWWF3EWrJ2RNM=; b=SouFgcRuTmIKuwKUQhkyc03VFBY99TWgOPQ70lNh6uZ5ooYQ7galKAdnUM5zL8qrxL CkPyIsviSXE2melR0sxN6xAvUPrnpOy7vez2RFmrKZkoHr2c2zBDk/d3fBRjsxAh6Plm 98iBf0QEDreqt+dZUwigwaVRlHeqX4PILc5MQYMY3CyQ25fdDiNih398njlPXnlvKw4Q 5gOQDdm5pSMPW+zOP9yByNdJsvNUehso2Wn6oy772RfypK9XgqYwyohkDHZ6UFEsgnyo u+ONQ05xl7Ik4KgHwlMgP8iRCOZm3OgxUarY93Ew6KXpYRHgrWbSNe7pJWm6GGFUPQyP j6XQ== 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 t10-20020a056638204a00b004145277bf3fsi9547036jaj.113.2023.05.11.06.08.08; Thu, 11 May 2023 06:08:23 -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 S237990AbjEKM7Y (ORCPT + 99 others); Thu, 11 May 2023 08:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237932AbjEKM7P (ORCPT ); Thu, 11 May 2023 08:59:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4124C65AD for ; Thu, 11 May 2023 05:59:12 -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 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-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?1765603282288776370?= X-GMAIL-MSGID: =?utf-8?q?1765603282288776370?= 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