public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Gabriel Paubert <paubert@iram.es>,
	Yoann Vandoorselaere <yoann@prelude-ids.org>
Cc: <cpufreq@lists.arm.linux.org.uk>, <cpufreq@www.linux.org.uk>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH]: fix 32bits integer overflow in loops_per_jiffy calculation
Date: Thu, 22 Aug 2002 15:02:00 +0200	[thread overview]
Message-ID: <20020822130200.31767@192.168.4.1> (raw)

Hi Gabriel !

>if(abs(div)<100) div=0;
>
>> +        val = old / div * mult;
>
>Now happily divide by zero.
>
>> +
>> +        carry = old % div;
>
>Again.
>
>> +        carry = carry * mult / div;
>
>Again.
>
>> +                
>> +        return val + carry;
>>  }

None of the above can happen in the domain of application of this
function. It's used to scale up/down the loops_per_jiffy value when
scaling the CPU frequency. Anyway, the above isn't worse than the
original function. Ideally, we would want 64 bits arithmetics, but
we decided long ago not to bring the libcc support routines for that
in the kernel.
>
>And I can't see how it can be more precise, you divide the numerator and
>denominator of the fraction by 100 and then proceed forgetting 
>everything about the rest. Basically this looses about 7 bits of precision.

Which is mostly ok for what we need. I think Yoann didn't mean it's
more precise that what it replace, but rather more precise than his
original implementation that divided by 1000 ;) Anyway, it's not
significantly worse than what we had and won't overflow as easily
which is all we want for this routine now.

>Now altogether I believe that such a function pertains to a per arch 
>optimized routine.

Maybe... though in the context of cpufreq, it may not make that much
sense.

Ben.



             reply	other threads:[~2002-08-22 11:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-22 13:02 Benjamin Herrenschmidt [this message]
2002-08-22 12:12 ` [PATCH]: fix 32bits integer overflow in loops_per_jiffy calculation Gabriel Paubert
2002-08-22 14:31   ` Benjamin Herrenschmidt
2002-08-22 15:23     ` Gabriel Paubert
2002-08-22 15:59       ` Yoann Vandoorselaere
2002-08-22 17:22         ` [PATCH]: fix 32bits integer overflow in loops_per_jiffycalculation george anzinger
2002-08-22 16:51       ` [PATCH]: fix 32bits integer overflow in loops_per_jiffy calculation Dominik Brodowski
2002-08-22 19:35         ` Benjamin Herrenschmidt
2002-08-22 17:46           ` Dominik Brodowski
2002-08-22 18:02             ` Yoann Vandoorselaere
2002-08-22 20:00             ` Benjamin Herrenschmidt
  -- strict thread matches above, loose matches on Subject: below --
2002-08-22  9:50 Yoann Vandoorselaere
2002-08-22 10:21 ` Gabriel Paubert
2002-08-22 13:00   ` Benjamin Herrenschmidt

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=20020822130200.31767@192.168.4.1 \
    --to=benh@kernel.crashing.org \
    --cc=cpufreq@lists.arm.linux.org.uk \
    --cc=cpufreq@www.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paubert@iram.es \
    --cc=yoann@prelude-ids.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