From: linux@horizon.com (George Spelvin)
To: linux-arm-kernel@lists.infradead.org
Subject: enabling libgcc for 64-bit divisions, was Re: PROBLEM: XFS on ARM corruption 'Structure needs cl
Date: 13 Aug 2015 14:18:41 -0400 [thread overview]
Message-ID: <20150813181841.10342.qmail@ns.horizon.com> (raw)
In-Reply-To: <CA+55aFwgaq3KkeXGQWxmVHsNVwJUWK3WssJ5_ADpQG4zTXjWPQ@mail.gmail.com>
> I'm not convinced that "64/32->32" is all that generic, though. If
> the dividend in 64-bit, there's no fundamental type-based guarantee
> that things will fit.
I agree that it's impossible to decide based on the types, but having
that knowledge is extremely common. Which is why it would be nice
to have a way for the programmer to communicate that knowledge.
> So your case is rather special, and depends (intimately) on knowing
> the actual ranges and how they interact.
Actually, it's the most common case. Going through "git grep -w do_div",
by far the *majority* of all calls to do_div immediately convert the
result to 32 bits (or unsigned long), with no overflow checking.
Partially that's because I'm cointing static code frequency and there
are a ridiculous number of different PLL drivers, but still.
On x86, the case that msword >= divsor causes a divide exception
(divide ba generalization of divide by zero), so it's tempting
to do the same sort of "assume no trap and fix up in the handler"
trick as <asm/uaccess.h>.
There are only 854 references to do_div in the kernel, so
doing a sweep over all of them is quite practical.
One function that would cover a significant number of use cases
(but not all, damn it) would be
rem = do_mul_div(x, mul,_div)
Which returns x * mul / div, with a 64-bit intermediate.
next prev parent reply other threads:[~2015-08-13 18:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20150813061109.29409.qmail@ns.horizon.com>
2015-08-13 16:28 ` enabling libgcc for 64-bit divisions, was Re: PROBLEM: XFS on ARM corruption 'Structure needs cl Linus Torvalds
2015-08-13 18:18 ` George Spelvin [this message]
2015-08-13 18:26 ` Linus Torvalds
2015-08-13 19:09 ` George Spelvin
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=20150813181841.10342.qmail@ns.horizon.com \
--to=linux@horizon.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).