Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3945789yba; Tue, 23 Apr 2019 12:13:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZA6li7ugiK7FHIUo3d8mILv9J/6ri2xVoTkVhzbjs+iZhkv1clGjC7igoSoqM9ixrgxl3 X-Received: by 2002:a65:5682:: with SMTP id v2mr4439918pgs.100.1556046811955; Tue, 23 Apr 2019 12:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556046811; cv=none; d=google.com; s=arc-20160816; b=LKHiD64+C2DFHKmmxKsFxFd7Ep/VKBsMDNZ4/3jS8YvJMhg83Qa3w8xECUDtc25jBP NzPrz+7vZZ45x3c/nCzxTfr9Y0tGbJ1mYr8Nr20ixC4oP4OpuRUTC3esfWX7EbTrJLA6 +65xG7QwLXuQTaEwWeTiAy5KCkv3Y2JxXd1AjR+jCkedewa7ZRaTvs1Ia02FbeVJywEE 8jjmeOFhQDIOcfeNpfCcDUt+mEh1KJ7+KvMfylxlfmYQ8T2r9OMXq9Bdm6Sz14Iq9Il/ mf5aIQ1Jhs5Q7GGlooTFmmW2QITaVE82ChFeJWvdddZJFW4hGHnwx4QUXUPbToTvi3fj BQ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=oCgh1T75qStFduFJvNRVabnGOov+uokuC14J3St/8kc=; b=01F+OSHHQi6tS2044+nYvftGoFnSEfQuXU9+0JTutaVPP6VqmPYYLmqaYT736LOwE+ tjizdRdeUv6mSrqSmW+uVmRzhA7ebrKQzdnBVJYyMJJKjBYmojvO5XO4pOqlO8sYhwuw fVS3x4Ye5TyHTXmih1qvpsToovoRjnYzYQcJXVJ96vpbH2+/yA4O9cFD94p8O6XdBbJe GrYGoLhN4YheqW6Dx+CBfy+MwbHlClVX8/8ZTv8jJOVyu48Cynj/dGN1w+W0HxYlfjAo TcE0psGH6bCTn95lPxq1FKepUWgs0nyXY/3n0njpnQLm8z5fTm7WkAftqO8jbde1l4Vl 55uQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 124si15683841pgi.38.2019.04.23.12.13.14; Tue, 23 Apr 2019 12:13:31 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726142AbfDWTMY (ORCPT + 99 others); Tue, 23 Apr 2019 15:12:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60590 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbfDWTMY (ORCPT ); Tue, 23 Apr 2019 15:12:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE13EC02E60C; Tue, 23 Apr 2019 19:12:23 +0000 (UTC) Received: from llong.remote.csb (ovpn-123-167.rdu2.redhat.com [10.10.123.167]) by smtp.corp.redhat.com (Postfix) with ESMTP id 836355D705; Tue, 23 Apr 2019 19:12:22 +0000 (UTC) Subject: Re: [PATCH v4 14/16] locking/rwsem: Guard against making count negative To: Linus Torvalds , Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Thomas Gleixner , Linux List Kernel Mailing , the arch/x86 maintainers , Davidlohr Bueso , Tim Chen , huang ying References: <20190418135151.GB12232@hirez.programming.kicks-ass.net> <20190418144036.GE12232@hirez.programming.kicks-ass.net> <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> From: Waiman Long Organization: Red Hat Message-ID: <4f62d7f2-e5f6-500e-3e70-b1d1978f7140@redhat.com> Date: Tue, 23 Apr 2019 15:12:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 23 Apr 2019 19:12:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > So if we play preemption games, I wonder if we should make them more > explicit than hiding them in that helper function, because > particularly for the slow path case, I think we'd be much better off > just avoiding the busy-loop in the slow path, rather than first > scheduling due to preempt_enable(), and then starting to look at the > slow path onlly afterwards. > > IOW, I get the feeling that the preemption-off area might be better > off being potentially much bigger, and covering the whole (or a large > portion) of the semaphore operation, rather than just the > rwsem_read_trylock() fastpath. > > Hmm? That is true in general, but doing preempt_disable/enable across function boundary is ugly and prone to further problems down the road. Cheers, Longman > Linus