On Friday, November 16, 2007 2:40 AM, Eric Saxe wrote:

> Hi Aubrey,
> 
> It looks like you are adding an lbolt count to keep track of how much
> time is being spent in each P-state. Is that right?
Yes, exactly what I want.

> I was thinking of doing this in DTrace by creating an association that
keeps track of
> aggregate time spent on a per CPU per 
> P-state basis...

Sorry, I didn't catch your point. We have only one probe, from which we
only have a timestamp.
Next time the probe fired, the key of the association is changed. 
How to track an interval between the first time and the second time of
the association with the same key?

Thanks,
-Aubrey



> 
> Li, Aubrey wrote:
>> Hi Eric,
>> 
>> I'm working on the P-state statistics of PowerTOP.
>> Based on the dtrace probe you added,
>> ----
>> DTRACE_PROBE2(cpu_change_speed, processorid_t, cpudsp->cpu_id,
>> uint_t, new_spd->speed); ----
>> It's too complex for me to collect data of P-state statistics.
>> (Maybe there is a better way I didn't realize).
>> So I have to make another patch as follows.
>> I'm not sure if it's acceptable, because I added a new member in the
>> structure "cpudrv_pm_spd_t". 
>> 
>> Any comments and suggestions?
>> 
>> Thanks,
>> -Aubrey
>> --------
>> diff -r 05bb1c8f17bc usr/src/uts/common/io/cpudrv.c
>> --- a/usr/src/uts/common/io/cpudrv.c Thu Nov 15 13:24:44 2007 +0800
>> +++ b/usr/src/uts/common/io/cpudrv.c Fri Nov 16 02:01:26 2007 +0800
>> @@ -455,9 +455,10 @@ cpudrv_power(dev_info_t *dip, int comp, 
>>      int                     instance; cpudrv_devstate_t     *cpudsp;
>>      cpudrv_pm_t             *cpupm;
>> -    cpudrv_pm_spd_t         *new_spd;
>> +    cpudrv_pm_spd_t         *cur_spd, *new_spd;
>>      boolean_t               is_ready;
>>      int                     ret;
>> +    uint_t                  lbolt_cnt;
>> 
>>      instance = ddi_get_instance(dip);
>> 
>> @@ -471,6 +472,11 @@ cpudrv_power(dev_info_t *dip, int comp,
>> 
>>      mutex_enter(&cpudsp->lock);
>>      cpupm = &(cpudsp->cpudrv_pm);
>> +    if ((cur_spd = cpupm->cur_spd) == NULL) {
>> +            mutex_exit(&cpudsp->lock);
>> +            return (DDI_FAILURE);
>> +    }
>> +
>> 
>>      /*
>>       * In normal operation, we fail if we are busy and request is
>> @@ -522,6 +528,10 @@ cpudrv_power(dev_info_t *dip, int comp, 
>>              mutex_exit(&cpudsp->lock); return (DDI_FAILURE);
>>      }
>> +
>> +    lbolt_cnt = lbolt - cur_spd->last_lbolt;
>> +
>> +    cur_spd->last_lbolt = lbolt;
>> 
>>      /*
>>       * Execute CPU specific routine on the requested CPU to change
its
>> @@ -537,8 +547,8 @@ cpudrv_power(dev_info_t *dip, int comp,
/*
>>       * DTrace probe to fire when changing to a new speed     */
>> -    DTRACE_PROBE2(cpu_change_speed, processorid_t, cpudsp->cpu_id,
>> -        uint_t, new_spd->speed);
>> +    DTRACE_PROBE3(cpu_change_speed, processorid_t, cpudsp->cpu_id,
>> +        uint_t, cur_spd->speed, uint_t, lbolt_cnt);
>> 
>> 
>>      /*
>> @@ -561,6 +571,7 @@ cpudrv_power(dev_info_t *dip, int comp,
>>      cpupm->lastquan_mstate[CMS_USER] = 0;
>>      cpupm->lastquan_lbolt = 0;
>>      cpupm->cur_spd = new_spd;
>> +    cpupm->cur_spd->last_lbolt = lbolt;
>>      CPUDRV_PM_RESET_THROTTLE_THREAD(cpupm);
>>      mutex_exit(&cpudsp->lock);
>> 
>> @@ -662,6 +673,7 @@ cpudrv_pm_init(cpudrv_devstate_t *cpudsp
>>              if (i == 0) {   /* normal speed */
>>                      cpupm->head_spd = cur_spd;
>>                      cur_spd->quant_cnt = CPUDRV_PM_QUANT_CNT_NORMAL;
>> +                    cur_spd->last_lbolt = lbolt;
>>                      cur_spd->idle_hwm =
>>                          (cpudrv_pm_idle_hwm * cur_spd->quant_cnt) /
100;
>>                      /* can't speed anymore */
>> @@ -669,6 +681,7 @@ cpudrv_pm_init(cpudrv_devstate_t *cpudsp
>>                      cur_spd->user_hwm = UINT_MAX;
>>              } else {
>>                      cur_spd->quant_cnt = CPUDRV_PM_QUANT_CNT_OTHR;
>> +                    cur_spd->last_lbolt = 0;
>>                      ASSERT(prev_spd != NULL);
>>                      prev_spd->down_spd = cur_spd;
>>                      cur_spd->up_spd = cpupm->head_spd;
>> diff -r 05bb1c8f17bc usr/src/uts/common/sys/cpudrv.h
>> --- a/usr/src/uts/common/sys/cpudrv.h        Thu Nov 15 13:24:44 2007
+0800
>> +++ b/usr/src/uts/common/sys/cpudrv.h        Fri Nov 16 01:32:11 2007
+0800
>> @@ -59,6 +59,7 @@ typedef struct cpudrv_pm_spd {
>>  typedef struct cpudrv_pm_spd {
>>      uint_t                  speed;          /* platform dependent
>> notion */
>>      uint_t                  quant_cnt;      /* quantum count in
>> ticks */
>> +    uint_t                  last_lbolt;     /* last lbolt */
>>      struct cpudrv_pm_spd    *down_spd;      /* ptr to next speed
>> down */
>>      struct cpudrv_pm_spd    *up_spd;        /* ptr to next speed up
*/
>>      uint_t                  idle_hwm;       /* down if idle thread
>> 
>>> = hwm */
>>> 
>> --------
>> _______________________________________________
>> tesla-dev mailing list
>> tesla-dev at opensolaris.org
>> http://mail.opensolaris.org/mailman/listinfo/tesla-dev

Reply via email to