From patchwork Fri Jan 28 13:09:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 12728515 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 9E739C433EF for ; Fri, 28 Jan 2022 13:10:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A34C6B0087; Fri, 28 Jan 2022 08:10:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 55B746B0082; Fri, 28 Jan 2022 08:10:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE7746B0093; Fri, 28 Jan 2022 08:10:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id 63DBE6B0080 for ; Fri, 28 Jan 2022 08:10:12 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1EB2F181AEF23 for ; Fri, 28 Jan 2022 13:10:12 +0000 (UTC) X-FDA: 79079729064.09.11AE30B Received: from server.lespinasse.org (server.lespinasse.org [63.205.204.226]) by imf14.hostedemail.com (Postfix) with ESMTP id C0CD0100010 for ; Fri, 28 Jan 2022 13:10:11 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-52-ed; t=1643375407; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=7+5QvEdtmG46cyTSwpuhmgwjYp8hFfGi6s7BBfWPw2Y=; b=2+PTKlEkpcO5i4QYKxeQTRm7LeyQtVi478aVZzl/7sCj4kBJ4ua+ErhWugoAJkfOJZCFG bATPcA9HkHi9zlcBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-52-rsa; t=1643375407; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=7+5QvEdtmG46cyTSwpuhmgwjYp8hFfGi6s7BBfWPw2Y=; b=2mC/3CoATcjgomsxJlVsgkFCMEqHUGQDhcHQzse5CKmFMppDw6BuyRCMAXfHsJWlmr1jb +yDu9wTtJz1tYoxVd/WlKzGyMyh5PtbTcfg43ZBsi8TTCDZp5QPasrmq25NozO0Dt4rgkeI 5NfMx8pKTn3F9DvOH0XNL1whff2V4qvD7IZIaQ3PbrQnmat49eTt/6k7mLTkggOuyk9zMaQ YL0DOmYJ9skwukaR9KJm45ufu0yHmc3vDiSZbycXC6lpdBhpWoNPwXUZJIziqhEFuYQfJma t1erBL6fEU16lbtA3njilP/fzWhi/SBHvC+C3aOWVHo1QTWAxvGzKsIzGV1w== Received: from zeus.lespinasse.org (zeus.lespinasse.org [10.0.0.150]) by server.lespinasse.org (Postfix) with ESMTPS id 1A68F16099F; Fri, 28 Jan 2022 05:10:07 -0800 (PST) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 04C7A20337; Fri, 28 Jan 2022 05:10:07 -0800 (PST) From: Michel Lespinasse To: Linux-MM , linux-kernel@vger.kernel.org, Andrew Morton Cc: kernel-team@fb.com, Laurent Dufour , Jerome Glisse , Peter Zijlstra , Michal Hocko , Vlastimil Babka , Davidlohr Bueso , Matthew Wilcox , Liam Howlett , Rik van Riel , Paul McKenney , Song Liu , Suren Baghdasaryan , Minchan Kim , Joel Fernandes , David Rientjes , Axel Rasmussen , Andy Lutomirski , Michel Lespinasse Subject: [PATCH v2 20/35] mm: implement speculative handling in do_numa_page() Date: Fri, 28 Jan 2022 05:09:51 -0800 Message-Id: <20220128131006.67712-21-michel@lespinasse.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220128131006.67712-1-michel@lespinasse.org> References: <20220128131006.67712-1-michel@lespinasse.org> MIME-Version: 1.0 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C0CD0100010 X-Stat-Signature: t741k6da9pb8g6795ezwk9mcpqtcbjkt Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=lespinasse.org header.s=srv-52-ed header.b=2+PTKlEk; dkim=pass header.d=lespinasse.org header.s=srv-52-rsa header.b="2mC/3CoA"; dmarc=pass (policy=none) header.from=lespinasse.org; spf=pass (imf14.hostedemail.com: domain of walken@lespinasse.org designates 63.205.204.226 as permitted sender) smtp.mailfrom=walken@lespinasse.org X-HE-Tag: 1643375411-293252 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: change do_numa_page() to use pte_spinlock() when locking the page table, so that the mmap sequence counter will be validated in the speculative case. Signed-off-by: Michel Lespinasse --- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 74b51aae8166..083e015ff194 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4441,8 +4441,8 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) * validation through pte_unmap_same(). It's of NUMA type but * the pfn may be screwed if the read is non atomic. */ - vmf->ptl = pte_lockptr(vma->vm_mm, vmf->pmd); - spin_lock(vmf->ptl); + if (!pte_spinlock(vmf)) + return VM_FAULT_RETRY; if (unlikely(!pte_same(*vmf->pte, vmf->orig_pte))) { pte_unmap_unlock(vmf->pte, vmf->ptl); goto out;