-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Huge pages volume plugin. #47658
Huge pages volume plugin. #47658
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: PiotrProkop Assign the PR to them by writing No associated issue. Update pull-request body to add a reference to an issue, or get approval with The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Hi @PiotrProkop. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@k8s-bot ok to test |
pkg/api/validation/validation.go
Outdated
if minSize.ScaledValue(resource.Mega) < 2 { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("minSize"), hugePages.MinSize, "MaxSize lower than pageSize")) | ||
} | ||
} |
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.
min <= max
@@ -2335,6 +2335,35 @@ func TestValidateVolumes(t *testing.T) { | |||
errtype: field.ErrorTypeRequired, | |||
errfield: "scaleIO.system", | |||
}, | |||
// HugePages |
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.
add a negative test case where min > max
func printHugePagesVolumeSource(hp *api.HugePagesVolumeSource, w PrefixWriter) { | ||
w.Write(LEVEL_2, "Type:\tHugePages (pseudo filesystem of type hugetlbfs representing HugePages)\n"+ | ||
" PageSize:\t%v\n"+ | ||
" Size:\t%v\n"+ |
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.
maxSize
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 will rename maxSize to Size so it will reflect mount options.
pkg/volume/hugepages/doc.go
Outdated
@@ -0,0 +1,19 @@ | |||
/* | |||
Copyright 2015 The Kubernetes Authors. |
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.
2017 (and for all new files)
pkg/volume/hugepages/hugepages.go
Outdated
|
||
var readFile = ioutil.ReadFile | ||
|
||
func detectHugepages() error { |
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.
return the amount of huge pages too and validate max is not more than huagepages_free or hugepages_total.
pkg/api/types.go
Outdated
// +optional | ||
PageSize string | ||
// Defaults to PageSize | ||
// The size option sets the maximum value of memory (huge pages). |
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.
s/size/MaxSize
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 will rename maxSize to Size so it will reflect mount options.
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 can't rename it because there is a generated method Size(), so i will leave MaxSize as struct field but change json, and protobuf field name to size.
pkg/api/types.go
Outdated
// The size option is specified as resource.Quantity | ||
MaxSize string | ||
// Defaults to PageSize | ||
// The min_size option sets the minimum |
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.
s/min_size/minSize
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.
pkg/api/v1/types.go also
pkg/api/types.go
Outdated
// Defaults to 2M | ||
// +optional | ||
PageSize string | ||
// Defaults to PageSize |
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.
If user specifies minSize, then the default maxSize should be minSize, IMO
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 wanted to stick as close to hugetlbfs mount options as possible so think it should default to nothing. Defaulting to PageSize is not a good idea 😄
pkg/api/v1/defaults.go
Outdated
if obj.PageSize == "" { | ||
obj.PageSize = "2M" | ||
} | ||
if obj.MaxSize == "" { |
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.
should guarantee the default values are valid.
e.g.suppose user specifies as below
hugePages:
pageSize: "2M"
maxSize: ""
minSize: "100M"
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.
It is valid not to specify size than there is no limit being set. But I do not handle this case in volume plugin itself I have to add it in prepareMountOptions().
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.
What I was saying wasn't if not to specify size is valid. I was saying is that if users specify as below:
hugePages:
pageSize: "2M"
maxSize: ""
minSize: "100M"
This will default to:
hugePages:
pageSize: "2M"
maxSize: "2M"
minSize: "100M"
Then the maxSize < minSize, which is invalid.
pkg/api/validation/validation.go
Outdated
|
||
// TODO(pprokop): add support for other PageSizes | ||
if hugePages.PageSize != "2M" { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("pageSize"), hugePages.PageSize, "Not supported page size")) |
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.
give the supported size in the error info
pkg/api/validation/validation.go
Outdated
allErrs = append(allErrs, field.Invalid(fldPath.Child("minSize"), hugePages.MinSize, "Not a valid quantity")) | ||
} else { | ||
if minSize.ScaledValue(resource.Mega) < 2 { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("minSize"), hugePages.MinSize, "MaxSize lower than pageSize")) |
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.
s/MaxSize/MinSize
pkg/api/validation/validation.go
Outdated
if hugePages.PageSize != "2M" { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("pageSize"), hugePages.PageSize, "Not supported page size")) | ||
} | ||
maxSize, err := resource.ParseQuantity(hugePages.MaxSize) |
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.
is 12.3 a valid value?
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.
It is an interesting case because doing mount with option size=5.3M will not fail but it will be transformed into 5 bytes because kernel will discard everything after dot. The code is here. So either K8s should not allowed using fractional sizes or convert every size option to bytes before mounting.
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.
even though, some integer value might be invalid for hugepages. For example, suppose the pagesize is 2M, how many pages should that be for minSize or maxSize being 5M? 2 pages or 3 pages or other number?
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.
Kernel itself rounds down size to HPAGE_SIZE boundary, so if you specify 5M it will be 2 pages.
@@ -744,6 +744,8 @@ func describeVolumes(volumes []api.Volume, w PrefixWriter, space string) { | |||
printCephFSVolumeSource(volume.VolumeSource.CephFS, w) | |||
case volume.VolumeSource.StorageOS != nil: | |||
printStorageOSVolumeSource(volume.VolumeSource.StorageOS, w) | |||
case volume.VolumeSource.HugePages != nil: | |||
printHugePagesVolumeSource(volume.VolumeSource.HugePages, w) |
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.
there is also another func where should place this in. (I'm reviewing on my phone, it's not easy to find that func, sorry)
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.
also need to add a case in func describePersistentVolume
} | ||
|
||
// HugePages are https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt | ||
// This struct implements "k8s.io/pkg/volume.Mounter" and "k8s.io/pkg/volme.UnMounter" interface.Mounter" and "k8s.io/pkg/volme.UnMounter" interfaces |
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.
fix this comment
} | ||
|
||
func getVolumeSource(spec *volume.Spec) (*v1.HugePagesVolumeSource, bool) { | ||
var readOnly bool |
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.
is this needed? Seems like it's not used.
@PiotrProkop run |
@rootfs should i push generated code also ? |
@PiotrProkop yes, please make two commits: with for generated code and one for the rest |
Is there an overall proposal for adding huge pages support for kubernetes? |
@vishh yes, the proposal is in the community repo: kubernetes/community#181 |
Can you update proposal kubernetes/community#181
<kubernetes/community#181> to include updates from
the recent design discussions?
I'd like to reach consensus on the high level design prior to reviewing
implementation PRs.
…On Tue, Jun 20, 2017 at 5:51 PM, Jeremy Eder ***@***.***> wrote:
@vishh <https://github.com/vishh> yes, the proposal is in the community
repo: kubernetes/community#181
<kubernetes/community#181>
And here is the doc prepared by @derekwaynecarr
<https://github.com/derekwaynecarr> for our f2f: kubernetes/enhancements#275
<kubernetes/enhancements#275>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#47658 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGvIKHIvufBP4owrndUHL0_8lubEbPQZks5sGGklgaJpZM4N8lBa>
.
|
@PiotrProkop fix the test errors, most can be fixed by running |
@PiotrProkop was there perhaps some offline conversation with @derekwaynecarr or @sjenning about this PR versus what we have in kubernetes/community#181 ? |
I only showed the volume plugin demo on resource management workgroup and now probably I should sync with @derekwaynecarr and @sjenning to add this to the proposal. |
@PiotrProkop PR needs rebase |
Hi @rootfs and @xiangpengzhao, I wanted to rebase a PR but this PR removed pkg/api/v1/types.go. Now I am a bit confused about how to make api changes should i create PR against this repo ? Are there any updated docs how to make api changes ? |
I think @caesarxuchao can help to explain. |
Was there some discussion/reasoning as to why this is a volume plugin and not a device plugin #695? I thought we wanted hugepages to be abstracted via resourceclasses which currently are a layer on top of device plugins. @sjenning @derekwaynecarr |
@jeremyeder there are two ways of consuming huge pages. First is transparent usage like JVM based application. Second is using a hugetlbfs mount point. Volume plugin was chosen because some application like DPDK based application use hugetlbfs and requires having e.g. |
That's what I thought but the end state is that we have potentially two ways of users consuming hugepages. We should aim for that not to be the case, agree? |
This proposal states that setting cgroup limits for transparent huge pages will be handled via CRI and not device plugins. In the future they will become a first class citizens ( capacityV2 objects) like CPU and memory and we could allocate them using Resource classes. |
pkg/api/v1/types.go is moved to staging/src/k8s.io/api/core/v1/types.go. I'll add a doc explaining the situation. Sorry for the troubles. |
@PiotrProkop late to response but @caesarxuchao has replied. Update |
@caesarxuchao and @rootfs thanks 😄 |
e42765f
to
1e21eb9
Compare
@PiotrProkop: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
1e21eb9
to
74514c9
Compare
I am closing this PR in favor of this #50072 PR. |
What this PR does / why we need it:
This PR adds a new volume plugin for huge pages volumes. Hugepages is a feature of the Linux Kernel that allows a subset of system memory to be managed in larger increments.
More documentation can be found here.
Which issue this PR fixes:
Support for huge pages was discussed on resource management work-group meetings. The doc can be found here.
Release note: