From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Mike Garrison <mcgarr@umich.edu>,
Andrew Morton <akpm@linux-foundation.org>,
Arjan van de Ven <arjan@linux.intel.com>,
Len Brown <len.brown@intel.com>,
Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>,
Corrado Zoccolo <czoccolo@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.6.32.2: undefined reference to `__udivdi3'
Date: Mon, 21 Dec 2009 12:21:21 -0800 [thread overview]
Message-ID: <20091221122121.6853d68c@nehalam> (raw)
In-Reply-To: <61FF0336-4E17-4EE5-9471-01360A6F7D29@umich.edu>
The new menu governor driver is written by Intel folks who never use 32-bit
anymore it seems :-)
---------------------------------------------------------
Subject: [PATCH] menu: use proper 64 bit math
The new menu governor is incorrectly doing a 64 bit divide.
Compile tested only
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/cpuidle/governors/menu.c 2009-12-21 12:02:25.840083589 -0800
+++ b/drivers/cpuidle/governors/menu.c 2009-12-21 12:16:42.418834255 -0800
@@ -18,6 +18,7 @@
#include <linux/hrtimer.h>
#include <linux/tick.h>
#include <linux/sched.h>
+#include <linux/math64.h>
#define BUCKETS 12
#define RESOLUTION 1024
@@ -169,6 +170,12 @@ static DEFINE_PER_CPU(struct menu_device
static void menu_update(struct cpuidle_device *dev);
+/* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */
+static u64 div_round64(u64 dividend, u32 divisor)
+{
+ return div_u64(dividend + (divisor / 2), divisor);
+}
+
/**
* menu_select - selects the next idle state to enter
* @dev: the CPU
@@ -209,9 +216,8 @@ static int menu_select(struct cpuidle_de
data->correction_factor[data->bucket] = RESOLUTION * DECAY;
/* Make sure to round up for half microseconds */
- data->predicted_us = DIV_ROUND_CLOSEST(
- data->expected_us * data->correction_factor[data->bucket],
- RESOLUTION * DECAY);
+ data->predicted_us = div_round64(data->expected_us * data->correction_factor[data->bucket],
+ RESOLUTION * DECAY);
/*
* We want to default to C1 (hlt), not to busy polling
next prev parent reply other threads:[~2009-12-21 20:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-21 18:22 2.6.32.2: undefined reference to `__udivdi3' Mike Garrison
2009-12-21 20:21 ` Stephen Hemminger [this message]
2009-12-22 10:28 ` Arjan van de Ven
-- strict thread matches above, loose matches on Subject: below --
2009-12-20 12:10 arvids
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=20091221122121.6853d68c@nehalam \
--to=shemminger@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=czoccolo@gmail.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgarr@umich.edu \
--cc=venkatesh.pallipadi@intel.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