Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1615639
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Linus Torvalds <torvalds@linux-foundation.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [RFC][PATCH] spin loop arch primitives for busy waiting |
| Date | Tue, 04 Apr 2017 02:50:02 +0200 |
| Message-ID | <tskPw-5PE-7@gated-at.bofh.it> (permalink) |
| References | <ts5nr-4l0-9@gated-at.bofh.it> <tscff-g5-7@gated-at.bofh.it> <tsk37-5hW-5@gated-at.bofh.it> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=9LbwNAgSwt8LtgVLhbWtPzerdTog1qb4+i//HfORO2k=; b=i55FdbBcx4e0TuwMP/TwqH9EdW/CYY6jkxtBMD+NLCMpqTTD/WK5/SD1RuBiUs3W1I 5S6Gb2VnifJ4DR7XqaThXPSxg4z6HrtK3TxjL5C/wtxqXAOpYG9nQAvBppfyGglc3wli ql0v1TtUJAArbh0icBgtcNSniDSL99hdXCBCAN6c9pxlyM6zevVhH0CArpRhblZk7HIl dtBiiCRSlhp1ZDD492VXJVPRhsT340noblLudk86Yj1WZYgQkne371+mpjf+Eoy+qPTl VS2IxoTRLbZVKmUYUtmnomT+6XLcUDf+0UhX0Kqi2bon/4bvhRouBHBYzaC3pAWKP8jy QZdg== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=9LbwNAgSwt8LtgVLhbWtPzerdTog1qb4+i//HfORO2k=; b=Ei4PMlMARj4ArkUQ3y+LHAe60LA96jSrF69gFVgyRXxV93UEoT2rYP4ik8BN+UKD59 3LYKkbp2ghl+tKVBl4xxKYwyqNNszWyA1i5ikynxUXMp7lyUON6fyFCCFuac/Y5KURTM QXGSHNYx6zX5VXWfGJJWL7hujm9e0OuoPM5AoSbZiSM16dsjEUbRkCgdfhQ+ABrt9FsV fNppZSeiMkHIaEZwpozCXDcH7i2YrIFo4/D5sXRLBqnJyGpHPfcT0epEhodwGd9TydXe YNndhQimcXXvgI+8RTlYND4FVSNC13MNJIxm6Q6/yEt8S8P7jfEXGjfVkuhAzzFIZyC/ OJpw== |
| X-Gm-Message-State | AFeK/H0mnU947mgrVx5sX771eef3EFuXc7trVf6k8QokBusRsxNA5tZdNlH+pSMOiURXs8xX1lb5P1r+Npgo8A== |
| X-Received | by 10.107.178.137 with SMTP id b131mr18374590iof.50.1491266586486; Mon, 03 Apr 2017 17:43:06 -0700 (PDT) |
| MIME-Version | 1.0 |
| X-Google-Sender-Auth | 9iYz2tPgonnzOSwnu811AvVViXk |
| Content-Type | text/plain; charset=UTF-8 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 49 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | "linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, Anton Blanchard <anton@samba.org>, linuxppc-dev <linuxppc-dev@ozlabs.org> |
| X-Original-Date | Mon, 3 Apr 2017 17:43:05 -0700 |
| X-Original-Message-ID | <CA+55aFzdUMZHzXtn9PyhJg7GjYNQ5fy6=LzBNJx==Ab=U=YYjw@mail.gmail.com> |
| X-Original-References | <20170403081328.30266-1-npiggin@gmail.com> <CA+55aFx92vOh28CWp5zid8RzbM=5pO0Or51zS4D8M97L=69hHA@mail.gmail.com> <20170404095001.664718b8@roar.ozlabs.ibm.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1615639 |
Show key headers only | View raw
On Mon, Apr 3, 2017 at 4:50 PM, Nicholas Piggin <npiggin@gmail.com> wrote:
>
> POWER does not have an instruction like pause. We can only set current
> thread priority, and current implementations do something like allocate
> issue cycles to threads based on relative priorities. So there should
> be at least one or two issue cycles at low priority, but ideally we
> would not be changing priority in the busy-wait loop because it can
> impact other threads in the core.
>
> I couldn't think of a good way to improve cpu_relax. Our (open source)
> firmware has a cpu_relax, and it puts a bunch of nops between low and
> normal priority instructions so we get some fetch cycles at low prio.
> That isn't ideal though.
>
> If you have any ideas, I'd be open to them.
So the idea would be that maybe we can just make those things
explicit. IOW, instead of having that magical looping construct that
does other magical hidden things as part of the loop, maybe we can
just have a
begin_cpu_relax();
while (!cond)
cpu_relax();
end_cpu_relax();
and then architectures can decide how they implement it. So for x86,
the begin/end macros would be empty. For ppc, maybe begin/end would be
the "lower and raise priority", while cpu_relax() itself is an empty
thing.
Or maybe "begin" just clears a counter, while "cpu_relax()" does some
"increase iterations, and lower priority after X iterations", and then
"end" raises the priority again.
The "do magic having a special loop" approach disturbs me. I'd much
rather have more explicit hooks that allow people to do their own loop
semantics (including having a "return" to exit early).
But that depends on architectures having some pattern that we *can*
abstract. Would some "begin/in-loop/end" pattern like the above be
sufficient? The pure "in-loop" case we have now (ie "cpu_relax()"
clearly isn't sufficient.
I think s390 might have issues too, since they tried to have that
"cpu_relax_yield" thing (which is only used by stop_machine), and
they've tried cpu_relax_lowlatency() and other games.
Linus
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC][PATCH] spin loop arch primitives for busy waiting Nicholas Piggin <npiggin@gmail.com> - 2017-04-03 10:20 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Linus Torvalds <torvalds@linux-foundation.org> - 2017-04-03 17:40 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Nicholas Piggin <npiggin@gmail.com> - 2017-04-04 02:00 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Linus Torvalds <torvalds@linux-foundation.org> - 2017-04-04 02:50 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Nicholas Piggin <npiggin@gmail.com> - 2017-04-04 05:10 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Nicholas Piggin <npiggin@gmail.com> - 2017-04-04 06:20 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting David Miller <davem@davemloft.net> - 2017-04-05 16:10 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Nicholas Piggin <npiggin@gmail.com> - 2017-04-06 03:10 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Will Deacon <will.deacon@arm.com> - 2017-04-06 16:20 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Linus Torvalds <torvalds@linux-foundation.org> - 2017-04-06 17:20 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Peter Zijlstra <peterz@infradead.org> - 2017-04-06 18:40 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Linus Torvalds <torvalds@linux-foundation.org> - 2017-04-06 19:40 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Peter Zijlstra <peterz@infradead.org> - 2017-04-06 21:30 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Linus Torvalds <torvalds@linux-foundation.org> - 2017-04-06 21:50 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Nicholas Piggin <npiggin@gmail.com> - 2017-04-07 05:40 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Peter Zijlstra <peterz@infradead.org> - 2017-04-07 11:50 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Nicholas Piggin <npiggin@gmail.com> - 2017-04-07 13:30 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Nicholas Piggin <npiggin@gmail.com> - 2017-04-06 17:40 +0200
Re: [RFC][PATCH] spin loop arch primitives for busy waiting Will Deacon <will.deacon@arm.com> - 2017-04-07 18:20 +0200
csiph-web