On Sun, May 15, 2022 at 10:35:43AM +0200, Mark Kettenis wrote:
> > From: "Ted Unangst" <t...@tedunangst.com>
> > Date: Sat, 14 May 2022 20:23:39 -0400
> > 
> > The cpu hz sensor is more accurate and updates faster than than the value
> > currently used for hw.cpuspeed. So return that value (scaled).
> > 
> > This doesn't set cpuspeed directly because the acpi does that and it's hard
> > to create a whole system of priority overrides. I think it's simpler and
> > maybe even better to track every value, and then return the best one
> > available.
> 
> At this point, I don't want this.  Right now, it is actually useful
> that hw.cpuspeed represents the requested P-state whereas the sensors
> give us the "effective" frequency the core is actually running at.
> And that is useful for evaluating what is actually happening.

I agree, I think both values are needed for scheduler and power management
changes. The next bit on the todo list is RAPL support so the energy
consumtion can be measured and shown.
 
> > Index: identcpu.c
> > ===================================================================
> > RCS file: /home/cvs/src/sys/arch/amd64/amd64/identcpu.c,v
> > retrieving revision 1.124
> > diff -u -p -r1.124 identcpu.c
> > --- identcpu.c      26 Apr 2022 10:48:20 -0000      1.124
> > +++ identcpu.c      15 May 2022 00:15:39 -0000
> > @@ -64,6 +64,7 @@ void      cpu_check_vmm_cap(struct cpu_info *
> >  /* sysctl wants this. */
> >  char cpu_model[48];
> >  int cpuspeed;
> > +uint64_t sensorspeed;
> >  
> >  int amd64_has_xcrypt;
> >  #ifdef CRYPTO
> > @@ -244,6 +245,8 @@ int
> >  cpu_amd64speed(int *freq)
> >  {
> >     *freq = cpuspeed;
> > +   if (sensorspeed)
> > +           *freq = sensorspeed / 1000000000000ULL;
> >     return (0);
> >  }
> >  
> > @@ -337,6 +340,8 @@ cpu_hz_update_sensor(void *args)
> >             val = (adelta * 1000000) / mdelta * tsc_frequency;
> >             val = ((val + FREQ_50MHZ / 2) / FREQ_50MHZ) * FREQ_50MHZ; 
> >             ci->ci_hz_sensor.value = val;
> > +           if (CPU_IS_PRIMARY(ci))
> > +                   sensorspeed = val;
> >     }
> >  
> >     atomic_clearbits_int(&curproc->p_flag, P_CPUPEG);
> > 
> > 
> 

-- 
:wq Claudio

Reply via email to