Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp578421pxf; Wed, 7 Apr 2021 06:53:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc0nMBsSzG2npaCoTP+19O/DeASjV+Gpj89kBqJkSE3UvmCgNCadRbRRa6DmXL1uEA/Hv3 X-Received: by 2002:a05:6402:17eb:: with SMTP id t11mr4647002edy.80.1617803629263; Wed, 07 Apr 2021 06:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617803629; cv=none; d=google.com; s=arc-20160816; b=HeoWtnm25OMBHzv+yCk8LLpqDsYHlH0R/12CthAtOVX1rfbBxCBDu3ldbCQgT4+zwS g/MM9VV/YyWwiu+JTDKX6D2xsQBhTlmdC63DXBzfD9h8pPeNbHRGTsKSNLQ4YAcCMTOk BKjma8g+goWSkNINboqXAOWq9Mjt4oETTX5CsxPAPn1UjOKtLhkzJmKQL0+cScbl9dHQ dKkGOIwPsF5Lz0/Qgetnfe/mnfV2h3+8QwwBNMfx00WOPjYaRYUx1F5bGE+L/fJbi1OU 3paqAdGbY+9Yy3HtO7gT1CF7NcuTnlgpHjIbFMM5c2FkqF/cSSpZtuELTJt1ip42EdlW J9dg== 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=dxj+e2mCTN/mq8/QKyjl2SahvK7RHudQGhkISRnBVig=; b=PIno+G5Md5DZClO/b6dHPxfgW90QrzKXOe3EPOrDg958fE6uwu2sI4eBLFFNSTBipU skMDvUvb/jYsAv0jI+ux7RVChaXA0d3da0PI27y7kMNZVQjVw2PJJNBL100pA8QHrFMd 6bG1ppru9VJWRVz1APsiMwmPx50kz2S1C0aWwdh4xfSv+re38+qoHvoQE5HLJPVQ7HWq WXnoVzdLMZPpWcc7YsMG+bSnYO/3WGQIqDokqdzsXy9NVRbsnE4miiLKeL5zaWtfyH3m oWNovZAikKs5LJd8LnfIaAPpJGn7sqkFw2kyenG5lyZ4+0GbZ18aOppEwM2KtiSlSTvK tP1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-11-ed header.b=+Q3LDhDV; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-11-rsa header.b=JZCFDV30; 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 z64si292108ede.560.2021.04.07.06.53.26; Wed, 07 Apr 2021 06:53:49 -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-11-ed header.b=+Q3LDhDV; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-11-rsa header.b=JZCFDV30; 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 S1344162AbhDGBxT (ORCPT + 99 others); Tue, 6 Apr 2021 21:53:19 -0400 Received: from server.lespinasse.org ([63.205.204.226]:52281 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347840AbhDGBvx (ORCPT ); Tue, 6 Apr 2021 21:51:53 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-11-ed; t=1617759903; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=dxj+e2mCTN/mq8/QKyjl2SahvK7RHudQGhkISRnBVig=; b=+Q3LDhDV38Tl/5VVpqEc6k0vUGZdg8aC5vuZTmv9XW2HYt5SSVn8xVrXOLUhh39OTr4Yk BKC/hKD7DF5025fBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-11-rsa; t=1617759903; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=dxj+e2mCTN/mq8/QKyjl2SahvK7RHudQGhkISRnBVig=; b=JZCFDV30/yXf6H5J+f3SdyNh3hYLqYl3vEW/Ni6crQkjRh6o64d2cKCZQ12mIdV86AgjG 0xb5dvncR9Q3KIcUxaTww6pmfH1dLtaCq1+ywsEV/VkJRKDmMqq2UPyWsGYMvmOB2h81Mps ZWcf0+Bkuo1o4Aul81AclAy77gUiuOhdyIRW9wyIF6E+BzIZARbKoxx0xNxmxbu11pF0uPI HpgNlVPPyxwfH5rbkK60cLgd+29R2XTs+4kyo2nRLVJ4eIM7XcMOQenuTzpR9GikW/t7IEy h18AfoPFjs2trfBmdlGX++FxPVo1dYiS2yW0X60gIkpTzML88X/k546hS3/A== Received: from zeus.lespinasse.org (zeus.lespinasse.org [10.0.0.150]) by server.lespinasse.org (Postfix) with ESMTPS id 59267160650; Tue, 6 Apr 2021 18:45:03 -0700 (PDT) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 4A03A19F31F; Tue, 6 Apr 2021 18:45:03 -0700 (PDT) From: Michel Lespinasse To: Linux-MM Cc: Laurent Dufour , Peter Zijlstra , Michal Hocko , Matthew Wilcox , Rik van Riel , Paul McKenney , Andrew Morton , Suren Baghdasaryan , Joel Fernandes , Rom Lemarchand , Linux-Kernel , Michel Lespinasse Subject: [RFC PATCH 33/37] mm: enable speculative fault handling only for multithreaded user space Date: Tue, 6 Apr 2021 18:44:58 -0700 Message-Id: <20210407014502.24091-34-michel@lespinasse.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210407014502.24091-1-michel@lespinasse.org> References: <20210407014502.24091-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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 48b86911a6df..b1a07ca82d59 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1318,6 +1318,10 @@ void do_user_addr_fault(struct pt_regs *regs, } #endif + /* Only try spf for multithreaded user space faults. */ + 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) @@ -1351,6 +1355,7 @@ void do_user_addr_fault(struct pt_regs *regs, spf_abort: count_vm_event(SPF_ABORT); +no_spf: /* * Kernel-mode access to the user address space should only occur -- 2.20.1