lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 15 May 2008 01:27:04 +0300
From:	Adrian Bunk <bunk@...nel.org>
To:	"Darrick J. Wong" <djwong@...ibm.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>, mhoffman@...htlink.com,
	linux-kernel@...r.kernel.org, lm-sensors@...sensors.org
Subject: Re: [PATCH] ibmaem: Fix 64-bit division on 32-bit platforms

On Thu, May 08, 2008 at 09:55:27PM -0700, Darrick J. Wong wrote:
> On Thu, May 08, 2008 at 04:34:43PM -0700, Andrew Morton wrote:
> 
> > This driver is littered with 64-bit divides and doesn't link on i386.
> > I'll make it depend on CONFIG_64BIT for now.
> 
> Oops, sorry, I didn't remember that one can't do 64-bit division on
> i386.  The patch below fixes that.
> ---
> ibmaem: Fix 64-bit division on 32-bit platforms
> 
> Signed-off-by: Darrick J. Wong <djwong@...ibm.com>
> ---
> 
>  drivers/hwmon/ibmaem.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
> index 22fa7d6..f808ca3 100644
> --- a/drivers/hwmon/ibmaem.c
> +++ b/drivers/hwmon/ibmaem.c
>...
> @@ -864,9 +865,10 @@ static ssize_t aem_show_power(struct device *dev,
>...
>  	time = timespec_to_ns(&a) - timespec_to_ns(&b);
> -	time /= 1000;
> +	time = div_u64(time, 1000);
>  
> -	return sprintf(buf, "%llu\n", (after - before) * 1000000000 / time);
> +	return sprintf(buf, "%llu\n",
> +		       div64_u64((after - before) * 1000000000, time));
>  }
>...

What are you actually trying to do here?

Converting mJ/ns to uJ/s?

Or do you want to convert mJ/ns to Watt in which case you should
multiply "time" with 1000 instead of dividing it through 1000?

In any case you should only need one expensive 64bit division
and you can fold the operation with 1000 into the second division.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