From patchwork Fri Jan 28 13:09:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 12728530 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 31DD5C433EF for ; Fri, 28 Jan 2022 13:11:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 485976B0099; Fri, 28 Jan 2022 08:10:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 272356B00A3; Fri, 28 Jan 2022 08:10:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3353B6B0096; Fri, 28 Jan 2022 08:10:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id E26F46B00A2 for ; Fri, 28 Jan 2022 08:10:13 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9C40491E4B for ; Fri, 28 Jan 2022 13:10:13 +0000 (UTC) X-FDA: 79079729106.22.6013003 Received: from server.lespinasse.org (server.lespinasse.org [63.205.204.226]) by imf09.hostedemail.com (Postfix) with ESMTP id D3473140002 for ; Fri, 28 Jan 2022 13:10:12 +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=N1bCyCqlqCPmn3u4dr/qGIvPJEOlMd8KVKMJcaELgEw=; b=GcBReqmwDZ82aVnHS0hCCWXYruQ1qrdcFPqUv1QkU6UoqgPLM+nRmvNS0Y8AYDNay6K1/ WrF/45/SfCMN4X4Bw== 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=N1bCyCqlqCPmn3u4dr/qGIvPJEOlMd8KVKMJcaELgEw=; b=0fIaqi5/e6TyDkW5DpsQrirQBlbVLQ6vD67HM9rQxnG/ldkbMS/1aO1AiQET+/+D1Wxp3 Vo3HWduaw/24aWGBGAOG7sRUAqxQa9gvY5TqSrmEIbhtiNXIFrxZzvVmTqly4Issy95x4JZ XpUoZZcE5SnkHhoHB10UfCAVkkVE2c9veNH+HcRiGCIJE7VAJr7oiNuou1QLzhuQ9Algvkf igQLboMXPIsg3bvd3gxPJfjO6ges3d0MKFpLCjlXZt+yUAlXlhwjVP8IkEAW9tPE7bRVYLM kP474IHw4IXNCpCJ02BnlHqMo47/ZINoDZlC8r5J6BYzN2BgvHhe5CoZbTdA== Received: from zeus.lespinasse.org (zeus.lespinasse.org [IPv6:fd00::150:0]) by server.lespinasse.org (Postfix) with ESMTPS id 33BE8160AAE; Fri, 28 Jan 2022 05:10:07 -0800 (PST) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 19D0820FB1; 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 28/35] mm: disable speculative faults for single threaded user space Date: Fri, 28 Jan 2022 05:09:59 -0800 Message-Id: <20220128131006.67712-29-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: rspam10 X-Rspamd-Queue-Id: D3473140002 X-Stat-Signature: inannwtigwicqwbzi1x6zeckfp7nggt4 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=lespinasse.org header.s=srv-52-ed header.b=GcBReqmw; dkim=pass header.d=lespinasse.org header.s=srv-52-rsa header.b="0fIaqi5/"; spf=pass (imf09.hostedemail.com: domain of walken@lespinasse.org designates 63.205.204.226 as permitted sender) smtp.mailfrom=walken@lespinasse.org; dmarc=pass (policy=none) header.from=lespinasse.org X-HE-Tag: 1643375412-664056 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: Performance tuning: single threaded userspace does not benefit from speculative page faults, so we turn them off to avoid any related (small) extra overheads. Signed-off-by: Michel Lespinasse --- arch/x86/mm/fault.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 6ba109413396..d6f8d4967c49 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1328,6 +1328,13 @@ void do_user_addr_fault(struct pt_regs *regs, #endif #ifdef CONFIG_SPECULATIVE_PAGE_FAULT + /* + * No need to try speculative faults for kernel or + * single threaded user space. + */ + if (!(flags & FAULT_FLAG_USER) || atomic_read(&mm->mm_users) == 1) + goto no_spf; + count_vm_event(SPF_ATTEMPT); seq = mmap_seq_read_start(mm); if (seq & 1) @@ -1362,7 +1369,9 @@ void do_user_addr_fault(struct pt_regs *regs, spf_abort: count_vm_event(SPF_ABORT); -#endif +no_spf: + +#endif /* CONFIG_SPECULATIVE_PAGE_FAULT */ /* * Kernel-mode access to the user address space should only occur