Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1374328

Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu critical sections

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu critical sections
Date 2016-04-08 18:00 +0200
Message-ID <rlGZc-67T-23@gated-at.bofh.it> (permalink)
References (4 earlier) <rlk2C-5YE-21@gated-at.bofh.it> <rlklY-65f-11@gated-at.bofh.it> <rlkvE-692-5@gated-at.bofh.it> <rlli2-6NG-27@gated-at.bofh.it> <rlyoW-8fi-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Apr 7, 2016 11:41 PM, "Peter Zijlstra" <peterz@infradead.org> wrote:
>
> On Thu, Apr 07, 2016 at 09:43:33AM -0700, Andy Lutomirski wrote:
> > enter the critical section:
> > 1:
> > movq %[cpu], %%r12
> > movq {address of counter for our cpu}, %%r13
> > movq {some fresh value}, (%%r13)
> > cmpq %[cpu], %%r12
> > jne 1b
>
> This is inherently racy; your forgot the detail of 'some fresh value',
> but since you want to avoid collisions you really want an increment.
>
> But load-store archs cannot do that. Or rather, they need to do:
>
>         load    Rn, $event
>         add     Rn, Rn, 1
>         store   $event, Rn
>
> But if they're preempted in the middle, two threads will collide and
> generate the _same_ increment. Comparing CPU numbers will not fix that.

Even on x86 this won't work -- we have no actual guarantee we're on
the right CPU, so we'd have to use an atomic.

I was thinking we'd allocate from a per-thread pool (say 24 bits of
thread ID and the rest being a nonce).  On load-store architectures
this wouldn't be async-signal-safe, though.  Hmm.

--Andy

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-06 18:00 +0200
  Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Peter Zijlstra <peterz@infradead.org> - 2016-04-07 14:10 +0200
    Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-07 16:40 +0200
      Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Peter Zijlstra <peterz@infradead.org> - 2016-04-07 17:30 +0200
        Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Peter Zijlstra <peterz@infradead.org> - 2016-04-07 17:50 +0200
        Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-07 17:50 +0200
          Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Peter Zijlstra <peterz@infradead.org> - 2016-04-07 18:00 +0200
            Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-07 18:50 +0200
              Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Peter Zijlstra <peterz@infradead.org> - 2016-04-07 22:20 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-08 00:10 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space  percpu critical sections Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-04-08 03:20 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-08 03:30 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space  percpu critical sections Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-04-08 04:10 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space  percpu critical sections Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-04-08 19:50 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-08 23:20 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Linus Torvalds <torvalds@linux-foundation.org> - 2016-04-08 23:30 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space  percpu critical sections Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-04-10 16:10 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Peter Zijlstra <peterz@infradead.org> - 2016-04-08 13:10 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-08 18:00 +0200
              Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Peter Zijlstra <peterz@infradead.org> - 2016-04-08 08:50 +0200
                Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space percpu  critical sections Andy Lutomirski <luto@amacapital.net> - 2016-04-08 18:00 +0200
              Re: [RFC PATCH 0/3] restartable sequences v2: fast user-space  percpu critical sections Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-04-12 00:00 +0200

csiph-web