Skip to content

Commit

Permalink
balloons: use new config more consistently.
Browse files Browse the repository at this point in the history
Don't delay updating stored config when reconfiguring the policy.
Some functions in the call-tree (e.g. newBalloon()) picks options
using p.bpoptions, so otherwise they would end up using old data.

Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Nov 3, 2023
1 parent 4aa2596 commit deb06d3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/plugins/balloons/policy/balloons-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,12 @@ func (p *balloons) setConfig(bpoptions *BalloonsOptions) error {
topologyBalancing: bpoptions.AllocatorTopologyBalancing,
preferSpreadOnPhysicalCores: bpoptions.PreferSpreadOnPhysicalCores,
})

// We can't delay taking new configuration into use beyond this point,
// because p.newBalloon() dereferences our options via p.bpoptions, so
// it would end up using the old configuration.
p.bpoptions = *bpoptions

// Instantiate built-in reserved and default balloons.
reservedBalloon, err := p.newBalloon(p.reservedBalloonDef, false)
if err != nil {
Expand Down Expand Up @@ -1101,8 +1107,7 @@ func (p *balloons) setConfig(bpoptions *BalloonsOptions) error {
for blnIdx, bln := range p.balloons {
log.Info("- balloon %d: %s", blnIdx, bln)
}
// No errors in balloon creation, take new configuration into use.
p.bpoptions = *bpoptions

p.updatePinning(p.shareIdleCpus(p.freeCpus, cpuset.New())...)
// (Re)configures all CPUs in balloons.
p.resetCpuClass()
Expand Down

0 comments on commit deb06d3

Please sign in to comment.