linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: paul.walmsley@sifive.com
Cc: Greg KH <gregkh@linuxfoundation.org>,
	linux-riscv@lists.infradead.org, palmer@sifive.com,
	zongbox@gmail.com
Subject: Re: [GIT PULL] RISC-V Patches for the 4.20 Merge Window, Part 1
Date: Thu, 25 Oct 2018 18:51:01 -0700	[thread overview]
Message-ID: <CAHk-=wiHy+39PkEjUuQRJdOO7aNytYXeAGD-tZwOfOEj6ZhTKg@mail.gmail.com> (raw)
Message-ID: <20181026015101.oUDWKxjtjFvpdOECRKsyw-gZMPjVhXa3GjDAPisu8-8@z> (raw)
In-Reply-To: <41b34e47-57de-bcc1-c86e-8b98f663367a@sifive.com>

On 10/25/18 6:12 PM, Linus Torvalds wrote:
>
> Almost always, the 64-bit divide turns out to be entirely pointless,
> and the code can be written as a (much cheaper) 64-by-32 divide
> instead using the functions in <asm/div.h> instead.

The other common situation for the kernel is that something was
written as "xyz / abc", when it turns out that abc is really just a
power-of-two.

So it's not necessarily always that the 64-bit divide can be
re-written as a 64-by-32 divide, sometimes it can be rewritten as
simply a shift. Which is even cheaper.

That's the reason I try to actively discourage full 64-by-64 divides.
We have had situations where people end up using a divide that can
take hundres of cycles, where alarmingly often it can be rewritten as
one that takes tens of cycles or even just _single_ cycles.

People don't sometimes appreciate just how expensive 64-by-64 divides
are when you don't have direct hardware support for them, and how
often there are much simpler and faster ways to avoid them.

                 Linus

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2018-10-26  1:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-24 20:42 [GIT PULL] RISC-V Patches for the 4.20 Merge Window, Part 1 Palmer Dabbelt
2018-10-24 20:42 ` Palmer Dabbelt
2018-10-26  1:12 ` Linus Torvalds
2018-10-26  1:12   ` Linus Torvalds
2018-10-26  1:35   ` Paul Walmsley
2018-10-26  1:35     ` Paul Walmsley
2018-10-26  1:51     ` Linus Torvalds [this message]
2018-10-26  1:51       ` Linus Torvalds
2018-10-26 16:13       ` Zong Li
2018-10-26 16:13         ` Zong Li
2018-10-26 16:19     ` Zong Li
2018-10-26 16:19       ` Zong Li
2018-10-26 19:32   ` Palmer Dabbelt
2018-10-26 19:32     ` Palmer Dabbelt

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='CAHk-=wiHy+39PkEjUuQRJdOO7aNytYXeAGD-tZwOfOEj6ZhTKg@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@sifive.com \
    --cc=paul.walmsley@sifive.com \
    --cc=zongbox@gmail.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;
as well as URLs for NNTP newsgroup(s).