Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1391468yba; Wed, 24 Apr 2019 21:50:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrGwNo3em+gZRPrvV5Pz5mtS9i0I0kg8aK6B4lV4iAg3on4DqIQ6AzpVeGs+CIARV0rxZu X-Received: by 2002:a17:902:567:: with SMTP id 94mr35905974plf.120.1556167812079; Wed, 24 Apr 2019 21:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556167812; cv=none; d=google.com; s=arc-20160816; b=V46+mBsrHFyjKWeRnfJ5NKsfFpiAqbK/JR5x17tO/4kXdtkGxM3+yXWB3iQPosgZXb PFA3vScX+30N19L3p9YTigvzYEToqMxmj7olZgwVxrFH/fHd9zxpTkHqPoQcjU1egInY LAf62H4g3rDOYuWMBiGIYH+I7LifHIFEXPK/LfJ9f5Fz2bGoa22NjGBWY+yYp62p4Q5Z Rh2kAc8/9CzJ9ljAoYQkREMbKIIa0NjiaPqK4rjhTfwc6dYzLx2Dx7Z+LrhztFGwEMAz jmsO9yNTQmfC5I1WWIAT7danYAYiE+XcqDZEF92sdoxybusQqtufkLVvZges+ofSxc4z 5SNA== 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=hAMP8lrnIAYvASMIpak2/qo17VBuOdCnb72SQGQnKPk=; b=mwdBAZBPolN0/wT7knB5PL7MkPW4ydN5gSW0DhxaRgOYu+sHvG5zoqQ5kbdODb4EXf KIBZKYLj5NNiXmMQizYU2Vtsf9gnNmtLc+bZZr4vUb+ummMX5axg/PjRHPXerD88dujj zEPbzsrcBkTXTheGfNsz6fuiYKs/dtso6QSovEHANmdJkreAFYVHR4jYshxvlzzoLb7q AdvfjlBM9LyPCUf0LNd7EoABq1USj4GreTzbIRjB9as9R+eG3VEfY8AHXZTx5IgJVT1a GP5L9l7wPCj3QKhY7f8maUF7DDeG0a/qoJzC4U8+PiWu/mW+6oEDYBPjinFF/G5u28ZL PFsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Pq10Ge2g; 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 d4si19798736pgc.304.2019.04.24.21.49.44; Wed, 24 Apr 2019 21:50:12 -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=Pq10Ge2g; 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 S2403795AbfDXR40 (ORCPT + 99 others); Wed, 24 Apr 2019 13:56:26 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45485 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390808AbfDXR4Y (ORCPT ); Wed, 24 Apr 2019 13:56:24 -0400 Received: by mail-lj1-f193.google.com with SMTP id y6so17712662ljd.12 for ; Wed, 24 Apr 2019 10:56:23 -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=hAMP8lrnIAYvASMIpak2/qo17VBuOdCnb72SQGQnKPk=; b=Pq10Ge2gP/s9W7oSsdB/c6u6LKJMWhFciYSFHNDhMzz6ALdyugqQaS1y+WHW3T18xq G9EPbo/mv7TNQWWm4Ydgu+6hjxI4QHlI3hQZZdATGuF0R7V4m9quSMNk/2K2K35OvOp8 jIXjIJ8rXClzaOmvT3sZDKaGEXa+AIVBXOeEU= 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=hAMP8lrnIAYvASMIpak2/qo17VBuOdCnb72SQGQnKPk=; b=kc9yAg6NjTakkvjyootBWxgP+VTk4DadwLzGmsQbM7KLs4DhsMJqd+aeDUPN07oeCO WKVLl/KHeF9g/z+Q4t0NUqVwratO+dzFsW4jfg5x3VCrzTjxM64YmK+t/OtxeOCSXRfG li2eUHjpGHhKrilMuuniSqqMSBLPRCYOMZ05csCZie5DJvgFe5Im8/NS0gcPiZe1VQwe tTJ/F6RGd8G+4975SEk8kTkFNk+NpT3qUFWjYUtd8yC040Mwhp6+iekI0pUAHwBXtLhO nmFoar4TmH8EInZFRsl864li+Hiil4Ur35tEaQxpTbY+370ahucx1jITgwtanKJ3Vuq/ VocA== X-Gm-Message-State: APjAAAV5DI9U0Bq+e1W3C1MgGqOCR5/ZJFN0JIrj/NGznpbeA5XP1oXJ WetpfrdF1Eb+0MwraRFT9pibp+2XhOI= X-Received: by 2002:a2e:810d:: with SMTP id d13mr18024499ljg.93.1556128581942; Wed, 24 Apr 2019 10:56:21 -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 77sm4069977ljs.58.2019.04.24.10.56.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 10:56:21 -0700 (PDT) Received: by mail-lj1-f177.google.com with SMTP id i186so3817693lji.9 for ; Wed, 24 Apr 2019 10:56:20 -0700 (PDT) X-Received: by 2002:a2e:9213:: with SMTP id k19mr3850766ljg.118.1556128580498; Wed, 24 Apr 2019 10:56:20 -0700 (PDT) MIME-Version: 1.0 References: <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> <20190424070959.GE4038@hirez.programming.kicks-ass.net> <51589ac0-3e1f-040e-02bf-b6de77cbda1d@redhat.com> <20190424170148.GR12232@hirez.programming.kicks-ass.net> In-Reply-To: <20190424170148.GR12232@hirez.programming.kicks-ass.net> From: Linus Torvalds Date: Wed, 24 Apr 2019 10:56:04 -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 , 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 Wed, Apr 24, 2019 at 10:02 AM Peter Zijlstra wrote: > > > For an uncontended rwsem, this offers no real benefit. Adding > > preempt_disable() is more complicated than I originally thought. > > I'm not sure I get your objection? I'm not sure it's an objection, but I do think that it's sad if we have to do the preempt_enable/disable around the fastpath. Is the *only* reason for the preempt-disable to avoid the (very unlikely) case of unbounded preemption in between the "increment reader counts" and "decrement it again because we noticed it turned negative"? If that's the only reason, then I think we should just accept the race. You still have a "slop" of 15 bits (so 16k processes) hitting the same mutex, and they'd all have to be preempted in that same "small handful instructions" window. Even if the likelihood of *one* process hitting that race is 90% (and no, it really isn't), then the likelihood of having 16k processes hitting that race is 0.9**16384. We call numbers like that "we'll hit it some time long after the heat death of the universe" numbers. Linus