From: Peter Zijlstra <peterz@infradead.org>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Yuyang Du <yuyang.du@intel.com>,
Chris Wilson <chris@chris-wilson.co.uk>,
Linus Torvalds <torvalds@linux-foundation.org>,
Mike Galbraith <efault@gmx.de>,
Thomas Gleixner <tglx@linutronix.de>,
bsegall@google.com, morten.rasmussen@arm.com, pjt@google.com,
steve.muckle@linaro.org, linux-kernel@vger.kernel.org,
kernel@kyup.com
Subject: Re: Divide-by-zero in post_init_entity_util_avg
Date: Fri, 17 Jun 2016 10:23:37 +0200 [thread overview]
Message-ID: <20160617082337.GM30154@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <5763B1D8.1010707@virtuozzo.com>
On Fri, Jun 17, 2016 at 11:16:24AM +0300, Andrey Ryabinin wrote:
> > I suppose instead we'd want something like:
> >
> > tmp = READ_ONCE(*ptr);
> > if (tmp > val)
> > tmp -= val;
> > else
> > tmp = 0;
> > WRITE_ONCE(*ptr, tmp);
> >
> > In order to generate:
> >
> > xchg %rax,0xa0(%r13)
> > mov 0x78(%r13),%rcx
> > sub %rax,%rcx
> > cmovae %r15,%rcx
> > mov %rcx,0x78(%r13)
> >
> > however, GCC isn't smart enough and generates:
> >
> > xchg %rax,0x98(%r13)
> > mov 0x70(%r13),%rsi
> > mov %rsi,%rcx
> > sub %rax,%rcx
> > cmp %rsi,%rax
> > cmovae %r15,%rcx
> > mov %rcx,0x70(%r13)
> >
> > Doing a CMP with the _same_ values it does the SUB with, resulting in
> > exactly the same CC values.
> >
>
> FYI - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3507 (Reported: 2001-07-01)
>
I found this one when I was googling yesterday:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30315
But yes, it seems this is a 'known' issue.
next prev parent reply other threads:[~2016-06-17 8:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-09 9:01 Divide-by-zero in post_init_entity_util_avg Chris Wilson
2016-06-09 1:33 ` Yuyang Du
2016-06-09 13:07 ` Peter Zijlstra
2016-06-12 22:25 ` Yuyang Du
2016-06-14 11:25 ` [tip:sched/core] sched/fair: Fix post_init_entity_util_avg() serialization tip-bot for Peter Zijlstra
2016-06-16 8:50 ` Divide-by-zero in post_init_entity_util_avg Peter Zijlstra
2016-06-16 12:25 ` Peter Zijlstra
2016-06-16 16:16 ` Peter Zijlstra
2016-06-17 8:16 ` Andrey Ryabinin
2016-06-17 8:23 ` Peter Zijlstra [this message]
2016-06-17 9:19 ` [PATCH] sched/fair: Fix cfs_rq avg tracking underflow Peter Zijlstra
2016-06-17 2:01 ` Yuyang Du
2016-06-20 13:24 ` [tip:sched/urgent] " tip-bot for Peter Zijlstra
2016-06-09 10:29 ` Divide-by-zero in post_init_entity_util_avg Peter Zijlstra
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=20160617082337.GM30154@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=aryabinin@virtuozzo.com \
--cc=bsegall@google.com \
--cc=chris@chris-wilson.co.uk \
--cc=efault@gmx.de \
--cc=kernel@kyup.com \
--cc=linux-kernel@vger.kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=pjt@google.com \
--cc=steve.muckle@linaro.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=yuyang.du@intel.com \
/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