All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Doug Smythies" <dsmythies@telus.net>
To: 'Stratos Karafotis' <stratosk@semaphore.gr>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	rjw@rjwysocki.net, viresh.kumar@linaro.org,
	dirk.j.brandewie@intel.com
Subject: RE: [PATCH] cpufreq: intel_pstate: Fix rounding of core_pct
Date: Wed, 11 Jun 2014 07:27:12 -0700	[thread overview]
Message-ID: <009c01cf8581$3d75a7f0$b860f7d0$@net> (raw)
In-Reply-To: <009b01cf857a$d5032090$7f0961b0$@net>


On 2014.06.11 06:42 Doug Smythies wrote:
On 2014.06.11 05:34 Stratos Karafotis wrote:

>> 	if ((rem << 1) >= int_tofp(sample->mperf))
>> -		core_pct += 1;
>> +		core_pct += int_tofp(1);
>> 
>> 	sample->freq = fp_toint(
>> 		mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));
>> -- 
>> 1.9.3

> No.

> The intent was only ever to round properly the pseudo floating
> point result of the divide.
> It was much more important (ugh, well 4 times more) when
> FRACBITS was still 6, which also got changed to 8 in a recent
> patch.

I forgot to mention there are other related roundings that are being considered.
I do not recall clearly, but I think Dirk and I agreed to hold off until
the recent panics had settled.

The analysis as to the importance needs to be re-done, as it was all done when FRACBITS was 6. Things were very "chunky" when
FRACBITS was 6.

These are what I was considering putting forward:

static inline int32_t fp_toint(int32_t x)
{
        if (x >= 0)
                x +=  (1 << (FRAC_BITS -1));
         else
                x -=  (1 << (FRAC_BITS -1));
        return (x >> FRAC_BITS);
}

static inline int32_t mul_fp(int32_t x, int32_t y)
{
        int64_t temp;
        temp = (int64_t)x * (int64_t)y;
        if (temp >= 0)
                temp +=  (1 << (FRAC_BITS -1));
         else
                temp -=  (1 << (FRAC_BITS -1));
        return (temp >> FRAC_BITS);
}

static inline int32_t div_fp(int32_t x, int32_t y)
{

        /* currently, there are only positive numbers to worry about here */

        int32_t rem;

        x = div_s64_rem((int64_t)x << FRAC_BITS, (int64_t)y, &rem);
        if((rem << 1) >= y) x++;
        return(x);
}



WARNING: multiple messages have this Message-ID (diff)
From: "Doug Smythies" <dsmythies@telus.net>
To: "'Stratos Karafotis'" <stratosk@semaphore.gr>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<rjw@rjwysocki.net>, <viresh.kumar@linaro.org>,
	<dirk.j.brandewie@intel.com>
Subject: RE: [PATCH] cpufreq: intel_pstate: Fix rounding of core_pct
Date: Wed, 11 Jun 2014 07:27:12 -0700	[thread overview]
Message-ID: <009c01cf8581$3d75a7f0$b860f7d0$@net> (raw)
In-Reply-To: <009b01cf857a$d5032090$7f0961b0$@net>


On 2014.06.11 06:42 Doug Smythies wrote:
On 2014.06.11 05:34 Stratos Karafotis wrote:

>> 	if ((rem << 1) >= int_tofp(sample->mperf))
>> -		core_pct += 1;
>> +		core_pct += int_tofp(1);
>> 
>> 	sample->freq = fp_toint(
>> 		mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));
>> -- 
>> 1.9.3

> No.

> The intent was only ever to round properly the pseudo floating
> point result of the divide.
> It was much more important (ugh, well 4 times more) when
> FRACBITS was still 6, which also got changed to 8 in a recent
> patch.

I forgot to mention there are other related roundings that are being considered.
I do not recall clearly, but I think Dirk and I agreed to hold off until
the recent panics had settled.

The analysis as to the importance needs to be re-done, as it was all done when FRACBITS was 6. Things were very "chunky" when
FRACBITS was 6.

These are what I was considering putting forward:

static inline int32_t fp_toint(int32_t x)
{
        if (x >= 0)
                x +=  (1 << (FRAC_BITS -1));
         else
                x -=  (1 << (FRAC_BITS -1));
        return (x >> FRAC_BITS);
}

static inline int32_t mul_fp(int32_t x, int32_t y)
{
        int64_t temp;
        temp = (int64_t)x * (int64_t)y;
        if (temp >= 0)
                temp +=  (1 << (FRAC_BITS -1));
         else
                temp -=  (1 << (FRAC_BITS -1));
        return (temp >> FRAC_BITS);
}

static inline int32_t div_fp(int32_t x, int32_t y)
{

        /* currently, there are only positive numbers to worry about here */

        int32_t rem;

        x = div_s64_rem((int64_t)x << FRAC_BITS, (int64_t)y, &rem);
        if((rem << 1) >= y) x++;
        return(x);
}



  parent reply	other threads:[~2014-06-11 14:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11 12:33 [PATCH] cpufreq: intel_pstate: Fix rounding of core_pct Stratos Karafotis
2014-06-11 13:41 ` Doug Smythies
2014-06-11 13:41   ` Doug Smythies
2014-06-11 14:08   ` Stratos Karafotis
2014-06-11 15:02     ` Doug Smythies
2014-06-11 15:02       ` Doug Smythies
2014-06-11 18:28       ` Rafael J. Wysocki
2014-06-11 21:40         ` Doug Smythies
2014-06-11 21:40           ` Doug Smythies
2014-06-11 21:45           ` Rafael J. Wysocki
2014-06-12  6:56             ` Doug Smythies
2014-06-12  6:56               ` Doug Smythies
2014-06-11 20:20       ` Stratos Karafotis
2014-06-11 21:15         ` Doug Smythies
2014-06-11 21:15           ` Doug Smythies
2014-06-12 14:35           ` Stratos Karafotis
2014-06-12 20:03             ` Rafael J. Wysocki
2014-06-13  6:49               ` Doug Smythies
2014-06-13  6:49                 ` Doug Smythies
2014-06-13 17:39                 ` Stratos Karafotis
2014-06-13 13:48               ` Dirk Brandewie
2014-06-13 14:36                 ` Doug Smythies
2014-06-13 14:36                   ` Doug Smythies
2014-06-13 16:56                 ` Stratos Karafotis
2014-06-11 14:27   ` Doug Smythies [this message]
2014-06-11 14:27     ` Doug Smythies

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='009c01cf8581$3d75a7f0$b860f7d0$@net' \
    --to=dsmythies@telus.net \
    --cc=dirk.j.brandewie@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=stratosk@semaphore.gr \
    --cc=viresh.kumar@linaro.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.