From: Jeff Garzik <jeff@garzik.org>
To: Carlos Pardo <Carlos.Pardo@siliconimage.com>
Cc: Tejun Heo <htejun@gmail.com>, linux-ide@vger.kernel.org
Subject: Re: Linux Question
Date: Mon, 10 Apr 2006 13:56:54 -0400 [thread overview]
Message-ID: <443A9C66.5090705@garzik.org> (raw)
In-Reply-To: <2E9B8131C44AF746B1E06BF9B15A434B088E3821@mail.siliconimage.com>
Carlos Pardo wrote:
> Does anyone know a way to do 64bit/32bit division in linux kernel space? I'm rewriting a lot of code to use the do_div macro in div64.h but I'm wondering if there's an easier way of doing this. Anyone fought this problem before?
(please turn on word wrap)
Here's the whole story:
A 64/32 division is normally promoted to 64/64 when generating the asm,
IIRC. With gcc, on a 32-bit platform such as x86, a 64/64 division
causes gcc to emit a function call to do the division, rather than doing
it inline. The 64/64 division operation on 32-bit is so expensive that
it is done in libgcc (a shared library), rather than directly by code
generated from the compiler.
The kernel never links with libgcc (or any other lib, such as libc),
never uses floating point/SSE registers[1], and thus can never contain
code that causes gcc to call libgcc functions.
Often 64/64 can be reduced manually to 64/32, but that requires the use
of do_div() to prevent gcc from generating a call to function that does
not exist in the kernel.
So yes, you'll have to use do_div(), if you cannot accomplish the
division via power-of-2 shifting or similar techniques.
Jeff
[1] well, there are rare cases such as RAID XOR
prev parent reply other threads:[~2006-04-10 17:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-10 16:32 Linux Question Carlos Pardo
2006-04-10 17:56 ` Jeff Garzik [this message]
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=443A9C66.5090705@garzik.org \
--to=jeff@garzik.org \
--cc=Carlos.Pardo@siliconimage.com \
--cc=htejun@gmail.com \
--cc=linux-ide@vger.kernel.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).