Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp636725pxy; Fri, 30 Apr 2021 12:56:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMrJq0H4FGRUhljzq4fPJZZAAG/R/5keinsIe+LUOWtgp4SVVA8il0U9yEsd2lRwiwSMWr X-Received: by 2002:a17:902:8d98:b029:eb:43c2:d294 with SMTP id v24-20020a1709028d98b02900eb43c2d294mr6986198plo.49.1619812580636; Fri, 30 Apr 2021 12:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619812580; cv=none; d=google.com; s=arc-20160816; b=X1+5Iu2jFPWE+q2S+j0wmAwN/1mdNMNIQ2XfAZpy0P+vs79G7M0obEqCo7lPO20LNG Fxcoepb1HeI400F1AvT9gE11H35RpaqI6tWA1pwfCbNQ6NRbjdcO97+fwJ60a8coNtxQ cPy969135phv6u0FXW2XvWklsGfhoeRWcq0xdHO7SkudmsUagpTK0Jj7MsuitGVTeI8N yNFiHQ2yyXoE/bM4kJeMz5+LAZb0b7alFnYF0rMmnb7ihvHaSf+Ma7PwfxgCDg4EQfah Vnv1TWeEsoR0YV3dBcBA2MUIL++/Vg1cU7PcptcOGlrNcdRWpZThwz3eIUMeOJ5eTh1/ Fbmg== 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=8JAcgap2Y6VBqeBYCFSL5shic9T9aRbFwbzzfMi53Zk=; b=cQPRWj6GzGAnR5SLuaXktZV/q0P7w6p+99DjA3xwnuzBjmLJi1FM6DT7PmeF94hkpi VJrzgPaTT9NO/5MqtT9tbzVZoMA19a9zcQoiLNp/GaJsTcEFl3XAVZBB9J+R0w3x+G93 AcZ8BNsU0IRXDsv7wGuGyxI4k/LlbGft2W9tR7j11F3+wFXc6XYUbMeTwm9CTAorv9KY +NUeUpzdZij69N0cydSwUwx64ZqgaKy0cOIDZx2usT/uCw5hwGLd70zLxiDb6eTo89/6 K4Ct4Uv5vwxI/RBZD5lRYPb31ucNCC8VYsNLkOcNgNLAAHqLpsPVZlFvNtVnPrysOQa6 awvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-14-ed; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=UOOGCy41; 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 f11si3316872pfc.232.2021.04.30.12.56.08; Fri, 30 Apr 2021 12:56:20 -0700 (PDT) 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-14-ed; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=UOOGCy41; 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 S234028AbhD3Ty6 (ORCPT + 99 others); Fri, 30 Apr 2021 15:54:58 -0400 Received: from server.lespinasse.org ([63.205.204.226]:56609 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232454AbhD3Txh (ORCPT ); Fri, 30 Apr 2021 15:53:37 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-ed; t=1619812353; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=8JAcgap2Y6VBqeBYCFSL5shic9T9aRbFwbzzfMi53Zk=; b=cHUjMGrj2X1IDinPMY0+dKYe5adB499TJ7H+bfr7ETPsZilLoPfMVym38TQeMy1ziuWpJ F9gf1FUC9B6sDyRAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-rsa; t=1619812353; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=8JAcgap2Y6VBqeBYCFSL5shic9T9aRbFwbzzfMi53Zk=; b=UOOGCy41woDuBjIDj9AxgKSCdxZe8jlgAyT+CGVtOzwTmo1GlRVsIqe2Zdz1vQCn5TA1M /JofEHwPBChM0jwFBGv0l1piRk7vawrDfwuf8LY+3xed2fTKScXpJPoombyg5uNGM7eV5ys xx3jPzEFN1dABh3CoMDkDS3TWTTz69MLk5zsxFvPx3xklT+UzFtYV9KZhNn5QP/dj3HJLuE oWD2jRpym5v+B+ektmeW8VK4vXJsA6jn/3xVM28w/qteRSICYJ9RWdZkWdfSooPqFR0JBEo CbTC/gyL58DqgVVo/N8uTUPO51ELndImk4v7llW3NZgVtzXawHqurgd+x5uA== Received: from zeus.lespinasse.org (zeus.lespinasse.org [10.0.0.150]) by server.lespinasse.org (Postfix) with ESMTPS id B03AB160361; Fri, 30 Apr 2021 12:52:33 -0700 (PDT) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id A135219F524; Fri, 30 Apr 2021 12:52:33 -0700 (PDT) From: Michel Lespinasse To: Linux-MM , Linux-Kernel Cc: Laurent Dufour , Peter Zijlstra , Michal Hocko , Matthew Wilcox , Rik van Riel , Paul McKenney , Andrew Morton , Suren Baghdasaryan , Joel Fernandes , Andy Lutomirski , Michel Lespinasse Subject: [PATCH 25/29] mm: disable speculative faults for single threaded user space Date: Fri, 30 Apr 2021 12:52:26 -0700 Message-Id: <20210430195232.30491-26-michel@lespinasse.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210430195232.30491-1-michel@lespinasse.org> References: <20210430195232.30491-1-michel@lespinasse.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 463061186827..b5c21585e35f 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1321,6 +1321,14 @@ 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) @@ -1353,7 +1361,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 -- 2.20.1