Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2728015pxb; Mon, 31 Jan 2022 03:03:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbYI188gquVejab+Bv2+tcefvi+oCbM8WXYXlUx2PazBQKJR2NtsGf2JrDVbFfW81HtQLA X-Received: by 2002:a17:90b:3808:: with SMTP id mq8mr33966328pjb.225.1643627011957; Mon, 31 Jan 2022 03:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643627011; cv=none; d=google.com; s=arc-20160816; b=hvaHV3XboMx7890i+980BV75V2YH+MP/ZNguYxot/lByn52MobT2jqFwYhHmgJKQST roGQQ2rkXX4PSnDvaDifF4OoPH72umsgX0dcSc9zpvYWkwdxS6qEAKezY7OldBZNdfs+ YOgHDG90D2Q8P5J6tMP7bTt6z9RQO8q4SEe1WfNIUE7wAC3OaG0dyPA4wo16VwOlLUvh +mHJ2OdyLt6YYJlCPTynO0TcljLxs3PhFEMx784nFCnisq/5jcvYJBuebA9TyXgOr1mr Zo/BTqmllDmqYz55pemGRmy4ncoRxHImAiUMYoSgt2cT9fKbMix59kqOxo4Hlilr4gH0 cUYA== 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 :dkim-signature:dkim-signature; bh=7+5QvEdtmG46cyTSwpuhmgwjYp8hFfGi6s7BBfWPw2Y=; b=fCBRyKsMqzKyHFnT0Cbny1uflHtLE9+Ni2sMLkXC2oPdyOcL0XhyOGh6sTvQtY5nce p5aXlY9nM78BDLkfbaMOA3fAJ/WUAmrZLkdDNWW2qRz4ZMaaBlMJ7U+PVq6Rz1Lf+On5 dHt3DqGlFSQmb7uFXekwPwXlHps9zVgEg/jP73icyokNQ5tmIXyFlILBvoI5GQj/ZIs+ z1hF4D3SuAHDVhHbpgD1OoZ3qB5i5mXOv8B5G6hcz/C4rF/r+levpUbQcjWquPRnJXs7 xqWxE6zK7iPc5nzsgE2VCpPZ4KoifYDL+/D//XUvwHM/oHfn7VzuRaZ5bG5xUVWMD5x4 8DIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-52-ed; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b="2mC/3CoA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i189si5156975pge.139.2022.01.31.03.03.21; Mon, 31 Jan 2022 03:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-52-ed; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b="2mC/3CoA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348657AbiA1NUV (ORCPT + 99 others); Fri, 28 Jan 2022 08:20:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348701AbiA1NTK (ORCPT ); Fri, 28 Jan 2022 08:19:10 -0500 Received: from server.lespinasse.org (server.lespinasse.org [IPv6:2001:470:82ab::100:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAAF0C061714 for ; Fri, 28 Jan 2022 05:19:08 -0800 (PST) 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.20.1