Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2729470pxb; Mon, 31 Jan 2022 03:05:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPzponNxokftPTm7yx6OVVjo9Xojy9tsuh7rowa5TmlLvjd2YoQi0MGkHM5abYpc8RqURG X-Received: by 2002:a05:6a00:1914:: with SMTP id y20mr10905844pfi.41.1643627108953; Mon, 31 Jan 2022 03:05:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643627108; cv=none; d=google.com; s=arc-20160816; b=w6pn4Mfv1zQB9XPhx3xzAuRhWU1Mge6rR4fzzAT92ns1Uw1BBLCaFpHm/n/aP77rFF Ok0WaeTcbuvhiRTGj9m6qZtZw/sCoRQ0p7hAxPt9gaoOe51o0aM70GZBR6Z9WwqXMo6a ETzUze03mjmfzdHJ+z/c3WjIzHlcV5a67xu7y5uNQ4eWmNg7CM2MYdLQVaehGIlXYioi otF2VqatKzpnY6BAc+Y8f5uO+VIynD17Z0FrFZ4mnG/MOr4geHRVy6eAf6qhQiOGAsDG uJ6ncA9E9HQWbZWahAUzmm3q/jRYh/yof1YltVnYqBqxq2qrtfxSNvMQeEnLMnJleGma 7JpA== 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=N1bCyCqlqCPmn3u4dr/qGIvPJEOlMd8KVKMJcaELgEw=; b=MwtF72UOX26M1647bRbCQGVE7NMbjq0QlHo9X8xXUlIh80UBAvE8PqGVoiWTtgmbYp vfonT3sjX+svwBdk+9VcUDR9x8fGaMDoxmVQ/lTnTgF6bPhl9wEK1CutyPAMarKo5PmS joP+Ap4hSwhsBREJPgijXe0E5V/cZpuEtapx+6FL3vfcrVC2nl6jdxV0mWBxQ8JqqJsy MxIi+JUnQ1l15UklmGBP5GHA9M7X6f4O3q81CiwZ8qf/DCJCsenD0/j1Yq2JJWh9RB/Q pmVw7ja8xjj1UDg6sWS9l+8VXeQ+sPi3kvspERubLyohiWTesoppiGXmeEU6x194EAQ1 /6uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-52-ed header.b=GcBReqmw; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b="0fIaqi5/"; 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 s16si14829629plg.330.2022.01.31.03.04.58; Mon, 31 Jan 2022 03:05:08 -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=GcBReqmw; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b="0fIaqi5/"; 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 S1348960AbiA1NT6 (ORCPT + 99 others); Fri, 28 Jan 2022 08:19:58 -0500 Received: from server.lespinasse.org ([63.205.204.226]:45043 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348670AbiA1NTK (ORCPT ); Fri, 28 Jan 2022 08:19:10 -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=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 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 | 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 -- 2.20.1