Skip to content

Commit

Permalink
Events refactored: add Current limitation & Cross domain.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyring committed Aug 15, 2018
1 parent bfff0ca commit 9ed799d
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 138 deletions.
24 changes: 12 additions & 12 deletions corefreq-api.h
Expand Up @@ -236,19 +236,19 @@ typedef struct

typedef struct
{
unsigned int Sensor,
Target;
unsigned int Sensor,
Target;
struct {
enum THERM_PWR_EVENTS Events;
unsigned int
TCC_Enable: 1-0,
TM2_Enable: 2-1,
TM_Select : 3-2,
Trip : 4-3,
Unused : 32-4;
TCC_Enable: 1-0,
TM2_Enable: 2-1,
TM_Select : 3-2,
Unused : 32-3;
};
CLOCK_MODULATION ClockModulation;
ENERGY_PERF_BIAS PerfEnergyBias;
MISC_PWR_MGMT PwrManagement;
CLOCK_MODULATION ClockModulation;
ENERGY_PERF_BIAS PerfEnergyBias;
MISC_PWR_MGMT PwrManagement;
} POWER_THERMAL;

typedef struct
Expand Down Expand Up @@ -642,9 +642,9 @@ typedef struct
} Uncore;

struct {
unsigned int Sensor;
enum THERM_PWR_EVENTS Events;
RAPL_POWER_UNIT Unit;
unsigned int Sensor,
Trip;
} PowerThermal;

