Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3781919yba; Tue, 23 Apr 2019 09:30:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJzKkTG+ZhVsX+FYnBEBn/acy69KP/Y8fqotCkL00KT95hTcllx9iILg0PJZAyrMCxjzfJ X-Received: by 2002:a62:4351:: with SMTP id q78mr27215709pfa.86.1556037032088; Tue, 23 Apr 2019 09:30:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556037032; cv=none; d=google.com; s=arc-20160816; b=T4yCN6D94nia0I/PBnTK/B/FEnf3ICn5PaL4xawSoWYltoMf2c/8ILjaDQ7SHNpbRB ++Kf8/+2XLwUtxOc0aLuoYCAfgyX7BiFPiXc4VhL10QAq+D6WTBYePuQJyF3JKvWNcid l2BWhNVeEgfOMV/9sbKmWH6dp4K7YIMYuw9/N08wAQKf8pt2VRThWe69ZDTaVR9E/TDx wrtMmBDDoIkzoN9yqQhEHUJjF7A9p2LaitB/3aNWaKkw9OSwhp0TmD12Z+SmoiF7fya2 d0sZInxtETOmvD4ma63XKRertuXbUKbL2Rk9g081gkecmsrjHGU8rZh1Gb9JZG+iDzWQ FhgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Hq70GMyrcNpGr6YMX9JFvVr2SCmZbppu9orqm02sFio=; b=YkGVgWppeMItRUVSWXFjqhe0eXWlB9Y3lhSkuyQ/j+slW61Nr6HfDSGWwtPGluQUAB i4KY4vAgbkje6dQKe21bo0uU54+Te/HSM+bICLwrD2eN8O0BV4UrUPfBlQ66/dUGyGBu i6/QNPPYep/JF2wgk6JsiY2lwx0zCewRxgPCEZ76TXlTigDpIrKxeDCTVS0IrN5jO71Q O7C8oo2L3DaU1LQruJkt+SpUEhzMPR9/7TPeX5n1ahS6NG2778vkLMQgo7CLeNVKUQU1 cUQYApJ1nzykzLmf5vhxSYrtxy6xypBUhJGZGSM9Y1XYp4R3i3EmxbSrMJFIfK0UOVGR 32UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=KBRmA2LB; 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 f9si16072847pgu.31.2019.04.23.09.30.15; Tue, 23 Apr 2019 09:30:32 -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=pass header.i=@linux-foundation.org header.s=google header.b=KBRmA2LB; 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 S1728612AbfDWQ2D (ORCPT + 99 others); Tue, 23 Apr 2019 12:28:03 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35790 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726655AbfDWQ2B (ORCPT ); Tue, 23 Apr 2019 12:28:01 -0400 Received: by mail-lf1-f67.google.com with SMTP id j20so12258931lfh.2 for ; Tue, 23 Apr 2019 09:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Hq70GMyrcNpGr6YMX9JFvVr2SCmZbppu9orqm02sFio=; b=KBRmA2LB3iAsjQu2OQJW3Hl0mMgLHWznuPkQMIXsh2VmkHwKK6kscei+aNySlhF4ir 2IOaC70fvmdKl8NZnB1olK9EvONMsWvsQhzk8ZBhD9JrIr2dgLUCHJdyYZUYv3IB9HdG MXxZPEjm8P+dW9F+5LrOytZF15RHV2ERumCPk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hq70GMyrcNpGr6YMX9JFvVr2SCmZbppu9orqm02sFio=; b=FcEdY9UsMKjutFFBtTZQhinCLUTUTnWQ8WtAf7R0Cx/j2T26l8WVTW636kUjbnQCqh PpiqZ1P8cJ7/s5dVi3GjzSqKNHxnogudQlYE5U2LkFshK0C8U1Y3F3528EkxrGk9yduL NRID6zAszueHxOoQPrBoZ1nm7hzXHrhlKaCmamPfjxf1HdgI9UFVJK0wzRWyaVEzy64H 6JCnG4VAadCBH/SkUmmNvZSIGOKJxEa3Gy4akJPMjaC9L1ExiNYWSXuMh3rTnXg/3BGA zZ4Aelmc4tUaSM+el+J2Ut94doDEIRxfGR1qkHSl9U8Wakm54gNYnPEoUQGqvw8L8xMd X+ZA== X-Gm-Message-State: APjAAAXGqU3YQXa74mIvJN+2ZlPECmLwZ4m9SFT6QTygxz122MwUF8zU tNo9xcw/Tkps9W342wHErkaN9msbOJ4= X-Received: by 2002:a19:760f:: with SMTP id c15mr13963117lff.105.1556036878681; Tue, 23 Apr 2019 09:27:58 -0700 (PDT) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com. [209.85.208.177]) by smtp.gmail.com with ESMTPSA id c5sm4553524ljd.18.2019.04.23.09.27.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 09:27:57 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id q66so14086414ljq.7 for ; Tue, 23 Apr 2019 09:27:57 -0700 (PDT) X-Received: by 2002:a2e:960b:: with SMTP id v11mr14076652ljh.135.1556036876926; Tue, 23 Apr 2019 09:27:56 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <20190423141714.GO11158@hirez.programming.kicks-ass.net> From: Linus Torvalds Date: Tue, 23 Apr 2019 09:27:40 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 14/16] locking/rwsem: Guard against making count negative To: Peter Zijlstra Cc: Waiman Long , Waiman Long , Ingo Molnar , Will Deacon , Thomas Gleixner , Linux List Kernel Mailing , "the arch/x86 maintainers" , Davidlohr Bueso , Tim Chen , huang ying Content-Type: text/plain; charset="UTF-8" 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 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, 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? Linus