Skip to content

Commit ade0481

Browse files
megteowghoffa
authored andcommitted
Alert when a partition's space utilization exceeds a threshold
Calculate the percentage utilization of a pnor partition by using binary file size + header size + ecc overhead (if used for partition). User is warned when a pnor partition exceeds a specific utilization threshold Change-Id: I00b0b69a039ffefdf086dc470fd0f76b72ee267d RTC: 212220 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/81990 Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E Bofferding <bofferdn@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: William G Hoffa <wghoffa@us.ibm.com>
1 parent 4536704 commit ade0481

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/build/buildpnor/PnorUtils.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ sub checkSpaceConstraints
409409

410410
my %sectionHash = %{$$i_pnorLayoutRef{sections}};
411411

412+
print "Note: the following metrics are not a true representation of section utilization, since some sections are substantially padded before applying ECC\n";
413+
412414
for $key ( keys %{$i_binFiles})
413415
{
414416
my $filesize = -s $$i_binFiles{$key};
@@ -422,9 +424,8 @@ sub checkSpaceConstraints
422424
my $eyeCatch = $sectionHash{$layoutKey}{eyeCatch};
423425
my $physicalRegionSize = $sectionHash{$layoutKey}{physicalRegionSize};
424426

425-
my $pctUtilized = sprintf("%.2f", $filesize / $physicalRegionSize * 100);
426427
my $freeBytes = $physicalRegionSize - $filesize;
427-
print "$eyeCatch is $pctUtilized% utilized ($freeBytes of $physicalRegionSize bytes free)\n";
428+
print "$eyeCatch section size: $physicalRegionSize, bytes used: $filesize, bytes unused: $freeBytes\n";
428429

429430
if($filesize > $physicalRegionSize)
430431
{

src/build/buildpnor/genPnorImages.pl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
my @systemBinFiles = ();
6262
my %pnorLayout = ();
6363
my %PhysicalOffsets = ();
64+
my %partitionUtilHash;
65+
66+
# percentage utilization threshold, if crossed display warning message
67+
# that partition is almost full
68+
use constant CRITICAL_THRESHOLD => 85.00;
6469

6570
# Truncate SHA to n bytes
6671
use constant SHA_TRUNCATE_SIZE => 32;
@@ -409,6 +414,17 @@
409414
manipulateImages(\%pnorLayout, \%binFiles, $system_target);
410415
}
411416

417+
# display percentage utilization data for each eyecatch
418+
foreach my $key (keys %partitionUtilHash) {
419+
420+
print "$key is $partitionUtilHash{$key}{pctUtilized} utilized ($partitionUtilHash{$key}{freeBytes} of $partitionUtilHash{$key}{physicalRegionSize} bytes free)\n";
421+
422+
# if percentage is greater than critical threshold, surface warning
423+
if ($partitionUtilHash{$key}{pctUtilized} > CRITICAL_THRESHOLD) {
424+
print "Warning: Percent utilization for $key shows that partition is almost full.\n";
425+
}
426+
}
427+
412428
################################################################################
413429
# Subroutines
414430
################################################################################
@@ -452,6 +468,7 @@ sub partitionDepSort
452468
################################################################################
453469
# manipulateImages - Perform any ECC/padding/sha/signing manipulations
454470
################################################################################
471+
455472
sub manipulateImages
456473
{
457474
my ($i_pnorLayoutRef, $i_binFilesRef, $system_target) = @_;
@@ -496,6 +513,7 @@ sub manipulateImages
496513
}
497514

498515
my $eyeCatch = $sectionHash{$layoutKey}{eyeCatch};
516+
my $physicalRegionSize = $sectionHash{$layoutKey}{physicalRegionSize};
499517
my %tempImages = (
500518
HDR_PHASE => "$bin_dir/$parallelPrefix.$eyeCatch.temp.hdr.bin",
501519
TEMP_SHA_IMG => "$bin_dir/$parallelPrefix.$eyeCatch.temp.sha.bin",
@@ -749,6 +767,22 @@ sub manipulateImages
749767

750768
setCallerHwHdrFields(\%callerHwHdrFields, $tempImages{HDR_PHASE});
751769

770+
771+
# store binary file size + header size in hash
772+
773+
# If section will passed through ecc, include this in size calculation
774+
if( ($sectionHash{$layoutKey}{ecc} eq "yes") )
775+
{
776+
$partitionUtilHash{$eyeCatch}{logicalFileSize} = %callerHwHdrFields->{totalContainerSize} * (9/8);
777+
}
778+
else
779+
{
780+
$partitionUtilHash{$eyeCatch}{logicalFileSize} = %callerHwHdrFields->{totalContainerSize};
781+
}
782+
$partitionUtilHash{$eyeCatch}{pctUtilized} = sprintf("%.2f", $partitionUtilHash{$eyeCatch}{logicalFileSize} / $physicalRegionSize * 100);
783+
$partitionUtilHash{$eyeCatch}{freeBytes} = $physicalRegionSize - $partitionUtilHash{$eyeCatch}{logicalFileSize};
784+
$partitionUtilHash{$eyeCatch}{physicalRegionSize} = $physicalRegionSize;
785+
752786
# Padding Phase
753787
if ($eyeCatch eq "HBI" && $testRun)
754788
{

0 commit comments

Comments
 (0)