struct {
Expand Down
4 changes: 2 additions & 2 deletions corefreq-cli-json.c
Expand Up @@ -1383,8 +1383,8 @@ void JsonSysInfo(SHM_STRUCT *Shm, CELL_FUNC OutFunc) {
json_literal(&s, "%u", Shm->Cpu[i].FlipFlop[i2].Thermal.Sensor);
json_key(&s, "Temp");
json_literal(&s, "%u", Shm->Cpu[i].FlipFlop[i2].Thermal.Temp);
json_key(&s, "Trip");
json_literal(&s, "%u", Shm->Cpu[i].FlipFlop[i2].Thermal.Trip);
json_key(&s, "Events");
json_literal(&s, "%u", Shm->Cpu[i].FlipFlop[i2].Thermal.Events);
json_end_object(&s);
}
json_key(&s, "Voltage");
Expand Down
55 changes: 39 additions & 16 deletions corefreq-cli.c
Expand Up @@ -4128,9 +4128,14 @@ void Top(SHM_STRUCT *Shm, char option)
break;
case SCANKEY_SHIFT_h:
{
ATTRIBUTE eventAttr[2] ={
MakeAttr(WHITE, 0, BLACK, 0),
MakeAttr(YELLOW, 0, BLACK, 0)
};
Window *win = SearchWinListById(scan->key, &winList);
if (win == NULL)
{
struct PKG_FLIP_FLOP *PFlop = &Shm->Proc.FlipFlop[!Shm->Proc.Toggle];
const Coordinate origin = {
.col = 53,
.row = TOP_HEADER_ROW + 3
Expand All @@ -4140,11 +4145,27 @@ void Top(SHM_STRUCT *Shm, char option)
};
Window *wBox = CreateBox(scan->key, origin, select,
" Clear Event ",
(ASCII*)" Thermal Sensor ", stateAttr[0], BOXKEY_CLR_THM_SENSOR,
(ASCII*)" PROCHOT# Agent ", stateAttr[0], BOXKEY_CLR_THM_PROCHOT,
(ASCII*)" Critical Temperature ", stateAttr[0], BOXKEY_CLR_THM_CRITIC,
(ASCII*)" Thermal Threshold ", stateAttr[0], BOXKEY_CLR_THM_THRESH,
(ASCII*)" Power Limitation ", stateAttr[0], BOXKEY_CLR_PWR_LIMITS);
(ASCII*)" Thermal Sensor ",
eventAttr[((PFlop->Thermal.Events & EVENT_THERM_SENSOR) == 1)],
BOXKEY_CLR_THM_SENSOR,
(ASCII*)" PROCHOT# Agent ",
eventAttr[((PFlop->Thermal.Events & EVENT_THERM_PROCHOT) == 1)],
BOXKEY_CLR_THM_PROCHOT,
(ASCII*)" Critical Temperature ",
eventAttr[((PFlop->Thermal.Events & EVENT_THERM_CRIT) == 1)],
BOXKEY_CLR_THM_CRIT,
(ASCII*)" Thermal Threshold ",
eventAttr[((PFlop->Thermal.Events & EVENT_THERM_THOLD) == 1)],
BOXKEY_CLR_THM_THOLD,
(ASCII*)" Power Limitation ",
eventAttr[((PFlop->Thermal.Events & EVENT_POWER_LIMIT) == 1)],
BOXKEY_CLR_PWR_LIMIT,
(ASCII*)" Current Limitation ",
eventAttr[((PFlop->Thermal.Events & EVENT_CURRENT_LIMIT) == 1)],
BOXKEY_CLR_CUR_LIMIT,
(ASCII*)" Cross Domain Limit. ",
eventAttr[((PFlop->Thermal.Events & EVENT_CROSS_DOMAIN) == 1)],
BOXKEY_CLR_X_DOMAIN);
if (wBox != NULL) {
AppendWindow(wBox, &winList);
} else
Expand Down Expand Up @@ -4884,13 +4905,15 @@ void Top(SHM_STRUCT *Shm, char option)
break;
case BOXKEY_CLR_THM_SENSOR:
case BOXKEY_CLR_THM_PROCHOT:
case BOXKEY_CLR_THM_CRITIC:
case BOXKEY_CLR_THM_THRESH:
case BOXKEY_CLR_PWR_LIMITS:
case BOXKEY_CLR_THM_CRIT:
case BOXKEY_CLR_THM_THOLD:
case BOXKEY_CLR_PWR_LIMIT:
case BOXKEY_CLR_CUR_LIMIT:
case BOXKEY_CLR_X_DOMAIN:
{
const enum THERMAL_POWER_EVENTS evt=(scan->key & CLEAR_EVENT_MASK) >> 4;
const enum THERM_PWR_EVENTS events=(scan->key & CLEAR_EVENT_MASK) >> 4;
if (!RING_FULL(Shm->Ring[0]))
RING_WRITE(Shm->Ring[0], COREFREQ_IOCTL_CLEAR_EVENTS, evt);
RING_WRITE(Shm->Ring[0], COREFREQ_IOCTL_CLEAR_EVENTS, events);
}
break;
case BOXKEY_TURBO_CLOCK_1C:
Expand Down Expand Up @@ -6213,7 +6236,7 @@ void Top(SHM_STRUCT *Shm, char option)
Pwr[Shm->Proc.Features.HyperThreading];

hTech1.attr[59] = hTech1.attr[60] = hTech1.attr[61] =
PFlop->Thermal.Trip ? MakeAttr(RED, 0, BLACK, 1)
PFlop->Thermal.Events ? MakeAttr(RED, 0, BLACK, 1)
: MakeAttr(WHITE, 0, BLACK, 1);

const ATTRIBUTE TM1[] = {
Expand Down Expand Up @@ -6268,7 +6291,7 @@ void Top(SHM_STRUCT *Shm, char option)
hTech1.attr[47] = hTech1.attr[48] = hTech1.attr[49] = \
TM2[Shm->Cpu[Shm->Proc.Service.Core].PowerThermal.TM2];

if (( (*processorHot) != -1 ) || PFlop->Thermal.Trip) {
if (( (*processorHot) != -1 ) || PFlop->Thermal.Events) {
hTech1.attr[51] = MakeAttr(RED, 1, BLACK, 1);
hTech1.attr[52] = hTech1.attr[53] = MakeAttr(RED, 0, BLACK, 1);
}
Expand Down Expand Up @@ -6322,7 +6345,7 @@ void Top(SHM_STRUCT *Shm, char option)
hTech1.attr[31] = hTech1.attr[32] = hTech1.attr[33] = \
Pwr[(Shm->Proc.Features.AdvPower.EDX.TTP != 0)];

if (( (*processorHot) != -1 ) || PFlop->Thermal.Trip) {
if (( (*processorHot) != -1 ) || PFlop->Thermal.Events) {
hTech1.attr[35] = MakeAttr(RED, 1, BLACK, 1);
hTech1.attr[36] = hTech1.attr[37] = MakeAttr(RED, 0, BLACK, 1);
}
Expand Down Expand Up @@ -6487,7 +6510,7 @@ void Top(SHM_STRUCT *Shm, char option)
if (Flop->Thermal.Temp >= Shm->Cpu[cpu].PowerThermal.Limit[1])
warning = MakeAttr(YELLOW, 0, BLACK, 0);
}
if (Flop->Thermal.Trip) {
if (Flop->Thermal.Events) {
warning = MakeAttr(RED, 0, BLACK, 1);
}
LayerAt(layer, attr, (LOAD_LEAD + 69), row) = \
Expand Down Expand Up @@ -7037,7 +7060,7 @@ void Top(SHM_STRUCT *Shm, char option)
{
struct FLIP_FLOP *Flop = &Shm->Cpu[cpu].FlipFlop[!Shm->Cpu[cpu].Toggle];
// Store thermal throttling
if (Flop->Thermal.Trip && (processorHot == -1)) {
if (Flop->Thermal.Events && (processorHot == -1)) {
processorHot = cpu;
}
if (cpu == Shm->Proc.Service.Core)
Expand Down Expand Up @@ -7433,7 +7456,7 @@ void Top(SHM_STRUCT *Shm, char option)
} else if (Flop->Thermal.Temp >= Shm->Cpu[_cpu].PowerThermal.Limit[1]) {
warning = MakeAttr(YELLOW, 0, BLACK, 0);
}
if (Flop->Thermal.Trip) {
if (Flop->Thermal.Events) {
warning = MakeAttr(RED, 0, BLACK, 1);
}
Dec2Digit(Flop->Thermal.Temp, digit);
Expand Down
9 changes: 6 additions & 3 deletions corefreq-cli.h
Expand Up @@ -107,9 +107,12 @@

#define BOXKEY_CLR_THM_SENSOR 0x3000000000020011
#define BOXKEY_CLR_THM_PROCHOT 0x3000000000020021
#define BOXKEY_CLR_THM_CRITIC 0x3000000000020041
#define BOXKEY_CLR_THM_THRESH 0x3000000000020081
#define BOXKEY_CLR_PWR_LIMITS 0x3000000000020101
#define BOXKEY_CLR_THM_CRIT 0x3000000000020041
#define BOXKEY_CLR_THM_THOLD 0x3000000000020081
#define BOXKEY_CLR_PWR_LIMIT 0x3000000000020101
#define BOXKEY_CLR_CUR_LIMIT 0x3000000000020201
#define BOXKEY_CLR_X_DOMAIN 0x3000000000020401

#define CLEAR_EVENT_MASK 0x0000000000000ff0

#define TRACK_TASK 0x0200000000000000
Expand Down
8 changes: 4 additions & 4 deletions corefreq.h
Expand Up @@ -103,8 +103,8 @@ typedef struct

struct {
unsigned int Sensor,
Temp,
Trip;
Temp;
enum THERM_PWR_EVENTS Events;
} Thermal;

struct {
Expand Down Expand Up @@ -209,8 +209,8 @@ typedef struct

struct {
unsigned int Sensor,
Temp,
Trip;
Temp;
enum THERM_PWR_EVENTS Events;
} Thermal;
} FlipFlop[2];

Expand Down
4 changes: 2 additions & 2 deletions corefreqd.c
Expand Up @@ -169,8 +169,8 @@ static void *Core_Cycle(void *arg)
}

// Per Core thermal formulas
CFlip->Thermal.Trip = Core->PowerThermal.Trip;
CFlip->Thermal.Sensor = Core->PowerThermal.Sensor;
CFlip->Thermal.Events = Core->PowerThermal.Events;

switch (Pkg->thermalFormula) {
case THERMAL_FORMULA_INTEL:
Expand Down Expand Up @@ -282,8 +282,8 @@ static void *Core_Cycle(void *arg)
* Shm->Proc.Power.Unit.Times;
}
// Package thermal formulas
PFlip->Thermal.Trip = Pkg->PowerThermal.Trip;
PFlip->Thermal.Sensor = Pkg->PowerThermal.Sensor;
PFlip->Thermal.Events = Pkg->PowerThermal.Events;

switch (Pkg->thermalFormula) {
case THERMAL_FORMULA_INTEL:
Expand Down

0 comments on commit 9ed799d

Please sign in to comment.