Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1612883imm; Thu, 18 Oct 2018 00:55:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV63amG4Ax1b2Cv0XUjWbJMmaUAGuB8993VypGKcOfXzM4l6nxVUBRaC9p5NAbDCJB9xFV7M9 X-Received: by 2002:a65:41c6:: with SMTP id b6-v6mr28024887pgq.421.1539849314361; Thu, 18 Oct 2018 00:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539849314; cv=none; d=google.com; s=arc-20160816; b=R5nvEq9DG9+5Hp9QamZcyTq+BWdaDBtFvXOAIFnrglV+ab7h8qS+sDYupJnZuzTCYB QiXE1d7tZyD3YGvA7dc6gBq7xKinL3W5CewOR00yNoRzEZPYM2DYc3wggffJ8BcB0Vs1 Rp/RSKl3X/yfX/jdcCB11xZXjISX0u2IYOz3RNM1hEAQgO72hEtPb5rmvDcJRhzFSxni TZNTNuS25HDP48T4tl4apRtacdM7Sx/ANYhxwI9NgTCPJIEB2TKh6t1ZX4Ftss4Is9hI TCCsdD7/su00RdyTmlwCmpUh7M+GlhhQnYzlW2h5s+uW790UYYNGO998atXskavtXNAV frKA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=31iYr2gt3LupenHLKywHfE0u3cQ+7guioVNuXuMXjxk=; b=pidZ0vfRJWLmCI7hgDXdQBmxww7tDIph0OJZU4Dkd3QM5CeKCxRMtEJ1Khm7d+uDkw SawwY43SCwZU00qSz5nSWeJCDysZM+ypvRk37gt2E4jiq7C6riQLq0houWU7KO0ioA3J UMD92GkMSOLWdEM5/OFK4n6jAo1px5ydo3SOqP+3k35abEoB/VtUrz9nHXUeRWbIfUdA lxdTG9+YL09tpzumfp8h+q2lZBDRKr05v68+EZgZWznZBK9c2vXT6NoYBO1rvUMuKaYf fC8ndptKIoT+8IpH+0tHWCvkqqb4Qj0SVnPP/g6JpPWEcCRq/6lrWSN5CsLDpckVFVBG i5ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=0aPYDYxd; 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 l185-v6si19902032pgl.270.2018.10.18.00.54.57; Thu, 18 Oct 2018 00:55:14 -0700 (PDT) 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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=0aPYDYxd; 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 S1727500AbeJRPyK (ORCPT + 99 others); Thu, 18 Oct 2018 11:54:10 -0400 Received: from merlin.infradead.org ([205.233.59.134]:39218 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727363AbeJRPyK (ORCPT ); Thu, 18 Oct 2018 11:54:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=31iYr2gt3LupenHLKywHfE0u3cQ+7guioVNuXuMXjxk=; b=0aPYDYxdc20PdPK5nMKjeslQtg zh3odWDoZG5075IPp4G2WZG2cs7StGKteLKeKHbdilNDzFsfc2hEDB/8CWkf/Njh6th7Ti2SnVQKh KCszkgGV+LvfaEbqprXLXES/XvcW+EtRIDS3Grdc7Ih7YY9ZcDtkiFnrBy73qmY6ggzwWzC99MXuc u/EIGu+WOKvyqkHwOcJKVZWVPKcBt2m6h0mQg+GaexAKoqQSufQq7LNDZrTv1jK8+nCkEDabI5yGG tlZ++b7cIALPIBXx1AVWWiJu17rBu2/6HhgLqClmC1Wi7p/5wN2Zw7Qo6hmaev6AgIYstI53eG9/8 jRvCYZBQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD38D-0002Fs-07; Thu, 18 Oct 2018 07:54:09 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 81FFC2029856A; Thu, 18 Oct 2018 09:54:05 +0200 (CEST) Date: Thu, 18 Oct 2018 09:54:05 +0200 From: Peter Zijlstra To: Andy Lutomirski Cc: Nadav Amit , Ingo Molnar , Andy Lutomirski , "H . Peter Anvin" , Thomas Gleixner , linux-kernel@vger.kernel.org, Nadav Amit , x86@kernel.org, Borislav Petkov , David Woodhouse Subject: Re: [RFC PATCH 1/5] x86: introduce preemption disable prefix Message-ID: <20181018075405.GS3121@hirez.programming.kicks-ass.net> References: <20181018005420.82993-1-namit@vmware.com> <20181018005420.82993-2-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 17, 2018 at 06:22:48PM -0700, Andy Lutomirski wrote: > > > On Oct 17, 2018, at 5:54 PM, Nadav Amit wrote: > > > > It is sometimes beneficial to prevent preemption for very few > > instructions, or prevent preemption for some instructions that precede > > a branch (this latter case will be introduced in the next patches). > > > > To provide such functionality on x86-64, we use an empty REX-prefix > > (opcode 0x40) as an indication that preemption is disabled for the > > following instruction. > > Nifty! > > That being said, I think you have a few bugs. > First, you can’t just ignore a rescheduling interrupt, as you > introduce unbounded latency when this happens — you’re effectively > emulating preempt_enable_no_resched(), which is not a drop-in > replacement for preempt_enable(). > To fix this, you may need to jump to a slow-path trampoline that calls > schedule() at the end or consider rewinding one instruction instead. > Or use TF, which is only a little bit terrifying... At which point we're very close to in-kernel rseq.