Skip to content

Add numa cpuset support #334

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

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

xibz
Copy link
Contributor

@xibz xibz commented Nov 18, 2019

This change adds support for specifying a set of cpu and memory nodes
during the CreateVM call. This will run the jailed process on those set
of cpus and restrict access to the specified nodes. This change also
adds the cpuset.Builder which allows for easy creation of cpus and mems
strings

Signed-off-by: xibz [email protected]

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@xibz xibz force-pushed the jailer-numa-node-clean branch 8 times, most recently from d393477 to fc75aa0 Compare November 18, 2019 22:48
@xibz xibz force-pushed the jailer-numa-node-clean branch 2 times, most recently from 15a8fd2 to ce46c24 Compare November 19, 2019 00:16
sep = ""
}

str += fmt.Sprintf("%s%d-%d", sep, r.min, r.max)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: _range seems like a good candidate for a String() method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Just a few suggestions about commenting and documentation.

}

// AddMemRange adds a range of memory nodes by utilizing the minimum node to
// use to the maximum node to use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure what you're trying to say here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are merge conflicts. Can you rebase this PR on top of the current master branch and resolve them?


func stringify(elems []int, ranges []_range) string {
str := ""
for _, elem := range elems {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for doing this instead of using strings.Join?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah, good call out. Just slipped the mind.

Copy link
Contributor

@samuelkarp samuelkarp Nov 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xibz Can you update this to use strings.Join?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns a string using Join. Was there something else you had in mind? Cause I think this is probably the simplest way to go?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xibz My apologies, I misread this. I might use strconv.Itoa instead of fmt.Sprintf, but that's really minor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah cool, and no worries! I'll go ahead and fix the fmt.Sprintf issue. Thanks!

str += fmt.Sprintf("%s%d", sep, elem)
}

for _, r := range ranges {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here.

@xibz xibz force-pushed the jailer-numa-node-clean branch 2 times, most recently from a33efce to c471534 Compare November 25, 2019 20:59
func TestJailerCPUSet_Isolated(t *testing.T) {
prepareIntegTest(t, withJailer())

t.Run("Jailer NumaNode", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the name to reflect the new function name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. Please just clean up the commit history at this point.

This change adds support for specifying a set of cpu and memory nodes
during the CreateVM call. This will run the jailed process on those set
of cpus and restrict access to the specified nodes. This change also
adds the cpuset.Builder which allows for easy creation of cpus and mems
strings

Signed-off-by: xibz <[email protected]>
@xibz xibz force-pushed the jailer-numa-node-clean branch from 221995e to 29ee484 Compare December 3, 2019 06:35
@xibz xibz merged commit 831c73f into firecracker-microvm:master Dec 3, 2019
@xibz xibz deleted the jailer-numa-node-clean branch December 3, 2019 09:13
@xibz xibz mentioned this pull request Dec 10, 2019
fangn2 pushed a commit to fangn2/firecracker-containerd that referenced this pull request Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants