Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3965923yba; Tue, 23 Apr 2019 12:36:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNKZh9jS6UeWFHFQXhWDsgGbGFRRMam1ruZwnqbQtvPjbneh9MTnqo5i4tBzrdFCEpzuim X-Received: by 2002:aa7:938b:: with SMTP id t11mr28758837pfe.67.1556048187031; Tue, 23 Apr 2019 12:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556048187; cv=none; d=google.com; s=arc-20160816; b=zSvgheANoj+yN0/l8ZocA8d8tyFX16p24xmIZjxNwrWk+3nCokhD2qvBWzvl31fCxd k7ex+EE+KacjsPmgNDVZ86CeiZwsI7uqWuz/ORs0oorkRBsFOGCkjjF6nHWJOolwt9Gr APguz4lSwnNMI5cSVdBnAfZY9OiBzJm3Z8/KrWN7w2tx4euKDE7nGWpmWZ8Czc38t0tU lJTuo6zDYPhL+dqFDt/x74xLRqz284/C5bBA1F8drg6t6dwX1t7QLpRHovqQO21q5Fby d9hxuUfcXQoQ4mtUljDQJAt/TdZ+jbqtZkwJNJT82qXNiB0M8QxHFdTPk7qdYrrdHyUG WNfA== 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=sU0OH+OkE04CbdTPlNqdVi5ayyffGhhufijK4RmPgH4=; b=AvEscgTFCSkrRiu1kjpiG0WLcEP1gaI+jE1vCyX1+xLABm1SNhkSlbOLLHLy4G/zzC pt2uKDdKUOXgenzk3/VjukY7Q4+dG6BL8GZ1Op4pyL5R3+UsI2tScMvU0wrrIevB7gD/ V090BCcyfFWVIaSJioZ7O8arP3hSiP/2ogmaV2BdGViGG1FXTIlnloq8xw7cDIax7kZb HC40xpocF1JxYrwgR6dN4PcaL7yJV8M+/2xcYDojdB2I1UbsdyJr6HFu7LNfuIrImkgO Q/Kx8dz2r3Ga9/UcR/ksB7AFBHHxS6FffSD0bJeoWA/9y+euBgDLFQOf9rADyYrg52EU e/Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=fL9Xx94R; 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 195si15576698pgc.279.2019.04.23.12.36.11; Tue, 23 Apr 2019 12:36:27 -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=fL9Xx94R; 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 S1726550AbfDWTet (ORCPT + 99 others); Tue, 23 Apr 2019 15:34:49 -0400 Received: from merlin.infradead.org ([205.233.59.134]:53994 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbfDWTet (ORCPT ); Tue, 23 Apr 2019 15:34:49 -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-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=sU0OH+OkE04CbdTPlNqdVi5ayyffGhhufijK4RmPgH4=; b=fL9Xx94RnBlU1urhwz8ErZ98q oMyGhyio9tneubY3y71Xz7qiZITIx17HlwFChQES6UleQWvY+tlh8/AiGqRLA9p094KaUD0g4ZBRy 8P6Pv6Y4qzRcSQsZpfda5nn1LoNn34RMyMYaEgaqufxqZLPfazz5y1Ihk5g8FoKVrLgmmd6+MF1d0 fS9a/7fbai0Xj6wXNMbFPCGyAS6+BCgmEoh9HzZuXFAR9LQlb+D07tnilNbf9F+2Pd33HpAHw0JXz B0kP8kTPbgFgvEHmuxRz3ZJGqbaiULZ6A5YLNks0ks8DFes952z0YK3YG6yOlSzZuligXf2BKvdfz 8yEA+vW0g==; 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 1hJ1Be-0000gU-6i; Tue, 23 Apr 2019 19:34:38 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6D86129C30E09; Tue, 23 Apr 2019 21:34:35 +0200 (CEST) Date: Tue, 23 Apr 2019 21:34:35 +0200 From: Peter Zijlstra To: Waiman Long Cc: Linus Torvalds , Ingo Molnar , Will Deacon , Thomas Gleixner , Linux List Kernel Mailing , the arch/x86 maintainers , Davidlohr Bueso , Tim Chen , huang ying Subject: Re: [PATCH v4 14/16] locking/rwsem: Guard against making count negative Message-ID: <20190423193435.GX4038@hirez.programming.kicks-ass.net> References: <4cbd3c18-c9c0-56eb-4e01-ee355a69057a@redhat.com> <20190419102647.GP7905@worktop.programming.kicks-ass.net> <20190419120207.GO4038@hirez.programming.kicks-ass.net> <20190419130304.GV14281@hirez.programming.kicks-ass.net> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4f62d7f2-e5f6-500e-3e70-b1d1978f7140@redhat.com> 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 03:12:16PM -0400, Waiman Long wrote: > On 4/23/19 12:27 PM, Linus Torvalds wrote: > > On Tue, Apr 23, 2019 at 7:17 AM Peter Zijlstra wrote: > >> I'm not aware of an architecture where disabling interrupts is faster > >> than disabling preemption. > > I don't thin kit ever is, but I'd worry a bit about the > > preempt_enable() just because it also checks if need_resched() is true > > when re-enabling preemption. > > > > So doing preempt_enable() as part of rwsem_read_trylock() might cause > > us to schedule in *exactly* the wrong place, > > You are right on that. However, there is a variant called > preempt_enable_no_resched() that doesn't have this side effect. So I am > going to use that one instead. Only if the very next line is schedule(). Otherwise you're very much not going to use that function.