mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matti Aarnio <matti.aarnio@zmailer.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Runaway cron task on 2.5.63/4 bk?
Date: Wed, 12 Mar 2003 02:48:36 +0200	[thread overview]
Message-ID: <20030312004836.GE1073@mea-ext.zmailer.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0303111458390.1709-100000@home.transmeta.com>

On Tue, Mar 11, 2003 at 03:02:31PM -0800, Linus Torvalds wrote:
> On Tue, 11 Mar 2003, Andrew Morton wrote:
> > gcc will generate 64bit * 64bit multiplies without resorting to
> > any library code
> 
> However, gcc is unable to do-the-right-thing and generate 32x32->64 
> multiplies, or 32x64->64 multiplies, even though those are both a _lot_ 
> faster than the full 64x64->64 case.
> 
> And in quite a _lot_ of cases, that's actually what you want. It might 
> actually make sense to add a "do_mul()" thing to allow architectures to do 
> these cases right, since gcc doesn't.

Some architectures have a bit stricter limitations -- S390 limits divisor
to 2^31-1, for example.

A number of systems simply flaunt the task, and instead implement
mere 32/32 division in  do_div().
(arm, cris, m68knommu, sh (?), sparc(32), v850)


The original pure C code to do 64/32 division to 64/32 results is
very much gone in favour of architecture specific assembly codes
(where system isn't 64 bit one already..)
Ah, include/asm-parisc/div64.h  still has it in 2.5.64 sources..


> > and you can probably do the division with do_div().

If you need arbitrary divisions at all.  Filesystems for example
can (in most cases) do with power-of-two divisions, e.g.:  LL >> count
You may, perhaps, need to pre-calculate a number of those shift-counts
when mounting a filesystem.

> Yes. This is the same issue - gcc will always promote a 64-bit divide to
> be _fully_ 64-bit, even if the mixed-size 64/32 -> [64,32] case is much
> faster and simpler. Which is why do_div() exists in the first place.

Originally it was  lib/vsprintf.c's  internal (and very portable)
divide numerator by small base, produce changed numerator, and
remainder...  The innermost element in arbitrary base number printing.

In 2.5 there is some odd:   #define sector_div(a, b) do_div(a, b)
(only with  CONFIG_LDB), and usage in jiffie-to-clock conversion...
... and all over the code in various odd nooks, XFS filesystem included...

> 		Linus

/Matti Aarnio

  parent reply	other threads:[~2003-03-12  0:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-10 23:05 Felipe Alfaro Solana
2003-03-10 23:33 ` Linus Torvalds
2003-03-11 10:20   ` george anzinger
2003-03-11 22:44     ` Andrew Morton
2003-03-11 23:02       ` Linus Torvalds
2003-03-11 23:09         ` Andrew Morton
2003-03-11 23:18           ` Linus Torvalds
2003-03-11 23:34             ` Andrew Morton
2003-03-11 23:46               ` george anzinger
2003-03-11 23:46           ` Linus Torvalds
2003-03-12  1:55           ` Jamie Lokier
2003-03-12 12:04           ` Denis Vlasenko
2003-03-11 23:35         ` george anzinger
2003-03-12  0:48         ` Matti Aarnio [this message]
2003-03-12  3:45   ` [PATCH] " george anzinger
2003-03-12  4:57     ` Andrew Morton
2003-03-12 10:09       ` george anzinger
  -- strict thread matches above, loose matches on Subject: below --
2003-03-09  7:30 Kevin Brosius
2003-03-09  8:08 ` Andrew Morton
2003-03-09  8:17   ` Andrew Morton
2003-03-10 19:42     ` george anzinger
2003-03-10 19:49       ` Linus Torvalds
2003-03-10 22:21         ` george anzinger
2003-03-10 22:29           ` Andrew Morton
2003-03-10 22:46             ` george anzinger

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=20030312004836.GE1073@mea-ext.zmailer.org \
    --to=matti.aarnio@zmailer.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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

all inboxes | Powered by JetHome®