Skip to content

Commit

Permalink
Alert when a partition's space utilization exceeds a threshold
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
megteo authored and wghoffa committed Aug 28, 2019
1 parent 4536704 commit ade0481
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/build/buildpnor/PnorUtils.pm
Expand Up @@ -409,6 +409,8 @@ sub checkSpaceConstraints

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

print "Note: the following metrics are not a true representation of section utilization, since some sections are substantially padded before applying ECC\n";

for $key ( keys %{$i_binFiles})
{
my $filesize = -s $$i_binFiles{$key};
Expand All @@ -422,9 +424,8 @@ sub checkSpaceConstraints
my $eyeCatch = $sectionHash{$layoutKey}{eyeCatch};
my $physicalRegionSize = $sectionHash{$layoutKey}{physicalRegionSize};

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

if($filesize > $physicalRegionSize)
{
Expand Down
34 changes: 34 additions & 0 deletions src/build/buildpnor/genPnorImages.pl
Expand Up @@ -61,6 +61,11 @@
my @systemBinFiles = ();
my %pnorLayout = ();
my %PhysicalOffsets = ();
my %partitionUtilHash;

# percentage utilization threshold, if crossed display warning message
# that partition is almost full
use constant CRITICAL_THRESHOLD => 85.00;

# Truncate SHA to n bytes
use constant SHA_TRUNCATE_SIZE => 32;
Expand Down Expand Up @@ -409,6 +414,17 @@
manipulateImages(\%pnorLayout, \%binFiles, $system_target);
}

# display percentage utilization data for each eyecatch
foreach my $key (keys %partitionUtilHash) {

print "$key is $partitionUtilHash{$key}{pctUtilized} utilized ($partitionUtilHash{$key}{freeBytes} of $partitionUtilHash{$key}{physicalRegionSize} bytes free)\n";

# if percentage is greater than critical threshold, surface warning
if ($partitionUtilHash{$key}{pctUtilized} > CRITICAL_THRESHOLD) {
print "Warning: Percent utilization for $key shows that partition is almost full.\n";
}
}

################################################################################
# Subroutines
################################################################################
Expand Down Expand Up @@ -452,6 +468,7 @@ sub partitionDepSort
################################################################################
# manipulateImages - Perform any ECC/padding/sha/signing manipulations
################################################################################

sub manipulateImages
{
my ($i_pnorLayoutRef, $i_binFilesRef, $system_target) = @_;
Expand Down Expand Up @@ -496,6 +513,7 @@ sub manipulateImages
}

my $eyeCatch = $sectionHash{$layoutKey}{eyeCatch};
my $physicalRegionSize = $sectionHash{$layoutKey}{physicalRegionSize};
my %tempImages = (
HDR_PHASE => "$bin_dir/$parallelPrefix.$eyeCatch.temp.hdr.bin",
TEMP_SHA_IMG => "$bin_dir/$parallelPrefix.$eyeCatch.temp.sha.bin",
Expand Down Expand Up @@ -749,6 +767,22 @@ sub manipulateImages

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


# store binary file size + header size in hash

# If section will passed through ecc, include this in size calculation
if( ($sectionHash{$layoutKey}{ecc} eq "yes") )
{
$partitionUtilHash{$eyeCatch}{logicalFileSize} = %callerHwHdrFields->{totalContainerSize} * (9/8);
}
else
{
$partitionUtilHash{$eyeCatch}{logicalFileSize} = %callerHwHdrFields->{totalContainerSize};
}
$partitionUtilHash{$eyeCatch}{pctUtilized} = sprintf("%.2f", $partitionUtilHash{$eyeCatch}{logicalFileSize} / $physicalRegionSize * 100);
$partitionUtilHash{$eyeCatch}{freeBytes} = $physicalRegionSize - $partitionUtilHash{$eyeCatch}{logicalFileSize};
$partitionUtilHash{$eyeCatch}{physicalRegionSize} = $physicalRegionSize;

# Padding Phase
if ($eyeCatch eq "HBI" && $testRun)
{
Expand Down

0 comments on commit ade0481

Please sign in to comment.