From: Andy Lutomirski <luto@amacapital.net>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Juri Lelli <juri.lelli@gmail.com>
Subject: Re: [RFC][PATCH 0/3] gcc work-around and math128
Date: Tue, 24 Apr 2012 14:15:18 -0700 [thread overview]
Message-ID: <4F9717E6.8030506@amacapital.net> (raw)
In-Reply-To: <20120424161039.293018424@chello.nl>
On 04/24/2012 09:10 AM, Peter Zijlstra wrote:
> Hi all,
>
> The SCHED_DEADLINE review resulted in the following three patches;
>
> The first is a cleanup of various copies of the same GCC loop optimization
> work-around. I don't think this patch is too controversial, at worst I've
> picked a wrong name, but I wanted to get it out there in case people
> know more sites.
>
> The second two implement a few u128 operations so we can do 128bit math.. I
> know a few people will die a little inside, but having nanosecond granularity
> time accounting leads to very big numbers very quickly and when you need to
> multiply them 64bit really isn't that much.
I played with some of this stuff awhile ago, and for timekeeping, it
seemed like a 64x32->96 bit multiply followed by a right shift was
enough, and that operation is a lot faster on 32-bit architectures than
a full 64x64->128 multiply. Something like:
uint64_t mul_64_32_shift(uint64_t a, uint32_t mult, uint32_t shift)
{
return (uint64_t)( ((__uint128_t)a * (__uint128_t)mult) >> shift );
}
or (untested, but compilable 32-bit gcc)
uint64_t mul_64_32_shift(uint64_t a, uint32_t mult, uint32_t shift)
{
uint64_t part1 = ((a & 0xFFFFFFFFULL) * mult) >> shift;
uint64_t part2 = ((a >> 32) * mult) << (32 - shift);
return part1 + part2;
}
--Andy
next prev parent reply other threads:[~2012-04-24 21:15 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-24 16:10 [RFC][PATCH 0/3] gcc work-around and math128 Peter Zijlstra
2012-04-24 16:10 ` [RFC][PATCH 1/3] kernel,sched,time: Clean up gcc work-arounds Peter Zijlstra
2012-04-24 19:39 ` Linus Torvalds
2012-04-25 0:14 ` Stephen Rothwell
2012-04-24 16:10 ` [RFC][PATCH 2/3] math128: Introduce {mult,add,cmp}_u128 Peter Zijlstra
2012-04-24 19:37 ` Linus Torvalds
2012-04-24 19:43 ` Peter Zijlstra
2012-04-24 20:12 ` Måns Rullgård
2012-04-24 21:54 ` Peter Zijlstra
2012-04-25 0:09 ` H. Peter Anvin
2012-04-25 1:46 ` Linus Torvalds
2012-04-25 8:35 ` Peter Zijlstra
2012-04-25 10:13 ` Peter Zijlstra
2012-04-25 0:23 ` Stephen Rothwell
2012-04-25 8:11 ` Peter Zijlstra
2012-04-25 11:23 ` Geert Uytterhoeven
2012-04-25 11:58 ` Peter Zijlstra
2012-04-25 14:35 ` Geert Uytterhoeven
2012-04-25 15:09 ` Peter Zijlstra
2012-04-24 16:10 ` [RFC][PATCH 3/3] math128, x86_64: Implement {mult,add}_u128 in 64bit asm Peter Zijlstra
2012-04-24 16:34 ` H. Peter Anvin
2012-04-24 16:36 ` Peter Zijlstra
2012-04-24 17:17 ` H. Peter Anvin
2012-04-24 17:19 ` Peter Zijlstra
2012-04-24 17:20 ` H. Peter Anvin
2012-04-24 22:00 ` Peter Zijlstra
2012-04-24 22:03 ` H. Peter Anvin
2012-04-24 17:22 ` [RFC][PATCH 0/3] gcc work-around and math128 H. Peter Anvin
2012-04-24 17:27 ` H. Peter Anvin
2012-04-24 21:15 ` Andy Lutomirski [this message]
2012-04-24 21:18 ` Linus Torvalds
2012-04-24 21:32 ` Peter Zijlstra
2012-04-24 21:35 ` Andy Lutomirski
2012-04-24 21:51 ` 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=4F9717E6.8030506@amacapital.net \
--to=luto@amacapital.net \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=juri.lelli@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.