Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1284311
| From | Waiman Long <waiman.long@hpe.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() |
| Date | 2015-12-04 23:50 +0100 |
| Message-ID | <qC7kR-l8-7@gated-at.bofh.it> (permalink) |
| References | (1 earlier) <qBBuI-53y-59@gated-at.bofh.it> <qBF5h-7z8-25@gated-at.bofh.it> <qBIFQ-1rh-21@gated-at.bofh.it> <qC5Cq-7E0-17@gated-at.bofh.it> <qC6I9-7o-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 12/04/2015 05:05 PM, Linus Torvalds wrote:
> On Fri, Dec 4, 2015 at 12:51 PM, Waiman Long<waiman.long@hpe.com> wrote:
>> Will the following work?
> Are we trying to win some obfuscated C contest here?
>
> Just make it do something like (skipping backslashes to make it easier
> to type and read)
>
> #define smp_cond_load_acquire(ptr, cond_expr) ({
> typeof(*ptr) VAL;
> for (;;) {
> VAL = READ_ONCE(*ptr);
> if (cond_expr) break;
> cpu_relax();
> }
> smp_rmb();
> VAL;
> })
>
> and then you'd have it be
>
> val = smp_cond_load_acquire(&lock->val.counter,
> !(VAL& _Q_LOCKED_PENDING_MASK));
>
> which is at least halfway legible. Not some odd "fragments of
> expressions" interfaces unless absolutely required, please.
It is just some random thought that I have. I am not saying that it is
the right way to go.
> Of course, I suspect we should not use READ_ONCE(), but some
> architecture-overridable version that just defaults to READ_ONCE().
> Same goes for that "smp_rmb()". Because maybe some architectures will
> just prefer an explicit acquire, and I suspect we do *not* want
> architectures having to recreate and override that crazy loop.
>
> How much does this all actually end up mattering, btw?
>
> Linus
I think what Will want to do is to provide an architecture specific
replacement for the whole macro, not just part of it. So using READ_ONCE
should be fine.
Cheers,
Longman
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4] scheduler ordering bits -v2 Peter Zijlstra <peterz@infradead.org> - 2015-12-03 13:50 +0100
[PATCH 3/4] locking: Introduce smp_cond_acquire() Peter Zijlstra <peterz@infradead.org> - 2015-12-03 13:50 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Will Deacon <will.deacon@arm.com> - 2015-12-03 17:40 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Peter Zijlstra <peterz@infradead.org> - 2015-12-03 21:30 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Peter Zijlstra <peterz@infradead.org> - 2015-12-03 22:20 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Will Deacon <will.deacon@arm.com> - 2015-12-04 16:00 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Waiman Long <waiman.long@hpe.com> - 2015-12-04 22:00 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Linus Torvalds <torvalds@linux-foundation.org> - 2015-12-04 23:10 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Waiman Long <waiman.long@hpe.com> - 2015-12-04 23:50 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Peter Zijlstra <peterz@infradead.org> - 2015-12-05 00:50 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Will Deacon <will.deacon@arm.com> - 2015-12-07 16:20 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Davidlohr Bueso <dave@stgolabs.net> - 2015-12-03 20:50 +0100
Re: [PATCH 3/4] locking: Introduce smp_cond_acquire() Peter Zijlstra <peterz@infradead.org> - 2015-12-03 21:40 +0100
csiph-web