Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2728373pxb; Mon, 31 Jan 2022 03:03:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxF8xE9Wn2iUB2i1hyEoSt02sWhGMVHVYTsPg0zxHwIx183NTo/NC+RRxyTKCdsqehOnP2R X-Received: by 2002:a17:906:c150:: with SMTP id dp16mr15174982ejc.736.1643627034951; Mon, 31 Jan 2022 03:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643627034; cv=none; d=google.com; s=arc-20160816; b=ANgmi+VeEUL1GaUU4oL3j9EwP5QiTKbp3Ayp4L2EuZmPsIdQ6ta0vvy323w07jRvT0 AobKI5aM84Lcp3Qt4CBy+MeWJgxc456x9u75MKWz1Xyig+eHI1aYuiHNaPAz4Pvgv1Pi Bi3Nr8rhGGPKKDNZMk/Yc6tPMR9HKlXN3xRpeaFtj2DDwJaIxnulJc1MXwxp1CnElXps NLBTZ7hnwcKKHNbkortWXq0hLQSudWecpeb9fshnsNlsXg2FTwVe+SqufBT7mIwoi3zE scEpXETFpknLkAH5APWnP0GAauixF4pQtggV/D6z9sXsEpzVTGSEtNfsVtzsOhrXQN6f 4anw== 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=brYV8LPA4M9MTtgPlp3UWTnacdv4IgtI3z+1Ewrumi8=; b=whx6PdpLYS0CSJlRK7XCSpOvkjmf/NIk/jaq60eUohkE7nmKFZ9H12BdbR+8dpsstL B2sTTpo9Uq1Fwu1ZpXGB7SkB5a2g2jyE7x2oLZh61fy89Xqg4QpubRk+WIlyGgyY0wp+ oGVBj/0Mc4jMMG036eLQ3GZym5VmMk2q8jvEVtOytny24PDKSuI53iLC00efjkghyYwN RqkdtNDidh7VTVOYk2gpP7j5LAxlYG1o/Gl5qcpxB7B06M8/FKc7U8jtq977InyRONoG Wwrie4o9AvQZ9Ogpu8JmuO+1b3vJqZPs1VRf17EZTE8QJufunPr4eUa9oP4phxF9BhsM zdvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-52-ed header.b=I1DZbEmz; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b=BnwIWxwa; 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 s30si7801318edi.340.2022.01.31.03.03.30; Mon, 31 Jan 2022 03:03:54 -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 header.b=I1DZbEmz; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b=BnwIWxwa; 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 S1349209AbiA1NUu (ORCPT + 99 others); Fri, 28 Jan 2022 08:20:50 -0500 Received: from server.lespinasse.org ([63.205.204.226]:45397 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348748AbiA1NTL (ORCPT ); Fri, 28 Jan 2022 08:19:11 -0500 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=brYV8LPA4M9MTtgPlp3UWTnacdv4IgtI3z+1Ewrumi8=; b=I1DZbEmzQI4BcXWoERJUPqVuo+xoDE/u5gIe/livDsttlyUfT+MZsR0eXQlVWW88IXojZ 0jaTameOtDQD5k0Cw== 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=brYV8LPA4M9MTtgPlp3UWTnacdv4IgtI3z+1Ewrumi8=; b=BnwIWxwakg1LSUdfMDZOXM07NSkkaRmm7gkd+wArC4muOcJ34MoFFiQ8zPm2Gv9Fvzeb6 Uvld4y0CFz/xgMOWzzPdrQS8SkI/FRPZS+avWFDq9lAW4LHsL1zFSMRRoDILiO22d27+8l4 h4wYnNj/8p/IH1qHJ2oEOMNuJpsAFjSLzHMu2eeXkTUpGHu3yjRJnPqUtFs0XGwkiuMcG/H voXrhVBC9PZEQuTti4ut+rreXnIDxCC/XYgPL3+TiU757qOBPUm39Ch+wXPw/DG0yIxAOTy 35hiWPkK/9hDr8NZ6eENLlEC6XtGLCsYgX477+xRrPBYMdb2h5hkkByDflOA== Received: from zeus.lespinasse.org (zeus.lespinasse.org [10.0.0.150]) by server.lespinasse.org (Postfix) with ESMTPS id 29450160AAB; Fri, 28 Jan 2022 05:10:07 -0800 (PST) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 0E8D620132; 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 24/35] mm: write lock mmu_notifier_lock when registering mmu notifiers Date: Fri, 28 Jan 2022 05:09:55 -0800 Message-Id: <20220128131006.67712-25-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 mm_take_all_locks to also take the mmu_notifier_lock. Note that mm_take_all_locks is called from mmu_notifier_register() only. Signed-off-by: Michel Lespinasse --- mm/mmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index b09a2c875507..a67c3600d995 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3592,6 +3592,10 @@ int mm_take_all_locks(struct mm_struct *mm) mutex_lock(&mm_all_locks_mutex); +#if defined(CONFIG_MMU_NOTIFIER) && defined(CONFIG_SPECULATIVE_PAGE_FAULT) + percpu_down_write(mm->mmu_notifier_lock); +#endif + for (vma = mm->mmap; vma; vma = vma->vm_next) { if (signal_pending(current)) goto out_unlock; @@ -3679,6 +3683,10 @@ void mm_drop_all_locks(struct mm_struct *mm) vm_unlock_mapping(vma->vm_file->f_mapping); } +#if defined(CONFIG_MMU_NOTIFIER) && defined(CONFIG_SPECULATIVE_PAGE_FAULT) + percpu_up_write(mm->mmu_notifier_lock); +#endif + mutex_unlock(&mm_all_locks_mutex); } -- 2.20.1