From: Peter Zijlstra <peterz@infradead.org>
To: Eric Dumazet <edumazet@google.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] x86/tsc: use real seqcount_latch in cyc2ns_read_begin()
Date: Thu, 11 Oct 2018 09:31:33 +0200 [thread overview]
Message-ID: <20181011073133.GZ5663@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20181011003336.168941-1-edumazet@google.com>
On Wed, Oct 10, 2018 at 05:33:36PM -0700, Eric Dumazet wrote:
> While looking at native_sched_clock() disassembly I had
> the surprise to see the compiler (gcc 7.3 here) had
> optimized out the loop, meaning the code is broken.
>
> Using the documented and approved API not only fixes the bug,
> it also makes the code more readable.
>
> Replacing five this_cpu_read() by one this_cpu_ptr() makes
> the generated code smaller.
Does not for me, that is, the resulting asm is actually larger
You're quite right the loop went missing; no idea wth that compiler is
smoking (gcc-8.2 for me). In order to eliminate that loop it needs to
think that two consecutive loads of this_cpu_read(cyc2ns.seq.sequence)
will return the same value. But this_cpu_read() is an asm() statement,
it _should_ not assume such.
We assume that this_cpu_read() implies READ_ONCE() in a number of
locations, this really should not happen.
The reason it was written using this_cpu_read() is so that it can use
%gs: prefixed instructions and avoid ever loading that percpu offset and
doing manual address computation.
Let me prod at this with a sharp stick.
next prev parent reply other threads:[~2018-10-11 7:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-11 0:33 Eric Dumazet
2018-10-11 7:31 ` Peter Zijlstra [this message]
2018-10-11 8:40 ` Peter Zijlstra
[not found] ` <CANn89iJdztFEMzeCoXu9J4X6roKKx+fuPkwzi9N9G7aiO=_=FQ@mail.gmail.com>
2018-10-11 15:24 ` Peter Zijlstra
2018-10-11 15:17 ` Eric Dumazet
2018-10-11 23:25 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181011073133.GZ5663@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®