[lkml]   [2019]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v4 14/16] locking/rwsem: Guard against making count negative
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

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.


 \ /
  Last update: 2019-04-24 19:56    [W:0.084 / U:4.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site