PpmParkCalculateCoreParkingMask
UINT8 __stdcall PpmParkCalculateCoreParkingMask(){
unsigned int v1;
unsigned int v2;
__int64 v3;
__int64 v4;
unsigned int v5;
unsigned int v6;
int v7;
_KPRCB *Prcb;
unsigned __int64 *v9;
__int64 v10;
UINT64 v11;
int v12;
unsigned __int64 v13;
int v14;
UINT64 v15;
unsigned int v16;
UINT64 v17;
unsigned __int64 v18;
_KPRCB *v19;
unsigned __int16 v20;
unsigned __int64 GroupSetMember;
int v22;
_KPRCB *v23;
unsigned __int64 CoreProcessorSet;
UINT8 v25;
UINT64 v26;
unsigned __int16 v27;
int v28;
unsigned __int16 v29;
int v30;
_KPRCB *v31;
unsigned __int64 v32;
unsigned __int64 v33;
UINT64 v34;
int v35;
_KPRCB *v36;
unsigned __int64 v37;
__int64 v38;
char v39;
unsigned int v40;
unsigned int v41;
unsigned int v42;
unsigned int v43;
unsigned int v44;
int v45;
unsigned int v46;
unsigned int v47;
bool v48;
char v49;
UINT64 v50;
UINT64 v51;
UINT64 v52;
UINT64 v53;
int v54;
__int64 v55;
UINT64 v56;
UINT64 v57;
_KAFFINITY_ENUMERATION_CONTEXT v58;
UINT64 IsolatedCores;
unsigned int v60;
UINT64 v61;
unsigned int v62;
__int64 v63;
UINT64 v64;
__int64 v65;
__int64 v66;
unsigned __int64 v67;
UINT64 v68;
__int64 v69;
__int64 v70;
UINT64 v71;
_KAFFINITY_ENUMERATION_CONTEXT Context;
UINT64 ProcessorNumber;
int v74;
UINT64 ProcIndex;
unsigned int v76;
memset(&v58, 0, sizeof(v58));
LODWORD(ProcessorNumber) = 0;
IsolatedCores = 0i64;
v68 = 0i64;
v64 = 0i64;
if( !PpmIsParkingEnabled )
return 1;
v1 = 0;
v60 = 0;
v70 = *(&stru_140C00F40 + 365) + 2736i64 * *(&stru_140C23628 + 441);
v2 = 100 * *(unsigned __int8 *)(v70 + 164);
v62 = v2;
if( !(_DWORD)PpmParkNumNodes )
goto LABEL_84;
do
{
v3 = PpmParkNodes + 272i64 * v1;
v66 = v3;
if( (*(_BYTE *)(v3 + 146) & 1) != 0 )
goto LABEL_83;
v4 = 0i64;
v5 = *(unsigned __int8 *)(v3 + 135);
*(_QWORD *)(v3 + 40) = *(_QWORD *)(v3 + 32);
v6 = *(unsigned __int8 *)(v3 + 137);
*(_DWORD *)(&Context.CurrentIndex + 1) = 0;
*(&Context.CurrentIndex + 3) = 0;
if( (unsigned __int8)v5 >= (unsigned __int8)v6 )
v5 = v6;
LODWORD(ProcIndex) = 0;
Context.CurrentIndex = *(_WORD *)(v3 + 4);
Context.CurrentMask = *(_QWORD *)(v3 + 8);
v76 = v5;
Context.Affinity = 0i64;
while( 1 )
{
KeEnumerateNextProcessor(&ProcIndex, &Context);
if( v7 )
break;
Prcb = KeGetPrcb((unsigned int)ProcIndex);
if( Prcb->PowerState.CheckContext.AffinitizedUtility >= v2 )
v4 |= Prcb->GroupSetMember;
}
v9 = (unsigned __int64 *)(v3 + 56);
v63 = v4;
v69 = v3 + 56;
v10 = 0i64;
LODWORD(ProcIndex) = 0;
v65 = 0i64;
do
{
v11 = *(v9 - 5);
v61 = v11;
if( !v11 )
break;
v12 = 0x100000;
if( (unsigned __int8)PpmParkGranularity <= 1u )
{
v13 = *v9;
}
else
{
v13 = 0i64;
v58.CurrentIndex = *(_WORD *)(v3 + 4);
v58.CurrentMask = *v9;
v58.Affinity = 0i64;
while( 1 )
{
KeEnumerateNextProcessor(&ProcessorNumber, &v58);
if( v14 )
break;
v13 |= KeGetPrcb((unsigned int)ProcessorNumber)->CoreProcessorSet;
}
}
v15 = v11 & v13;
v71 = v15;
if( v15 )
v12 = 1114112;
v74 = v12;
v16 = v5;
if( *(unsigned __int8 *)(v3 + v10 + 128)
- ((unsigned int)((0x101010101010101i64
* ((((v15 - ((v15 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v15 - ((v15 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)
+ ((((v15 - ((v15 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v15 - ((v15 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)) >> 4)) & 0xF0F0F0F0F0F0F0Fi64)) >> 32) >> 24) <= v5 )
v16 = *(unsigned __int8 *)(v3 + v10 + 128)
- ((unsigned int)((0x101010101010101i64
* ((((v15 - ((v15 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v15 - ((v15 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)
+ ((((v15 - ((v15 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v15 - ((v15 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)) >> 4)) & 0xF0F0F0F0F0F0F0Fi64)) >> 32) >> 24);
v17 = 0i64;
LODWORD(v18) = 0;
v56 = 0i64;
if( !KiClockTimerPerCpu )
{
LODWORD(ProcessorNumber) = KiClockTimerOwner;
v19 = KeGetPrcb((unsigned int)KiClockTimerOwner);
v20 = *(_WORD *)(v3 + 4);
if( v19->Group == v20 )
{
GroupSetMember = v19->GroupSetMember;
if( (GroupSetMember & v11) != 0 )
{
v58.Affinity = 0i64;
v58.CurrentIndex = v20;
v58.CurrentMask = GroupSetMember;
while( 1 )
{
KeEnumerateNextProcessor(&ProcessorNumber, &v58);
if( v22 || (unsigned int)v18 >= v16 )
break;
v23 = KeGetPrcb((unsigned int)ProcessorNumber);
CoreProcessorSet = v23->GroupSetMember;
if( (CoreProcessorSet & v15) == 0 )
{
if( (unsigned __int8)PpmParkGranularity > 1u )
CoreProcessorSet = v23->CoreProcessorSet;
v12 |= 0x100u;
v74 = v12;
v17 |= CoreProcessorSet;
v18 = (0x101010101010101i64
* ((((v17 - ((v17 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v17 - ((v17 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)
+ ((((v17 - ((v17 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v17 - ((v17 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)) >> 4)) & 0xF0F0F0F0F0F0F0Fi64)) >> 56;
}
}
v3 = v66;
v11 = v61;
v56 = v17;
}
}
}
v25 = KeCpuSetQueryUnparkRecommendation(*(unsigned __int16 *)(v3 + 4), v11, &IsolatedCores);
v67 = v25;
if( v25 )
{
v26 = IsolatedCores;
if( (unsigned __int8)PpmParkGranularity > 1u )
{
v27 = *(_WORD *)(v3 + 4);
v58.Affinity = 0i64;
v58.CurrentIndex = v27;
v58.CurrentMask = IsolatedCores;
while( 1 )
{
KeEnumerateNextProcessor(&ProcessorNumber, &v58);
if( v28 )
break;
v26 |= KeGetPrcb((unsigned int)ProcessorNumber)->CoreProcessorSet;
}
IsolatedCores = v26;
v67 = (0x101010101010101i64
* ((((v26 - ((v26 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v26 - ((v26 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)
+ ((((v26 - ((v26 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v26 - ((v26 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)) >> 4)) & 0xF0F0F0F0F0F0F0Fi64)) >> 56;
}
v29 = *(_WORD *)(v3 + 4);
v58.Affinity = 0i64;
v58.CurrentIndex = v29;
v58.CurrentMask = v26;
while( 1 )
{
KeEnumerateNextProcessor(&ProcessorNumber, &v58);
if( v30 || (unsigned int)v18 >= v16 )
break;
v31 = KeGetPrcb((unsigned int)ProcessorNumber);
v32 = v31->GroupSetMember;
if( (v32 & v15) == 0 )
{
if( (unsigned __int8)PpmParkGranularity > 1u )
v32 = v31->CoreProcessorSet;
v12 |= 0x10u;
v56 |= v32;
v74 = v12;
v18 = (0x101010101010101i64
* ((((v56 - ((v56 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v56 - ((v56 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)
+ ((((v56 - ((v56 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v56 - ((v56 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)) >> 4)) & 0xF0F0F0F0F0F0F0Fi64)) >> 56;
}
}
}
v58.CurrentIndex = *(_WORD *)(v3 + 4);
v33 = v61 & v63 & *(_QWORD *)(v3 + 40);
v58.Affinity = 0i64;
v34 = v56;
v58.CurrentMask = v33;
while( 1 )
{
KeEnumerateNextProcessor(&ProcessorNumber, &v58);
if( v35 || (unsigned int)v18 >= v16 )
break;
v36 = KeGetPrcb((unsigned int)ProcessorNumber);
v37 = v36->GroupSetMember;
if( (v37 & v15) == 0 )
{
if( (unsigned __int8)PpmParkGranularity > 1u )
v37 = v36->CoreProcessorSet;
v12 |= 0x20000u;
v74 = v12;
v34 |= v37;
v18 = (0x101010101010101i64
* ((((v34 - ((v34 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v34 - ((v34 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)
+ ((((v34 - ((v34 >> 1) & 0x5555555555555555i64)) & 0x3333333333333333i64)
+ (((v34 - ((v34 >> 1) & 0x5555555555555555i64)) >> 2) & 0x3333333333333333i64)) >> 4)) & 0xF0F0F0F0F0F0F0Fi64)) >> 56;
}
}
v38 = v65;
v39 = IsolatedCores;
v57 = v34;
v3 = v66;
v40 = *(unsigned __int8 *)(v65 + v66 + 130);
if( (unsigned int)v18 < v40 && (unsigned int)v18 < v16 )
{
v12 |= 4u;
v74 = v12;
if( v40 >= v16 )
v40 = v16;
LODWORD(v18) = v40;
}
v41 = *(unsigned __int8 *)(v65 + v66 + 132);
v42 = v16;
if( v16 > v41 && (unsigned int)v18 < v16 )
{
v12 |= 8u;
v42 = *(unsigned __int8 *)(v65 + v66 + 132);
v74 = v12;
if( v41 <= (unsigned int)v18 )
v42 = v18;
}
if( *(&stru_140C23628 + 3472) )
{
v43 = *(unsigned __int8 *)(v66 + v65 + 128);
v12 |= 0x40000u;
}
else
{
if( (_DWORD)ProcIndex || !*(_BYTE *)(v66 + 139) )
{
v44 = *(unsigned __int8 *)(v65 + v66 + 138);
v45 = *(unsigned __int8 *)(v66 + v65 + 128);
if( (unsigned __int8)v44 >= (unsigned __int8)v45 )
v44 = *(unsigned __int8 *)(v66 + v65 + 128);
v43 = v44;
if( *(&PopIrpWorkerControlEvent + 315)
&& (v45 * (unsigned int)*(unsigned __int8 *)(v70 + v65 + 119) + 50) / 0x64 > v44 )
{
v12 |= 0x40u;
v43 = (v45 * (unsigned int)*(unsigned __int8 *)(v70 + v65 + 119) + 50) / 0x64;
v74 = v12;
}
if( (unsigned __int8)PpmParkGranularity > 1u )
v43 = (unsigned __int8)PpmParkGranularity
- 1
+ v43
- ((unsigned __int8)PpmParkGranularity - 1 + v43) % (unsigned __int8)PpmParkGranularity;
goto LABEL_75;
}
v43 = *(unsigned __int8 *)(v66 + 128);
v12 |= 0x80u;
}
v74 = v12;
LABEL_75:
v46 = v43 + v67;
*(_BYTE *)(v65 + v66 + 138) = v43;
v47 = v18;
if( v46 >= v42 )
v46 = v42;
if( v46 > (unsigned int)v18 )
v47 = v46;
v76 -= v42;
v48 = PpmParkSoftParkingEnabled == 0;
*(_BYTE *)(v38 + v3 + 143) = v47;
if( v48 )
{
v42 = v47;
v74 = v12 | 0x200000;
}
v49 = v71;
v50 = v61 & v63;
PpmParkComputeUnparkMask(
*(_WORD *)(v3 + 4),
v61,
v61 & *(_QWORD *)(v3 + 40),
v61 & v63,
v47,
v42,
v71,
v57,
&v68,
&v64,
&v74);
v51 = ~v61;
v52 = v68 | v64 | *(_QWORD *)(v3 + 32) & ~v61;
*(_QWORD *)(v3 + 32) = v52;
*(_QWORD *)(v3 + 48) = v64 | v51 & v52;
v55 = v50;
LODWORD(v50) = ProcIndex;
PpmEventTraceSoftCoreParkingSelection((_QWORD *)v3, ProcIndex, v47, v42, v18, v49, v57, v55, v39, v74);
v9 = (unsigned __int64 *)(v69 + 8);
v5 = v76;
v10 = v65 + 1;
LODWORD(ProcIndex) = v50 + 1;
++v65;
v69 += 8i64;
}
while( (unsigned int)(v50 + 1) < 2 );
v1 = v60;
v2 = v62;
LABEL_83:
v60 = ++v1;
}
while( v1 < (unsigned int)PpmParkNumNodes );
LABEL_84:
PpmParkComputeDiff();
if( PpmParkLpiEngaged != (*(&stru_140CF2E80 + 1951) != 0) || (v54 = 0, PpmParkLpiCapChanged) )
v54 = 1;
PpmParkLpiEngaged = *(&stru_140CF2E80 + 1951) != 0;
PpmParkLpiCapChanged = 0;
if( v54 )
PpmEventLPICoreParking(v53);
return 1;
}Referenced by:
No references.