Skip to content

Commit

Permalink
Pass thread information to virt-launcher for pinning decisions
Browse files Browse the repository at this point in the history
Take the dom capability sibling information and make it available to
virt-launcher which can use it to do more sophisticated pinning
decisions.

Signed-off-by: Roman Mohr <[email protected]>
  • Loading branch information
rmohr committed Sep 6, 2021
1 parent db97a4b commit 4825e9f
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 87 deletions.
157 changes: 83 additions & 74 deletions pkg/handler-launcher-com/cmd/v1/cmd.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/handler-launcher-com/cmd/v1/cmd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ message VMI {

message CPU {
uint32 id = 1;
repeated uint32 siblings = 2;
}

message Sibling {
Expand Down
27 changes: 22 additions & 5 deletions pkg/virt-handler/node-labeller/api/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package api
import (
"encoding/xml"
"fmt"
"strconv"
"strings"
)

type yesnobool bool

type CPUSiblings []uint32

type Capabilities struct {
XMLName xml.Name `xml:"capabilities"`
Host Host `xml:"host"`
Expand All @@ -32,11 +36,11 @@ type Counter struct {
}

type CPU struct {
ID uint32 `xml:"id,attr"`
SocketID uint32 `xml:"socket_id,attr"`
DieID uint32 `xml:"die_id,attr"`
CoreID uint32 `xml:"core_id,attr"`
Siblings string `xml:"siblings,attr"`
ID uint32 `xml:"id,attr"`
SocketID uint32 `xml:"socket_id,attr"`
DieID uint32 `xml:"die_id,attr"`
CoreID uint32 `xml:"core_id,attr"`
Siblings CPUSiblings `xml:"siblings,attr"`
}

type CPUs struct {
Expand Down Expand Up @@ -100,3 +104,16 @@ func (b *yesnobool) UnmarshalXMLAttr(attr xml.Attr) error {
}
return fmt.Errorf("value %v of %v is not (yes|no)", attr.Value, attr.Name)
}

func (b *CPUSiblings) UnmarshalXMLAttr(attr xml.Attr) error {
if attr.Value != "" {
for _, cpuStr := range strings.Split(attr.Value, ",") {
val, err := strconv.ParseInt(cpuStr, 10, 32)
if err != nil {
return fmt.Errorf("failed to parse %v to int from %v: %v", cpuStr, attr.Value, err)
}
*b = append(*b, uint32(val))
}
}
return nil
}
23 changes: 17 additions & 6 deletions pkg/virt-handler/node-labeller/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ var _ = Describe("Capabilities", func() {
Expect(bool(counter.Scaling)).To(BeFalse())
})

It("should properly read cpu siblings", func() {
f, err := os.Open("testdata/capabilities.xml")
Expect(err).ToNot(HaveOccurred())
defer f.Close()
capabilities := &api.Capabilities{}
Expect(xml.NewDecoder(f).Decode(capabilities)).To(Succeed())
Expect(capabilities.Host.Topology.Cells.Cell).To(HaveLen(1))
Expect(capabilities.Host.Topology.Cells.Cell[0].Cpus.CPU).To(HaveLen(8))
Expect(capabilities.Host.Topology.Cells.Cell[0].Cpus.CPU[0].Siblings).To(ConsistOf(uint32(0), uint32(4)))
})

It("should read the numa topology from the host", func() {

expectedCell := api.Cell{
Expand Down Expand Up @@ -81,42 +92,42 @@ var _ = Describe("Capabilities", func() {
SocketID: 0,
DieID: 0,
CoreID: 0,
Siblings: "0",
Siblings: []uint32{0},
},
{
ID: 1,
SocketID: 1,
DieID: 0,
CoreID: 0,
Siblings: "1",
Siblings: []uint32{1},
},
{
ID: 2,
SocketID: 2,
DieID: 0,
CoreID: 0,
Siblings: "2",
Siblings: []uint32{2},
},
{
ID: 3,
SocketID: 3,
DieID: 0,
CoreID: 0,
Siblings: "3",
Siblings: []uint32{3},
},
{
ID: 4,
SocketID: 4,
DieID: 0,
CoreID: 0,
Siblings: "4",
Siblings: []uint32{4},
},
{
ID: 5,
SocketID: 5,
DieID: 0,
CoreID: 0,
Siblings: "5",
Siblings: []uint32{5},
},
},
},
Expand Down
5 changes: 3 additions & 2 deletions pkg/virt-handler/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ func distanceToDistance(distance api.Sibling) *cmdv1.Sibling {
}
}

func cpuToCPU(distance api.CPU) *cmdv1.CPU {
func cpuToCPU(cpu api.CPU) *cmdv1.CPU {
return &cmdv1.CPU{
Id: distance.ID,
Id: cpu.ID,
Siblings: cpu.Siblings,
}
}

0 comments on commit 4825e9f

Please sign in to comment.