From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Chris Metcalf <cmetcalf@mellanox.com>
Subject: [PATCH 4.4 10/21] tile: avoid using clocksource_cyc2ns with absolute cycle count
Date: Wed, 30 Nov 2016 10:27:26 +0100 [thread overview]
Message-ID: <20161130092655.440607276@linuxfoundation.org> (raw)
In-Reply-To: <20161130092654.890709900@linuxfoundation.org>
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Metcalf <cmetcalf@mellanox.com>
commit e658a6f14d7c0243205f035979d0ecf6c12a036f upstream.
For large values of "mult" and long uptimes, the intermediate
result of "cycles * mult" can overflow 64 bits. For example,
the tile platform calls clocksource_cyc2ns with a 1.2 GHz clock;
we have mult = 853, and after 208.5 days, we overflow 64 bits.
Since clocksource_cyc2ns() is intended to be used for relative
cycle counts, not absolute cycle counts, performance is more
importance than accepting a wider range of cycle values. So,
just use mult_frac() directly in tile's sched_clock().
Commit 4cecf6d401a0 ("sched, x86: Avoid unnecessary overflow
in sched_clock") by Salman Qazi results in essentially the same
generated code for x86 as this change does for tile. In fact,
a follow-on change by Salman introduced mult_frac() and switched
to using it, so the C code was largely identical at that point too.
Peter Zijlstra then added mul_u64_u32_shr() and switched x86
to use it. This is, in principle, better; by optimizing the
64x64->64 multiplies to be 32x32->64 multiplies we can potentially
save some time. However, the compiler piplines the 64x64->64
multiplies pretty well, and the conditional branch in the generic
mul_u64_u32_shr() causes some bubbles in execution, with the
result that it's pretty much a wash. If tilegx provided its own
implementation of mul_u64_u32_shr() without the conditional branch,
we could potentially save 3 cycles, but that seems like small gain
for a fair amount of additional build scaffolding; no other platform
currently provides a mul_u64_u32_shr() override, and tile doesn't
currently have an <asm/div64.h> header to put the override in.
Additionally, gcc currently has an optimization bug that prevents
it from recognizing the opportunity to use a 32x32->64 multiply,
and so the result would be no better than the existing mult_frac()
until such time as the compiler is fixed.
For now, just using mult_frac() seems like the right answer.
Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/tile/kernel/time.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/arch/tile/kernel/time.c
+++ b/arch/tile/kernel/time.c
@@ -218,8 +218,8 @@ void do_timer_interrupt(struct pt_regs *
*/
unsigned long long sched_clock(void)
{
- return clocksource_cyc2ns(get_cycles(),
- sched_clock_mult, SCHED_CLOCK_SHIFT);
+ return mult_frac(get_cycles(),
+ sched_clock_mult, 1ULL << SCHED_CLOCK_SHIFT);
}
int setup_profiling_timer(unsigned int multiplier)
next prev parent reply other threads:[~2016-11-30 9:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20161130092741epcas3p26e2df0db74c37be618b757b132dcab10@epcas3p2.samsung.com>
2016-11-30 9:27 ` [PATCH 4.4 00/21] 4.4.36-stable review Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 05/21] usb: chipidea: move the lock initialization to core file Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 06/21] USB: serial: cp210x: add ID for the Zone DPMX Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 07/21] USB: serial: ftdi_sio: add support for TI CC3200 LaunchPad Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 08/21] Fix USB CB/CBI storage devices with CONFIG_VMAP_STACK=y Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 09/21] scsi: mpt3sas: Fix secure erase premature termination Greg Kroah-Hartman
2016-11-30 9:27 ` Greg Kroah-Hartman [this message]
2016-11-30 9:27 ` [PATCH 4.4 11/21] cfg80211: limit scan results cache size Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 12/21] apparmor: fix change_hat not finding hat after policy replacement Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 13/21] NFSv4.x: hide array-bounds warning Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 14/21] parisc: Fix races in parisc_setup_cache_timing() Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 15/21] parisc: Fix race in pci-dma.c Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 16/21] parisc: Also flush data TLB in flush_icache_page_asm Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 17/21] mpi: Fix NULL ptr dereference in mpi_powm() [ver #3] Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 19/21] mei: me: disable driver on SPT SPS firmware Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 20/21] mei: me: fix place for kaby point device ids Greg Kroah-Hartman
2016-11-30 9:27 ` [PATCH 4.4 21/21] mei: fix return value on disconnection Greg Kroah-Hartman
2016-11-30 13:46 ` [PATCH 4.4 00/21] 4.4.36-stable review Andre Noll
2016-11-30 13:53 ` Greg Kroah-Hartman
2016-11-30 14:04 ` Andre Noll
2016-11-30 14:28 ` Eric Dumazet
2016-11-30 14:31 ` Greg Kroah-Hartman
2016-11-30 14:53 ` David Miller
2016-11-30 15:11 ` Andre Noll
2016-11-30 14:50 ` David Miller
2016-11-30 15:37 ` Greg KH
2016-11-30 16:03 ` Shuah Khan
2016-11-30 23:28 ` Guenter Roeck
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=20161130092655.440607276@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=cmetcalf@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@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).