-
Notifications
You must be signed in to change notification settings - Fork 285
Add support for creating and assigning cpugroups on pod creation #871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package oci | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/Microsoft/hcsshim/internal/uvm" | ||
| ) | ||
|
|
||
| // HandleCPUGroupSetup will parse the cpugroup annotations and setup the cpugroup for `vm` | ||
| func HandleCPUGroupSetup(ctx context.Context, vm *uvm.UtilityVM, annotations map[string]string) error { | ||
| cpuGroupOpts, err := annotationsToCPUGroupOptions(ctx, annotations) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if err := vm.ConfigureVMCPUGroup(ctx, cpuGroupOpts); err != nil { | ||
| return err | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // annotationsToCPUGroupOptions parses the related cpugroup annotations and creates the CPUGroupOptions from the values | ||
| func annotationsToCPUGroupOptions(ctx context.Context, annotations map[string]string) (*uvm.CPUGroupOptions, error) { | ||
| processorTopology, err := uvm.HostProcessorInfo(ctx) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to get host processor information: %s", err) | ||
| } | ||
| lpIndices := []uint32{} | ||
| for _, l := range processorTopology.LogicalProcessors { | ||
| lpIndices = append(lpIndices, l.LpIndex) | ||
| } | ||
|
|
||
| opts := &uvm.CPUGroupOptions{ | ||
| CreateRandomID: parseAnnotationsBool(ctx, annotations, annotationCPUGroupCreateRandomID, false), | ||
| ID: parseAnnotationsString(annotations, annotationCPUGroupID, uvm.CPUGroupNullID), | ||
| LogicalProcessors: parseCommaSeperatedUint32(annotations, annotationCPUGroupLPs, lpIndices), | ||
| Cap: parseAnnotationsUint32(ctx, annotations, annotationCPUGroupCap, uvm.DefaultCPUGroupCap), | ||
| Priority: parseAnnotationsUint32(ctx, annotations, annotationCPUGroupPriority, uvm.DefaultCPUGroupPriority), | ||
| } | ||
| return opts, nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| // CPU groups allow Hyper-V administrators to better manage and allocate the host's CPU resources across guest virtual machines | ||
| type CpuGroup struct { | ||
| Id string `json:"Id,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| type CpuGroupAffinity struct { | ||
| LogicalProcessorCount int32 `json:"LogicalProcessorCount,omitempty"` | ||
| LogicalProcessors []int32 `json:"LogicalProcessors,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| type CpuGroupConfig struct { | ||
| GroupId string `json:"GroupId,omitempty"` | ||
| Affinity *CpuGroupAffinity `json:"Affinity,omitempty"` | ||
| GroupProperties []CpuGroupProperty `json:"GroupProperties,omitempty"` | ||
| // Hypervisor CPU group IDs exposed to clients | ||
| HypervisorGroupId int32 `json:"HypervisorGroupId,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| // Structure used to return cpu groups for a Service property query | ||
| type CpuGroupConfigurations struct { | ||
| CpuGroups []CpuGroupConfig `json:"CpuGroups,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| type CPUGroupOperation string | ||
|
|
||
| const ( | ||
| CreateGroup CPUGroupOperation = "CreateGroup" | ||
| DeleteGroup CPUGroupOperation = "DeleteGroup" | ||
| SetProperty CPUGroupOperation = "SetProperty" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| type CpuGroupProperty struct { | ||
| PropertyCode uint32 `json:"PropertyCode,omitempty"` | ||
| PropertyValue uint32 `json:"PropertyValue,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| // Create group operation settings | ||
| type CreateGroupOperation struct { | ||
| GroupId string `json:"GroupId,omitempty"` | ||
| LogicalProcessorCount uint32 `json:"LogicalProcessorCount,omitempty"` | ||
| LogicalProcessors []uint32 `json:"LogicalProcessors,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| // Delete group operation settings | ||
| type DeleteGroupOperation struct { | ||
| GroupId string `json:"GroupId,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| // Structure used to request a service processor modification | ||
| type HostProcessorModificationRequest struct { | ||
| Operation CPUGroupOperation `json:"Operation,omitempty"` | ||
| OperationDetails interface{} `json:"OperationDetails,omitempty"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * HCS API | ||
| * | ||
| * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
| * | ||
| * API version: 2.4 | ||
| * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
| */ | ||
|
|
||
| package hcsschema | ||
|
|
||
| const ( | ||
| CpuCapPropertyCode = uint32(0x00010000) | ||
| SchedulingPriorityPropertyCode = uint32(0x00020000) | ||
| ) | ||
|
|
||
| // Set properties operation settings | ||
| type SetPropertyOperation struct { | ||
| GroupId string `json:"GroupId,omitempty"` | ||
| PropertyCode uint32 `json:"PropertyCode,omitempty"` | ||
| PropertyValue uint32 `json:"PropertyValue,omitempty"` | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like passing in the UVM into the oci package and having it do work against it. Can we just cache the
processorTopologyinformation we get when we callHostProcessorInfoduring UVM setup and just pass this into an exportedAnnotationsToCpuGroupOptionsand have this return the info we need?