Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4019158yba; Tue, 23 Apr 2019 13:37:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwj5xdQaPf/2VICd3BTvah8Dyc91C7v2GCBqRuiZFmvTcG1CPh5vh1QpY7dxKFqYwj7hKWy X-Received: by 2002:a65:62c9:: with SMTP id m9mr26656360pgv.309.1556051877248; Tue, 23 Apr 2019 13:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556051877; cv=none; d=google.com; s=arc-20160816; b=IBDf5crodrHRiKVaYs6xmGpa6L4nzYfLJEg4TLcv+mJBRsMqbeNtwtHsxID0o7cZkr FnTgWYwFsOJMNsQd8MwT4wi+eifJPGkEb/XGygl6SJpkHxVWHjuyQl7XMkzEG4IX35IT +At55C6NOIYpsKWE+lv6djB8a2FZ6Pc8emcUaEysH6e6AtajA4i7Sb4To43MCoDCpwUs DdRhS8iN1plMyssoNXcnd777um/MyJ3Eh+zPGIZZ7aDIgYH5sklJ8n2ruwwerGzotUgk SQUBdymm+JBFl24t8/xcD8Hfc1WiLPEgPoAwEwWUqjsrgadQ0bAsLhV79sq85xv3ekch giwg== 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:dkim-signature; bh=LHt7hvhwuSkoDxOqTTuECvGOGRn/jYTU2FUWz9oeQsU=; b=H5PEofCECbwgrPgPWqe6Ia2eMjNeRWeeftSMCLpR7h7GxdLpINcF/Zy9bRD+4EJyqW 4qah57/zvRe+9AwA/3acGpv6cgcdGVJ1vxGUREI9K+1Gwj+dxZrThi8gB4aojm5mLFpS oaG8Ui3VAucMftgXMuFzguzwHA3j+aXrb+jab4tgZIaURN1mmleapjLWQHLl7iDBg3+/ QdTRB12FWPX57rMpLUJJgaf2UQBHSITlj+C/T/MLrFdoxD9J0Ow/ajXtHx2l4R2xZXPX wOvUG3lyisdlJxmcChbiiEoSpkc4nL5DWBjvsikPBxthk6/87bf2IvdKkhnmXfTteuBz 8LYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=gXKWAojJ; 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 31si16042116ple.102.2019.04.23.13.37.39; Tue, 23 Apr 2019 13:37:57 -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=bombadil.20170209 header.b=gXKWAojJ; 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 S1727294AbfDWUfc (ORCPT + 99 others); Tue, 23 Apr 2019 16:35:32 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37652 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726029AbfDWUfc (ORCPT ); Tue, 23 Apr 2019 16:35:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding: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=LHt7hvhwuSkoDxOqTTuECvGOGRn/jYTU2FUWz9oeQsU=; b=gXKWAojJ+Fbgyjk0c66HnLujq WwgtAA/LV6XUVDp9t7inLhDx9gCqqhfFl9AkftXXDPZoHsWc6whMutPm1FOwf1ecgLcVGqX4QVOFR F95DGKfH5CGbr1lkY0aOUFIEC7LIEaPWegDOx/KzLY1iHYYHvqLWJdvTx1Oemc7kiOvTuRx+cgfxX 1ZDWjb8Mv/iJzq2u4gQ6V0bWikHsYLeSX50x8C/OE5RYSXFG6rZf5QK6sC6kSnEJl2QKNEjv6dcst lYVaXI/sn+4w8NNGkdaKjUfWhkV+6XTLWpJsW6K1MbgtSs/J6vDmyPeEYH9zDBwHPlf5flY7z1o9H fvzB0EQ5A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJ28I-00085i-1L; Tue, 23 Apr 2019 20:35:14 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6D47729C2574D; Tue, 23 Apr 2019 22:35:12 +0200 (CEST) Date: Tue, 23 Apr 2019 22:35:12 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Waiman Long , Ingo Molnar , Will Deacon , Thomas Gleixner , Linux List Kernel Mailing , the arch/x86 maintainers , Davidlohr Bueso , Tim Chen , huang ying , Roman Gushchin , Alexei Starovoitov , Daniel Borkmann Subject: Re: [PATCH] bpf: Fix preempt_enable_no_resched() abuse Message-ID: <20190423203512.GB4038@hirez.programming.kicks-ass.net> References: <20190419131522.GW14281@hirez.programming.kicks-ass.net> <57620139-92a3-4a21-56bd-5d6fff23214f@redhat.com> <7b1bfc26-6e90-bd65-ab46-08413acd80e9@redhat.com> <20190423141714.GO11158@hirez.programming.kicks-ass.net> <4f62d7f2-e5f6-500e-3e70-b1d1978f7140@redhat.com> <20190423193435.GX4038@hirez.programming.kicks-ass.net> <88ba7be0-9ec5-941e-1b3f-80fbe05fe3a0@redhat.com> <20190423195559.GY4038@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Tue, Apr 23, 2019 at 01:27:29PM -0700, Linus Torvalds wrote: > On Tue, Apr 23, 2019 at 12:56 PM Peter Zijlstra wrote: > > > > Unless the very next line is schedule(), or implies it, one must not use > > preempt_enable_no_resched(). It can cause a preemption to go missing and > > thereby cause arbitrary delays, breaking the PREEMPT=y invariant. > > That language may be a bit strong, or m,aybe the "implies it" might at > least be extended on. > > It doesn't need to be "schedule()" per se, it can be any of the things > that check if we _need_ to be scheduled. I'll try and word-smith that tomorrow, brain is fried. But yes, something that ends up in schedule() 'soon'. The usage in ist_exit() is particularly 'fun'. That really should've had a comment. That relies on the return-from-interrupt path. > IOW, various variations of "if (need_resched())" exiting a loop, and > then outside the loop there's a cond_resched() or similar. That one 'funnily' doesn't actually work; cond_resched() is a no-op on PREEMPT=y.