Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2728013pxb; Mon, 31 Jan 2022 03:03:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeTQewoHY/gQ/towpvG8mnA/CF5jr0IkGeqfMSPyZRgHv53f32wDBDv45hk4m2hbnvkAud X-Received: by 2002:a62:1813:: with SMTP id 19mr19467779pfy.14.1643627011844; 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=F3U4uBUlFejX+budrC9o2U0ZQ2K5ouT86pTQhqbq/wpvrWBn/968neu4O69QTgw8os OYO0bfQ0yAnjzkkOSukjnis8XGtvyqpjF9i78MepFPHr6K40FaS6mRf6aEILUkLA5hU9 8Q+cqVBKwfjA0cPQsxsYGEtVKBOA0Lhc0vgtYafG2xRRP4MCkaNcpaGBklJycSK5Sm6I D3FtvhnLubfsoOR5L64jXZexiO18KlWXSI8XEmHsKm01xU+0XVd7mQaBkraew4+gahFd iJV0Zwn2dWmODGdiBn+NrqKAtu7dD7QLUp58dHaf2PX0nQiC25qkvXGu0CnmNdg0h255 yPOA== 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=RZET6KbJQW7VW1QW9ZpHlj8GvOwKrY4N8XGYpxkjsRk=; b=FfTkUaHW+uF6sJKQJGGkUAzICczvNsyS2FQAKhOp7JuYhnfvGFdazBiHcSmtEyzjTf enUPAAylcjAv0fmo01b9GHT3jue5PSfwnKYm1ullgSj0UoRuGM8V+VAfLkoB9zBWV50C PedbhIqm5IImSfrf+utJhYCAfZCoMhzqGad/cccDMXKP3kv8X7+as7Yb5qb3SsfMer9q WYx+oO+w+U8Uer/RzFEdPBl3TLc+6ZTUVhMXfZH4FvK3RRbcSqYusyzwANFSLutEFAxB v8lnWXnT3DkEqhfvnrOU67Plo8g6fH5MiumM2TXlfq50XKD+Mf5AW+FgSK3C+qlrq6Et m6Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b=I5CUBm8D; 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 j24si12349563pgl.348.2022.01.31.03.03.20; 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; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b=I5CUBm8D; 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 S1349133AbiA1NUS (ORCPT + 99 others); Fri, 28 Jan 2022 08:20:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348727AbiA1NTK (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 BAFB8C061755 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=RZET6KbJQW7VW1QW9ZpHlj8GvOwKrY4N8XGYpxkjsRk=; b=lg7mwIi1UUybUJbUCaCkKGLFeyjCzcgmEUUUtMqA2m435D54fPR9BuFNzrtW1IzZHziPP IZmxP4OfpkTNZIZBw== 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=RZET6KbJQW7VW1QW9ZpHlj8GvOwKrY4N8XGYpxkjsRk=; b=I5CUBm8DMAq9QhQZuDTlz8HPE2GIJe8Pl3qJLv9+aAuCuvlUoLHPmQcQy4o+btcgoFyJW 3Y7vobYfMEpLBYKSi+cUmMCTZmiDcDl9/0RST+kJVyF9iQstS//R4caHv/PgITt2zBu5Yqr Gbf03b8Kb9YrDIUKGUSbIFHu7CjsWATo32dn+aB5Kn4rvTcVkILtwbJNea7ub2Yc6ff0esG y0U2jbBv910miMShGu4zYhfJNj6ssvqdDUaNOZfYyHezMQlfu9JyzcjMlEooD06liuQ1w+G iP51OphoqkfoVswBHn3l8LMgiQgbkAt1EBXgCT9AJwbLwtb4u87lUpO7PAIw== Received: from zeus.lespinasse.org (zeus.lespinasse.org [IPv6:fd00::150:0]) by server.lespinasse.org (Postfix) with ESMTPS id 34E4D160AAF; Fri, 28 Jan 2022 05:10:07 -0800 (PST) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 116CF20561; 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 25/35] mm: add mmu_notifier_trylock() and mmu_notifier_unlock() Date: Fri, 28 Jan 2022 05:09:56 -0800 Message-Id: <20220128131006.67712-26-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 These new functions are to be used when firing MMU notifications without holding any of the mmap or rmap locks, as is the case with speculative page fault handlers. Signed-off-by: Michel Lespinasse --- include/linux/mmu_notifier.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index ace76fe91c0c..d0430410fdd8 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -772,4 +772,29 @@ static inline void mmu_notifier_synchronize(void) #endif /* CONFIG_MMU_NOTIFIER */ +#if defined(CONFIG_MMU_NOTIFIER) && defined(CONFIG_SPECULATIVE_PAGE_FAULT) + +static inline bool mmu_notifier_trylock(struct mm_struct *mm) +{ + return percpu_down_read_trylock(mm->mmu_notifier_lock); +} + +static inline void mmu_notifier_unlock(struct mm_struct *mm) +{ + percpu_up_read(mm->mmu_notifier_lock); +} + +#else + +static inline bool mmu_notifier_trylock(struct mm_struct *mm) +{ + return true; +} + +static inline void mmu_notifier_unlock(struct mm_struct *mm) +{ +} + +#endif + #endif /* _LINUX_MMU_NOTIFIER_H */ -- 2.20.1