Skip to content

Commit

Permalink
fix uasgeWithHotPageCache and add usageWithPageCache
Browse files Browse the repository at this point in the history
Signed-off-by: BUPT-wxq <[email protected]>
  • Loading branch information
BUPT-wxq committed Oct 19, 2023
1 parent 33f0ebb commit 71bfab7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/koordlet/util/system/kidled_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func ParseMemoryIdlePageStats(content string) (*ColdPageInfoByKidled, error) {
// boundary is the index of [1,2) [2,5) [5,15) [15,30) [30,60) [60,120) [120,240) [240,+inf).
// if boundary is equal to 3, it will compute sum([5*scan_period_scands,+inf)) of cold page cache
func (i *ColdPageInfoByKidled) GetColdPageTotalBytes() uint64 {
return sum(i.Cfei, i.Dfei, i.Cfui, i.Dfui)
return sumUint64Slice(i.Cfei, i.Dfei, i.Cfui, i.Dfui)
}

// check kidled and set var isSupportColdSupport
Expand Down Expand Up @@ -214,13 +214,11 @@ func NewDefaultKidledConfig() *KidledConfig {
}
}

func sum(nums ...[]uint64) uint64 {
func sumUint64Slice(nums ...[]uint64) uint64 {
var total uint64
for _, v := range nums {
for i, num := range v {
if i >= int(kidledColdBoundary) {
total += num
}
for i := kidledColdBoundary; i < len(v); i++ {
total = total + v[i]
}
}
return total
Expand Down

0 comments on commit 71bfab7

Please sign in to comment.