Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp448155imp; Thu, 21 Feb 2019 04:48:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IYDgE7etnFiVxWY3uNdTASLEVOXO9iQJTmxTLMLemer1v1SB/fOkK7nvOvNPhr3rx/OQvcY X-Received: by 2002:a63:1766:: with SMTP id 38mr34455035pgx.204.1550753332520; Thu, 21 Feb 2019 04:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550753332; cv=none; d=google.com; s=arc-20160816; b=HcDzYk/zXtGG5mVZCSb7SC+Vm8nFLZCSttMSSl8Grh16FROsbH/jQ6xhJ6peKe0ixE 0oOC8IdZn0P12lpPdhZIJuVD7TMEUZFXMZ+0GrUsUUQ7hAbKFGAJO/Uu4eC6q8iI6F6V 1+08310/AfVwHGeLDcVvM44frsNt/AlwlJpinHR6j4HiHhamJLrjAKPIFlo0bdxcJ6Tk AgGp/NIHkA+vfLuMv4JIEFhX9sfVtcONba4kWE0lxI6sPwU8eJopOIoIi3ANB/98ilMC H3TCPrz0kfwcWoNRPlWpM3BJ8RFqDqtES8JeYgdwcMg80JYeVL9Tu6kD6Mb5yyx804Jo AB1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/nQiP1JVfUyLt2Yz3QB+ljiA5yx4IFuK7Jk0n0z+adA=; b=Mv3yMCnpPWHzUoCleGU7VVZtpzcWDHLgo6JqspxRqMXz+H6pUrYY6xTlY+jBFpFFRz WR0tG8sv25eQhVfOFUwgjUS8wOlAtOfCXd5DzTCdhFzwtOqExC4WzGm5yuBF3wAs1oAD OsU2p7p5YP8raG1NzrUxd2h2nQUp1iMMJBdlRhTgGAl3TTK1Pi9Hgz9f8k+mm1K1cUmU 32YZ9A094H0y6nzRICRWzoeo6ZNpiPXm/3tvqmLXPtMvpTE7Nnwsb3QQ/BX9Lr+lSYTc +PxiOfyn43hSkv/zMNR3WOQavwFl2MAOd7rkjuCu0jK6RN2sMyfOQt7OJ7XMPXf9bhgo S5kA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si20588774pgc.174.2019.02.21.04.48.35; Thu, 21 Feb 2019 04:48:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbfBUMqi (ORCPT + 99 others); Thu, 21 Feb 2019 07:46:38 -0500 Received: from foss.arm.com ([217.140.101.70]:43832 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbfBUMqi (ORCPT ); Thu, 21 Feb 2019 07:46:38 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AF44680D; Thu, 21 Feb 2019 04:46:37 -0800 (PST) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7A3E83F575; Thu, 21 Feb 2019 04:46:34 -0800 (PST) Date: Thu, 21 Feb 2019 12:46:29 +0000 From: Will Deacon To: "H. Peter Anvin" Cc: Peter Zijlstra , Andy Lutomirski , Julien Thierry , Ingo Molnar , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mingo@redhat.com, catalin.marinas@arm.com, james.morse@arm.com, valentin.schneider@arm.com, brgerst@gmail.com, jpoimboe@redhat.com, luto@kernel.org, bp@alien8.de, dvlasenk@redhat.com, torvalds@linux-foundation.org, tglx@linutronix.de Subject: Re: [PATCH] sched/x86: Save [ER]FLAGS on context switch Message-ID: <20190221124629.GA12696@fuggles.cambridge.arm.com> References: <20190213222146.GC32494@hirez.programming.kicks-ass.net> <20190214101429.GD32494@hirez.programming.kicks-ass.net> <20ABBED1-E505-45F6-8520-FB93786DF9A9@zytor.com> <20190216103044.GR32494@hirez.programming.kicks-ass.net> <9e037d68-75e7-1beb-0c9c-33a7ffeced1b@zytor.com> <20190219090409.GW32494@hirez.programming.kicks-ass.net> <20190219124808.GG8501@fuggles.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 20, 2019 at 02:55:59PM -0800, H. Peter Anvin wrote: > On 2/19/19 4:48 AM, Will Deacon wrote: > > > > I think you'll still hate this, but could we not disable preemption during > > the uaccess-enabled region, re-enabling it on the fault path after we've > > toggled uaccess off and disable it again when we return back to the > > uaccess-enabled region? Doesn't help with tracing, but it should at least > > handle the common case. > > > > There is a worse problem with this, I still realize: this would mean blocking > preemption across what could possibly be a *very* large copy_from_user(), for > example. I don't think it's legitimate to call copy_{to,from}_user() inside a user_access_{begin,end} region. You'd need to add some unsafe variants, which could periodically disable uaccess and call cond_resched() inside the loop to avoid the problem you're eluding to. For existing callers of copy_{to,from}_user(), there's no issue as they don't call into the scheduler during the copy operation. Exceptions are handled fine by the code in mainline today. GCC plugins are a cool idea, but I'm just a bit nervous about relying on them for things like this. Will